Stalker tutorial

Tabs - jQuery plugin for accessible, unobtrusive tabs

The participants need to build two separate autonomous robots such that the first robot is capable of line following and the second robot can trace the path followed by the first robot on another surface.

The above problem statement can be broken down into these aspects which the robot has to have. Let us analyze :

  1. Two robots (two differential drives) where one needs to navigate a line using sensors(line follower).Thereby it needs to have a mechanism to follow lines.
  2. Tracing of path: The follower bot needs to trace the path followed by the guide bot by effective communication between the two bots.Thereby the algorithm requires the bots to communicate within themselves implying we need to have a module for communication as well, in the bots.

Now, to take each part in detail we are dividing the tutorial into the following divisions:

  1. Drive mechanism
  2. Sensors for line following.
  3. Micro-controllers.
  4. Means of communication between the two bots.

There are many drive mechanisms that can be used in a bot.The simplest drive however is the differential drive.
Differential Drive, as the name suggests, is the drive caused due to a "difference”. This is chosen by beginners generally for its simplicity and ease in use. Actually, the rotational motion of the bot occurs in a differential drive due to the difference in the direction of rotation of two different wheels.



In a differential drive, the 2 drive wheels are on either side of the body of the robot, usually in the front. Straight-line motion is attempted by rotating the wheels at the same RPM. Rotation is achieved by either turning wheels in same direction at different RPM, or by turning the wheels in opposite directions. For an in-place (zero radius) turn, the wheels are rotated in opposite directions at same RPM. Arbitrary motion is achieved by dynamically changing the angular velocity of the two wheels.
For more details on differential drive, click  here

SENSORS FOR LINE FOLLOWING

LED-LDR SENSORS

An LED-LDR sensor can easily be used for following white lines on black surfaces, as is the case in this event. These are used for detecting surfaces that reflect light at intensity different from the adjoining surfaces.

Basically, an LED (Light Emitting Diode) is a small elongated bulb-like object that emits light. They are available in various colours such as red, green, white etc.

An LDR (Light Dependent Resistor) is a small resistor, the resistance of which depends upon the intensity of light incident on it. More the intensity of light falling on it, lesser is its resistance. The resistance usually varies in the range of about 10k ohms. Hence a 10k ohm resistance should be used in series with a LDR.

WORKING



Now as more intensity of light falls on the LDR, its resistance drops and the potential at -ve terminal of comparator increases. If this potential is less than that at the +ve terminal, a high signal is obtained as output.

IR SENSORS

In these sensors, infrared LEDs and detectors are used instead of normal ones. As in an LED-LDR circuit, here too the principle behind working of the circuit is the resistance of the detector which varies with the intensity of infrared light falling on it.


In the event rules, it is required to follow 2cm wide white lines on a black arena floor.

Now, if we hold an LED-LDR sensor or an IR sensor above the white line (light reflecting), the intensity of reflected light falling on the LDR will be much more than the intensity when it is held above the black floor (light absorbing). This phenomenon is used for line following.
There is a minimum of two sensors required for this task, one for detecting each edge of the line. If the sensor gives a high when above the floor and a low when above the ridge, then the simple algorithm for line following will be :

Left Sensor Right Sensor Left Motor Right Motor
1 1 1 1
0 1 0 1
1 0 1 0


A basic tutorial for a simple line follower can be found here

A sample line follower code can be found here

The above method for line following works well for slower speeds. However this process has its limitations though, mainly when the speed is increased.  This is when a PID controller comes into picture.

For a detailed tutorial on line following by PID control click here





We need to have some sort of a system which takes the required data as input and correspondingly plans the motion. Now, since this is an autonomous event, the bots needs to be self controlled. We need something which performs small processing operations like this, and can be attached to the robot itself. A good option can be to use controllers. controllers are basically small processors with input and output ports. There are chiefly 3 types of controllers used in India: 8051/52, the most common one; AVR controllers and PIC controllers.

Among these AVR is a good option because it is quite easy to program with the help of the serial/parallel ports of the desktop computer. The programming circuit is the easiest and cheapest to build. The programming can be done in most of the common languages such as C or Assembly language.


Now, there is a basic mechanism followed to make a working AVR. Say for instance we use Atmega16, which is one of the members of the family of AVR controllers. The entire architecture, working, details etc. can be found in this link The mechanism goes as follows: write down the code in a valid programmer's notepad or visual C++ (depends on the language you are using, we take C as the base language here). Then, compile it using WinAVR. Then, using a programming software such as PonyProg, connect it to the programmer circuit, which can be built or bought readymade, and over!


One such programmer circuit is shown in this link. You can also buy it from any of the robotics shops.


To learn the coding of the program, you may check the following links :

  1. http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=320566 (For AVR Timer)

  2. http://members.shaw.ca/climber/avrtimers.html (For Timer and other links)

  3. http://avrbeginners.net/ (Complete Basics)

  4. http://winavr.scienceprog.com/ (Different Topics)



Now, we look at one important part of the tutorial. i.e. the burning of the code you write into your controller. It is generally quite confusing for the first time users, but becomes subsequently simple once you are comfortable with it.

The procedure and some tips to program is as follows :
  1. For compiling the code, use WinAVR, it is freeware. Download WinAVR setup from this link

  2. For burning the compiled code, use PonyProg for parallel/serial port programmers.

  3. Note: - The USB to serial converter CANNOT be used with PonyProg, because it uses its own interface for burning and it is not compatible with the hardware.

  4. Always refer the datasheet while programming, it is more informative than any book.

  5. Run calibration and interface setup from setup in PonyProg, and run appropriate setup according to your hardware.

  6. Open the flash file you want to burn on the controller and click on Write Program Memory. Always check power supply voltage and polarity before doing anything with the chip. First burn fuesbits setting on chip according to the chip and oscillator, because the AVR chip gets damaged easily.

  7. Now, if you are done in your first attempt, it is well and good. Otherwise, check the power supply well, check for loose connections from the computer side as well as the computer side.

  8. For debugging purposes, you can use AVR studio, which can be used for simulation.

  9. Before compiling the main code, you need to make a MAKEFILE, which will be described later.

  10. After the MAKEFILE is made, you need to change certain settings in it, according to our needs.

  11. F_CPU(frequency of the oscillator), which is by default 8000000 should be changed to 1000000, if no external oscillator is used. TARGET must be changed to our file name WITHOUT any extension. e.g. "XYZ" instead of "XYZ.c"

  12. Always take care of AVR Registers, e.g. before taking the input from the ADC, the ADMUX registers must be set to proper values.

  13. Change fusebits very carefully! Because once AVR is locked, its nearly impossible to unlock it. Refer datasheet for information about the fusebits.



Making the flash file:
  1. First install WinAVR

  2. Open Programmers' Notepad.

  3. Make a new file for your format ( .c or .cpp), write down the code, and save it.

  4. Then, go to Start -> All Programs ->WinAVR ->Mfile

  5. Set these options - makefile-> Main file name =name of your file WITHOUT EXTENSION

  6. makefile-> MCU Type=which chip you are using like ATmega 16 or ATmega32

  7. makefile-> ouput format=hex (default)

  8. makefile-> Optimization level= s (default)

  9. makefile-> Debug Format = AVR-ext-COFF

  10. makefile-> Programmer which programmer for AVR you are using

  11. makefile-> Which port you are using for burning (This is implemented only if you are burning through WinAVR)

  12. Then Save As and save it in the same folder (i.e. your code file .c or .cpp)

  13. Then open it with notepad and change F_CPU value (i.e Frequency of XTAL oscillator you are using) (default 8000000)

  14. Now go to winAVR and open your code file (i.e. .c file)

  15. Go to Tools and click on "Make All".

You will get your flash file in the same folder. It can be burnt using PonyProg.

Now that the guide bot is following the line on the lower surface ,it
needs to communicate with the follower bot and thereby help it trace the same path as followed by the guide bot itself.

The follower can trace its path in the following ways:

  • Move a certain distance behind the guide say starts when the guide has reached the first checkpoint of the run.
  • Follower starts after the guide has completed its run.
  • STALK the guide:follower may move exactly above the guide.


Some effective means of communication are discussed as below:-

USART

In any case an effective means of communication becomes the need of the hour .If we want to transfer data between bots they need to have some mechanism to communicate with each other for which we will see digital transmission.

Digital transmission is the transfer of data over a point-to-point or point-to-multi point transmission medium.There are two basic kinds of digital communication serial and parallel. Serial transmission is the sequential transmission of signal elements of a group representing a character or other entity of data. Digital serial transmissions are bits sent over a single wire, frequency or optical path sequentially.

To implement serial transmission one of the good options is to use USART on the AVR platform. USART can be learnt once the user is comfortable with programming -controllers. It is better to be done with making the afore-mentioned sensors before building USART communication. For detailed tutorial on USART click here

For more information, visit the following links:
http://extremeelectronics.co.in/avr-tutorials/using-the-usart-of-avr-controllers-reading-and-writing-data/
http://www.ip-extreme.com/IP/usart.shtml

FOLLOWING A LIGHT SOURCE


Now that we know about USART as one way of effective communication, lets see one more method as well.Consider a source of light placed on the guide bot emitting laser or light in some other form.If the follower bot is able to follow this source of light then it would essentially solve our problem.
If you have read our tutorial on line following then this would be very similar. Here also the position of the robot is dependent on the intensity of light detected by the sensor. The sensor used for this purpose is a light sensor.




The light sensor enables a robot to detect light. Robots can be programmed to have a specific reaction if a certain amount of light is detected. The light sensor uses a cadmium sulfosolenide (CdS) photoconductive photocell. The CdS photocell is a photo resistor, meaning that its resistance value changes based on the amount of incident light.
The light sensor can detect distance accurately from 0-6ft away, depending on the intensity of the light source and the intensity of the ambient light.

Technical Information

§  Sensor Type:  Photo-resistor
§  Usable range:  0 to 6 feet
§  Detector:  CdS Photocell
§  Sensitivity: 500 (Light to 5M (Dark)
§  Weight:  0.03 lbs
§  Wiring:Black – ground; Red – (+) power; White – control signal

§  Schematic:






To make the method more accurate, three similar sensors can be placed on the corners and the center of the bot . For more information click here

If ever you face any problem in this tutorial, feel free to post on the technical forum of our website  http://robotix.in/forum

Untitled Document