| Print | Contact Me
Alan's Corner of the Internet

My Robot


There project is very much in progress. Unfortunately I don't work on it often enough so when I do work on it, it takes a while to get back to where I left off.

The latest version of the robot is powered by two modified servo motors. Shaft encoders on the wheels provide feedback to the control system but not much is done with that yet.

The control system is a PIC Microchip microprocessor. For testing, I'm using the 12F675.

Wheel Encoders - Motor Control - Object Detectors

Wheel Encoders

My plan is to use the wheel encoders to implement a dead reckoning navigation system. Also, the encoders might will be helpful to get the robot to drive in a straight line since the servos are not exactly matched. Seattle Robotics has a good article on dead reckoning and includes a good template for making your own encoders.

Wheel Encoder Detector Circuit diagram

My sensor is the QRD1114 which is an analog 4 pin IR emitter/detector module. I feed the output from the sensor to an op-amp configured as a voltage comparator with the threshold voltage set by a voltage divider (the 10k/15k resistors). The output from the op-amp is digital.

The digital signal is connected to an IO pin of the 12F675 configured to interrupt on change. So every time a black/white boundary passes the sensor, an interrupt is triggered. In the interrupt handler, I determine which encoder has fired and increment a counter. The plan is that periodically, the processor will integrate these counters to determine its new location.

I placed the sensor and a couple of resistors next to the wheel (the dashed box) with the op-amp and remaining circuitry on the main board. A 3-wire lead connects between the two sections. The circuit diagram above only shows the circuit for a single wheel. The other wheel is exactly the same, except it uses the second op-amp in the LM385 package.

Update (Oct 2005): I noticed that 'svo' has used and improved my circuit for the wheel encoders on his robot. Svo uses a similar circuit with general purpose IR transmitter/receivers and places the entire circuit inside a modified servo motor case. He has step-by-step instructions with photo illustrations.

Front side of wheel 
encoder detector
The detector is mounted next to the servo motor with the sensor aligned near the rim of the wheel. The wheel has been removed but the backside of the opposite wheel is visible in the background. A - the power shaft of the servo motor. B - the sensor. C - leads to additional circuitry.
Back side of wheel 
encoder detector
The back side of the wheel and encoder showing the encoder disk. There is about 2mm between the encoder disk and the sensor.

To Top

Motor Control

I recently moved from using modified servo motors (see in the above photos) to using GM2 geared motors. They have the advantage of better speed control using PWM control than the pulse control of the servos. I used the L293D dual 'push-pull' motor driver which allows directional control of two motors - it handles all the high current stuff that would overwhelm a microprocessor.

The challenge was to develop a PWM controller for two motors using a single 16F819 PIC microprocessor. Some of the bigger microprocessors (such as the 16F877A) have dual PWM controls built-in but the 819 only has one.

I wrote an assemble program which using a single 8bit timer (TMR0) to drive both channels of PWM as well as control direction.

To Top

Object Detector

This is an older module. My current version does not have any object detection yet. The next version of the object detection will likely move more to the microprocessor by using the analog->digital converter.

Here is a circuit diagram of the IR detector unit I am using for object detection.

IR Object Detector Circuit 
Here are the values I used: Notes:

R2 should be larger then the maximum resistance of the detector. Measure the resistance of the detector when it is pointing into a dark area and then choose the next larger resister. This means the voltage on the op amp is close to zero when there is no signal.

R3 and R4 determine the amplification of the op amp, gain = 1 + R4/R3. An appropriate ratio can be determined by connecting up the circuit and measuring the voltage entering the op amp and knowing the threshold value needed at Vout. Vout = (1 + R4/R3)Vin so just solve for the ratio using the values for Vout and Vin.

As stated above, I used a LM358 Dual op amp package. The specs and pin outs are available on the net at any of the semiconductor manufacturers such as National Semiconductor.

I used an approximately Vcc = 5 Volt power source on my robot but almost any power source greater then that can easily be used with appropriate values of R1, R2 and within the specs for the OP Amp chip.

The Vout signal is connected directly to an I/O pin of the Basic Stamp. The ground used for this circuit is required to be the same as the ground used by the processor.

To Top

Main Page:
Popular Pages:
Table of Contents