7 lines
913 B
Text
7 lines
913 B
Text
//! title: A board samples its ADC, low-passes the frame and reports its RMS
|
|
//! description: The fixed-size frame DSP on a microcontroller (diligence move 12): 64 ADC conversions 1 ms apart, a 4th-order Butterworth low-pass at 50 Hz as two biquad sections, a 3-tap FIR, every 4th sample kept, and the RMS over the last 8. Every array is sized at codegen and every loop bounded by a literal; the browser, the Host program and the firmware compute the same f32 bits. Exported with flowrsc firmware for the Nucleo-F401RE, the Nucleo-G071RB or the Pico.
|
|
let n0 = embedded.adc.capture { channel: 0, samples: 64, interval_us: 1000 };
|
|
let n1 = dsp.biquad(input: n0.frame) { family: butterworth, order: 4, cutoff: 50, sample_rate: 1000 };
|
|
let n2 = dsp.fir(input: n1.output) { taps: "0.25 0.5 0.25" };
|
|
let n3 = dsp.decimate(input: n2.output) { factor: 4 };
|
|
let n4 = dsp.moving(input: n3.output) { stat: rms, window: 8 };
|