Program Converts Real Sequences To Cosine Series

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...

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 bottom 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, generating 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).

To download the listings, click Download the Code.

Sponsored Recommendations

TTI Transportation Resource Center

April 8, 2024
From sensors to vehicle electrification, from design to production, on-board and off-board a TTI Transportation Specialist will help you keep moving into the future. TTI has been...

Cornell Dubilier: Push EV Charging to Higher Productivity and Lower Recharge Times

April 8, 2024
Optimized for high efficiency power inverter/converter level 3 EV charging systems, CDE capacitors offer high capacitance values, low inductance (< 5 nH), high ripple current ...

TTI Hybrid & Electric Vehicles Line Card

April 8, 2024
Components for Infrastructure, Connectivity and On-board Systems TTI stocks the premier electrical components that hybrid and electric vehicle manufacturers and suppliers need...

Bourns: Automotive-Grade Components for the Rough Road Ahead

April 8, 2024
The electronics needed for transportation today is getting increasingly more demanding and sophisticated, requiring not only high quality components but those that interface well...

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!