View Single Post
  #28   Spotlight this post!  
Unread 14-04-2010, 16:30
vamfun vamfun is offline
Mentor :Contol System Engineer
AKA: Chris
FRC #0599 (Robodox)
Team Role: Engineer
 
Join Date: Jan 2009
Rookie Year: 2003
Location: Van Nuys, California
Posts: 182
vamfun is a glorious beacon of lightvamfun is a glorious beacon of lightvamfun is a glorious beacon of lightvamfun is a glorious beacon of lightvamfun is a glorious beacon of lightvamfun is a glorious beacon of light
Send a message via AIM to vamfun
Re: Unexpected results from Encoder::GetRate()

Quote:
Originally Posted by jhersh View Post
I think the fundamental misunderstanding here is that what you are doing in your microcontroller-based 1x decoder is take a shortcut that is not a valid quadrature decoder.

To create a valid 1x decoder, you must be sensitive to a different edge of A based on the value of B, not always be sensitive to one edge of A and choose direction based on B.
The scheme that I'm describing is a valid quadrature decoder in that it uses the B channel to determine direction. When going CW , the uprising A edge occurs when say B is High and when going CCW, the uprising A edge occurs when B is low. So when going a given direction, B is essentially static when looked at during the uprising edge.

Quote:
Naturally the correct way to implement this is not simple on a microcontroller because interrupt configuration cannot be tied to a digital input, so the mistake is often made because it is seen as the only option. The fact that it almost works only reinforces to the misunderstanding.
Seems simple to me... in the A rising edge interrupt handler, we just read B digital port immediately and either countup or countdown pending value. The only requirement is that B not be changing for those few useconds. It does give half the interrupt traffic so we have been using this with MPLAB Vex for years primarily to conserve the interrupt ports.

]

Last edited by vamfun : 15-04-2010 at 15:54.
Reply With Quote