![]() |
Issues with encoder code
My team has been using Kevin Watson's encoder code in conjunction with the KOP gear tooth sensors, to great success. Unfortunately, during one of our last matches, the wires got yanked off of the RC, and broke the signal pin on digital IO 1. Fortunately, this is not a huge deal, so we got the broken pin out of the cable, and moved the encoders over to digital IO 3 and 4. Now, when I run the code, encoders 3 and 4 start out at 0. If I spin one side of the drivetrain, the count for that side increases to 1, and no more. I have the same problem if I try IO 5 or 6. I know that the sensors are still working fine, because if I move one back to IO 2, then I get the expected counts. Has anyone else run into trouble with using encoders on 3-6? Any suggestions? I'm hoping we'll be able to have a working autonomous mode again in Atlanta.
|
Re: Issues with encoder code
Could you post your InterruptHandlerLow code? As I remember it took a little work to get those "Port B" interrupts working.
|
Re: Issues with encoder code
Quote:
Code:
void InterruptHandlerLow () |
Re: Issues with encoder code
Here are a couple things (differences with my code) to try :
Try declaring Old_Port_B like this: Code:
unsigned char Port_B;Code:
if (Port_B & 0x10) Int_3Rise_Handler();Those are the only differences between my handler (2 encoders & 3 GTS) and your handler. We changed it last year and I don't remember exactly what fixed what. |
Re: Issues with encoder code
Quote:
|
Re: Issues with encoder code
I also remember that his code is defaultly optimized for velocity readings on ports 1 and 2 and optimized for position control on ports 3 and 4. I might be wrong with the numbers, but different ports are optimized for different purposes. Check if your new ports were optimized for a purpose other than your old ports where.
|
Re: Issues with encoder code
Mike,
It occurs to me that you've hit the nail on the head. 3 and 4 are opitmized for positions, so they're expecting a quadrature encoder. They look for the B channel on another set of pins (can't remember which) and they will only increment properly if the cycle goes A rise, B rise, A fall, B fall. If B stays high or low, then the code thinks the encoder is fiddling back and forth and not actually turning. There should be a way to fix this in the code, but I don't have it in front of me. That's exactly what the problem is, however. JG, Check Kevin's readme and code comments. They should tell you how to use those inputs for velocity instead of position. |
Re: Issues with encoder code
Quote:
-Kevin |
| All times are GMT -5. The time now is 17:29. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi