Go to Post Angry Teams will not get the field going any quicker trust me on that! - mtaman02 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 17-06-2008, 09:29
programmr's Avatar
programmr programmr is offline
Registered User
AKA: Face
FRC #0522
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Staten Island, NY
Posts: 83
programmr is a jewel in the roughprogrammr is a jewel in the roughprogrammr is a jewel in the rough
Send a message via AIM to programmr
Exclamation 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?
  #2   Spotlight this post!  
Unread 17-06-2008, 10:40
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,381
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
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
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
  #3   Spotlight this post!  
Unread 17-06-2008, 12:09
tseres's Avatar
tseres tseres is offline
obsessed with FIRST...
FRC #1565 (Think Tank Tech)
Team Role: Leadership
 
Join Date: Apr 2007
Rookie Year: 2007
Location: Cambridge, ON
Posts: 305
tseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of light
Re: Help Programming a Quadrature Encoder

kevin.org/frc download the encoder file and read everything in there
__________________


  #4   Spotlight this post!  
Unread 17-06-2008, 13:13
programmr's Avatar
programmr programmr is offline
Registered User
AKA: Face
FRC #0522
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Staten Island, NY
Posts: 83
programmr is a jewel in the roughprogrammr is a jewel in the roughprogrammr is a jewel in the rough
Send a message via AIM to programmr
Re: Help Programming a Quadrature Encoder

i know neither.. could you please help?
  #5   Spotlight this post!  
Unread 17-06-2008, 14:26
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,381
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Help Programming a Quadrature Encoder

Quote:
Originally Posted by tseres View Post
kevin.org/frc download the encoder file and read everything in there
Bingo! If you follow this link, you will find everything you need to know. Kevin Watson is a resource for code that is AMAZINGLY well documented. That is the place to start. Personally I believe he has contributed more to learning coding for sensors than just about anyone else in FIRST.

Quote:
Originally Posted by programmr View Post
i know neither.. could you please help?
Quadrature encoders have two outputs. Both are 50% duty cycle square waves and are usually referred to as Phase A and Phase B. Phase B usually lags behind A by 90 deg.
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.
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
  #6   Spotlight this post!  
Unread 17-06-2008, 14:28
pogenwurst pogenwurst is offline
Ubuntu User
AKA: Brian
FRC #2007 (Robots of the Round Table)
Team Role: Leadership
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Duluth, GA
Posts: 78
pogenwurst is on a distinguished road
Send a message via AIM to pogenwurst
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
  #7   Spotlight this post!  
Unread 17-06-2008, 16:47
Bomberofdoom's Avatar
Bomberofdoom Bomberofdoom is offline
Biggest FIRST addict in Israel
AKA: Nir Levanon
FRC #2230 (Zcharia's Angels)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Israel
Posts: 471
Bomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond repute
Send a message via MSN to Bomberofdoom
Re: Help Programming a Quadrature Encoder

Quote:
Originally Posted by billbo911 View Post
Quadrature encoders have two outputs. Both are 50% duty cycle square waves and are usually referred to as Phase A and Phase B. Phase B usually lags behind A by 90 deg.
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.
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?
__________________
TEAM 2230 ZECHARIA'S ANGELS

2009 Microsoft Israel FRC Regional Winners!
2009 Microsoft Israel FRC Regional Chairman's Award Winners!!!
---------------------------------
2008 Microsoft Israel FRC Regional semi-finalist.
2008 Microsoft Israel FRC Regional Delphi's "Driving Tommorow's Technology" Award winner.
2008 Robot Driver
---------------------------------
2007 GM/Technion Israel FRC Regional semi-Finalist.
2007 GM/Technion Israel FRC Regional Xerox Creativity Award winner.
2007 Robot Driver.
  #8   Spotlight this post!  
Unread 17-06-2008, 17:36
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,381
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
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?
Sorry, I am not sure how to answer. Looking at the length of time B is high or low doesn't seem to be part of his code. Using interrupts 4 through 6 for the A phase does look at the previous state of B. This way it knows if you are stationary with the A sitting right at a transition and floating back and forth, thus eliminating erroneous counting.


Take a look at his code. It is really good.
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
  #9   Spotlight this post!  
Unread 17-06-2008, 19:25
IKE's Avatar
IKE IKE is offline
Not so Custom User Title
AKA: Isaac Rife
no team (N/A)
Team Role: Mechanical
 
Join Date: Jan 2008
Rookie Year: 2003
Location: Michigan
Posts: 2,150
IKE has a reputation beyond reputeIKE has a reputation beyond reputeIKE has a reputation beyond reputeIKE has a reputation beyond reputeIKE has a reputation beyond reputeIKE has a reputation beyond reputeIKE has a reputation beyond reputeIKE has a reputation beyond reputeIKE has a reputation beyond reputeIKE has a reputation beyond reputeIKE has a reputation beyond repute
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.
  #10   Spotlight this post!  
Unread 18-06-2008, 15:48
pogenwurst pogenwurst is offline
Ubuntu User
AKA: Brian
FRC #2007 (Robots of the Round Table)
Team Role: Leadership
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Duluth, GA
Posts: 78
pogenwurst is on a distinguished road
Send a message via AIM to pogenwurst
Re: Help Programming a Quadrature Encoder

Quote:
Originally Posted by IKE View Post
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.
I just took a glance there, and the following page has some nice illustrations of encoders: http://www.killerbees33.com/index.ph...86&Itemi d=50
  #11   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
  #12   Spotlight this post!  
Unread 19-06-2008, 12:26
Bomberofdoom's Avatar
Bomberofdoom Bomberofdoom is offline
Biggest FIRST addict in Israel
AKA: Nir Levanon
FRC #2230 (Zcharia's Angels)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Israel
Posts: 471
Bomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond repute
Send a message via MSN to Bomberofdoom
Re: Help Programming a Quadrature Encoder

So just to be sure, if phase B lead is forward, then phase B lag is reverse?
__________________
TEAM 2230 ZECHARIA'S ANGELS

2009 Microsoft Israel FRC Regional Winners!
2009 Microsoft Israel FRC Regional Chairman's Award Winners!!!
---------------------------------
2008 Microsoft Israel FRC Regional semi-finalist.
2008 Microsoft Israel FRC Regional Delphi's "Driving Tommorow's Technology" Award winner.
2008 Robot Driver
---------------------------------
2007 GM/Technion Israel FRC Regional semi-Finalist.
2007 GM/Technion Israel FRC Regional Xerox Creativity Award winner.
2007 Robot Driver.
  #13   Spotlight this post!  
Unread 19-06-2008, 12:29
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
So just to be sure, if phase B lead is forward, then phase B lag is reverse?
Yup!
__________________
Steve Guerrera

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

Boston Regional Mentor
MIT Grad Student
  #14   Spotlight this post!  
Unread 19-06-2008, 23:59
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,381
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Help Programming a Quadrature Encoder

Quote:
Originally Posted by Bomberofdoom View Post
So just to be sure, if phase B lead is forward, then phase B lag is reverse?
That could be true. But, if one encoder is on the right side and one on the left, they could be different. That is not really a problem, just modify your ISRs to meet your needs.
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
  #15   Spotlight this post!  
Unread 20-06-2008, 05:54
Bomberofdoom's Avatar
Bomberofdoom Bomberofdoom is offline
Biggest FIRST addict in Israel
AKA: Nir Levanon
FRC #2230 (Zcharia's Angels)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Israel
Posts: 471
Bomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond repute
Send a message via MSN to Bomberofdoom
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?
__________________
TEAM 2230 ZECHARIA'S ANGELS

2009 Microsoft Israel FRC Regional Winners!
2009 Microsoft Israel FRC Regional Chairman's Award Winners!!!
---------------------------------
2008 Microsoft Israel FRC Regional semi-finalist.
2008 Microsoft Israel FRC Regional Delphi's "Driving Tommorow's Technology" Award winner.
2008 Robot Driver
---------------------------------
2007 GM/Technion Israel FRC Regional semi-Finalist.
2007 GM/Technion Israel FRC Regional Xerox Creativity Award winner.
2007 Robot Driver.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Quadrature shaft encoder source billbo911 Kit & Additional Hardware 7 06-01-2008 19:52
Encoder help E_Unit Electrical 5 16-02-2007 11:02
Turning a gear-tooth sensor into a quadrature output encoder Jared Russell Programming 4 18-01-2006 22:19
Encoder help Windward Programming 21 14-01-2006 15:10
shaft encoder help stephenthe1 Programming 2 03-12-2004 16:09


All times are GMT -5. The time now is 19:26.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi