I have a situation that the measurement device is generating a known signal in the data at 1/4 of the rate. In this case that is a 500 Hz signal when sampling at 2000 Hz.
Now I can extract the 500 Hz signal using a Butterworth Band-Pass at 490–510 Hz which works, but it takes >1/8th of a second to extract the signal. In our setup we know the measurement and the signal are perfect in sync (same clock source etc) so a perfect 500 Hz filter would be ideal.
Is there a better extraction method? Ideally without the latency of the Butterworth or more computationally efficient or more accurate to extract the signal?
Here is an example of the 2 kHz data:
-34561, -32650, -3422, -5064, -33967, -32061, -2807, -4436, -33364, -31447, -2108, -3771, -32863, -31050, -1801, -3516, -32634, -30871, -1711, -3496, -32761, -31115, -2027, -3919, -33237, -31652, -2684, -4606, -33831, -32279, -3394, -5291, -34442, -32775, -3764, -5582, -34667, -32969, -3872, -5589, -34532, -32665, -3446, -5064, -34014, -32082, -2771, -4385, -33355, -31437, -2114, -3771, -32854, -31032, -1796, -3501, -32651, -30819, -1593, -3425, -32671, -31067, -1924, -3859, -33214, -31631, -2639, -4519, -33802, -32225, -3301, -5254, -34406, -32736, -3741, -5594, -34652, -32932, -3886, -5572, -34453, -32592, -3377, -5056, -33953, -32043
Edit: The aspect of interest is the amplitude of the 500hz signal, the amplitude can be converted to give a circuit impedance which we wish to efficiently measure. The butterworth takes a long time for a 1st order butterworth to converge to a steady amplitude measurement with fixed circuit impedance. A higher order could viable but this feels like overkill and as there is so many known about the signal so a more efficient approach would feel to be viable, just magnitude is the key. I tried some simple approached but these still had oscillation of amplitude at 50hz albeit the average was good, there may be formal methods I'd like to try.
Update: Here is a plot showing the butterworth vs the given solution shown in Green which does exactly what I had hoped with 4 samples latency! Previously I had looked at peak-signal but taking peak-average does look preferable anyway and what the solution is giving us. Thankyou for your help.