![]() |
Help Programming a Quadrature Encoder
Hello, i am fairly new at programming, however i am capable or programming hybrid and tele-operated periods.... we recently added Quadrature Encoders and encoder disks. I need some help on programming them. Our robot leans to one side when driving full forward or reverse and we thought putting these on might fix that problem if we could program them by revolutions or something. Can anyone help us program these encoders or anywhere where we may be able to find a template program?
|
Re: Help Programming a Quadrature Encoder
Before I respond, I would like to know two things about your question.
1) Do you want to know how to get them to give you information? Or.... 2) Do you want to know how to use the information they give you?? Or... 3) Both? OK, I forgot how to count :) |
Re: Help Programming a Quadrature Encoder
kevin.org/frc download the encoder file and read everything in there
|
Re: Help Programming a Quadrature Encoder
i know neither.. could you please help?
|
Re: Help Programming a Quadrature Encoder
Quote:
Quote:
Typically Phase A is used as a trigger, or more specifically, tied to an interrupt on the RC. When the "trigger", or interrupt, takes place, an IRS (Interrupt Service Routine) looks at Phase B. If B is high, the ISR increments the content of a counter, if B is low, the counter is decremented. Incrementing or decrementing can be swapped easily by modifying the code. Usually incrementing means you are moving forward, decrementing means reverse, but again, you can determine in code what you want it to represent. Now, the value in the "counter" represents a unit of measure. The measurement it represents is determined by what it is physically driven by. Lets just use the output of a transmission as an example. Let's also assume we are using a 100 count per revolution encoder. The output shaft has a 15 tooth sprocket on it and it is driving a 6 in. dia. wheel with a 22 tooth sprocket on it. Here is the math. Pi*D=18.85 in. per wheel revolution 22/15=1.466 revolutions of the encoder per wheel revolution. 100*1.466=146.6 counts per wheel revolution. 18.85/146.6 = .129 inches of travel per count from the encoder. |
Re: Help Programming a Quadrature Encoder
In addition to the above comments, I found the following explanation of the workings of quad encoders to be excellent, and successfully wrote my own encoder code for an off-season project with its help: http://abrobotics.tripod.com/Ebot/using_encoder.htm
|
Re: Help Programming a Quadrature Encoder
Quote:
|
Re: Help Programming a Quadrature Encoder
Quote:
Take a look at his code. It is really good. |
Re: Help Programming a Quadrature Encoder
http://www.killerbees33.com/index.ph...d=27&Itemid=50
This is a link to some of Jim Z's programming tips. If your robot is slicing one way or the other, wheel encoders may help, but you can also use a gyro and have it adjust to keep a 0 heading. Sorry I am not a programmer, but hopefully some of Jim's stuff might help. |
Re: Help Programming a Quadrature Encoder
Quote:
|
Re: Help Programming a Quadrature Encoder
Quote:
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! |
Re: Help Programming a Quadrature Encoder
So just to be sure, if phase B lead is forward, then phase B lag is reverse?
|
Re: Help Programming a Quadrature Encoder
Quote:
|
Re: Help Programming a Quadrature Encoder
Quote:
|
Re: Help Programming a Quadrature Encoder
You mean there's a difference between putting the encoder on the left side or the right side of the gear/wheel?
|
| All times are GMT -5. The time now is 13:53. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi