View Single Post
  #11   Spotlight this post!  
Unread 10-11-2005, 14:16
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,112
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: Why are four states needed with Quadratuer encoders?

Quote:
Originally Posted by Issues
Thank you for the feedback. The colored wheel illistration was helpful. I still have a question. I looked at how you set up the code and I think I get it, but what edge should be set for interupt? For the machine to keep up with the state changes wouldn't you want to interupt both when it goes from white to black and from black to white?
It turns out that you only need to generate an interrupt based on one edge of one of the phases. If you set things up to interrupt on the rising edge of the A phase, you will be be notified about two state transitions: 00->10 and 01->11. The level of the B phase at the time tells you immediately which direction the encoder is turning. You only get information for one transition out of four, but that's usually more than enough. In order to track the relative motion of the encoder continuously, the interrupt service routine just needs to increment or decrement a value based on what the B phase is.

Occasionally details in the imperfect real world make it necessary to get fancier than that, but the very simple scheme is generally sufficient.