Using Quadrature Encoding
Technique for using Quadrature Encoding with the Make Controller Generally used on Shaft Encoders
Concept
There is no subsystem dedicated to Quadrature encoded hardware in the make controller. In order to have a quick fix to projects using shaft encoding, i have created a firmware which reports all analogin values as well as Encoder activity. The encoder data leads should be attached to inputs 6 and 7.
http://makingthings.com/Members/tunell/firmwares-of-all-colors/encoder-make.c/view
This firmware allow the user to avoid using the analogin autosend and poll functions normally necessary.
Overview
Shaft encoding is a technique that allows rotational direction and distance with a single number. The encoder emits pulses from its leads as the shaft is rotated. The pulses will be offset by 50%, so that the leads can be compared to detect rotational direction. If Line 6 goes high while Line 7 is low, then rotation is forward, if 6 goes high while 7 is high, then rotation is backward. This is known as gray encoding.
The firmware uses the fasttimer subsystem poll all inputs every 150 microseconds. Lines 0-5 are reported directly as analog inputs, while 6 and 7 are compared for rotation. All data is reported every 150 milliseconds. As rotation is detected, a generic 'PULSES' variable is incremented or decremented depending on direction. If no rotation is detected, or the overall rotation during the150 millisecond interval is zero, a zero is reported. A positive 'PULSES' indicates overall forward rotation and vice versa.
The analog input and pulse data is reported automatically via OSC using the Debug subsystem. The 6 values will appear as follows:
(A0 A1 A2 A3 A4 A5 PULSES)
A split function may be used to separate these variables into their independent components when using a PC via OSC.
If the PULSES variable is thought of in the context that it is distance traveled over 150 milliseconds, it can be considered a speed: distance/time. This means that the information you are truly receiving is:
- Distance Traveled
- Rotational Direction
- Speed
note: If the encoder only has one data line, it is not a quadrature encoder, and will not give directional information, but still provides distance and speed. Care should be taken to reduce vibration in systems using singular encoders. Vibration may be interpreted as forward motion even though overall shaft rotation is zero.
Considerations
The biggest issue with this technique, is that the Fasttimer subsystem and Servo subsystems cannot be run simultaneously (as of 11/12/08). This means that when using the Fasttimer, the Servo response will be jittery and unpredictable. Some modifications can be made to the Servo subsystem that will reduce this behavior, but not eliminate it. For this reason, it may be necessary to add a second hardware device to the make controller that will be in charge of servo movement. I have personally added a second Make controller to the project. This extra device reads additional analog inputs, controls digital outputs, and monitors the encoder, and sends all values through the primary controller, which is in charge of I/O as well as Servo control.
It may be possible to connect a simpler, cheaper device to the serial port of the MC that will control servos. Such as this one:
http://www.sparkfun.com/commerce/product_info.php?products_id=8897

