|
Re: KOP Gear Tooth Encoder Trouble
I'm guessing that the encoder is working fine, but your printf() is broken.
The encoder count functions return a long integer. You've probably tried to print the value using the %d format string, which expects an integer. All you're getting printed is the first half of the count, essentially 1/65536 of the true value. If you wait long enough, you'll see it change. Change the %d to %ld, or put (int) in front of the encoder function call to cast it to a 16-bit value for printing.
If that isn't the problem, I'd look at the encoder wiring. You said you're supplying +12 and ground, and that's good. Along with the signal, you do have ground and +5 from the RC's digital input connected to the proper pins as well, right?
|