2022-11-18 08:41 AM
Hello, I'm using a timer to measure the frequency of an Hall effect speed sensor.
The point here is that the routine that measure the frequency is triggered by the falling edge of the signal. Then the difference is calculated between two interval to retrieve the frequecy. But if the speed equals to 0, no interrupt are generated and the measured frequency is the latest greater than 0. The same problem if the sensor is disconnected (to implement some failsafe logics). If the sensor is working and at certain point the cable is broken no more interrupt will be generated.
Any idea to solve this problem?
2022-11-18 12:08 PM
Implement a timeout, which is longer than the longest signal period for the lowest speed. It can be done even on the same timer. Introduce an overflow counter, which is incremented in the update interrupt. Then in capture interrupt check and reset it. If it is larger than 1, more than one timer period has passed. You can wait for more timer periods to pass, before you report the missing signal. Actually this way you can also measure signals with periods of virtually unlimited length.