|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#16
|
|||
|
|||
|
Quote:
|
|
#17
|
||||
|
||||
|
Re: encoder vs. motor
Postscript:
Go to Optical Encoder Tutorial and read the sections "Introduction To Encoders" and "Technical Overview". I'm sure you will have questions... Post 'em here... |
|
#18
|
|||||
|
|||||
|
Re: encoder vs. motor
Continue in the direction Mike is sending you. I just want to address some of the previous outstanding questions.
Quote:
The statement “static unsigned int encoder = 0;” will only take effect at compile time, not while the code is running. It sort of nails the variable in place and sets it’s initial value only once. The statement “unsigned int encoder = 0;” will take effect while the code is running. Every time the routine is entered the variable encoder will be “created” and assigned the value of 0. Referring back to Sean’s comment earlier about only counting rc_dig_06 when it changes, not every pass through the code that it happens to equal 1… The following is an example of only counting changes in rc_dig_06. This particular method actually doubles the resolution of your encoder as it counts both when it changes to 1 and when it changes to 0. Code:
static char toggle=1; // Start as TRUE
if (toggle == rc_dig_in06) // Encoder has changed
{
toggle = !toggle;
encoder = encoder + 1;
}
|
|
#19
|
||||
|
||||
|
Re: encoder vs. motor
Quote:
Quote:
Quote:
-Kevin |
|
#20
|
||||
|
||||
|
Re: encoder vs. motor
I also highly recommend Kevin's code.
We used it on our FRC last year and it worked PERFECTLY. We also used it with a relatively low-resolution encoder, about 64 ticks per revolution. Some advantages: - Uses interrupts, so that you don't have to worry about missing your encoder ticks. - Reads two quadrature outputs, so that you can detect which direction your encoder is spinning (increment your encoder variable when spun in one direction, decrement it in the other) Things to look out for: - The version I used had one interrupt per encoder, and interrupted only on rising edges - This meant my encoder variable would only increase or decrease after about 4 encoder state changes, dividing my effective encoder resolution by 4 - This wasn't a BAD thing, in fact it was a very good exercise in learning, and implementing two interrupts per encoder, which interrupted on rising AND falling edges, and gave me back full encoder resolution *hint: don't use two interrupts per encoder... to me external interrupts are more expensive than getting a higher resolution encoder. Last year, we had an interrupt or two to spare after we removed our IR after Pittsburgh. Next year, I know we WON'T have any spare external interrupts. I know it sounds crazy, maybe this advice comes a bit late, but buy an encoder with twice the resolution you expect to require. It gave me a great opportunity to teach students about interrupts vs. polling, and the concepts of rising edges, falling edges and such. Even the whole concept of quadrature was quite interesting to them. Most didn't think it was that easy to figure out which way an encoder was spinning. In addition, we purchased an inexpensive mechanical encoder where we opened up the back, and you could physically see how the quadrature signal was generated with just a sweeping arm, and a few contacts. I definitely learned a lot, and so did the students on 188. Thanks Kevin for your code! We used your IR code too =), and were very successful in our empty gymnasium, but weren't so successful on the actual playing field. -Shawn... |
|
#21
|
||||
|
||||
|
Re: encoder vs. motor
Quote:
Quote:
Thank you for your help. |
|
#22
|
|||||
|
|||||
|
Re: encoder vs. motor
Everybody has been focusing on the programming, but nobody has answered the other question:
Quote:
A couple of weeks ago I put together a mini-dongle, with the "disable" toggle switch built into a plastic DB-15 connector housing (the extra channel access is wired to be permanently active, and autonomous control is not available). It's mostly going to be used when someone is working on the robot and doesn't want it to bite them if a joystick gets bumped. It'll also come in handy when we want to have multiple robots running at the same time. |
|
#23
|
||||
|
||||
|
Re: encoder vs. motor
Alan,
Thank you for catching that. I teach my team to pull the power plug or the tether (depending on how it is powered) to the OI to disable the robot. Also, when loading untested code, one team member is to have their hand on the 120 amp circuit breaker disconnect button until the code is verified. The reason I do not have them use the dongle is that the connection is normally enabled (a broken wire enables the robot). We use the dongle for autonomous mode testing only. |
|
#24
|
||||
|
||||
|
Re: encoder vs. motor
Shawn,
Quote:
Quote:
Quote:
Quote:
-Kevin |
|
#25
|
||||
|
||||
|
Re: encoder vs. motor
Quote:
Quote:
-Kevin |
|
#26
|
||||
|
||||
|
Re: encoder vs. motor
Quote:
Teams will have lots of I/O and interrupt requirements. They need to understand that there is not "one size fits all" and that different timers. interrupts, et cetera, act differently (eventually, you have to read the manual). As to your previous statement, I can't get to your website at all now... Please let us know when everything is resolved. Your's is much to precious of a resource to be lost. Once again, thank you for your guidance and support... |
|
#27
|
||||
|
||||
|
Re: encoder vs. motor
Quote:
http://kevin.org/frc/frc_encoder.zip and here: http://robotics.jpl.nasa.gov/~kevinw/frc_encoder.zip As I won't get a chance to test it for a few days, please let me know if you have problems with the code. -Kevin |
|
#28
|
|||
|
|||
|
Re: encoder vs. motor
Where do you wire the 5v and ground to pin 1 and 2 of the encoder. Pin 3&4 to the digital input /output?
Thanks I searched but do not fine anything. |
|
#29
|
||||
|
||||
|
Re: encoder vs. motor
Quote:
-Kevin |
|
#30
|
|||
|
|||
|
Re: encoder vs. motor
Quote:
EC202A050A2(S or T)D Sorry about that |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [OCCRA]: motor brush springs | greencactus3 | OCCRA Q&A | 1 | 28-09-2004 20:56 |
| Multiple Motors | phrontist | Motors | 12 | 21-06-2004 23:05 |
| Mounting the drill motor | Veselin Kolev | Motors | 11 | 26-04-2004 14:27 |
| WHich motor to lift and for arm | thoughtful | Motors | 8 | 25-02-2004 10:34 |
| Thermal Protection | archiver | 2000 | 1 | 23-06-2002 23:27 |