Electronic Design

C Program Generates Gated Sine Waves Digitally

The C program presented will generate gated-digital sine waves at a 10-Hz frequency (see the listing). Three parameters are user-defined at the head of the program—the output frequency (FO), the sampling rate (FS), and the number of samples to be saved to disk file “xxx”.

The sine function is synthesized by an undamped-biquad IIR digital filter. The sine waves are initiated by an impulse signal of a sampling period width (1/FS), whose impulse amplitude equals the sine-wave amplitude response of the filter (see the figure).

The sineOn( ) and sineOff( ) macros control the initiation of the gated sine waves. These are implemented as inline code in the for( ) loop in the program. A multitude of non-overlapping gated sine waves can be generated. Two such sine waves are shown in the figure. A multiple of sine frequencies (FO) can be generated with a suitable data structure.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish