Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer ....
Transcript of Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer ....
![Page 1: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/1.jpg)
Rapid prototyping of DSP algorithmsRapid prototyping of DSP algorithmsRapid prototyping of DSP algorithms
Mattias Arlbrant
real-time
Grupphandledare, ANC
![Page 2: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/2.jpg)
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
![Page 3: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/3.jpg)
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
![Page 4: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/4.jpg)
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
![Page 5: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/5.jpg)
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:
![Page 6: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/6.jpg)
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!
![Page 7: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/7.jpg)
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
![Page 8: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/8.jpg)
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”
![Page 9: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/9.jpg)
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
![Page 10: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/10.jpg)
Adding blocks from the Simulink Library BrowserModeling in SimulinkModeling in Simulink
Drag and drop
![Page 11: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/11.jpg)
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
![Page 12: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/12.jpg)
Changing block propertiesModeling in SimulinkModeling in Simulink
Type
Coefficients
Double-clicking on a block opens a parameter dialog:
Ex. Digital Filter:
![Page 13: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/13.jpg)
Simulation in SimulinkSimulation in Simulink
Start buttonSimulation time
![Page 14: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/14.jpg)
Simulation in SimulinkSimulation in Simulink
![Page 15: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/15.jpg)
Add a “Target preferences”
block
...to let Simulink know what to generate C code for!
Simulink Simulink ––
generating DSP code generating DSP code
![Page 16: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/16.jpg)
Add A/D and D/A blocksSimulink Simulink ––
generating DSP code generating DSP code
![Page 17: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/17.jpg)
Simulink Simulink ––
generating DSP code generating DSP code Check AD/DA settings: smpl per frame, fs etc.
![Page 18: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/18.jpg)
Press the magic button...Simulink Simulink ––
generating DSP code generating DSP code
![Page 19: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/19.jpg)
CCS opens automatically... and connects to the DSP
Run / stop buttons
Simulink Simulink ––
generating DSP code generating DSP code
![Page 20: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/20.jpg)
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
![Page 21: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/21.jpg)
RTDX RTDX ––
RealReal--Time Data ExchangeTime Data ExchangeEx. : Add an RTDX block to control the output level
Name of channel
Enable
![Page 22: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/22.jpg)
RTDX RTDX ––
RealReal--Time Data ExchangeTime Data ExchangeSet RTDX data in the MATLAB GUI
Channel name
![Page 23: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/23.jpg)
Select DSP/BIOS –
CPU Load Graph
Performance Performance ––
CPU LoadCPU Load
![Page 24: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/24.jpg)
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
![Page 25: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/25.jpg)
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
![Page 26: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/26.jpg)
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!
![Page 27: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/27.jpg)
-
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)
![Page 28: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/28.jpg)
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
![Page 29: Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer . Simulink generates C-code from a “model” at the press of a button! CCS does compiling,](https://reader033.fdocuments.net/reader033/viewer/2022043009/5f9aeca16132a2250163aacd/html5/thumbnails/29.jpg)
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