Line following robot, using IR

Go To Last Post
35 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

For a school project, last year project. I have to make something, a technical thing.
My idea was to make a 'Line following Robot', I have searched on the internet for some information. Some robots use LDR's to 'see' the lines, but I don't no how I can connect a LDR to a Microcontroller.
I have never worked before with a microcontroller. And haven't bought a microcontroller, yet.
I have a technical brother, so he can help me, but he also don't have experience with Microcontrollers.

- I've programmed in PHP, and C before, so I now the syntax.
- I also have 'played' with electrical stuff before.

I hope you can help me, to find a good Microcontroller and the way to work with LDR's. A guide to work with the programmer etc. is also needed.

Last Edited: Thu. Apr 15, 2010 - 09:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

a very interesting project,

I´m sorry but i have to say this sounds not like a project for a beginner in:
* electronics
* microcontroller (hardware)
* embedded microcontroller programming
* speed- and direction controlling.

Klaus
********************************
Look at: www.megausb.de (German)
********************************

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Maybe you take a look at the AVR butterfly.
This is a very nice and cheap (Germany 25€ + shipping) evaluation board.

The Butterfly already contains many hardware like
- LCD Display
- 5 Way Joystick
- LDR-Resistor (For Light Measurement)
- NTC-Resistor For Temperature Measurement)
- Speaker (For simple sound output like for Jump and Run Games)
- A big external flash memory

I think, when you hold it in your hands, you'll get a lot ideas
what you can do with it.

The butterfly is shipped already with an example application running on it.
You can get the source code for it, too.
But the source code was written for a non free Compiler but you can get
the ported code for the GCC compiler, which is totally free, here:
http://www.siwawi.arubi.uni-kl.de/avr_projects/#bf_app

The WinAVR package which contains the free GCC compiler is available here:
http://sourceforge.net/projects/winavr

To enable an easy start on AVR programming I recommend the book of smileymicros
which you can order here:
http://www.smileymicros.com/
The book explains how to program a microcontrollers in C on the basis
of the free GCC compiler and the AVR butterfly.
You can purchase the book as PDF file, too.

The Butterfly and the book would give a much easier entry to
the microcontroller world.
You have an already running hardware and a lots of tested
example code.

Regards
Sebastian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for your reply S-Sohn I'll look to a store in The Netherlands, If they are to expensive I will go to Germany or buy it on internet.
If it is to difficult for a 'beginner', my brother studies 'mechatronica', a ict, electronic and a ???? study, I have to look at an other idea, but dont have another idea.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The trickiest thing you probably face is the motor control, the stuff such as light/dark detection should be fairly trivial in comparison.

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

By the way I'm sure you already Googled for "line following robot AVR" and may already have found this VERY useful looking article:

http://www.kmitl.ac.th/~kswichit...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I have to look at an other idea, but dont have another idea.

Some guys from my swimming club build at school a very nice looking LED clock
which was controlled by a PC.

Or you can build a simple GPS navigator.
You can buy a GPS receiver for 50€ to 100€.
The GPS receiver puts out all data as a continious text stream.
You'll need to program a text parser and output the position on a display (STEP 1)
or you can use the data to navigate a RC Car on a big place (STEP 2)
(GPS data aren't very accurate. I think around +/- 2m).
If you're interested in GPS than google for "NMEA protocol"

There are many, many more possibilities...

Edit:
Like a weather station. The Butterfly already contains a sensor for light and a sensor for temperature. You can add sensors for air pressure and wind velocity and display the data on the LCD.

Regards
Sebastian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Actually the motor control on a line follower is not that difficult. The robot doesn't have to go in a straight line like a maze runner would, the line you're following is your reference and you simply follow it. I've used reflective IR sensors with good results, something like a P5587 you can get here http://www.junun.org/MarkIII/Store.jsp or the QRB1113 you can get at Digikey. Here's my SpyBot turned Line follower that uses a Mega48 http://members.cox.net/~dksmall/flatline_main.html

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I had to choose between Physics and chemistry. I have choosen for Phycics. The weather station and GPS are great ideas! But is it easy to display data on a lcd-screen? OK, I've to buy the AVR butterfly, I looked on internet, couldn't the lowest price in the Netherlands: €29,- + 19% btw = +- €34 without shipping, the shipping cost where 10-15€, I could pay it, but it has to be cheaper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Like I said, you can get the source code of the example application
which is already programmed on the butterfly. And yes, it already
contains code about how to access the display.
Smileymicros book is great on explaining how to "steal" code
for your own application.

Found a butterfly at www.ebay.de
http://cgi.ebay.de/AVR-Butterfly-Evaluation-Kit-fuer-ATMEGA-169_W0QQitemZ330027698586QQihZ014QQcategoryZ12949QQssPageNameZWDVWQQrdZ1QQcmdZViewItem
Costs: 21.50€ + 7.90€ shipping = 29,80€

Regards
Sebastian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Be aware that the butterfly has very few I/O pins available for external use. If you want to use this for
your linefollower, you may need to sacrifice some display lines to run the robot.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just go to
http://www.seattlerobotics.org/W...

you will find everything you need, to include a line following robot and all the software, and it is a great way to learn all of the above skills.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

actually to make a line followr you could also try PICAXE microcontroler. it's basik controlled and has all you need to make a bot. 18X is the way to go when making a line follower. you need to connect 2 LDR's to Analog inputs and read the values (2 red superbrights are showing light to it) and to control the motors you only need higher power transistors or motors. No H-Bridge is needed as you don't have to reverse the motors. and then all you need to do is write a wuick 100 line program and a way you go...
should take about a week maximum to get this working if you have the parts.
Picaxe can be bought from picaxe.co.uk
Good luck with your project.

P

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For you it sounds easy, but for me, a beginner, it's not posible to do it in a week. Even when I have the parts.

BTW. Pay with an creditcard is not possible. I'm only 16, so I don't have a creditcard.

[edit]@jimlake, I have to build it at my own, not with a complete kit.[/edit]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Build the kit first, and when you understand it and the software, then build your own. I do not think you fully appreciate how complex this can be for a beginner.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

With a good guide etc I can make my own. Someone placed a line follow guide here.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would think that using an LDR would be too slow and not sensitive enough to really be a good line follower.

More commonly used is a LED illuminator (to light the line) and then a Iight Sensitive transistor to sense the reflection (or lack of it).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

it's not just easy but also doable in a week. as you have someone who can possibly do the mechanical parts then first thing to do is make a rolling cassy. connect 2 motors to a base plate. use DC motors or Servos. if using DC it's easier to control with AVR but it makes a lot of noise so you must take some steps to make it smaller (add caps etc, search the Internet for ways to do it). if you have chosen the motors, gear reductions and wheels. connect them to your base plate. i think 10cmx10cm will do for a smaller line follower...

Then if you have this working start making a schematic. get yourself a microcontoller (like ATTiny2313, which has an analog comparator) or something bigger that also has ADC pins. chose transistors to drive your DC motors or connect the servo and find example codes on how to drive a servo. if you go to the DC way you must find a big enough transistor to support the voltage and amps of your motor and connect the transistor to the microcontroller. i suggest connecting it via opto isolator to further reduce the noise. then start controlling the bot use PWM if the chip has one so that you can change the speed of the motor. make your bot go round and round.

If your bot moves nice then start with the sensor part. make 2 sensors using red super bright LED's and LDR's connect them on an angle and shield them from other light sources with tape, cloth or wood(drill holes into wood blocks and insert the sensor and led in it like i did). connect those sensor modules in front of your bot. Actually the best place is about 3cm from the point where the turning wheels are, but in front will do also. start experimenting with them reading the ADC values or using an Analog comparator to see witch one is lighter or dimmer (to compare the LDR values without the need of ADC).

if you are certain your sensors work well then you can start making the final program for the bot. make a block diagram of what your bot must do (flowcharts) and then using them start making the program. how to make that is another weeks topic and if you cant think of it ask me if you have done all the other steps above...

I hope it helped you get on the right track. if you don't understand anything feel free to ask me.

Rain

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
led   ldr
 \    / 
  \  / 
___\/_____
^
|
line

Is that what you mean with 'connect them on an angle'?

I've got the idea from this page
http://www.exo.science.ru.nl/bronnen/natuurkunde/robotica.html and http://www.exo.science.ru.nl/bronnen/natuurkunde/robotica2002.html
(They are both in Dutch)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And that's exactly what the QRB1113 sensor looks like. Did you look at those sensors I listed?

http://www.junun.org/MarkIII/datasheets/QRB113x.pdf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

well yes i ment that. try to calculate the best angle. ose cosinus etc to do that.
Aend i really suggest using those wood blocks as i said before. i can make pics of mine if needed.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Last Edited: Thu. Sep 21, 2006 - 01:52 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks,

I think your last photo is not uploaded completely. The last part is missing.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sorry... reuploaded and added some pics (in 16:45)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I finally decided to try it!

Quote:
Then if you have this working start making a schematic. get yourself a microcontoller (like ATTiny2313, which has an analog comparator) or something bigger that also has ADC pins. chose transistors to drive your DC motors or connect the servo and find example codes on how to drive a servo. if you go to the DC way you must find a big enough transistor to support the voltage and amps of your motor and connect the transistor to the microcontroller. i suggest connecting it via opto isolator to further reduce the noise. then start controlling the bot use PWM if the chip has one so that you can change the speed of the motor. make your bot go round and round.

In the last line you say PWM, what is that?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

PWM stands for Pulse Width Modulation.
The AVR will output a rectangle waveform at a fixed freuency. The AVR can vary the duty cycle of the wave. That means the ratio of the high time to the low time of the signal can be changed. If the output frequency is fast (some kHz) then you can use it to control the speed of a DC motor. To faster the motor speed you need to increase high time of the PWM signal. To lower the motor speed you need to decrease the high time.

The PWM is is well explained in the datasheet. Take a look at timer description chapter "Modes of operation". The fast PWM mode will fit to your needs.

You'll find some more explainations in the Atmel application note "AVR130: Setup and use the AVR Timers" which is available here:
http://www.atmel.com/dyn/products/app_notes.asp?family_id=607

Regards
Sebastian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Update:

I finally made the chassis and bought the electronic parts(3 x Sensors, 2 x motor etc). Now I have to code it.
I don't understand the whole syntax:

  
  DDRD |= 
  &= ~ 

I can not find a clear documentation about that syntax, they always use it, but don not explain it.

[edit]I don not have ldr's, but ir-sensors (cny70)[/edit]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

naffets wrote:
I don't understand the whole syntax:

DDRD |= 
  &= ~


naffets wrote:
- I've programmed in PHP, and C before, so I now the syntax.

Then you should know that:

DDRD |= Something;

is, ligically OR DDRD, bit fot bit, with Something.

This is equivelent to:

DDRD = DDRD | Something;

And:

DDRD &= ~Something;

is, logically AND DDRD with the compliment of all the bits in Something, with DDRD.

This is equivelent to:

DDRD = DDRD & ~Something;

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, I found:http://www.mikrocontroller.net/articles/AVR-GCC-Tutorial(german), my German is good enough to read that.
And about that C programming, that was so little.... but is like PHP.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

naffets wrote:
I can not find a clear documentation about that syntax, they always use it, but don not explain it.

Look no further than here on Freaks:

https://www.avrfreaks.net/index.p...

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don not like the search engine of avrfreaks, so I use google.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry for this late post... I started a 'weblog' for my robot today, on somebodies request. The weblog is still a bit empty, but it will change. My goal is to 'teach' the beginner by a beginner with some more experience(me). I learned a lot of this project, and still learning, while my project is running.
http://avr.naffets.nl/

I hope you will not see it as spam.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Is that what you mean with 'connect them on an angle'?...

I wouldn't advise these sensors! They can only 'see' a line in an exact distance. Try CNY70 or similar! They have a wide range of 'seeing'

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

http://elm-chan.org/works/ltc/re...

It would be cool if someone made a butterfly do this.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@daqq I use the CNY70's

BTW. I do not start this topic again, only let you know I started my weblog :)