View Single Post
  #3   Spotlight this post!  
Unread 11-02-2005, 23:37
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: Third Encoder Channel

Quote:
Originally Posted by crazykid234
Yo. I'm new to encoders. From what I can understand, the default code at Kevin Watson's website only allows for two channels: the first channel uses analog inputs 1 & 6, and the second uses analog inputs 2 & 8. Does anyone know how to create a third encoder channel? Any help will be highly appreciated. Thank you.
It's not hard, but you do have to know what you're doing to get it right.

We're using three encoders. Two of them are on pins 1&7 and 2&8, using essentially Kevin's code. The third is on pins 3&9, with a few lines of interrupt initialization and service routine copied from Kevin's interrupts.c to dispatch the third encoder's handler when INT4 occurs. There is also an extra check to call the handler only when INT4 was triggered by a falling edge of the signal on pin 3. (That part of the code seems a little inconsistent, as if the input pin were going low and then high again before we had a chance to look at it. I'm considering wiring in a hardware pulse-stretch circuit to deal with it.)

To avoid extra interrupts that we would just have to ignore, we have nothing connected to pins 4-6.