Skip to main content
Topic: Arduino-based line folowing robot NOW WITH SOME CODE! (Read 11832 times) previous topic - next topic

Arduino-based line folowing robot NOW WITH SOME CODE!

Go to here:

UPDATE: Here's a current picture of the PCB. It still needs some hours but it's being nice to make. I use oversized traces on proupose.


I'm a member of an university IEEE student branch, and every year we organize a basic-intermediate electronics and robotics course for beginners and to catch members. I'm the organizer for the next course, that will take place in early october, but as a big proyect that I was involved into has been delayed and now I have some spare weeks, I have decided to design a learning but at the same time powerful line following robot and i've already started the design.

It'll be a  line following robot, completely based on arduino (not because I like arduino, but because it's simpler for beginners) and concretely on arduino duemilanove, because I think that we coudn't legally use the VID and PID of the ATMEGA8U2 that UNO's have so an FT232 could be the safest way. I will also correct the power distribution system to prevent current injection to the USB. It will feature an array of 8 infrared sensors to read the line on the floor. The PCB will be the chasis of the robot, supporting the motors. the lipo battery and the rest of the mechanics, so it'll be fairly big (should fit in 10x15). The idea is to include in the PCB lots of IC's (H-bridge, lipo charger, an accelerometer (cuz it's cheap and people loves things with accelerometers) and the sensors and related electronics ) without making too much impact to the arduino's functionalities, i.e. not stealing too many pins. The H-bridge needs 4 lines, but it can be disabled and apart for the negligible capacitive loads, it shouldn't affect those lines' functionality. The accelerometer has I2C and will have a couple of jumpers to disable it, I think.

The problem comes with the sensors. They are infrared reflective sensors (like the famous CNY70's) and you can get an analog voltage related to the amount of light reflected out of them. You only have to distinguish between a dark colour and a light colour.
I have designed line following robots in the past, and what I did was feeding the analog signal from every sensor to a comparator with some hysteresis, with the threshold controlled by the microcontroller via a DAC or electronic pot. Then the output of every comparator was either fed directly to the microcontroller if there were enough pins, or via some paralel to serial shift register. That is a very fast and reliable way to read the sensors, but it's a bit expensive and hard to implement due to the amount of IC's required.


So i've though using another approach that i've seen implemented in similar robots, althought i'm a bit skeptical about it's reliability. The idea is to use an analog mux to sequentially feed the output of the sensors to an analog pin of the arduino, and just reading that value and applying the required thresholds and hysteresis on software. Something that arduiners love to do :p. Do you think this will be a reliable way to read the sensors, considering that the output impedance of the sensors should be around 50K and that I don't wanna use buffers?  I don't know very much about the ATMEGA's ADC, but for PIC's it should somehow work, although it wouldn't be the best idea.

I would love to share this proyect with the community, but I think that I'll get (if i haven't already got) past the 1sheet of schematic and 80x100 board size of the free version of eagle and I'm not sure if I could share it. I'm using components and footprints from the dp library, the sparkfun library, eagle itself and some made by me, and I'm working over the arduino duemilanove's schematic. Would it be possible to share it?

Re: Arduino-based line folowing robot (custom PCB)

Reply #1
Hi erdabyz,

I'm not sure about the AVR ADC. I do know that the free version of eagle can open the multi-page schematics and PCBs, it just can't edit and same them.
Got a question? Please ask in the forum for the fastest answers.

Re: Arduino-based line folowing robot (custom PCB)

Reply #2
Thanks for the answer, I already tested the ADC with a sensor and it works. But now it won't use an alagog switch + arduino's ADC, it'll use a PIC as the sensors processor, that will interface with the arduino through I2C. That way I minimize the arduino pins usage.

I'll share everything when it's done. For now, the schematic is done and i've started to route the board.

Re: Arduino-based line folowing robot (Now W/ Picture(s))!

Reply #3
Well, so here we are almost a year later. The first prototype had some minor flaws which were corrected in the second version, and a major flaw (two mistaken pull-up resistors) which took 3 months to solve because of my sudden lack of spare time. By december 2011 the final prototype board was sent to seeedstudio, and by early january the final production prototype was assembled and had everything working flawlessly. So we ordered 50 PCB's of that and all the electronic and mechanical parts required to make 27 of these babies. After one order getting lost, another one getting stolen to the delivery man, some invoice problems with Mouser which delayed an order more than two weeks and suddenly left them without stock for a critical part which was impossible to source elsewhere, delaying us two more months, we finally received the last component by late june 2012, and then assembly started. For now 10 robots are fully assembled and 17 more await their moment in the all manual production line. Two paste stencils were ordered and some wooden frames assembled to support the boards and the stencils while applying paste. I tried to gather as many people as possible for the production line but due to some very important congress organized by us not many people will be available until late july, when we expect to finish the 17 remaining robots.

So yeah, the course was to be made by november 2011 and it will be finally (and hopefully) made by november 2012 after a year of delays and problems. Only testing software has been written for now to check all systems. A library to fully access all the sensors and features of the robot is being developed and is about 50% done. Motors, accelerometer and color sensor have been already integrated, but it's still neccesary to write the functions to access the secondary PIC microcontroller that handles the reflective sensors. Firmware for that PIC has also been written but it still requires some testing. So I'm not going to release any software for now until it's made.

Also, we found that the robot could also work as a self-balancing robot by changing the wheels and motors and adding a gyroscope to allow for inclination angle measurement with a kalman/complementary filter processing gyro and accelerometer data. So I thought about making an addon board (shield) which has the gyro and also some bluetooth module for wireless serial communication, a microSD socket, a triaxial magnetometer and a connector to plug I2C ultrasonic range sensors which are also under development.

Here are the full schematics and  board designs for both the robot itself and the addon board (the first prototype of the later will be sent to seeed by next week for fabrication and is expected to be assembled and tested by late july).
Sorry for the extremely messy schematics D:.

For the robot board:
You have to leave JP1 and JP2 opened and D4/D5 are not to be mounted. The resonator is this one: ... -16.00CV-T
AND BE SURE TO BUY QRE1113GR sensors (the SMD version) and not QRE1113 (the through-hole version). You can also use the capacitor values you want for your particular 3.3V regulators (there are 3 of them). The ones I bought required fairly large capacitor values.
The motors for line-following are pololu #1099 and the ones for self-balancing are the 50:1 version of that model of motor (the non HP ones). The rest of the mechanics can be easily found at pololu (extended brackets for the motors, 42mm offroad wheels (for line-following)  and tamiya ballcasters). The batteries are Turingy 500mAh 2S1P 20-30C Lipo's from hobbyking.

And here's a picture of two puppies already assembled. The green one is equipped with wheels and motors for line-following, and the blue one has wheels and motors for self-balancing application.

If someone really really wants to build one I can sell one of the blue boards for 5€ shipped anywhere except if shipping costs go above 1,5€. Then the price would be 3,5€ + shipping. We have 20 of them to spare or to build a hypothetic second batch.

More documentation, software and those things to come. Stay tuned!

Re: Arduino-based line folowing robot BIG UPDATE INSIDE!!!

Reply #4
I'd love to see a video!

Re: Arduino-based line folowing robot BIG UPDATE INSIDE!!!

Reply #5
[quote author="rohitdesa"]I'd love to see a video![/quote]

There will be videos. Hopefully the library will be completed this week and some software for line-following will be written. It shouldn't be too hard to get it running since most of the code is already avaiable in arduino libraries so it should just be a matter of tuning the PD/PID control loop.

Re: Arduino-based line folowing robot BIG UPDATE INSIDE!!!

Reply #6
Really great job erdabyz. Do you mind if I ask what was the final cost of the build? I'm excited to see two models running.

Re: Arduino-based line folowing robot BIG UPDATE INSIDE!!!

Reply #7
[quote author="freile"]Really great job erdabyz. Do you mind if I ask what was the final cost of the build? I'm excited to see two models running.[/quote]

Buying parts in bulk the cost price is around 85€.

The board, fully assembled, runs for about 35€. The rest is mechanics and battery (15€ per motor + 6€ wheels + 3€ ballcaster + 4,5€ battery + 5€  motor brackets). This takes into account quantity discounts and also shipping costs, import taxes and all that stuff that makes importing something in bulk awfully expensive. The mechanical parts cost more to us imported in bulk than it would cost for someone in the USA to buy only one of each part. Fortunately we had great discounts on electronics. (mass produced in 1000's quantities, the board could be made for 20€ or even less.).

We will charge just those 85€ to take the course and get the robot. I hope enough people gets enrolled (just to clarify, the course will be for students at our university, not an online course or something).

Re: Arduino-based line folowing robot NOW WITH SOME CODE!

Reply #8
I look forward to populating and using the boards you sent once i get them thanks for starting this project ti looks very promising.