Real-Time DSP for Educators Michael Morrow University of Wisconsin-Madison Thad Welch United States Naval Academy Cameron Wright University of Wyoming
Introduction Agenda 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
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?
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
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-bysample 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
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 realtime DSP hardware into your DSP courses/labs
The DSP Big Picture y[n] =... difference equation h[n] impulse response H(z) transfer function H(e jω ) frequency response pole/zero diagram block diagram
The Real-time DSP Big Picture y[n] =... difference equation h[n] impulse response H(z) transfer function real-time implementation H(e jω ) frequency response pole/zero diagram block diagram
DSP of Analog Signals analog world anti aliasing filter sample and hold analog to digital converter analog world reconstruction filter digital to analog converter DSP
Our Methodology Review of theory Demonstration/motivation using windsk6 MATLAB coding Transition to real-time C on the DSK
Introduction Agenda 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
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
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)
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
TI TMS320C6713 DSK
TI TMS320C6713 DSK
DSK w/ HPI Daughtercard
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
Introduction Agenda 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
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
A Basic Application (Talk-through)
Introduction Agenda 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
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
CCStudio: A Tutorial Appendix A of the textbook
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)
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
Introduction Agenda 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
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
FIR Filter x[n] b 0 + y[n] z -1 x[n-1] b 1 + z -1 x[n-2] b 2 + z -1 x[n-3] b 3 + z -1 x[n-4] b 4
FIR Difference Equation k= 0 [ ] [ ] [ ] [ ] yn [ ] = hk xn k = hn* xn k= N [ ] [ ] [ ] [ ] yn [ ] = bk xn k = bn* xn N [ 0] = [ ] [ ] y b k x k k= 0 [ 0] = [ 0] [ 0] + [ 1] [ 1] + L+ [ ] [ ] y b x b x b N x N
FIR Difference Equation (con t) [ 0] = [ 0] [ 0] + [ 1] [ 1] + L+ [ ] [ ] y b x b x b N x N but we can modify the indices [ 0] = [ 0] [ 0] + [ 1] [ 1] + L+ [ ] [ ] y b x b x b N x N
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
Sptool Startup GUI
Fdatool Startup GUI
More FIR a few ideas Flanging Chorus Circular buffering Echo creation Other FIR filter forms e.g., second order sections Impulse modulator digital transmitter
Introduction Agenda 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
Real-time Waveform Generation Your mission generate a 1 khz sinusoid Some ways to do it V OUT = V MAX sin(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
Introduction Agenda 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
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
Introduction Agenda 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
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
Introduction Agenda 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
Individual Project Time Have at it! Feel free to ask questions
Introduction Agenda 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
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 daughtercard see the Educational DSP website http://www.educationaldsp.com
Real-Time DSP for Educators Michael Morrow (morrow@ieee.org) University of Wisconsin-Madison Thad Welch (t.b.welch@ieee.org) United States Naval Academy Cameron Wright (c.h.g.wright@ieee.org) University of Wyoming
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
windsk6 Numerous demonstration and experimentation applications Other software DSK6_Control host application and DSP software C6XDAQ MATLAB data acquisition C6XDSK MATLAB program interface