This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Trying to set external interrupts to zero

Hi,
can anyone help me understand how to set external interrupts to zero.
I am using a dc motor with an optoswitch and displaying the output in rpm on a LCD display. The calculation for rpm uses capture mode register of module zero to capture the interrupts. When the motor stops running it does not display zero.
Any suggestions?

Edwin

Parents
  • Use a timer that will be reset by rpm input (it does not have to be hardware-reset, you can reset the timer in the rpm interrupt routine). If the rpm input is not toggling (motor stopped), your timer will time-out and then you know that your rpm is zero. Set the timer period to be longer than the lowest speed of interest.

    - Dejan

Reply
  • Use a timer that will be reset by rpm input (it does not have to be hardware-reset, you can reset the timer in the rpm interrupt routine). If the rpm input is not toggling (motor stopped), your timer will time-out and then you know that your rpm is zero. Set the timer period to be longer than the lowest speed of interest.

    - Dejan

Children
  • I think I did something very similar to what you have suggested. I just assigned a variable to increment to 10 as soon as the motor stopped spinning, then reset the timer to zero. Which seems to work for the moment, I now have to add a PID system, so hopefully it still works after this addition.
    Thank you for your help though, much appreciated.
    Edwin