Rapid prototyping of DSP algorithmsRapid prototyping of DSP algorithmsRapid prototyping of DSP algorithms
Mattias Arlbrant
real-time
Grupphandledare, ANC
Agenda Agenda
1. Our DSP system1. Our DSP system
2. Creating a Simulink model2. Creating a Simulink model
3. Running the Simulink model on our C6713 signal processor
3. Running the Simulink model on our C6713 signal processor
4. Changing parameters in the signal processor in real-time
4. Changing parameters in the signal processor in real-time
5. Measuring performance5. Measuring performance
In Active Noise Controlprocessing latency (=time delay) is critical!
Longer delay Lower performance
t
Timet-1t-2t-3 t+1 t+2 t+3 t+4t-4
= acoustic delay + processing delay
Prediction
Depends on distance betw. loudspeaker and mic
Depends on our signal processing system
Processing TimeProcessing TimeWaiting Waiting
TimeTime
Sample TimeSample Time(= 0.125ms @ 8kHz, sound travels ~ (= 0.125ms @ 8kHz, sound travels ~ 0.000125*340=4.25cm during that time)0.000125*340=4.25cm during that time)
nn n+1n+1
RealReal--time time processing processing
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 DSPs
-
Special instructions for common signal processing tasks
- Cheap
-
Low power consumption
= Digital Signal Processors, special CPUs for signal processing
Characteristics of DSPs:Characteristics of DSPs:
Our feedback ANC systemOur feedback ANC system
DSP board with AD/DA
AmplifierMic
USB cable
No more noise! Let's cancel it all!
PCAwful noise!
The Texas Instruments C6713 DSK boardThe 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 generationAutomatic DSP code generation
Simulink/MATLABSimulink/MATLAB
CCS (Code Composer Studio) CCS (Code Composer Studio)
TI C6713 DSK boardTI C6713 DSK board
Clever DSP engineer
Simulink generates C-code from a “model”
at the press of a button!
CCS does compiling, linking and downloads executable to the DSP!
The user only has to create a Simulink “model”
and press a button!
(That could be you!)
= “Target”
Modeling in SimulinkModeling in SimulinkCreating a new Simulink model
Click the “Simulink”
button in MATLAB to open an empty model
Click the “Simulink”
button in MATLAB to open an empty model
Adding blocks from the Simulink Library BrowserModeling in SimulinkModeling in Simulink
Drag and drop
Connecting the blocksModeling in SimulinkModeling in Simulink
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 basedsignals
Changing block propertiesModeling in SimulinkModeling in Simulink
Type
Coefficients
Double-clicking on a block opens a parameter dialog:
Ex. Digital Filter:
Simulation in SimulinkSimulation in Simulink
Start buttonSimulation time
Simulation in SimulinkSimulation in Simulink
Add a “Target preferences”
block
...to let Simulink know what to generate C code for!
Simulink Simulink ––
generating DSP code generating DSP code
Add A/D and D/A blocksSimulink Simulink ––
generating DSP code generating DSP code
Simulink Simulink ––
generating DSP code generating DSP code Check AD/DA settings: smpl per frame, fs etc.
Press the magic button...Simulink Simulink ––
generating DSP code generating DSP code
CCS opens automatically... and connects to the DSP
Run / stop buttons
Simulink Simulink ––
generating DSP code generating DSP code
RTDX RTDX ––
RealReal--Time Data ExchangeTime Data ExchangeTo communicate with the DSP while it is running
RTDX Channels (via USB)
GUI (=Graphical User Interface) designed in MATLAB
C6713 DSK
RTDX RTDX ––
RealReal--Time Data ExchangeTime Data ExchangeEx. : Add an RTDX block to control the output level
Name of channel
Enable
RTDX RTDX ––
RealReal--Time Data ExchangeTime Data ExchangeSet RTDX data in the MATLAB GUI
Channel name
Select DSP/BIOS –
CPU Load Graph
Performance Performance ––
CPU LoadCPU Load
Performance Performance --
LatencyLatency
We can measure the delay that our DSP board introduces by comparing impulse response measurements on two channels:
RME soundcardOut In
PC with MATLAB
Performance Performance --
AliasingAliasing
-
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!Important advice!
Build your Simulink model one step at Build your Simulink model one step at a time and test it after EVERY step!a time and test it after EVERY step!
Good luck!
-
Help>Link for CCS>Automation Interface>Getting started with RTDXRTDX
Resources and tipsResources and tipsResources and tips
Simulink
MATLAB GUI
-
MATLAB GUI prototype implementing RTDX communication (available on course web site)
-
Type “guide”
in MATLAB, opens a nice GUI editor
http://www.mathworks.com/demos/getting_started_with_simulink_demo_video.html
- Help>Simulink
-
Help>MATLAB>Creating graphical user interfaces
-
MATLAB GUI prototype implementing RTDX communication (available on course web site)
Useful Simulink blocksUseful Simulink blocksUseful Simulink 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 pitfallsSimulink pitfallsSimulink 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