I am pretty new to DSP and I need some help to pinpoint my mistake.
I am using Matlab to simulate an embedded environment. I have three signals all centered on 50Hz (6.4KHz sampling rate) which have no offset or harmonics in them. I generate such signals and write them to file using a trusted program. All signals have the same magnitude and frequency content (ie only 50Hz signal) but are 120 degrees apart. Signal 1 starts at zero degrees, second signal is at 240 degrees and third at 120 degrees.
The Matlab signal chain starts with the opening (/dumping) of the file which contains the AC signals. Decimation of the signals is performed using resample() from 6.4KHz down to 1.6KHz (Decimation factor 4), followed by an FFT on a full signal cycle. From the fundamental component (50Hz) the RMS-Magnitude is calculated.
On the ARM Cortex M7 platform now, in a very similar manner as above, I have the same signals written in flash memory. I zero pad at the end of my signal data block to compensate for the FIR group delay. I then decimate the signals using CMSIS arm_fir_decimate_f32(), with filter coefficients generated from Maltab Filter Designer, floowed by a left shift to compensate for the FIR group delay. I then perform an FFT using arm_rfft_fast_f32() on a full signal cycle. Finally, from the fundamental component (50Hz) the RMS-Magnitude is calculated.
I was expecting the Magnitude estimation of the embedded signal to closely match that of the known generated magnitude (/Matlab estimation). However, I am finding the magnitude estimation on the embedded platform to be slightly off when compared to the signal magnitude I know I am generating.
Signal 1 is ~+0.4% (higher), signal 2 is ~-1.7% (lower) and signal 3 is ~-2.03%.
My best guess at the moment is that this discrepancy lies with a mistake I have made with regards to the arm_fir_decimate_f32() filter coefficients. As far as I can tell Matlabs resample() uses the firls() function to generate coefficients.
I have used the same firls() function to generate the coefs, from filter order 20 up to 80 but still get this discrepancy.
Typically I am using Fpass: 160Hz, Cut-off frequency (Fstop): 800Hz, Apass: 0.1dB, Astop: 106dB (ADC SINAD value).
Does resample() compensate for the FIR response?
Any help much appreciated.