Go to Post When more STEM teams exist outside schools than in them, that will be one indication that a true cultural change has occurred. - gblake [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
  #46   Spotlight this post!  
Unread 08-02-2005, 14:40
Workaphobia Workaphobia is offline
Registered User
AKA: Jon
FRC #1546 (Chaos Inc.)
Team Role: Alumni
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Long Island
Posts: 26
Workaphobia will become famous soon enough
Re: encoders

I've got a few encoder questions. I'm trying to decide whether or not to spend $100 of my team's money on Greyhill optical quadrature encoders, when the kit already includes HAL-effect sensors. Things are beginning to look bleak in terms of the amount of time we have until ship-date, and it'll be hard enough finding someone in the construction section of the team to mount any sensor as it is.

First, I understand that quadrature encoders can detect direction, and that in addition optical encoders are more reliable, but would this high-end technology really be useful for a team that just needs to reliably determine how far the bot has traveled (or turned)?

Second, will Kevin's code work with non-quadrature encoders? I assume it wouldn't - in that case, is it difficult to write my own code to interface with them, or is it as simple as reading an input?

Third, is it possible to use encoders without interrupts, and just poll how many clicks have elapsed, or would polling only return whether or not it is currently clicked?

Thanks.
  #47   Spotlight this post!  
Unread 08-02-2005, 15:12
stephenthe1 stephenthe1 is offline
Registered User
#1008
 
Join Date: Dec 2004
Location: Ohio
Posts: 113
stephenthe1 is on a distinguished road
Re: encoders

well, it shouldn't be too much a pain to change his code to use the regular encoders. polling would only tell whether it's currenlty clicked or not. I've tried doing that and I always got messed up measurements, because it's random when it records a tick. therefore, no matter the speed of the shaft, I would suggest using interrupts always.
  #48   Spotlight this post!  
Unread 08-02-2005, 15:18
stephenthe1 stephenthe1 is offline
Registered User
#1008
 
Join Date: Dec 2004
Location: Ohio
Posts: 113
stephenthe1 is on a distinguished road
Re: encoders

if anyone has time, I would greatly appreciate it if you could upload the new compiler that Microchip temporarily released for free for me. I had it, but it's walked off to magical places. just let me know where you uploaded it to. or try Emailing it to me. idk what the max. file size limit is for my Email. or if Microchip hasn't taken the ftp link away yet, tell me the link, cause I couldn't find it. thank you a bunch.
  #49   Spotlight this post!  
Unread 08-02-2005, 15:58
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,600
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: encoders

Quote:
Originally Posted by Workaphobia
Second, will Kevin's code work with non-quadrature encoders? I assume it wouldn't - in that case, is it difficult to write my own code to interface with them, or is it as simple as reading an input?

Third, is it possible to use encoders without interrupts, and just poll how many clicks have elapsed, or would polling only return whether or not it is currently clicked?
Kevin's code will work with non-quadrature encoders, as long as you don't hook anything else up to digital inputs 6 or 8. It will only count in one direction, though. You could remove the parts of his code that deal with quadrature fairly easily.

You can handle encoders without interrupts, as long as they tick slowly. If you can guarantee that you poll the pin at twice the rate it transitions, you would be able to poll it reliably.
  #50   Spotlight this post!  
Unread 08-02-2005, 16:13
stephenthe1 stephenthe1 is offline
Registered User
#1008
 
Join Date: Dec 2004
Location: Ohio
Posts: 113
stephenthe1 is on a distinguished road
Re: encoders

Quote:
Originally Posted by Joe Ross
You can handle encoders without interrupts, as long as they tick slowly. If you can guarantee that you poll the pin at twice the rate it transitions, you would be able to poll it reliably.
just thinking, if you poll it at twice the rate it transitions, chances are you will get more ticks than actually occur with the encoder.
  #51   Spotlight this post!  
Unread 08-02-2005, 16:29
Ssbfalcon's Avatar
Ssbfalcon Ssbfalcon is offline
The beta version
AKA: Arthur
FRC #1546 (Chaos Inc.)
Team Role: Alumni
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Baldwin, New York
Posts: 8
Ssbfalcon is an unknown quantity at this point
Send a message via AIM to Ssbfalcon
Re: encoders

Based on what I see, interupts would be more reliable. However, assuming that the reliability of each method are equal, what are the pros and cons of polling and interupts, besides code complexity?
__________________
Don't Lick Dry Ice!
  #52   Spotlight this post!  
Unread 08-02-2005, 16:38
stephenthe1 stephenthe1 is offline
Registered User
#1008
 
Join Date: Dec 2004
Location: Ohio
Posts: 113
stephenthe1 is on a distinguished road
Re: encoders

Quote:
Originally Posted by Ssbfalcon
Based on what I see, interupts would be more reliable. However, assuming that the reliability of each method are equal, what are the pros and cons of polling and interupts, besides code complexity?
polling= slow roation only, less reliability overall, I'm not sure, but possibly unnecessary strain on the processor (but I doubt it), won't be prepared for using encoders in the future with interrupts on drive shafts, etc. adv. easy coding like you said.

interrupts=every advantage you could imagine, except tough coding. this is why Mr. Watson wrote code to handle encoders with interrupts, it's truly a wonderful thing he has made. go to www.kevin.org and scroll down to the robotics link, and look for frc encoders template. It's what I used to learn about encoders and interrupts, and it is so easy to use because all the work is already done pretty much. though I wish he would consider setting up a third encoder interrupt as well, but what he has is awesome.
  #53   Spotlight this post!  
Unread 08-02-2005, 17:30
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,245
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Re: encoders

Quote:
Originally Posted by stephenthe1
if you poll it at twice the rate it transitions, chances are you will get more ticks than actually occur with the encoder.
No. You don't count a tick if the pin state hasn't changed since the last time you polled it.
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me
  #54   Spotlight this post!  
Unread 08-02-2005, 17:33
stephenthe1 stephenthe1 is offline
Registered User
#1008
 
Join Date: Dec 2004
Location: Ohio
Posts: 113
stephenthe1 is on a distinguished road
Re: encoders

if the pin state hasn't changed, how does it know to not make another tick count? is there a flag, kind of like interrupts that must be cleared before you can register another tick? if so, that's pretty neat.
  #55   Spotlight this post!  
Unread 08-02-2005, 18:30
stephenthe1 stephenthe1 is offline
Registered User
#1008
 
Join Date: Dec 2004
Location: Ohio
Posts: 113
stephenthe1 is on a distinguished road
Re: encoders

can somebody please send me a copy of the new compiler? ( stephen51@safe-t.net ) thanks in advance.
  #56   Spotlight this post!  
Unread 08-02-2005, 18:57
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Cañada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Cañada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: encoders

Quote:
Originally Posted by stephenthe1
if the pin state hasn't changed, how does it know to not make another tick count? is there a flag, kind of like interrupts that must be cleared before you can register another tick? if so, that's pretty neat.
This is what state variables are for. As an example:

Code:
// assumptions:
//   left encoder phase-A signal goes to rc_dig_in01
//   left encoder phase-B signal goes to rc_dig_in06
//   right encoder phase-A signal goes to rc_dig_in02
//   right encoder phase-B signal goes to rc_dig_in08
 
static long left_encoder_count = 0;
static long right_encoder_count = 0;
static unsigned char prior_left_phase_a_state = 0;
static unsigned char prior_right_phase_a_state = 0;
 
// look for a rising edge on left phase A
if(rc_dig_in01 != prior_left_phase_a_state && rc_dig_in01 != 0)
{
   // get direction information from left phase B
   if(rc_dig_in06 != 0)
   {
	  left_encoder_count++;
   }
   else
   {
	  left_encoder_count--;
   }
}
 
// look for a rising edge on right phase A
if(rc_dig_in02 != prior_right_phase_a_state && rc_dig_in02 != 0)
{
   // get direction information from right phase B
   if(rc_dig_in08 != 0)
   {
	  right_encoder_count++;
   }
   else
   {
	  right_encoder_count--;
   }
}
 
// update state variables
prior_left_phase_a_state = rc_dig_in01;
prior_right_phase_a_state = rc_dig_in02;
Placed in the fast loop, this code will emulate the interrupt-driven code.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #57   Spotlight this post!  
Unread 08-02-2005, 19:17
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: encoders

Quote:
Originally Posted by stephenthe1
can somebody please send me a copy of the new compiler? ( stephen51@safe-t.net ) thanks in advance.
Stephen,

That would be illegal (copyright laws and all of that...). As they had announced at the kickoff, the V2.4 download was available for 2 weeks only and you had to link to it via the FIRST site. Now they have shut it down, as promised.

Please have your main team contact phone FIRST and they will send you a CD.

Mike
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #58   Spotlight this post!  
Unread 08-02-2005, 20:53
Workaphobia Workaphobia is offline
Registered User
AKA: Jon
FRC #1546 (Chaos Inc.)
Team Role: Alumni
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Long Island
Posts: 26
Workaphobia will become famous soon enough
Re: encoders

It suddenly occurred to me that the encoders can be reused for next year's competition, so I told my adviser to go ahead with the order. I guess I'll take another look through the readme for the encoder module and prepare to implement some autonomous driving functionality.
  #59   Spotlight this post!  
Unread 09-02-2005, 11:49
stephenthe1 stephenthe1 is offline
Registered User
#1008
 
Join Date: Dec 2004
Location: Ohio
Posts: 113
stephenthe1 is on a distinguished road
Re: encoders

I think I found our copy. and I would have to say that I disagree about it being illegal. if I purchased (or in this case got it free) a cd, and simply broke it somehow, I wouldn't be cheating the business by getting a copy from someone else, because I already paid for thir product. anyway, is the newest compiler on the disk that came with the kit this year? just to be sure. thanks
  #60   Spotlight this post!  
Unread 09-02-2005, 12:08
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,906
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: encoders

Quote:
Originally Posted by stephenthe1
anyway, is the newest compiler on the disk that came with the kit this year? just to be sure. thanks
No it is not. The new compiler wasn't available until after the KOP CD was made.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
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
Mechanical Wheel Encoders? Jaine Perotti Electrical 15 04-12-2004 22:46
Shaft Encoders wun Programming 3 12-10-2004 16:40
encoders? what kind and where from? ajlapp Electrical 1 03-02-2004 01:49
Who used wheel encoders CyberWolf_22 Technical Discussion 12 04-05-2003 15:37


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

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