Monday, January 23, 2012

aBot – Maiden Voyage

Time for an update…

Tonight, I ran a short test.  The plan was to go in a straight line for five seconds and then stop.  Unfortunately, while I was successful with the go, the five seconds and stop the straight line didn’t quite work.

Over the last three and a half weeks have been busy with a lot of things.  However, I did manage to squeeze in some time to work on the new wheel encoders for aBot.  During this time I made several discoveries that have shaped the design.
  1. I found out that the output from the LM339 is an uncommitted collector and therefore I need pull up resistors on the digital input pins.
  2. I determined that unused comparator pins should be grounded.
  3. I discover that in order to get a clean digital signal I needed to implement hysteresis with the LM339.  This consisted of adding two additional resistors to the design so that the comparator wouldn’t cycle at the set point causing numerous interrupts until the voltage rises enough that it constantly stays above the set point. 

That brings us to tonight’s test.  Below are two pictures of aBot at the time of the test.  It wasn’t pretty but it was functional.

PICT0301
PICT0302
As I said at the start of the post aBot ran and stopped according to plan.  What didn’t work was running in a straight line.  The problem was that during the 5 second run aBot’s left wheel travelled 31 inches while the right travelled 33 inches.

If the wheel encoders and the software monitoring them was working right this shouldn’t happen.  So now it is back to troubleshooting to find out where the problem is.

Wednesday, December 28, 2011

aBot – Wheel Encoder Mystery Solved Again

Short story:

I was wrong.  The waves formed by the sets of peaks and valleys was not due to the wheel being untrue.  It appears to have been a combination of:

  1. The reflectance sensor being too far away from the encoding disk.  Needs to be 1mm to 2mm away from the encoder disk.
  2. The width of the white and black stripes on the disk being too narrow.  I believe this causes a higher low reflectance as the sensor gets reflection from a mix of white and black and not just black.

Long story:

On Thursday, December 22 my parts for the new wheel encoder came in.  Given it was 3 days to Christmas I didn’t get a chance to work on things until a couple days later.

I wired up the QRD1114 to an analog pin and collected some data.  What I found when I plotted it was a similar double wave pattern that I had seen with the QRT-1RC. 

As you can see from the graph from my post, aBot – Wheel Encoder Mystery, the highest valleys are higher than the lowest peaks.  This created a problem as there was not one voltage that could be fed into the comparator.

I spent parts of the next two days trying to figure out how to fix the problem and get a consistent set of peaks and valleys. 

As I thought my problems were caused by the wheel being untrue I experimented with other wheels.  No matter what I tried it didn’t solve the problem…

I thought maybe it was because I didn’t have the disk centered on the wheel so I adjusted the disk on the wheel.  Still no solution…

I tried placing the sensor at different distances from the wheel and double checked the datasheet.  I found as I put the sensor closer to the wheel I got a more consistent baseline for the valleys.

I found I need to put QRD1114 1mm to 2mm from the encoder disk.  Peaks are still all over the place and the voltage difference is too low…

I tried varying the speed of the motor turning the encoder disk.  The time between peaks and valleys increased as was expected.  The peaks are still inconsistent and too low…

I was running out of things to change…

On a whim I reduced the number of white and black stripes.  I dropped from 64 (32 black / 32 white) to 24 (12 black / 12 white) and was on to something…

The peaks were much more consistent peaks and much higher.

I was stumped if it could handle 24 transitions at high speed why couldn’t it handle 64 transitions at well below half the speed.  I played around with the timing a bit more before deciding that it must have to do with the size of the white and black stripes on the encoder disk.

I was using a disk that was just under 3”.  As a result on the 24 stripe disk the size of the white and black stripes was around 10mm.  On the 64 stripe disk the size of the white and black stripes was only 3mm.  My hypothesis is that with the narrower stripes the reflectance was based on a mix of white and black while with the larger stripes it wasn’t and therefore resulted in a higher peak.

To test this I created a 6” disk with 64 transitions on it and it appears to be correct.  With the larger disk the stripes end up being 6mm and the QRD1114 has a consistent baseline of valleys, consistent peaks, and a significant voltage difference between the peaks and valleys.

Sunday, December 18, 2011

aBot – Wheel Encoder New Design

Tonight I am toying around with a new design for the wheel encoders suggested by someone on the Arduino forum.
It consists of two QRD1114 sensors, one for each wheel, fed into an LM339 with two 5K trim pots to allow for adjusting the sensitivity.  The outputs from the LM339 go two two digital pins on the Arduino.



The parts list looks like this:
  • 2 - FAIRCHILD SEMICONDUCTOR QRD1114
  • 1 - FAIRCHILD SEMICONDUCTOR LM339AN
  • 2 - TRIMMER, POT 5KOHM 23TURN THD T93XB-5K-10-D06
  • 2 – 220 Ohm Resistors
  • 2 – 10K Ohm Resistors

Saturday, December 17, 2011

aBot – Wheel Encoder Mystery Solved (or So I Thought)

This morning I solved the mystery of the second wave.  It turns out the wheel is not exactly true and therefore as it rotates the distance between the sensor and the encoder disk varies slightly. 
How this affects the values is that as the distance varies the reflectance for the white and black lines increases when the sensor is closer to the disk and decreases when the sensor is further away.  This in turn consistently increases or decreases the discharge times for the capacitor which causes the peaks and valleys to form a wave as the wheel rotates.

Thursday, December 15, 2011

aBot – Wheel Encoder Mystery Part 2

I wanted to post some additional information on the wheel encoder development.  I have included a picture and a schematic of the setup I am using for testing purposes.
image
The QTR-1RC digital reflectance sensor is positioned over the wheel (1) with vcc, gnd and signal connected to the breadboard (2) and finally the signal line is connected to pin D2 (3).
image
All of the grounds: the servo, the +6V power supply, the QTR-1RC, the Boarduino and the +5V power supply are tied together.

Monday, December 12, 2011

aBot – Wheel Encoder Mystery

Tonight I started working on the wheel encoders for aBot.

I assembled one of the XWheels and put the 64 segment encoder disk shown below on the back of it.  I found the encoder disk on the Robot Gestation website in a very good article on IR Sensors.

image

I mounted the wheel on one of the servos and clamped the servo in a vice so that the back was pointing up.  Above the wheel I positioned one of the QTR-1RC sensors and wired it back to the Boarduino with the signal pin connected to the d2 pin.  I connected the servo to four AA batteries and connected the signal pin from the servo to the d5 pin.

The next step was to create a simple sketch which would both drive the servo and charge the reflective sensor and record the amount of time it took for the sensor’s signal pin to go from high to low.

Arduino Sketch

#include <MsTimer2.h>     
#include <Servo.h>
#define RRSPIN 3

Servo leftServo;

volatile boolean chargeRS;
volatile unsigned long leftRSStartTime;     
volatile unsigned long leftRSTimer;

void chargeRSISR() {      
  chargeRS = true;      
}

void leftRSISR() {
  leftRSTimer = micros() - leftRSStartTime;      
}      

void setup() {      
  Serial.begin(57600);      
  Serial.println("Starting...");      
  leftServo.attach(5);      
  leftServo.writeMicroseconds(1600);      
  attachInterrupt(0, leftRSISR, FALLING);      
  chargeRS = false;      
  MsTimer2::set(2, chargeRSISR); // 2ms period      
  MsTimer2::start();      
}

void loop() {
  if (chargeRS) {      
    pinMode(LRSPIN, OUTPUT);    // make line an output      
    digitalWrite(LRSPIN, HIGH); // drive line high       
  
    delayMicroseconds(10);      // charge line      
    
    pinMode(LRSPIN, INPUT);     // make line an input      
    leftRSStartTime = micros();      
    digitalWrite(LRSPIN, LOW);  // disable pull-up!      
    chargeRS = false;      
  }      
  if (leftRSTimer) {      
    Serial.println(leftRSTimer);      
    leftRSTimer = 0;      
  }      
}

When I ran the sketch I expected to see the amount of time for the capacitor on the reflective sensor to discharge would vary depending on if the sensor was over a black or white stripe on the wheel.
I have to say when I graphed the results I was a bit surprised.

Arduino

The difference between capacitor discharge times over the black and white stripes showed up.  As expected the faster the wheel rotated the narrow the width of the intervals was.

What surprised me as that the series of discharge intervals change forming a second set of peaks and valleys that also decrease in width the faster the servo spins. I am not exactly sure what causes this “macro” interval.

More to follow…

Robot Project – aBot (Arduino Robot)

I have decided to call my current robot project aBot for Arduino Robot.  As I shared in my last post I am going base to be using the Budget Robotics’ ArdBot Chassis. 

Here is the parts list as it now stands:

  1. Budget Robotics ArdBot Chassis
  2. Pair of Budget Robotics XWheels
  3. Adafruit Boarduino
  4. Two Pololu Digital Reflectance Sensors (QTR-1RC)
  5. Two Sparkfun Large Full Rotation Servos (ROB-09347)

I expect I will add a few more things as the project progresses.

The first step is to develop wheel encoders using the Pololu Digital Reflectance Sesnors.