The C source listing shown is a complete operating program that generates first and second-order IIR digital filter coefficients from analog filter prototypes. The program prompts users for all of the required parameter inputs, then it outputs the frequency-scaled analog prototype filter and IIR filter coefficients.
As an option, users can execute a prototype frequency prewarp or do straight frequency scaling. Note that the target frequency (TargetFreq) is the desired IIR corner frequency for low-pass/ high-pass filters, or the center frequency for bandpass/notch filters. Also, the prototype frequency (ProtoFreq) is the corresponding unscaled frequency.
Check your program with this third-order low pass:
normalized (WC = 1)
where TargetFreq = 100 Hz; ProtoFreq = 0.15915 Hz; and Prewarp = Yes.
See the figure for signal flow diagram conventions.