View Full Version : How do Encoders work?
4AngryNutjobs
16-10-2011, 12:49
Hey all,
Our programming team is pretty new and we're really fumbling around in the dark here not knowing what to do or how to do it. Our 2 main questions are: How do encoders work, and which sensors are the best to use?
Thanks in advance :)
plnyyanks
16-10-2011, 13:17
The first question in response would be: What type of encoders do you mean? There are lots of different types with different usages. For now, I guess I'll assume you mean rotary encoders (http://en.wikipedia.org/wiki/Rotary_encoder), which are probably the most common type in FRC robots.
Now, an optical rotary encoder has three main parts: a rotating disc, light source, and photosensor (which senses the light source). It looks something like this:
http://zone.ni.com/cms/images/devzone/tut/a/0ac2be30497.gif
The encoder will have two of the light sensors offset at 90 degree angles to each other. They will output two square waves offset by 90 degrees:
http://zone.ni.com/cms/images/devzone/tut/a/0ac2be30498.gif
You can use these two waves to determine the speed and direction of the rotating shaft.
That's a very simplified overview of encoders - there's undoubtedly someone who can go into more detail than I can. For more reading:
http://zone.ni.com/devzone/cda/tut/p/id/3321
http://www.societyofrobots.com/sensors_encoder.shtml
http://en.wikipedia.org/wiki/Rotary_encoder
As to which encoders are the best to use, it really depends on the application. Most drivetrains use these (http://www.usdigital.com/products/E4P-360-250-D-H-D-B) encoders (they work, and they come in the KOP). Once you move into other robot attributes, there's much more variety and diversity of sensor choices. Potentiometers (http://en.wikipedia.org/wiki/Potentiometer) and Magnetic Rotary Encoders (http://www.austriamicrosystems.com/eng/Products/Magnetic-Encoders/Rotary-Encoders/AS5030) are also popular.
DonRotolo
16-10-2011, 13:17
I can only offer a short answer, since I think the question you really wanted to ask was "How do we use encoders?"
There are many kinds of encoders, the ones in the KoP use a tiny precision disk that has black and shiny lines on it, that are spun past an optical sensor. Every time a sensor sees a line go past, it generates an electrical pulse. These pulses are sent to the software, and by counting the pulses in a period of time, you know how fast the encoder (and thus whatever it's attached to) is moving.
By using two sensors (in the encoder) on the same disk, mounted "in quadrature", you can tell which direction it's going too. The KoP encoders do this, using "Channel A" and "Channel B". (BTW, they connect to digital inputs in a cRio)
As for how you should use them, they are made to know (rather than guess) how far your robot has moved, or how far your robot arm (for example) has moved. Lots of ways that information can be valuable, for example during Autonomous mode.
As for how you use them in software, you might find that 238 pulses means you have moved one foot. So, to move 10 feet, just turn on the motors until the count reaches 2380. (Of course, you'll want to slow them down as you approach that number and stop exactly when you hit it, otherwise you'll coast past it)
Does that help?
4AngryNutjobs
17-10-2011, 23:03
Yes, thank you so much, both of you :) you've been a tremendous help to us.
What programing software are you using? They all have encoder objects in their library. A lot easier than trying to program it yourself.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.