TUTORIAL

We divide the tutorial into the following divisions:

  1. Drive Mechanism
  2. Detection of objects
  3. Microcontrollers

Drive mechanism

The simplest drive, the Differential drive is explained here.

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. When it is to be moved forward/backward, the two wheels rotate in the same direction.

It basically contains two wheels controlled by two DC motors(preferably geared) on one axis, and one extra caster wheel for support.

For more information on constructing a differential drive, you may check the link Differential Drive

Now, if you are happy with constructing the drive, we come to controlling it.

Specifically for manual robots, one good method of controlling it is the H-bridge. It is basically controlling one motor with two single pole switches.

Two switches can be set on/off in 4 different ways, each way corresponds to rotating the motor clockwise, anticlockwise, braking it, or allowing it in free-running condition.

The circuit is very simple.

When the left high and right low are switched on, the motor moves in one direction. When the right high and left low are switched on, the motor moves in the opposite direction. When both the high side switches are switched on, the motor brakes and comes to an instant halt.

When both the low side switches are on, the motor is in a free running condition and does not force/resist motion.

Detection of Objects

For detecting open/closed walls, we can use Infra Red(IR) proximity detectors. This is basically an IR emitter-IR receiver pair. The emitter emits IR rays, which bounce back from the obstruction(wall/object) and reach the receiver. The voltage drop across the receiver is dependent on the distance.

The total details of the IR proximity detector can be found here

Once you are clear with the working of the sensor, you may continue to the next part, calibration.

It can be calibrated to give a high at a desired distance. Assuming the use of a comparator, e.g. LM339 has 4 comparators, we can have a preset voltage value with the help of a variable resistor on the negative terminal of the comparator and the voltage drop across the resistance adjacent to the IR receiver on the positive terminal. Then, keep the emitter receiver pair at the required distance from a wall (not paper) and measure the voltage drop across the mentioned resistor. Then, turn the pot so that the voltage is the same as the value of the measured voltage. Then, we have a calibrated proximity detector! But, mind the fact, if you are using it for the first time, you may have several problems regarding the calibration. Mostly, beginners face the problem with the circuit, i.e. shorts, loose soldering etc.

To check whether your IR LED is working or not, simply view the LED using a phone's camera or any digital camera available, and the LED can be seen glowing.

But, if you have bought a ready made one, then you shouldn't have any problem with it.

These generally work till distances of 25 cm.

The above sensor is a quite complicated one, it works on a single frequency. i.e. TSOP sensor.

Now, to detect an obstacler, calibrate the IR proximity detector at a distance a little greater than the distance of that sensor from the obstacle. So, when the obstacle is present , it gives a low, and when the it is not , it gives a high.

LDR-Photoresistor

Mechanism of working

Basically, a small intense red/white LED in series with a 120 ohm resistor is sufficient for the light emission.

Now, for detection of the line intersection, we have to use a certain property which differentiates black color from white. We use the fact that the white surface reflects more light than the black surface. Light is emitted from the LED, reaches the surface and is reflected back, to be received by the LDR. So, the voltage drop across the 10k resistor will be greater when the sensor is facing the white surface. We connect this across the comparator, again with a preset value attached to the negative terminal. Hence, we get a high output for the white surface, and we have detected the line intersection!!!

The calibration is a bit different in this case. Here, we keep the sensor above the white surface. Measure the voltage drop across the 10k resistor. Note the value as V1. Then repeat this with the sensor above the black surface. Note the value as V2. Turn the preset so that the voltage supplied to the negative terminal of the comparator is (V1 + V2)/2.

And, we have a calibrated sensor! ready for work!

You can check the following link for more details.

Kam Leang robotics

How to build a line follower, and how to use these sensors are explained in the last section.

Microcontrollers A lot of description has been given about the detection of the doors, the central white circle. But, how do we use it? we need to have some sort of a system which takes these data as the input and correspondingly plans the motion. Now, since this is an autonomous event, the bot needs to be self controlled. So, using a computer is ruled out. We need something which performs small processing operations like this, and can be attached to the bot itself. A good option can be using microcontrollers. Microcontrollers are basically small processors with input and output ports. These are widely used in autonomous events.

There are chiefly 3 types of microcontrollers used in India. 8051/52, the most common one. AVR microcontrollers and PIC microcontrollers.

Here, the AVR can be used. AVR is chosen 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 microcontrollers. The entire architecture, working, details etc. can be found in its Datasheet.

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 ready made, and over!

One such programmer circuit is shown here . You can also buy it from any of the roboshops.

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

http://www.omegav.ntnu.no/avr/resources.php3 (for material)

http://209.85.175.104/search?q=cache:9B6kteeE_CsJ:www.engr.sjsu.edu/bjfurman/courses/

ME106/projects/auto_temp_control.pdf+delay.h+lcd.h+atmega&hl=en&ct=clnk&cd=15&gl=i

n&client=firefox-a#14

(for sample code with timer)

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=320566 (for avr timer)

http://members.shaw.ca/climber/avrtimers.html (for timer n other links)

http://avrbeginners.net/ (complete basic)

http://www.ee.iitb.ac.in/uma/~kartikmohta/tech/avr/tutorial/ (for more sample codes)

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 microcontroller. 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 it is as follows

  1. For compiling the code, use WinAVR, it is freeware. Download WinAVR
  2. For burning the compiled code, use STK500 / BSD programmer for parallel/serial port programmers.
  3. Note : - The USB to parallel converter CANNOT be used with BSDs, 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 BSD , and run appropriate setup according to your hardware.
  6. Open the flash file you want to burn on the microcontroller and click on Write Program Memory.
  7. 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.
  8. 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.
  9. For debugging purposes, you can use AVR studio, which can be used for simulation.
  10. Before compiling the main code, you need to make a MAKEFILE, which will be described later.
  11. After the MAKEFILE is made, you need to change certain settings in it, according to our needs.
  12. 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"
  13. Always take care of AVR Registers, e.g. before taking the input from the ADC, the ADMUX registers must be set to proper values.
  14. Change fusebits very 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 ur 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 u r using
  11. makefile-> which port u r using for burning (This is implemented only if u r burning through winAVR)
  12. Then Save As and save it in the same folder (i.e. ur code file .c or .cpp)
  13. Then open it with notepad and change F_CPU value (i.e Frequency of XTAL oscillator you ar eusing) (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"
  16. You will get your flash file in the same folder.
  17. It can be burnt using BSD.

If you have faced any problem, please feel free to mail robotics.cvrce@gmail.com.

Related Events: BASKET BALL RACE