|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#46
|
|||
|
|||
|
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
|
|||
|
|||
|
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
|
|||
|
|||
|
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
|
||||||
|
||||||
|
Re: encoders
Quote:
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
|
|||
|
|||
|
Re: encoders
Quote:
|
|
#51
|
||||
|
||||
|
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?
|
|
#52
|
|||
|
|||
|
Re: encoders
Quote:
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
|
|||||
|
|||||
|
Re: encoders
Quote:
|
|
#54
|
|||
|
|||
|
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
|
|||
|
|||
|
Re: encoders
can somebody please send me a copy of the new compiler? ( stephen51@safe-t.net ) thanks in advance.
|
|
#56
|
||||
|
||||
|
Re: encoders
Quote:
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;
-Kevin |
|
#57
|
||||
|
||||
|
Re: encoders
Quote:
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 |
|
#58
|
|||
|
|||
|
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
|
|||
|
|||
|
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
|
|||||
|
|||||
|
Re: encoders
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |