View Single Post
  #2   Spotlight this post!  
Unread 08-02-2008, 20:52
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
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?