Quote:
|
Originally Posted by Astronouth7303
If you really need direction, I recomend going with quadrature.
The pulses off the GTS are so miniscule that by the time I got to the bottom of my ISR, the pulse had already passed. Just camera or high-priority interrupts could screw up timing. This is using PIC C, not EasyC.
|
Do you mind sharing your code? I haven't run the numbers myself, but it SEEMS like you should be able to differentiate a forward vs. reverse pulse. I'm wondering if you weren't trying to do too much in your interrupt routine.
Quote:
|
Originally Posted by teh_r4v3
A timer can go down to 100ns if you want I believe... but at that point the interrupts will be taking over way too many processor cycles.
|
I believe the 100ns number means that the timer counter increments that fast, but you have control over how many times the counter increments before it interrupts. I THINK that in your gear tooth sensor ISR, you should be able to set the timer to go off in 60 μs, and then in your timer ISR, check the gear tooth sensor line again. So then, all you really need to do in your gear tooth sensor ISR is to increment your gear tooth counter, set your timer, and return. Then in your timer ISR, if the line is still high, decrement your counter by 2. (At this point you might need to turn off your timer, so you don't get keep getting interrupted EVERY 60 μs.)
Note: If necessary, you can optimize your ISR code to add and subtract the VALUE of the I/O line, rather than TESTING the state, and conditionally subtracting.