I need to write a subroutine for my main program where I am looking for a transition from an encoder where there is one transition per second. I am new to PIC programming and I am having trouble figuring out how to use the timers in a 16F628A to accomplish this task. My programming experience has been mostly with PLC’s and I could easily figure out how to do it with the timers or counters in a PLC, but I just haven’t figured out how to do it with a PIC. I am using an external RC oscillator which runs at 6 KHz. The direction I planned to go was to reset a timer and clear the interrupt flag and then look for the edge of a transition on the encoder input. If I see a transition within a 3 second window, I would reset the timer to keep it from overflowing. If I don’t see a transition in this 3 second window then I would go into an ISR. I wanted to use the timer so that it could be running in the background while I also monitored the encoder and some other inputs. The other inputs could determine that it is okay to not get a transition from the encoder. This seems like it should be a simple task but I am have trouble figuring out how to have the timer run in the background while I monitor the encoder input transitions and continue to scan other inputs at the same time. I have used the Search feature on this forum to look at different timer examples but I don’t seem to find any example that will work for me.
Bookmarks