Hi,
A schematic would be nice but I think we've covered this before. Two encoder signals on the same pin, fighting each other, is most likely not a good solution. You mention a relay, switching between the two, and that should be fine. Just make sure the signal at the PIC input is well defined (pulled up/down) and not floating at any point.
And Richard is spot on. If the frequeuncy of the encoder signal is anything above "a couple of Hz" you definitely do not want the LCDOUT statements within the ISR. Those two statments takes at least 5ms to exectute, then there's the rest of the ISR itself (which isn't much but still...) and the system variable save/restore. But let's say 5ms (and that's probably on the LOW side) then your input frequency can't be higher than 200Hz.
If you have a two channel scope you can test this.
1) Scope the input signal to the PIC with channel 1 on the scope.
2) Set a pin high at the beginning of the ISR. Set it LOW at the end of the ISR.
3) Scope this output of this pin with channel 2 on the scope.
The time between the rising edge on Ch1 and the rising edge on Ch2 is the interrupt latency, the time it takes to save the system vars and "get to" the actual ISR code.
The pulse width on Ch2 is the execution time of the ISR itself.
Then there's the time it takes to restore the system vars and "get out" of the ISR. This is pretty much equal to the measured latency.
Add the numbers together, ie 2*latency + ISR execution time and see what you get. Make sure you do this with a LOW(ish) input frequency to ENSURE you're not "overrunning" yourself. Then remove the LCDOUT statements from the ISR and measure again.
/Henrik.
Bookmarks