How to perform Digital averaging via the FPGA?

On our robot we’re using a sensor to detect the presence of a disc. It’s a pretty good sensor, but it will occasionally produce false positives and false negatives, as well as having a bit of a “bouncing” issue when a disc just starts to pass overhead. In each of these cases, the value is correct somewhere between 75%-98% of the time.

Due to some time-critical mechanisms, we can’t afford to read this sensor multiple times in a software. We need to make one good read and take action.

Is there a way to have the FPGA do this averaging for us? Ideally, it’d read the signal thousands of times and tell me if there were more TRUE values or FALSE values since I last called it.

You might try doing analog averaging of the signal. Feed your ones (5v) and zeros (0v) into an analog input configured to average a large number of samples, and see if the averaged result is closer to 0 or to 5.