Skip to main content
bigfede94
Associate II
November 18, 2022
Question

How correctly measure speed with an hall effect sensor using TIMER

  • November 18, 2022
  • 1 reply
  • 1928 views

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?

This topic has been closed for replies.

1 reply

Piranha
Principal III
November 18, 2022

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.