Re: decoding quadrature encoders
When I added the mcu context save routine the display crashed. It will ~ work if I move the shaft slowly, however, moving quickly caused the code to trip over itself and lockup the screen.
My first guess was that when jumping out of the ISR, the next return in the main program uses the most recent return address on the stack and returns to the point the interrupt occurred, crashing the program.
I have not tried your code but can assure you that it is essential to save the mcu context upon isr entry and to restore it on exit . restoring the context without saving it can only lead to tears, not saving it can only lead to tears.
so good luck with that
dave
the chip used here in this somewhat hijacked thread is a 16F876 it has only one "INT" pin your suggestion just cannot work in that case.
afaik no pic16 chips can respond to rising and falling levels on an INT int pin simultaneously
its one or the other. as henrik says to do a full quadrature decode every edge needs to cause an interrupt.
RBC int can do it a single INT int cannot , the intx edge would need to be toggled on every interrupt .
secondly that circuit with all its extra bits cannot use the full resolution of a encoder its a 1x decode.
thirdly since the portb rbc pins on a 16F876 are schmidt trigger type inputs and if the chip is close enough to
the re (opto type not mechanical)no other components are required at all to do a full 4x decode , why complicate it ?
Warning I'm not a teacher
Bookmarks