48
Real-Time DSP for Educators Michael Morrow University of Wisconsin-Madison Thad Welch United States Naval Academy Cameron Wright University of Wyoming

Real-Time DSP for Educators - Texas · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

  • Upload
    haduong

  • View
    229

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Real-Time DSP for Educators

Michael MorrowUniversity of Wisconsin-MadisonThad WelchUnited States Naval AcademyCameron WrightUniversity of Wyoming

Page 2: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Agenda• Introduction

– Motivation– DSK and Software Installation

• Building Real-Time DSP Applications– Software Organization– Building a CCStudio Talk-Through Application– FIR Filtering– Signal Generation

• Advanced Topics– DSP/BIOS™ Application– HPI Daughtercard (DSP Services/Host Services)– Individual Projects

• Wrap-Up

Page 3: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Motivation

• Do you teach or want to teach a DSP course?

• Do you use MATLAB® exercises in your courses?

• Do you assign exercises that work with actual signals (not generated in MATLAB)?

• Do you include real-time DSP demonstrations in your courses?

• Do you assign real-time projects?

Page 4: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Real-time DSP• It can be a real struggle to get started with

real-time DSP– Lots of details come up that just aren’t an issue

when programming in a workstation environment– Documentation is written for experts

• Learning curve is steep, if not vertical!

– Few understandable examples are available• Complexity is the norm

– On-line and seminar style training is available directly from TI and the third party vendors

– But, most of this training is not appropriate for the typical student (or educator) due to at least one of the following issues…

Page 5: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Typical Training Issues• Not meant for educators

– Our first courses should motivate our students to learn more about real-time DSP

– Much of the industry does not do sample-by-sample DSP, despite the fact that few teach anything else

• Meant for DSP experts– Expects significant familiarity with DSP system

design– Intended for engineers transitioning from other

DSP targets– Usually introducing the latest innovations and

technologies, not fundamentals

Page 6: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

What You Can Take Away From This Workshop

• A TI TMS320C6713 DSK (and Code Composer Studio™ software development suite)– Also includes some useful accessories - a

microphone, headphones, audio cable, and music CD

• An Educational DSP DSK6XXXHPI daughtercard• Our real-time DSP book, and (most importantly)• The ability to easily use the DSK and incorporate real-

time DSP hardware into your DSP courses/labs

Page 7: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

The DSP Big Picturey[n] = ...

differenceequation

H(z)transferfunction

H(ejω)frequencyresponse

h[n]impulse

response

pole/zerodiagram

blockdiagram

Page 8: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

The Real-time DSP Big Picturey[n] = ...

differenceequation

H(z)transferfunction

H(ejω)frequencyresponse

h[n]impulse

response

pole/zerodiagram

blockdiagram

real-timeimplementation

Page 9: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

DSP of Analog Signals

antialiasing

filter

sampleandhold

DSPdigital

to analogconverter

analog todigital

converter

reconstructionfilter

analogworld

analogworld

Page 10: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Our Methodology

• Review of theory• Demonstration/motivation using winDSK6• MATLAB coding• Transition to real-time C on the DSK

Page 11: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Agenda• Introduction

– Motivation– DSK and Software Installation

• Building Real-Time DSP Applications– Software Organization– Building a CCStudio Talk-Through Application– FIR Filtering– Signal Generation

• Advanced Topics– DSP/BIOS™ Application– HPI Daughtercard (DSP Services/Host Services)– Individual Projects

• Wrap-Up

Page 12: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Hardware Discussion• Let’s unpack our DSKs• Look at what comes in your box• Note that like many USB devices, the

hardware installation comes AFTER the software installation

• A quick tour of the board …

Page 13: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

DSK Overview• TMS320C6713 DSP at 225MHz• TLV320AIC23 stereo codec

– Microphone & line inputs– Headphone & line outputs– Uses both McBSPs– We configure for 16-bits at 48KHz

• 16MB SDRAM / 512KB Flash memory• Onboard USB-based JTAG emulator• 4 DIP switches & 4 LEDs (user controlled)

Page 14: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

DSK Overview (continued)• Three daughtercard connectors

– J1 – HPI interface • New to the C6713 DSK• Used by the Educational DSP HPI daughtercard

– Direct DSP control from a host computer – DSP can use daughtercard for communications (USB/RS-

232), digital I/O, and analog inputs

– J3 – Peripheral Interface• McBSPs, Timers

– J4 – EMIF (parallel memory bus)• SDRAM, Flash Memory

• Many EVMs and daughtercards are available from TI and others

Page 15: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

TI TMS320C6713 DSK

Page 16: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

TI TMS320C6713 DSK

Page 17: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

DSK w/ HPI Daughtercard

Page 18: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Software Installation• Quick Start Installation Guide• CCStudio software installation

– Follow the CD’s instructions– Do not attempt to register the software at this time– Be sure to install both CCStudio 3.1 and the C6713 DSK target

content.– Leave the CD in after the install finishes and then connect the

DSK to install the USB driver.– Note that there are two CCStudio icons on the Desktop

• The C6713 icon will automatically import the DSK into CCStudio.

• winDSK6• A quick look at the contents of the textbook CD-ROM

Page 19: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Agenda• Introduction

– Motivation– DSK and Software Installation

• Building Real-Time DSP Applications– Software Organization– Building a CCStudio Talk-Through Application– FIR Filtering– Signal Generation

• Advanced Topics– DSP/BIOS™ Application– HPI Daughtercard (DSP Services/Host Services)– Individual Projects

• Wrap-Up

Page 20: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Our Software Organization• All software is interrupt-driven• All configuration code is contained in a

“common_code” directory• All applications are designed to run on both the

C6713 DSK and the TMS320C6711 DSK (with the onboard codec and several codec daughtercards)

• A single #define selects the proper software to configure the codec, the input source, and the sampling rate

Page 21: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

A Basic Application (Talk-through)

Page 22: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Agenda• Introduction

– Motivation– DSK and Software Installation

• Building Real-Time DSP Applications– Software Organization– Building a CCStudio Talk-Through Application– FIR Filtering– Signal Generation

• Advanced Topics– DSP/BIOS™ Application– HPI Daughtercard (DSP Services/Host Services)– Individual Projects

• Wrap-Up

Page 23: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

The CCStudio Project Big Picture• Open CCStudio• Create a project

– Be aware of what directory you are in, especially if you then navigate somewhere within CCStudio

• Add files to the project directory• Add files to project

– Our code is interrupt driven, so most work today will be done on isrs.c

• Setup the compiler options• Build the project• Load the project• Run the project

Page 24: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

CCStudio: A Tutorial

• Appendix A of the textbook

Page 25: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

CCStudio Observations• Does the talk-through program work?• You can run or halt the program at

anytime and you don’t need to reload• You can establish a watch window by

highlighting and right-clicking on the variable that you selecting, then selecting Add to Watch Window

• Watched variables can be modified while the program is running (if they are in scope)

Page 26: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

A Few Comments• Watch window(s)

– Make sure that you are in scope• The volatile keyword• Function prototypes and return types• ISRs and the run-time schedule• Sample-by-sample processing• Gain adjustments (volume control)• “Hello, world” … can we print to the host PC?• Turning the user LEDs on and off

Page 27: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Agenda• Introduction

– Motivation– DSK and Software Installation

• Building Real-Time DSP Applications– Software Organization– Building a CCStudio Talk-Through Application– FIR Filtering– Signal Generation

• Advanced Topics– DSP/BIOS™ Application– HPI Daughtercard (DSP Services/Host Services)– Individual Projects

• Wrap-Up

Page 28: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

FIR Filtering• FIR filters are the most popular type of

digital filter• Always stable• Easy to design• Easy to ensure linear phase response• Require more coefficients for same roll off

compared to IIR filters

Page 29: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

FIR Filter

z-1

z-1

z-1

z-1

+

+

+

+

x[n] y[n]b0

b1

b2

b3

b4

x[n-1]

x[n-2]

x[n-3]

x[n-4]

Page 30: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

FIR Difference Equation

[ ] [ ] [ ] [ ]

[ ] [ ] [ ] [ ]

[ ] [ ] [ ]

[ ] [ ] [ ] [ ] [ ] [ ] [ ]

0

0

[ ] *

[ ] *

0

0 0 0 1 1

kN

kN

k

y n h k x n k h n x n

y n b k x n k b n x n

y b k x k

y b x b x b N x N

=−∞

=

=

= − =

= − =

= −

= + − + + −

∑L

Page 31: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

FIR Difference Equation (con’t)

[ ] [ ] [ ] [ ] [ ] [ ] [ ]

[ ] [ ] [ ] [ ] [ ] [ ] [ ]

0 0 0 1 1but we can modify the indices

0 0 0 1 1

y b x b x b N x N

y b x b x b N x N

= + − + + −

= + + +

L

L

Page 32: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

CCStudio Implementation• Local declaration

– Declare the b coefficients in the ISR– Cut-and-paste can also work

• Additional files (e.g., coeff.c and coeff.h)– Great for large filters

• But do you really want to type in all of those coefficients by hand?

– Create the files directly from MATLAB• FIR_dump2c.m

Page 33: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Sptool Startup GUI

Page 34: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Fdatool Startup GUI

Page 35: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

More FIR … a few ideas• Flanging• Chorus• Circular buffering• Echo creation• Other FIR filter forms

– e.g., second order sections• Impulse modulator … digital transmitter

Page 36: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Agenda• Introduction

– Motivation– DSK and Software Installation

• Building Real-Time DSP Applications– Software Organization– Building a CCStudio Talk-Through Application– FIR Filtering– Signal Generation

• Advanced Topics– DSP/BIOS™ Application– HPI Daughtercard (DSP Services/Host Services)– Individual Projects

• Wrap-Up

Page 37: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Real-time Waveform Generation

• Your mission – generate a 1 kHz sinusoid• Some ways to do it

– VOUT = VMAXsin(2πft)– Calculate directly as a function of t– Calculate as a function of the desired signal phase– Use lookup table to obtain sine values, use index as phase

accumulator– Use complex vector rotation– Use a digital resonator

• May want to glance at textbook• Modify your talk-through application as necessary create

a sinusoid generator

Page 38: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Agenda• Introduction

– Motivation– DSK and Software Installation

• Building Real-Time DSP Applications– Software Organization– Building a CCStudio Talk-Through Application– FIR Filtering– Signal Generation

• Advanced Topics– DSP/BIOS™ Application– HPI Daughtercard (DSP Services/Host Services)– Individual Projects

• Wrap-Up

Page 39: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Intro to DSP/BIOS™ Software Kernel Foundation

• DSP/BIOS™ kernel is a lean real-time operating system (RTOS) specific to the TI DSPs

• There are advantages and disadvantages to introducing it into an academic setting

• Follow Appendix B of your textbook– Section B.1 – Introduction– Section B.2 – Exercise in using threads

• Can come back to this if you have time & desire– Section B.5 – Talk-through on the C6713 DSK

• This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

• Text for cut-and-paste is on your CD-ROM

Page 40: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Agenda• Introduction

– Motivation– DSK and Software Installation

• Building Real-Time DSP Applications– Software Organization– Building a CCStudio Talk-Through Application– FIR Filtering– Signal Generation

• Advanced Topics– DSP/BIOS Application– HPI Daughtercard (DSP Services/Host Services)– Individual Projects

• Wrap-Up

Page 41: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

eDSP DSK6713HPI Daughtercard• Host Services

– Using a host PC to control the DSK without CCStudio• winDSK6• MATLAB Interfaces (data acquisition and real-time control)• DSK6X_Control for host application development

• DSP Services– The DSP software can use the daughtercard resources

as well• USB and RS-232 communications• Up to 16 digital I/O pins• Up to 8 analog inputs

– Software interface is already provided – simple function calls are used to access all resources

Page 42: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Agenda• Introduction

– Motivation– DSK and Software Installation

• Building Real-Time DSP Applications– Software Organization– Building a CCStudio Talk-Through Application– FIR Filtering– Signal Generation

• Advanced Topics– DSP/BIOS™ Application– HPI Daughtercard (DSP Services/Host Services)– Individual Projects

• Wrap-Up

Page 43: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Individual Project Time• Have at it!• Feel free to ask questions

Page 44: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Agenda• Introduction

– Motivation– DSK and Software Installation

• Building Real-Time DSP Applications– Software Organization– Building a CCStudio Talk-Through Application– FIR Filtering– Signal Generation

• Advanced Topics– DSP/BIOS™ Application– HPI Daughtercard (DSP Services/Host Services)– Individual Projects

• Wrap-Up

Page 45: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Wrap-Up• The DSK development environment is

fairly easy to use … once you know how!• Practice making your own CCStudio

projects• Mike’s software page has lots of software

for the C6713 and older DSKs– http://eceserv0.ece.wisc.edu/~morrow/software/

• For more information on the HPI daughtercardsee the Educational DSP website– http://www.educationaldsp.com

Page 46: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

Real-Time DSP for Educators

Michael Morrow ([email protected])University of Wisconsin-MadisonThad Welch ([email protected])United States Naval AcademyCameron Wright ([email protected])University of Wyoming

Page 47: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

References• [1] – TMS320C6713 DSK Technical

Reference, Spectrum Digital, Jan. 2004• [2] – Digital Signal Processing, a

computer-based approach, Sanjit K. Mitra, McGraw Hill, 2001

• [3] – Real-time Digital Signal Processing from MATLAB to C with the TMS320C6X™, Thad B. Welch, Cameron H. G. Wright, Michael G. Morrow, CRC Press, 2006

Page 48: Real-Time DSP for Educators - Texas  · PDF fileReal-Time DSP for Educators ... • MATLAB coding ... • This is equivalent to the earlier tutorial, but in a DSP/BIOS environment

winDSK6

• Numerous demonstration and experimentation applications

• Other software– DSK6_Control host application and DSP software– C6XDAQ MATLAB data acquisition– C6XDSK MATLAB program interface