Fall 2016 Biped Experiment/Trade off Study- Encoder
Encoder Specification
By: Alan Valles (Electronics and Control Engineer)
Approved by: Ijya Karki (Project Manager)
Table of Contents
Introduction
A rotary encoder must be used to get the positional reading of the motor shaft. This information is key in understanding which part of the walk cycle the robot is in. For example, if the robot’s right foot is on a color pad, the rotary encoder would read that it is in this position.
Study
With this information, the code could be utilized to read the color pad at this part in the flow chart. Another example is if we want to turn left, the walk function would be called until the left foot is planted. It is at this point that the robot would hold position, shift weight to the planted foot, and then use the ankle servos to turn.
Since a precise stepper motor will not be used in walking, a motor encoder must be used in order to have positional awareness of the robot. The two types of encoders that will be considered are an optical encoder and a rotary position sensor. The optical encoder subsystem uses a QRD1114 phototransistor and diode to send an IR signal and read with the phototransistor. It reads the amount of the IR signal that is reflected. The phototransistor receives an analog signal based on the light that is reflected and absorbed by the phototransistor. Thus, as the resolution of slices increases as shown in figure 4-17 or the parallax student manual, the resolution is improved. Another circuit is also necessary to convert the analog to a digital signal to be read by an input; the I2C bus is used. The other option is to utilize a rotary position sensor. This is essentially a potentiometer that is connected to the shaft so it is allowed to freely rotate. Its resistance is anywhere between 0 and 10k depending on the angle between o and 360 degrees. However, the Bourns 3322 series position sensor has a unknown region where its value is between 330 and 360 degrees based on the data sheet.
Table 1
Encoder | MFG | Challenge | Additional components | Price: |
Rotary | Bourns | Unknown region between 330 and 360 degrees | ADS1015 | 2.73 |
Optical | TI | Signal processing and acquisition | OpAmp COmparator | 1.77 |
In Order to meet scheduling requirements, the rotary position sensor will be used in order to meet our deadline. It will also be used by the velociraptor group which will aid in debugging and coding. The best way to move the all projects forward across The Robot Company is to work in a collaborative environment which is easier if the platform is consistent across all BiPed robots.
An experiment was also done by the Electronics and control Division to test the optical encoder circuits which is similar to a lab done on campus for control systems.
The code below was done by Electronics and Control and is modified from sparkfun guide below.
The code:
/******************************************************************************
QRD1114_Proximity_Example.ino
Example sketch for SparkFun’s QRD1114 Reflectance Proximity Sensor
(https://www.sparkfun.com/products/246)
Jim Lindblom @ SparkFun Electronics
May 2, 2016
Connect a QRD1114, 330 resistor and 10k resistor as follows: QRD1114 Pin ---- Arduino ---- Resistors 1 A0 10k Pull-up to 5V 2 GND 3 330 Resistor to 5V 4 GND
As an object comes closer to the QRD1114, the voltage on A0 should go down.
Development environment specifics:
Arduino 1.6.7
******************************************************************************/
int QRD1114_PIN = A0; // Sensor output voltage
int LED = 13;
int x = 0;
int y = 1;
int z = 0;
void setup()
{
Serial.begin(9600);
pinMode(QRD1114_PIN, INPUT);
pinMode(LED,OUTPUT);
}
void loop()
{
// Read in the ADC and convert it to a voltage:
int proximityADC = analogRead(QRD1114_PIN);
if (proximityADC < 630){
digitalWrite(LED,HIGH);
z=x;
}
else {
digitalWrite(LED,LOW);
y=1;
}
if (y==1){
increment();
}
if (z!=x){
Serial.println(x);
}
// float proximityV = (float)proximityADC * 5.0 / 1023.0;
// Serial.println(proximityV);
// Serial.println(proximityADC);
delay(10);
}
void increment()
{
if (digitalRead(13)==HIGH){
z = x;
x = x + 1;
y=0;
}
else if (digitalRead(13)==LOW){
x=x;
y=1;
}
}
Figure 1
Figure 2
Figure 1 shows the realized circuit and an example of the Pizza slices that could be used for the encoder. Since it is difficult to get precise values from the optical sensor, the code above utilizes flags and a threshold value, which when passed dictates a state flag y. The circuit shown in figure 2 is a example circuit that could be used to output a square wave into an available pin on the GPIO expander, SX1509. However, due to the additional circuit complexity, and software hardware integration complexity, the rotary position sensor will be used since it is the most straight forward.
The Bourns 3382 series in conjunction with an ADS1015 delivers a digital value that is able to be mapped onto an SX1509 empty pin. The ADS1015 takes an additional address space on the I2C bus and appears much more straightforward. The optical sensor had to poll and use a counter to keep track of the number of logic HIGH that appeared. There are issues with timing based on this design among other things. Therefore, the Rotary encoder suite in conjunction with an ADS1015 will be used going forward.
Conclusion
In Conclusion a Rotary positions sensor, Bourns 3382 series will be used in conjunction with an ADS 1015. This subsystem was chosen over an optical encoder due to the simplicity, in hardware and software design.
Resources
[1]https://www.parallax.com/sites/default/files/downloads/122-28176-Process-Control-Text-v1.0.pdf
[2]https://www.sparkfun.com/datasheets/BOT/QRD1114.pdf
[3] https://learn.sparkfun.com/tutorials/qrd1114-optical-detector-hookup-guide
[4]http://www.digikey.com/catalog/en/partgroup/3382-series/7106
[5] http://www.ti.com.cn/cn/lit/ds/symlink/ads1015.pdf
[6] http://www.digikey.com/product-search/en?mpart=3382H-1-103&vendor=118
[7] http://www.digikey.com/product-detail/en/fairchild-semiconductor/QRD1114/QRD1114-ND/187536