View Single Post
  #7   Spotlight this post!  
Unread 19-06-2008, 08:34
steveg's Avatar
steveg steveg is offline
Livin' the Dream
AKA: Stephen Guerrera
no team
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Boston, MA
Posts: 70
steveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to behold
Send a message via AIM to steveg
Re: Help Programming a Quadrature Encoder

Quote:
Originally Posted by Bomberofdoom View Post
In order to know if B is high, we need to compare to the last length of phase B, or does Kevin's Encoder calculate that automaticly somehow?
You don't need to know anything about the length of B. To check whether B is high or not, all you need to look at is the value of the Digital input that B is connected to.

The way an interrupt works is that you enter the ISR on the transition from a low state to a high state. You can choose which transition it is, but I'm pretty sure it's low-to-high by default in Kevin's code.

In the ISR, you check the value of B by just using the standard "rc_dig_inX" variable. In Kevin's code, that's #defined to ENCODER_Y_PHASE_B_PIN. When you're going forward, B will be one value, let's say 1. When you're going reverse, B will be the opposite value, 0.

A picture illustrates this better:

(from: http://digital.ni.com/public.nsf/all...256275005E18E2)

Hope that helps. Ask more if you still have questions!
__________________
Steve Guerrera

-2003 T.R.I.B.E. 237
2004-2008 Nutrons 125

Boston Regional Mentor
MIT Grad Student