Professional Documents
Culture Documents
Chapter 4 Sine Waves
Chapter 4 Sine Waves
Sine Waves
Texas Instruments University Programme Teaching Materials
0-1
Sine Waves
Chapter 4 - Slide 2
Introduction
DSP can be used to generate sine waves Sine waves can be used in audio to:
Generate musical tones and complex waveforms Generate tones for touch phones (DTMF) Modulate audio signals (alien voices) Control audio effects (chorus/phasing/flanging).
Chapter 4 - Slide 3
Objectives
To generate sine waves from 10Hz to 16000Hz. To introduce the Texas Instruments library of DSP functions DSPLIB.
Chapter 4 - Slide 4
Knowledge Required
Some understanding of fixed-point and floating-point numbers is required.
Details of two useful articles from www.cnx.org are given in the References Section.
Chapter 4 - Slide 5
Chapter 4 - Slide 6
Chapter 4 - Slide 7
Chapter 4 - Slide 8
Look-up Table
This is the simplest way to generate a sine wave. Put known values into a table:
Chapter 4 - Slide 9
Disadvantages:
Can only be used for exact divisions of sampling frequency.
Chapter 4 - Slide 10
Recursive Equation
Uses the following mathematical equation:
Chapter 4 - Slide 11
Taylor Series
A sine function can be implemented as a geometric series:
x x x sin( x) x 3! 5! 7!
where
Chapter 4 - Slide 12
Chapter 4 - Slide 13
C Code Implementation
Chapter 4 - Slide 14
Sine Function in C
As standard, C comes with the function sin(x) in math.h.
Chapter 4 - Slide 15
Introducing DSPLIB
Chapter 4 - Slide 16
About DSPLIB
Texas Instruments provides a library containing a whole range of useful functions used in DSP:
Chapter 4 - Slide 17
Chapter 4 - Slide 18
DSPLIB Library
The library file 55xdsph.lib must be present in the build.
Parameter 3. Always 1.
Chapter 4 - Slide 20
Chapter 4 - Slide 21
Magic Numbers
Where did the magic number 22368 come from? The TMS320C5505 is a 16-bit fixed-point processor that uses:
32767 to represent 1.000 32767 to represent 1.000
Here 22368 represents 0.682 decimal. We shall now look at how this magic number was obtained.
Chapter 4 - Slide 22
Chapter 4 - Slide 23
Sine 90o
To generate a waveform using 4 values we use:
sin 0o sin 90o sin 180o sin 270o.
Chapter 4 - Slide 24
Sine 45o
To generate a waveform using 8 value use:
sin 0o sin 45o sin 90o sin 135o etc.
Chapter 4 - Slide 25
Chapter 4 - Slide 26
Fixed-Point Implementation
For 1 Hz we require each angle to be multiples of:
360o/48000 = 0.0075o
Chapter 4 - Slide 27
Scaling Factor
We can use the value for 1 Hz as a scaling factor to calculate other frequencies:
For 10 Hz:
10 * SCALING FACTOR = 10 * 360o/48000 = 0.075o
Chapter 4 - Slide 28
32767 2* 48000
In fixed-point maths, to divide by 48000 is awkward
Chapter 4 - Slide 30
Introduction to Laboratory
Chapter 4 - Slide 31
Headphones
Chapter 4 - Slide 32
Chapter 4 - Slide 33
Chapter 4 - Slide 34
Chapter 4 - Slide 35
Console
Sampling frequency and Gain are shown in the Console window.
Chapter 4 - Slide 36
Experiments
Chapter 4 - Slide 37
Chapter 4 - Slide 38
A = 440 Hz
C = 523 Hz
Chapter 4 - Slide 39
Chapter 4 - Slide 40
Questions
What are 3 ways to generate sine waves? Which method is best suited to the TMS320C5505 USB Stick? What are 3 applications of sine waves?
Chapter 4 - Slide 41
References
TMS320C55xx DSP Library Programmers Reference. SPRU 422.
Digital Signal Processing with C and the TMS320C30 by Rulph Chassaing. ISBN 0-471-55780-3. www.cnx.org Fixed Point Arithmetic and Format (m10919) by Hyeokho Choi.
www.cnx.org Fixed Point Arithmetic (m11054) by Hyeokho Choi.
2010 Texas Instruments Inc
Chapter 4 - Slide 42