Go to Post Blasphemy! Everyone knows Mountain Dew is roboteer fuel. - Racer26 [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 28-03-2008, 14:38
beefy23 beefy23 is offline
Registered User
no team
 
Join Date: Mar 2008
Location: Israel
Posts: 9
beefy23 is an unknown quantity at this point
Question Question about Gear Sensor

I have tried to look for some guides about Gear tooth sensor, but what I`ve found doesn`t really help me.

Some stuff is ambiguous for me.

What are the meanings of quadrature encoder`s states, what does each of them tell me about?

What is Get_Encoder_1_Count() and Get_Encoder_2_Count() , and what`s the meaning of the number in the name of the function.

-I use MPLAB

Thank you in advance.

Last edited by beefy23 : 28-03-2008 at 15:13.
  #2   Spotlight this post!  
Unread 28-03-2008, 15:01
JamesBrown JamesBrown is offline
Back after 4 years off
FRC #5279
Team Role: Engineer
 
Join Date: Nov 2004
Rookie Year: 2005
Location: Lynchburg VA
Posts: 1,277
JamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond repute
Re: Question about Gear Sensor

Quote:
Originally Posted by beefy23 View Post
I have tried to look for some guides about Gear tooth sensor, but what I`ve found doesn`t really help me.

Some stuff is ambiguous for me.

What are the meanings of quadrature encoder`s states, what does each of them tell me about?

What is Get_Encoder_1_Count() and Get_Encoder_2_Count() , and what`s the meaning of the number in the name of the function.

Thank you in advance.
Quadrature encoders are similar in purpose to gear tooth sensors but are different in functionality. A quadrature encoder has an additional channel that indicates the direction the encoder is being turned.

In Kevin Watson's FRC code the functions like Get_Encoder_1_Count() return the net number of pulses sent by the encoder plugged into the port as declared in the encoder.h file. The numbers are used to distinguish between encoders, I believe Kevin's code allows for 6 to be used at a time.

The value returned by Get_Encoder_1_Count() can be converted into distance traveled since the encoder was last reset by multiplying the value by the ratio of encoder turns to wheel turns then by multiplying by the wheel circumference.
__________________
I'm Back


5279 (2015-Present)
3594 (2011)
3280 (2010)
1665 (2009)
1350 (2008-2009)
1493 (2007-2008)
1568 (2005-2007)
  #3   Spotlight this post!  
Unread 28-03-2008, 15:21
beefy23 beefy23 is offline
Registered User
no team
 
Join Date: Mar 2008
Location: Israel
Posts: 9
beefy23 is an unknown quantity at this point
Re: Question about Gear Sensor

Quote:
Originally Posted by JamesBrown View Post
Quadrature encoders are similar in purpose to gear tooth sensors but are different in functionality. A quadrature encoder has an additional channel that indicates the direction the encoder is being turned.

In Kevin Watson's FRC code the functions like Get_Encoder_1_Count() return the net number of pulses sent by the encoder plugged into the port as declared in the encoder.h file. The numbers are used to distinguish between encoders, I believe Kevin's code allows for 6 to be used at a time.

The value returned by Get_Encoder_1_Count() can be converted into distance traveled since the encoder was last reset by multiplying the value by the ratio of encoder turns to wheel turns then by multiplying by the wheel circumference.
And how do you know which analog input to receive the information?
  #4   Spotlight this post!  
Unread 28-03-2008, 15:29
JamesBrown JamesBrown is offline
Back after 4 years off
FRC #5279
Team Role: Engineer
 
Join Date: Nov 2004
Rookie Year: 2005
Location: Lynchburg VA
Posts: 1,277
JamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond repute
Re: Question about Gear Sensor

Quote:
Originally Posted by beefy23 View Post
And how do you know which analog input to receive the information?
Encoders and Gear tooth sensors are both traditionally digital sensors, you can find what ports to use in encoder.h
__________________
I'm Back


5279 (2015-Present)
3594 (2011)
3280 (2010)
1665 (2009)
1350 (2008-2009)
1493 (2007-2008)
1568 (2005-2007)
  #5   Spotlight this post!  
Unread 28-03-2008, 15:36
beefy23 beefy23 is offline
Registered User
no team
 
Join Date: Mar 2008
Location: Israel
Posts: 9
beefy23 is an unknown quantity at this point
Re: Question about Gear Sensor

Quote:
Originally Posted by JamesBrown View Post
Encoders and Gear tooth sensors are both traditionally digital sensors, you can find what ports to use in encoder.h
how could it be a digital sensor? it has more than 2 possibilities..
and where can I see exactly what the ports are in encoder.h?
  #6   Spotlight this post!  
Unread 28-03-2008, 15:50
Tottanka's Avatar
Tottanka Tottanka is offline
It isnt about bots,its about humans
AKA: Liron Gurvitz
FRC #3211 (The Y Team)
Team Role: Mentor
 
Join Date: Dec 2006
Rookie Year: 2006
Location: Hadera, Israel
Posts: 1,418
Tottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond repute
Re: Question about Gear Sensor

Quote:
Originally Posted by beefy23 View Post
how could it be a digital sensor? it has more than 2 possibilities..
and where can I see exactly what the ports are in encoder.h?
it does not have more than 2 options...
__________________
My FRC record: 10 Years,FTA (2008-9), 3 Teams(1947,2669,3211).3 RCA, 1 Championship EI(2016), 1 Divisional finalist (2016), 1 Regional winner.
Israeli 2016 Volunteer of the year.
  #7   Spotlight this post!  
Unread 28-03-2008, 16:00
JamesBrown JamesBrown is offline
Back after 4 years off
FRC #5279
Team Role: Engineer
 
Join Date: Nov 2004
Rookie Year: 2005
Location: Lynchburg VA
Posts: 1,277
JamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond repute
Re: Question about Gear Sensor

For encoder 1 phase A goes to dig_in 1 phase b to dig_in 11
encoder 2 uses 2 and 12, 3 uses 3 and 13, ans so on.

There is not more than one option, the encoder or gear tooth sensor just pulses once for every set fraction of a rotation, ie when ever the gear tooth sensor senses a gear tooth. This pulse triggers an interrupt in Kevin's code and that tallies the number of pulses, adding one for each forward pulse and subtracting one for each reverse pulse. This tally is returned by get_encoder_count.
__________________
I'm Back


5279 (2015-Present)
3594 (2011)
3280 (2010)
1665 (2009)
1350 (2008-2009)
1493 (2007-2008)
1568 (2005-2007)

Last edited by JamesBrown : 28-03-2008 at 16:03.
  #8   Spotlight this post!  
Unread 28-03-2008, 16:40
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,113
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: Question about Gear Sensor

Quote:
Originally Posted by beefy23 View Post
What are the meanings of quadrature encoder`s states, what does each of them tell me about?
The word "quadrature" refers to two signals which are out of phase with each other by one quarter of a cycle. The signals on a quadrature encoder are digital, and there are four possible combinations: 00, 01, 11, and 10. Notice that they don't "count" in binary; instead, only one of the signals changes for a transition between states. A change from 00 to 01 indicates the encoder is turning in one direction; a change fom 01 to 00 indicates it is turning in the other. Here's the full list of possibilities:

Code:
from to direction
 00  01 forward
 00  10 reverse
 01  11 forward
 01  00 reverse
 11  10 forward
 11  01 reverse
 10  00 forward
 10  11 reverse
A simple way to use quadrature encoders is to use interrupts to detect a transition from 0 to 1 on one signal (usually called Phase A), and look at the state of the other signal (Phase B) at that time to decide which direction the sensor is turning. That only uses two of the possible eight changes, but it's sufficient: 01 to 11 is forward, and 00 to 10 is reverse.
  #9   Spotlight this post!  
Unread 28-03-2008, 18:15
beefy23 beefy23 is offline
Registered User
no team
 
Join Date: Mar 2008
Location: Israel
Posts: 9
beefy23 is an unknown quantity at this point
Re: Question about Gear Sensor

Quote:
Originally Posted by Alan Anderson View Post
The word "quadrature" refers to two signals which are out of phase with each other by one quarter of a cycle. The signals on a quadrature encoder are digital, and there are four possible combinations: 00, 01, 11, and 10. Notice that they don't "count" in binary; instead, only one of the signals changes for a transition between states. A change from 00 to 01 indicates the encoder is turning in one direction; a change fom 01 to 00 indicates it is turning in the other. Here's the full list of possibilities:

Code:
from to direction
 00  01 forward
 00  10 reverse
 01  11 forward
 01  00 reverse
 11  10 forward
 11  01 reverse
 10  00 forward
 10  11 reverse
A simple way to use quadrature encoders is to use interrupts to detect a transition from 0 to 1 on one signal (usually called Phase A), and look at the state of the other signal (Phase B) at that time to decide which direction the sensor is turning. That only uses two of the possible eight changes, but it's sufficient: 01 to 11 is forward, and 00 to 10 is reverse.
but how can you easily get the bits content? Can you please write a code(I work in MPLAB). Thanks.

Last edited by beefy23 : 28-03-2008 at 19:20.
  #10   Spotlight this post!  
Unread 04-04-2008, 16:38
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,113
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: Question about Gear Sensor

Quote:
Originally Posted by beefy23 View Post
Can you please write a code(I work in MPLAB). Thanks.
Kevin Watson has written exactly what you need, and makes it available to all. Here it is, complete with detailed instructions for adding it to your project in MPLab.
  #11   Spotlight this post!  
Unread 06-04-2008, 23:59
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Question about Gear Sensor

Do as above, but note that the gear tooth sensors in the kit have only a single phase. This means that the encoder code will only count either up or down.

If you want direction information (i.e. a count that goes up when rotating one way, and down when rotating the other), you need to estimate it based on other factors (such as commanded motor direction, etc.).
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
Gear Tooth Sensor Question Semicolon Electrical 7 19-01-2008 22:54
Question about the IR sensor DemonYawgmoth Electrical 4 08-01-2008 22:26
Question about Gear-tooth? Nicodemus Control System 4 21-01-2007 02:19
Quick question regarding the gear tooth sensor... Brad Voracek Electrical 3 12-01-2007 01:07
Gear Tooth Sensor Question (InsrtNameHere) Electrical 2 20-01-2006 02:19


All times are GMT -5. The time now is 01:00.

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