View Single Post
  #3   Spotlight this post!  
Unread 23-02-2004, 08:40
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
Re: Big Question concerning Interrupt Pins 3-6

Kevin Watson posted an encoder example on his web site kevin.org/frc. The output of the encoder is called Gray Code and is set up so that only one channel changes at a time. Channel A leads channel B by 90 degrees. Thats just a fancy way of saying that channel B won't see a state change until halfway through a state change on channel A. Here is the order the signals will change as the shaft rotates:
Code:
A   B
--  --
0   0
1   0
1   1
0   1
0   0
Looking at Channel A, there are two rising edges (transition from 0 to 1). In one direction, from top to bottom, Channel B is 0. In the other direction Channel B is 1. That means that an interrupt triggered on the rising edge of Channel A will give you both distance and direction. You will connect Channel A to an interrupt set up to look for a rising edge and Channel B to a digital input. Inside the ISR, if Channel B is high you're moving in one direction and if its low you're moving in the other.