Digital Signal Processing Reference
In-Depth Information
// sine8000_table.h Sine table with 8000 points generated with MATLAB
short sine8000[8000]=
{0, 1, 2, 2, 3, 4, 5, 5,
6, 7, 8, 9, 9, 10, 11, 12,
13, 13, 14, 15, 16, 16, 17, 18,
19, 20, 20, 21, 22, 23, 24, 24,
25, 26, 27, 27, 28, 29, 30, 31,
31, 32, 33, 34, 35, 35, 36, 37,
38, 38, 39, 40, 41, 42, 42, 43,
44, 45, 46, 46, 47, 48, 49, 49,
50, 51, 52, 53, 53, 54, 55, 56,
57, 57, 58, 59, 60, 60, 61, 62,
63, 64, 64, 65, 66, 67, 67, 68,
69, 70, 71, 71, 72, 73, 74, 75,
75, 76, 77, 78, 78, 79, 80, 81,
82, 82, 83, 84, 85, 86, 86, 87,
88, 89, 89, 90, 91, 92, 93, 93,
94, 95, 96, 96, 97, 98, 99, 100,
100, 101, 102, 103, 103, 104, 105, 106,
107, 107, 108, 109, 110, 111, 111, 112,
.
.
.
-13, -12, -11, -10, -9, -9, -8, -7,
-6, -5, -5, -4, -3, -2, -2, -1};
FIGURE 2.25. Partial listing of a sine with 8000 data points ( sine8000_table.h ).
Figure 2.25 shows a partial listing of the file sine8000_table.h .
The initial frequency is set at 100 Hz and increments every 200 Hz until a stop
frequency of 3500 Hz is reached. The frequencies generated are 100, 300, 500,...,
3500 Hz, and each frequency is generated for 1 second.
Increase delay_msecs from 1000 to 2000 for a slower sweep, since each fre-
quency would be generated for 2 seconds rather than 1 second. If step_freq
is increased to 700, the frequencies generated would be 100, 800, 1500, 2200, and
2900 Hz.
The index i is incremented by i + freq , which determines the values chosen from
the table (see also Example 2.4, sine2sliders ). For example, to generate 100 Hz, every
100th value in the table is selected to output 80 data points, corresponding to 1 cycle,
that is, 8000 points over 100 cycles. With this scheme, 8000 points are always used
to generate each frequency over x cycles per second.
Build and run this project as sweep8000 . Verify the output as a sweeping
sinusoid. Note that the source program sweep8000.c is polling-driven (use the
appropriate vector file). A slider can be used to control the amplitude of the fre-
quency generated with the variable amp , the duration at each frequency with
delay_msecs (sweep speed), and the incremental frequency with step_freq .
Search WWH ::




Custom Search