Rapid prototyping of of DSP algorithms real-time Mattias Arlbrant Grupphandledare, ANC
Agenda 1. 1. Our Our DSP DSP system system 2. 2. Creating Creating a Simulink Simulink model model 3. 3. Running Running the the Simulink Simulink model model on on our our C6713 C6713 signal signal processor processor 4. 4. Changing Changing parameters parameters in in the the signal signal processor processor in in real-time real-time 5. 5. Measuring Measuring performance
In Active Noise Control processing latency (=time delay) is critical! Prediction Time t-4 t-3 t-2 t-1 t t+1 t+2 t+3 t+4 = acoustic delay + processing delay Depends on distance betw. loudspeaker and mic Depends on our signal processing system Longer delay Lower performance
Real-time processing Processing Time Waiting Time n n+1 Sample Time (= 0.125ms @ 8kHz, sound travels ~ 0.000125*340=4.25cm during that ( time We can say we have a real-time application if the CPU can do all processing in the time between two samples. Note that we also have to take care not to introduce extra delay in the algorithms, like for example by using block processing
DSPs = Digital Signal Processors, special CPUs for signal processing Characteristics of of DSPs: DSPs: - Special instructions for common signal processing tasks -Cheap - Low power consumption
Our feedback ANC system No more noise! Let's cancel it all! PC USB cable Awful noise! DSP board with AD/DA Amplifier Mic
The Texas Instruments C6713 DSK board - 225 MHz TMS320C6713 floating point DSP - 16 MB Dynamic RAM, 512 kb Flash memory - USB interface, 4 DIP switches, 4 LEDs - AD/DA with 8-96kHz sampling frequency
Automatic DSP code generation The user only has to create a Simulink model and press a button! Simulink/MATLAB Clever DSP engineer (! you (That could be Simulink generates C-code from a model at the press of a button! ( ComposerStudio CCS CCS (Code (Code Composer CCS does compiling, linking and downloads executable to the DSP! TI TI C6713 C6713 DSK DSK board board = Target
Modeling in Simulink Creating a new Simulink model Click Click the the Simulink Simulink button button in in MATLAB MATLAB to to open open an an empty empty model model
Modeling in Simulink Adding blocks from the Simulink Library Browser Drag and drop
Modeling in Simulink Connecting the blocks Signals, can be - Sample-based = one sample at a time - Frame-based = a block of samples at a time - Multi-channel = two or more frame/sample based signals
Modeling in Simulink Changing block properties Double-clicking on a block opens a parameter dialog: Ex. Digital Filter: Type Coefficients
Simulation in Simulink Start button Simulation time
Simulation in Simulink
Simulink generating DSP code Add a Target preferences block...to let Simulink know what to generate C code for!
Simulink generating DSP code Add A/D and D/A blocks
Simulink generating DSP code Check AD/DA settings: smpl per frame, fs etc.
Simulink generating DSP code Press the magic button...
Simulink generating DSP code CCS opens automatically... and connects to the DSP Run / stop buttons
RTDX Real-Time Data Exchange To communicate with the DSP while it is running GUI (=Graphical User Interface) designed in MATLAB RTDX Channels ( USB (via C6713 DSK
RTDX Real-Time Data Exchange Ex. : Add an RTDX block to control the output level Name of channel Enable
RTDX Real-Time Data Exchange Set RTDX data in the MATLAB GUI Channel name
Performance CPU Load Select DSP/BIOS CPU Load Graph
Performance - Latency We can measure the delay that our DSP board introduces by comparing impulse response measurements on two channels: Out In RME soundcard PC with MATLAB
Performance - Aliasing - Make sure you use efficient decimation and interpolation filters when you process at a lower sample rate - Non-linearities like aliasing components in the feedback loop can cause instability - Check with sinusoids that the aliasing is kept at a low level
Important advice! Build your Simulink model one step at a time and test it after EVERY step! Good luck!
Resources Resources and and tips tips Simulink http://www.mathworks.com/demos/getting_started_with_simulink_demo_video.html -Help>Simulink RTDX - Help>Link for CCS>Automation Interface>Getting started with RTDX - MATLAB GUI prototype implementing RTDX communication ( site (available on course web MATLAB GUI - Type guide in MATLAB, opens a nice GUI editor - Help>MATLAB>Creating graphical user interfaces - MATLAB GUI prototype implementing RTDX communication ( site (available on course web
Useful Useful Simulink Simulink blocks blocks The Subsystem block use it to make the model less cluttered Delay line and Matrix multiply to implement your own filters Mux and Demux to join and split vector signals Transpose - to transpose vector signals Scope, Spectrum scope, To workspace - to inspect signals FIR Decimation/Interpolation or Digital filter and Upsample/Downsample - to do processing at a lower sample rate
Simulink Simulink pitfalls pitfalls The Delay line block make sure you set Allow direct feedthrough correctly The Delay line block the output column vectors have the least delayed sample at the bottom Make sure there is at least one sample of delay in feedback loops