Designing Implementing Real-Time Signal Processing Systems

Transcription

Designing and Implementing Real-TimeSignal Processing SystemsVidya Viswanathan 2015 The MathWorks, Inc.1

Smart Systems What makes a system “smart”?––––SensorsAnalysis based on available dataNetworking capabilitiesStandalone devices2

Signal Processing is everywhere!Computer Vision andImage ProcessingAudio Systems andConsumerElectronicsCommunicationsMedical Devices3

Problem Statement Photoplethysmography (PPG)– Measuring the volumetric change during eachcardiac cycle due to pumping of blood– Illuminate the skin and measure the variation inintensityPulse Oximeter What are we going to build?– An android app that estimates the heart ratebased on optical sensors4

Real-Time Stream ProcessingFrame 1Frame 2Frame nFrame 3 Data acquisitionAlgorithm processingtimeAs long asData acquisition Algorithm processing Frame timeWe haveReal-time signal processing5

Challenges in a Real-Time Signal Processing System DesignFramework for real-time simulations“I have to process large data and test my simulations with streaming signals. Ineed a simulation testbench that can keep up with real-time data.”Rapid innovation“I need to find innovative algorithms and create andmodel a working system very quickly.”Simulation acceleration & implementation“I need to optimize my high-level MATLAB algorithm for speed. I then need toverify that the optimized code works the same way as the original MATLAB code.”6

Model Based Design WorkflowRequirementsResearch & Design Explore and discoverData Analysis Gain insight into the problemAlgorithmDevelopment Evaluate options, trade-offsData ModelingDesktop andWeb DeploymentEmbeddedSoftwareDigitalElectronics.exeC, C VHDL, VerilogMCU DSPFPGA ASICJavaVerification&ValidationImplement7

AgendaConnect and AcquireSignalProcessing AlgorithmEmbedded ImplementationAutomate8

Data Acquisition Image Acquisition Toolbox enables you to acquire live video streamsdirectly into MATLAB and SimulinkImage Acquisition Toolbox Support Package for OS Generic Video Interface9

Data Acquisition Signal of interest : Average intensity of each frame How do you choose the frame rate?– Heart Rate Range : 40 to 230 beats per minutei.e 0.667 to 3.8333 beats per second (Hz)– Minimum frame rate required: 8fps How do you choose the resolution?– High resolution images are not required in this case– Resolution chosen : 640 x 48010

MATLAB Connects to Your Hardware DevicesInstrument Control ToolboxInstruments and RS-232 serialdevicesData Acquisition ToolboxPlug-in data acquisition devicesand sound cardsImage Acquisition ToolboxImage capture devicesCommunications System ToolboxUSRP, RTL-SDR, FPGA-SDRMATLABInterfaces for communicatingwith everything11

AgendaConnect and AcquireSignalProcessing AlgorithmEmbedded Implementation12

Algorithm DevelopmentStep 1: Computing the average intensity of each frame 2D Mean Estimation13

Algorithm DevelopmentStep 2: Extracting the band of interest (Filter specification) Heart Rate Range :40 to 230 beats perminute (0.667 to 3.8333 Hz) Choice of Filter?– Bandpass filter FIR or IIR?Order of Filter?14

Algorithm DevelopmentStep 2: Extracting the band of interest (Filtered output)15

Algorithm DevelopmentStep 3: Heart Rate Estimation Techniques to estimate number of troughs (peaks) in one second– Count of number of troughs in a span of “N” seconds“findpeaks”– Estimate the average time between adjacent peaks over “N” seconds– Spectral Analysis Non-parametric : Periodogram, WelchParametric : Yule-Walker, Burg Subspace methods : Eigen Vector, MUSIC – Wavelet Analysis16

Algorithm DevelopmentStep 3: Heart Rate Estimation[pks val,locs] findpeaks(-u,'MinPeakDistance',5)17

Signal Processing with MATLABSignal Processing with SimulinkThis two-day course shows how to analyze signalsand design signal processing systems usingMATLAB , Signal Processing Toolbox , and DSPSystem Toolbox .This three-day course, targeted toward new users of Simulink , uses basicmodeling techniques and tools to demonstrate how to develop Simulink blockdiagrams for signal processing applications.Topics include: Creating and analyzing signals Performing spectral analysis Designing and analyzing filters Designing multirate filters Designing adaptive filtersTopics include: Using the Simulink interface Modeling single-channel and multi-channel discretedynamic systems Implementing sample-based and frame-basedprocessing Modeling mixed-signal (hybrid) systems Developing custom blocks and libraries Modeling condition-based systems Performing spectral analysis with Simulink Integrating filter designs into Simulink Modeling multirate systems18

AgendaConnect and AcquireSignalProcessing AlgorithmEmbedded Implementation19

Implement and Prototype Algorithms in HardwareEmbeddedCoderHDLCoderC, C VHDL, VerilogASICDSP / MCUFPGAProgrammable SoC20

Why Automatic Code Generation?e.ci teratWith automatic code generation, design engineers can:Algorithm Design andCode Generation inMATLAB/ SimulinkRTLverify/a ccelerate Maintain one design across simulation andimplementation Design faster and get to C or RTL quickly Test more systematically and frequently Spend more time improving algorithmsChallenges with manual coding: Separate functional and implementation specification Leads to multiple implementations that are inconsistent Hard to modify requirements during development Manual coding errors Time-consuming and expensive process21

From Simulation model to Implementation model (Android device)Simulation ModelImplementation Model22

One-Click Implementation and Execution23

Parameter Tuning using External Mode Find the optimal values for performanceAccelerate parameter tuningDevelop and validate your model using the actual data and hardware forwhich it is designed[pks val,locs] findpeaks(-u, 'MinPeakDistance',5)24

Simulink Support Package for SamsungGALAXY Android Devices Interactive parameter tuning and signalmonitoring Model deployment for standaloneoperation Simple UI using sliders and buttons Generation of Android Studio compatibleprojects25

Code Generation Products for C/C Embedded CoderSimulinkCoderMATLAB CoderEmbedded Coder Automatically generate C and C optimized for embedded systemsSimulink Coder Automatically generate C and C fromSimulink models and Stateflow chartsMATLAB Coder Automatically generate C and C fromMATLAB code26

Embedded Coder Support for ARM ProcessorsOptimized functions for signal processing algorithms FFT/IFFT Mulitrate FIR decimation/interpolation FIR filter, FIR lattice filter Digital Down Converter and Up Converter CIC Compensator Decimator and InterpolatorSupport for ARM processors27

Connecting MATLAB and Simulink to Hardware Android and iOS Arduino Uno, Mega 2560 Raspberry Pi Model B BeagleBone Black Texas Instruments processors Analog Devices processors Hardware Support28

MATLAB to C with MATLAB CoderThis two-day course focuses on generatingC code from MATLAB code usingMATLAB Coder . The focus is ondeveloping MATLAB code that is ready forcode generation, generating C code thatmeets optimization requirements, andintegrating generated code into parentprojects and external modules. This courseis intended for intermediate to advancedMATLAB users.Embedded Coder for Production Code GenerationThis hands-on, three-day course focuses on developing models in theSimulink environment to deploy on embedded systems. The course is designedfor Simulink users who intend to generate, validate, and deploy embedded codeusing Embedded Coder .Topics include: Generated code structure and executionCode generation options and optimizationsIntegrating generated code with external codeGenerating code for multirate systemsCustomizing generated codeCustomizing dataDeploying code29

VivaQuant Accelerates Development and Validation of EmbeddedDevice for Ambulatory ECG SensingChallengeDesign and implement an embedded system for extracting accurateinformation from noisy electrocardiogram signalsSolutionUse MATLAB to develop an algorithm for removing in-band noise, and useECG snippet before and after processing withVivaQuant’s embedded in-band noise removalalgorithm.Fixed-Point Designer and MATLAB Coder to implement it on an ARM Cortex-M“MATLAB, MATLAB Coder, and Fixed-Point Designerseries processorenabled our small team to develop a complex real-Results Development accelerated by 300% Power and memory consumption minimized Rigorous testing enabledtime signal processing algorithm, optimize it toreduce power and memory requirements, accelerateembedded code implementation, and perform therigorous testing required for medical devicevalidation.”Marina BrockwayLink to user storyVivaQuant30

Implement and Prototype Algorithms in HardwarePrepare model for code generationGenerate HDL codeEmbeddedCoderHDLCoderIntegrated RTL VerificationCritical Timing Information AnalysisC, C Area and Speed OptimizationVHDL, VerilogASICDSP / MCUFPGAProgrammable SoCFPGA-in-Loop Verification31

Preparation of an Implementation ModelFixed-Point DesignerSetup themodelFixed-Point Designer enables you to Prepare mode forconversionAutomate conversion from floating-point to fixed-pointalgorithms Generate floatingpoint baseline Derive range informationProposing data types based on the rangesCompare floating-point and fixed-point resultsDebug fixed-point modelsPropose g andoverflow modesVerify Fixed-PointData TypesGenerateCodeYesAre resultssatisfactory?No32

Verification of Implemented DesignHDL onVerify your generated RTLagainst MATLAB/ SimulinkresultsOUTRTL HDL(VHDL, Verilog)Test benchHDL SimulatorStimulusResponseHDL SimulatorMATLAB/ Simulink as a test benchHDL EntityOutputArgumentsINOUTInputArguments33

What HDL Coder and HDL Verifier offers? Code Generation– Target-independent HDL Code VHDL-1993 (IEEE 1076-1993) or laterVerilog-2001 (IEEE 1364-2001) or laterMATLAB and Simulink Algorithm and System DesignHDL CoderHDL VerifierLink for ModelSimVerification Generate– Generate HDL test-bench– Co-simulate with ModelSim and Incisive– FPGA-in-the-loop verificationDesign automation– Synthesize using integrated Xilinx andAltera synthesis tool interface– Optimize for area-speed– Program Xilinx and Altera boardsVerify HDLFPGAASIC34

Generating HDL Code from SimulinkDSP for FPGAsTwo-day course shows how to generate and verify HDLcode from a Simulink model using HDL Coder andHDL Verifier This three-day course will review DSP fundamentals from the perspective ofimplementation within the FPGA fabric. Particular emphasis will be given tohighlighting the cost, with respect to both resources and performance, associatedwith the implementation of various DSP techniques and algorithms.Topics include: Preparing Simulink models for HDLcode generation Generating HDL code and testbench fora compatible Simulink model Performing speed and areaoptimizations Integrating handwritten code andexisting IP Verifying generated HDL code usingtestbench and cosimulationTopics include: Introduction to FPGA hardware and technology for DSPapplicationsDSP fixed-point arithmeticSignal flow graph techniquesHDL code generation for FPGAsFast Fourier Transform (FFT) ImplementationDesign and implementation of FIR, IIR and CIC filtersCORDIC algorithmDesign and implementation of adaptive algorithms such as LMSand QR algorithmTechniques for synchronisation and digital communications timingrecovery35

FLIR Accelerates Development of Thermal Imaging FPGAChallengeAccelerate the implementation of advanced thermal imaging filtersand algorithms on FPGA hardwareSolutionUse MATLAB to develop, simulate, and evaluate algorithms, anduse HDL Coder to implement the best algorithms on FPGAsRaw image (left) and image after applying filter developed with HDL Coder(right).“With MATLAB and HDL Coder we are much moreresponsive to marketplace needs. We nowembrace change, because we can take a new ideato a real-time-capable hardware prototype in just aResults Time from concept to field-testable prototype reduced by 60% Enhancements completed in hours, not weeks Code reuse increased from zero to 30%few weeks. There is more joy in engineering, sowe’ve increased job satisfaction as well ascustomer satisfaction.”Nicholas HogastenFLIR SystemsLink to user story36

Model Based Design WorkflowRequirementsResearch & DesignExecutable Specification Explore and discoverData Analysis Gain insight into the problemAlgorithmDevelopment Evaluate options, trade-offsData ModelingDesign with SimulationAutomatic Code GenerationDesktop andWeb DeploymentEmbeddedSoftwareDigitalElectronics.exeC, C VHDL, VerilogContinuous Test and VerificationJavaVerification&ValidationMCU DSPFPGA ASICImplement37

Real-Time Signal Processing System Designwith MATLAB and SimulinkFramework for real-time simulationsStreamaccessthat“I have toprocessingprocess largetechniquesdata and testandmy hardwaresimulationsperipheralwith streamingsignals.Iup simulationandcanreducememoryfootprintneedspeeda simulationtestbench thatkeep upwith real-timedata.”Rapid nsandandblocks“I need to findinnovativecreateand formodel a quickworkingprototypingsystem very quickly.”Simulation acceleration & ImplementationSupportmyforhigh-levelC/C codeandalgorithmHDL code“I need to optimizeMATLABforgenerationspeed. I then need toenables codedesigncontinuityfastersimulationverify thatthatthe optimizedworksthe same andway asthe originalMATLAB code.”38

Call to ActionGet Hardware Support PackagesFrom the MATLAB Toolstrip:Add-Ons Get Hardware Support PackagesFrom the MATLAB Command Line: supportPackageInstaller39

Call to ActionVideos and Webinars Real-time Audio Processing for Algorithm Prototyping and CustomMeasurements– Process low-latency streaming audio directly in MATLAB, including via ASIO orCoreAudio– Tune parameters in real-time through user interfaces or external MIDI controls Signal Processing and Machine Learning Techniques for Sensor DataAnalytics– Introduction to common signal processing methods– Explore and test different classification algorithms– Embedded sensor analytics workflow Understanding Wavelets40

Call to Action41

Call to Action42

Call to ActionDemo Stations and Workshops Machine Learning Made Easy Using MATLAB– Data import and feature selection– Choosing algorithms Simulink for Maker Hardware– Develop standalone applications for Arduino, LEGO MINDSTORMS EV3, and Raspberry Pi– Create Android and iOS apps using Simulink Hardware-Software Codesign and Prototyping on SoC FPGAs– HDL and C code generation– Partitioning an algorithm between ARM core and programmable logic Hands-on workshop on HDL code generation43

Speaker DetailsContact MathWorks IndiaEmail: Vidya.Viswanathan@mathworks.inProducts/Training Enquiry BoothLinkedIn:Call: anatEmail: info@mathworks.inhanYour feedback is valued.Please complete the feedback form provided to you.44

and algorithms on FPGA hardware Solution Use MATLAB to develop, simulate, and evaluate algorithms, and use HDL Coder to implement the best algorithms on FPGAs Results Time from concept to field-testable prototype reduced by 60% Enhancements completed