# Boxcar, Removing DC signal from an ADC on a FPGA

I have been reading on different ways to do this. I have seen this Linear-phase DC Removal Filter This seems like it would work just fine, but it would take some time to implement.

Is there any reason you can't just say average 16192 * 256 samples and every time this completes, use this latest output value to subtract each input sample by this amount?

I have new samples every 12.5 MHz, system clock is 150 MHz.

Resource wise this will take more, but are there any fundamental issues doing this vs a moving average?

• Aren't you doing a moving average by doing that? Meaning, are you suggesting that for every new input sample, you will average it with the previous 16192*256-1 samples? If so, yes it just takes up that amount of memory and adders but fundamentally would give you an identical result to a CIC filter. If you were concerned about resources you would consider doing it differently but otherwise the result is the same. @RichardLyons is often on here, so I will leave it to him to detail further since he wrote the referenced article. Feb 22, 2022 at 23:25
• A bit different, in this case I get the average of 16192*256 samples. Once that finishes, all new inputs are subtracted by this amount. At the same time, it will start making a new average with new samples. It does not use the old average's values for this calculation. Although... writing this out now, I suppose this isn't as good since there will be a jump in the output values. Feb 23, 2022 at 0:26
• Right, that wouldn't be good for that reason. The average loses its applicability the further you drift from it. This would only work well if you had a stationary signal with a constant average that was the same over each block. I recommend just doing a simple moving average if you are not resource constrained with a FIFO (for every new sample add it and subtract the latest sample, or its CIC reduction if you want to save some addition operations (see here: dsp.stackexchange.com/questions/38377/…), or Richard's cool implementations. Feb 23, 2022 at 4:51
• Yup a moving average seems the way to go! I think I'll actually start with the example Richard shows as having that -2.9dB drop and then once that works I'll work my way down. Thanks a lot guys, wish I could upvote. Feb 23, 2022 at 18:20