Quote:
Originally Posted by programmr
Hello, I know how to program basic tasks. such as sticks, pwms, pneumatics, relays, autonomous, etc. We are putting these Optical Encoders on our robot to make sure our robot goes straight, instead of veering to the left or the right. Can someone please help me, i have no idea how to program these or where to even start. I found some information on the actual encoder we have, but i need programming help. Any help would greatly be appreciated. Thank You.
http://usdigital.com/products/encode...l/modules/em1/
|
We used these encoders a couple of years ago, actually something like the E6 kit which includes the plastic encoder wheels. In the past two or three years, the kit-of-parts from FIRST has also included hall effect encoder modules which detect the steel in gear teeth. Due to the fragility of all these solutions, and the time to swap out or align them during competitions, we have standardized on Grayhill 61K128 encoders for all cases.
The theory of using encoders in this application, where you have a left-side driver motor and a right-side drive motor for your robot, is to mount one encoder per side. The "quadrature" encoders such as the EM1 output two digital pulse signals - Phase A signal, and Phase B signal - which are connected to two digital input ports on the robot controller. Of course you have two encoders (left and right side) so you will be using four digital input ports.
Code such as Kevin Watson's watches the signals and counts them. When the motor is going in one direction the Phase A signals will be slightly earlier than the Phase B signals, and vice versa when the motor runs in the opposite direction, so the software can tell which way the motor is running, can counts the the number of pulses per time unit (in one second, say) to determine the rotational speed of the shaft, and the total number of counts can represent distance.
To drive straight, you would compare the speed or even the total counts of the encoders on the left and right sides. Assuming the wheel diameters are the same - adjusting the motor speeds (by varying values sent to the Victor speed controllers) to keep the encoder counts identical results in the robot driving straight. How to best do THAT is your next challenge
