Electronic Design

  
Reprints     Printer-Friendly    Email this Article    RSS        Font Size     What's This?


[Ideas For Design]
Program Converts Real Sequences To Cosine Series

Frank N. Vitalijic  |   ED Online ID #3895  |   June 18, 2001


This program converts a sampled real sequence stored in a disk file to a harmonically related set of cosine waveforms To view the program, click Download the Code at the top of the page.. The cosine series can be used for waveform approximation, circuit design and analysis, simulation, and waveform synthesis.

First, the program downloads N samples of the waveform from disk and copies the data to the signal[n] array. Then, the discrete Fourier transform (DFT) is applied to the real sequence in signal[n]. The resulting N complex-amplitude spectral components X(k) are stored in the spectrum[k] array. Real and image frequencies (k), which have conjugate-symmetry for real sequences, make up the spectrum X(k). If N is even, the program eliminates the last sample, forcing an odd value of N. This ensures complete conjugate pairs of real/image frequencies.

As shown in the following, the inverse DFT applied to the spectrum X(k) has the form of a cosine series.

where θ(k) = tan−1( imX( k )/reX( k ) ) radians.

From the Nyquist sampling criterion,

where F = actual frequency (Hz) and FS = sampling frequency (Hz).

The coefficients of the series are stored in an array of coefficient structures [k] as demonstrated below:

These coefficients are listed in tabular form. To test the program, a single pulse is used. Next, the function get_real-data( ) in function main( ) is disabled and these statements are added:

int i;

for (i=0; i < 50; i++) signal(i) = 10.0;

for (i=50; i < 250; i++) signal(i) = 0.0;

After this, the program is recompiled and run, generati ng a 10-V input pulse that's 50 samples wide. At the prompt, the number of real data points is entered as 200. The program then displays the calculated cosine coefficients versus index k (see the table).


Reprints   Printer-Friendly  Email this Article  RSS    Font Size   What's This?



POST YOUR COMMENTS HERE
Name:

Email:
Your Comments:

Enter the text from the image below


Please refresh the page if you have trouble reading this text.

Search Electronic Design
     
  
 
Web Seminar
Sponsored By:
Title: Read Pacing: A Performance Enhancing Feature of PCI Express Gen 2 Switch Devices
Speakers: 
Date: 07/01/08
Register: 

Electronic Design Europe Electronic Design China EEPN Power Electronics Auto Electronics Microwaves & RF
Mobile Dev & Design Schematics Find Power Products Military Electronics EE Events Related Resources