I am building a 4 wheel rover and am using PID DC motor control for the back set of wheels. The feedback for the speed is provided by Hall effect sensors, with two pulses per rotation.
This means with the motor as 100% duty, the sensor returns a 240Hz signal (4.2ms between pulses) and at the lowest duty for when the wheels are turning 20% duty, the sensor returns a 14.33 Hz signal (74.2 ms between pulses).
I'm using a STM32 Cortex-M3 part for the controller and a timer to capture the hall effect input and convert this to frequency. This is done by comparing two capture samples through a ISR that triggers on each rising edge.
The issue I have is the PID loop is running at a rate of 50Hz, so when the motor is running at low speeds and a timer compare has not been done, it returns the last calculated value. This is fine, but I could also find myself in the situation where the motor has stopped spinning and I haven't been able to update the captured frequency due to the second pulse not having arrived.
Im just wonder if there is a sensible way of handling this ?