+ All Categories
Home > Documents > Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer ....

Mattias Arlbrant - signal.uu.se · TI C6713 DSK board. TI C6713 DSK board Clever DSP engineer ....

Date post: 07-Aug-2020
Category:
Upload: others
View: 2 times
Download: 3 times
Share this document with a friend
29
Rapid prototyping of DSP algorithms Rapid prototyping of DSP algorithms Mattias Arlbrant real-time Grupphandledare, ANC
Transcript
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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

-

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,

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,

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


Recommended