You are on page 1of 6

9 December 2014

Professor Maharbiz

EE40 Final Hack Writeup

Project Name: Analog Line Follower


Authors: SHU TING CHEN, VINCENT JOHN POLITZER, HONG-KIT WONG

Description:
Create a line following robot using an analog circuit that generates a PWM
signal that varies depending on a voltage-based sensor input. This will allow
varying motor speed, which facilitates a smooth motion, instead of a zig-zag.

Materials:

● 1x half-sized breadboard ● 1x 820Ω Resistor (R5)

● Several tongue depressors for the ● 2x 1kΩ Resistor (R6)

frame ● 2x 300Ω Resistor (R7)

● A little bit of heat shrink tubing ● 1x 180kΩ Resistor (R8)

● Several zip ties ● 2x 0.1µF Capacitor (C1)

● Prototype board with copper pads ● 2x 10µF Capacitor (Voltage

● Jumper wires Regulator)

● 1x LM1086 3.3V Regulator ● 2x 1N4001 Rectifier Diode

● 1x LMC6484 Quad Amplifier ● 2x Photocells

● 2x 50kΩ Potentiometer ● 2x Bright white LED

● 1x 15kΩ Resistor (R1) ● 1x 9V battery and connector

● 1x 18kΩ Resistor (R2) ● 2x Transistors (Motor)

● 1x 120kΩ Resistor (R3) ● 2x Gear motors with wheels

● 1x 47kΩ Resistor (R4)


Schematics and Diagrams:

(The top left op-amp circuit is a Schmitt-trigger, the top right is an Integrator,
and the two on the bottom are comparators.)
Instructions:
Building the Robot Frame and Testing Its Functionalities

1. Build the T-frame out of tongue depressors, but omit the cross-piece at the
bottom where the battery would go. Instead, the battery will be stuck on the
bottom with double-sided tape, and the sensor array will go where the battery
would have gone originally.

2. Build the circuit on the breadboard, except for the LEDs and their resistors and
photocells.

3. Attach the gear motors and wheels to the frame. We decided to use gear motors
because they were more reliable for finely controlled movement. For some kinds
of motors, zip ties would work well for attachment. However, our motors were
oddly shaped. Since we had access to a 3D printer, we modeled and printed out
mounting brackets to secure the motors to the frame. While wheels that fit the
motors could have been purchased, we went ahead and modeled and printed
those as well.

4. For our sensor array, we use a small piece of prototype board with copper pads,
which is essentially a circuit board without any connections. This is so that we can
have a nice assembled sensor board that just needs to be mounted and plugged
in. Our sensor array consists of two photocells to measure reflectance, and an
LED for each photocell to provide a consistent light source. Heatshrink is used as
spacers for the photocells and LEDs to ensure uniform distance from the board, as
well as prevent shorts on the exposed component leads. On the board, we put the
LEDs, resistors for the LEDs, and the photocells. The LEDs should not extend
much further from the board than the photocells. Make sure there is enough
distance between the pairs so that they can sit on either side of a black line. We
put roughly an inch between the pairs and a half-inch between each LED and
photocell. Attach the sensor array to the end of the protruding tongue depressor.
You will want to check how high the photocells are from the ground. The distance
should be about quarter-inch or so. Attach a small piece of a tongue depressor
vertically in front of the array: this will be used to ensure proper sensor height.
The wires that come off the sensor array are 9V, GND, and one for each
photocell, which connect to the inverting terminals of the comparators.

5. Tune the potentiometers. The motors should not turn if the sensors are over an
entirely black area, but they should turn when they are over white. Once this is
tuned, the potentiometers serve as a way to set maximum speed.
Calculation of the Resistor and Capacitor values:

We want a triangle wave with peaks between 0V and 3.3V, since that is the range
we have available, as VDD = 3.3V, and VSS = 0V. Let us try peaks at 1.2V and 2.5V
(our sensor input will not go to zero, since it is a voltage divider, and testing
didn’t show too large of a range of values.)

This Schmitt-trigger/Integrator circuit requires a reference voltage to be applied


to the Schmitt-trigger’s inverting input. We arbitrarily chose 1.5V, so we need to
pick R1 and R2 such that the resulting VREF = 1.5V. 1.5V = 3.3V(R2/(R1+R2)). R1 =
18kΩ and R2 = 15kΩ satisfies this.

Now we need to pick R3. The op-amp’s input-bias current at the non-inverting
input of the Schmitt-trigger is 0.02pA. We want this to be negligible compared to
the current running through R3 to reduce error, so let us ensure the current
through R3 is several magnitudes larger, say, 2pA. The voltages across R3 could
either be VREF, or VDD - VREF, based on the two output states of the Schmitt-trigger.
So R3=1.5V/2pA or R3=1.8V/2pA. Since we want the current to be larger than
2pA, the smaller of the two possible R3 values will be the largest resistance
necessary for our circuit. Smaller resistance values will just increase the current,
which is fine, because all we have is a minimum current requirement. It turns out
that both of these values are rather large, so we will just use an arbitrary
resistance of 120kΩ.

Next, we must pick R4 and R8. We get two equations by applying nodal analysis to
the non-inverting input of the Schmitt-trigger, one equation for each output state,
given the triangle-wave peak thresholds.

Since our peaks are going to be from 1.2V to 2.5V, let VSTlo and VSThi be equal to
these thresholds, respectively. VSS is 0V, VDD is 3.3V, and R3 is 120kΩ. This results
in R4 = 47kΩ, and R8 is 173kΩ. We will use a standard 180kΩ resistor for R8.

Lastly, we can design the integrator.

To ensure the motors are not under supplied, we will try setting the frequency
somewhere between 5kHz and 10kHz, say 7.5kHz. We have a 0.1µF cap, so we
will use that for C1. VOUT P-P is the peak to peak voltage, 1.3V. Then, after solving,
we find that R5 = 839Ω. We will use an 820Ω resistor for R5.
R1 = 18kΩ
R2 = 15kΩ
R3 = 120kΩ
R4 = 47kΩ
R5 = 820Ω
R8 = 180kΩ
C1 = 0.1µF

We use variable resistors to make voltage dividers with the photocells to allow for
calibration, as the sensor input voltage needs to fall between the peaks of the
triangle wave.

Documentation:

http://youtu.be/-W54c9VUJVo

You might also like