Go Down

Topic: Interrupt Missing Pulses (Read 4635 times) previous topic - next topic


I would assume this would be the same issue everyone has who uses a wheel encoder and needs an accurate count for navigation.  Anybody have a solution?

It's the same issue that anyone has who needs to have cooperation between an interrupt service routine and the main loop. Sometimes you can design the interface in such a way that both pieces of code can execute without any synchronisation, but the more general approach is to disable interrupts briefly while accessing the volatile shared data from the main loop.


Where's the datasheet for the encoder?  Does yours need schmitt-trigger inputs to clean up the signal?
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]



You were right.  I removed the reset and it counted every change.  It must just be a timing issue.
Changing pulse_count from Int to Byte in the original code showed no improvement. 
I changed the code to only reset pulse_count after every 10 counts and now there are no timing issues.  It still counts two or three pulses for a single pulse sometimes but a couple of caps should clear that.
Thanks everyone for the help.

Go Up