Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: The Circuit
The circuit works like this:
There's an IR LED pointing down at the front of the robot, the reflected light is sensed by the two phototransistors, then, the voltage signal is sent to the op-amp and it send more or less current to the motor (through a NPN transistor) depending on the gain, adjusted with the feedback pot.
The design of the circuit is divided into two equal parts, which have the same sensing and driving components.
The robot works in this way:
When it's on the black line, it advances at an average speed, when the line is curved, one of the phototransistors is out the line, and the other is going into it; the signal from the phototransistor out the line is a higher voltage than before, because it's resistance has dropped down, then the op-amp sends a bigger signal to the transistor and the motor of it's side goes faster, turning the robot back into the line.
If you want to make a robot that follows a white line on a black background, you'll have to switch the posotion of the phototransistor and the divider resistor, so the phototransistor has the emitter connected to GND and the collector to the resistor and the IN+ of the op-amp.
To make the circuit you'll need to make the PCB, you can print the PDF below, or order one with the .BRD file.
The componens I used are:
-Two 3mm phototransistors (mine from TCRT5000 modules)
-An IR LED
-a 2x and a 3x bent male headers, and a jumper.
-0805 resistors (2x4K7, 2x150ohm, 1x120ohm)
-2x 10K 3mm SMD pot
-2x S8050 SMD transistors
-a MCP602SN dual op-amp (rail to rail)
Step 2: The Mechanical Part
In the circuit, i left two 3mm holes at the back, so anyone can hook up it's own mechanical part.
I made mine from a 1mm thick brass plate, in the photos you can see how i cut and bent it. This structure can hold the mini motors and the wheels together and it makes a pretty decent rpm reducer. Then i threaded the holes so i can bolt this structure to the PCB without nuts.
The mini ball roller is used at the front of the robot as an all direction wheel, you can just solder a 5mm LED in that part, it has more friction, but it should work.
With this mechanical design, there are a few problems, the robot turns too fast the front part when there's a speed change in a motor, resulting in a instable direction, without changing the design, the only solution is making the robot slower, that can be done lowering the gain with the pot. But i realized that a better solution would be to made a different robot design, with the wheels in the same part as the sensors, so the feedback would be much better. But for my first robot, this is OK.
Step 3: Building the Robot
To build the robot i had to bolt the motors in the back, and solder them to the outputs. I glued a couple pieces of metal at the front to prevent crosstalk between the IR LED and the phototransistors. Then i put the battery with double side tape and soldered it to the circuit. Finally i added a screen to prevent external light reaching the back of the sensors, and i secured it with the bolted ball roller and a nut.
The final result is a tiny line tracer, the overall size is 15mm tall, 55mm long and 35mm wide.
A lot of improvements can be done to this design, from mechanical ones, to using a microcontroller. But i wanted to keep it as simple as possible, using the least components and materials.
Step 4: The Charger
If you use a li-ion battery, you'll need a proper charger. My battery was from a smartwatch that was broken. I didn't have the charger, so i had to make one. Battery datasheet: http://pdf.datasheetcatalog.com/datasheets2/45/45633_1.pdf
There are plenty of ICs designed for this application, and they make the circuit design easier, but they're rather expensive, and i had all the components i used avalible.
The charger consists in a current and voltage limitter, that is what a li-ion battery needs. I used a MCP602SN dual op-amp (rail to rail) to controll the charging cycle in the circuit, R4 and R5 set a voltage reference equal to the max current in amps, in this case, 100mV for a 100mA max charging current.
The current is controlled in that way: The first op-amp outputs enough voltage so the transistor starts conducting, and continues until de current gets up to 100mA, at that point, if the circuit outputs a little more current, the voltage accross the 1ohm sensing resistor would be greater that the one set in the first reference, so the op-amp would ouput a lower voltage than before, maintaining a constant current. When the battery is in the constant current AKA CC stage, the op-amp keeps the refernece voltage equal to the one in the sensing resistor.
Meanwhile, the voltage in the battery is slowly increasing (see the chart in the datasheet), and we all know that li-ion batteries shouldn't be charged above 4.2v. The second op-amp is there to save the day:
When the battery voltage is under 4.2v, the voltage at IN- is higher than the 0.8v refernece in IN+ ( which is always VCC-4.2v). But when the battery voltage reaches 4.2v, the voltage at IN- is slightly lower than the reference at IN+, and the op-amp otput voltage increases, the diode starts conducting and the voltage in the first op-amp at IN- goes higher, the op-amp beging to output lower voltages, and the current starts to drop. The constar voltage or CV stage has begun.
Along this stage, the voltage at the battery remains constant, at an ideal value of 4.2v. Meanwhile, the current slowly drops, until it goes under the ideal value of 3% of the max charging current. At this point the battery is fully charged.
You can see, that in the circuit i haven't installed any charge indicator. I just leave it charging 3 hours, because i know that it will be fully charged. If a battery is already charged, with this circuit, is okay to leave it plugged a bit more, because the current is still going down and it won't harm the battery.
If you use this charger design with a 200mAh battery, you can leave the design untouched. If you use lower capacity batteries, lower the first voltage reference (R4 & R5) at the value where the voltage in milivolts is 0.5 times the capacity of the battery in mAh.
If you use this charger design with bigger batteries, you'll have to do a little modifications in the circuit:
First of all, use a transistor capable of delivering more current, this will force you to use another package, like TO-122 (not sot23).
Then, if you still use the 5v as VCC, don't use a computer USB if you draw more than 300mA, and then, use a lower value sensing resistor, in the way That 4.2v plus Collector-Emitter Saturation Voltage AKA VCE(sat) plus the voltage accross the sensing resistor at peak current still under VCC 5v.
If you use a higher voltage power supply, for example 12v, you'll have to calculate the voltage dividers again, the second one, must output VCC-4.2v or more, not less. The first one should output the same voltage as the spected accross the sensing resistor at maximun charging current.
As you can see, this circuit can be used in more battery-powered projects by adjusting some component values. It can charge both li-ion and li-poly batteries.