# Remove a signal that is known to repeat every 4 samples at a known phase i.e. exactly 500 Hz signal in 2000 Hz data

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 already measure the amplitude of the 500Hz signal using the Heterodyne technique (See previous question Extract a signal that is known to repeat every 4 samples at a known phase i.e. exactly 500 Hz signal in 2000 Hz data) and was wondering if a similar/same method is exists to subtract/remove the 500Hz signal from the signal?

Currently we would employ a Butterworth bandstop of 490-510Hz but this doesn't completely cut-out 500Hz under some conditions? Also if we make the filter too narrow it has a very long latency.

-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

Currently we would employ a Butterworth bandstop of 490-510Hz but this doesn't completely cut-out 500Hz under some conditions

Use a notch filter instead. It will completely remove the 500Hz component and you can adjust the Q to dial in the width vs latency or group delay distortion

Also if we make the filter too narrow it has a very long latency.

That's unavoidable: the narrower/steeper a filter is in one domain, the wider it is on the other.

if a similar/same method is exists to subtract/remove the 500Hz signal from the signal?

Yes, many. For example you can use phase locked loop (PLL) to determine both phase and amplitude of the 500 Hz component and then simply subtract it out of the signal. This will cause NO delay or latency to the remaining signal. If your 500Hz has any type of amplitude or phase drift, the PLL will simply track it and you can adjust the speed of PLL controller to match the drift.

If your 500 Hz noise signal is guaranteed to be EXACTLY a 1/4 of the sample rate, that gets really simple. Just heterodyne it down with a cosine and a sine at 500 Hz, that gives you the real part and the imaginary part. Calculate amplitude and phase, create sine wave and subtract.

• We are definitely in the last situation you mention where it is EXACTLY a 1/4 of the sample rate. I will try this approach again but the 500Hz waveform isn't quite sinusoidal so wasn't sure it could work correctly directly with this approach? I will update the description to include the source data for reference. – Crog May 28 at 7:05
• Okay, so I went back and realised I had some elements of m Heterodyne a bit wrong. The waveform is actually square-ish so things looked okay. As you mention the Phase needs to be determined. I am still not sure how to do this properly... I did it manually by tweaking a constant for Phase at the moment! – Crog May 28 at 14:47
• @Crog. Create a 500Hz cosine and a 500 Hz sine (which are really just [1 0 -1 0 ..] and [0 1 0 -1 ...].).Multiply with your signal and and take the mean (or use a suitable low pass filter). That gives you the real and imaginary part of the spectrum at 500Hz. Create a 500 Hz sine wave with the same amplitude and phase. – Hilmar May 28 at 20:45