
A microcontroller is similar to a processor in a computer. The primary difference is that the microcontroller has the CPU , the flash memory, the RAM and external ports all built into a single chip. All this makes the microcontroller very cheap and is true value for money. But where it takes a beating is the speed. Microcontrollers are low speed devices when compared to their equivalent microprocessors. Faster microcontrollers are available. Since I didn't need complex processing for the robot I settled for the microcontroller.
FIRE uses an 8051 microcontroller as its CPU. The 8051 has many breeds and I use the one made by ATMEL called AT89S8252.
8051 FAMILY
Intel Corporation first designed 8051 Micro-controller and after several years Intel Corporation gave license to other companies like Siemens, Atmel, Dallas Semiconductor, Phillips. The micro-controllers designed by other companies are a part of 8051 family and also have the instruction set and same architecture. The main difference between the different manufactures is the on-chip memory and type of ROM used. The different types of ROM used are Flash, UV RAM, NV RAM and OTP. The commercial product from Intel is called 8751 and that Micro-controller used UV ROM. The main disadvantage of using this type of ROM was it takes time to erase the chip and program the chip. Atmel introduced micro-controllers with Flash ROM. The main advantage is, very easy to program and no need for external hardware for erasing the chip. The programming kit itself, erase and then program. Also the time consumed is very less and this improved the developing time. Dallas Semiconductor introduced micro-controllers with NV RAM. The advantage of this micro-controller is that it can be programmed even when it is on-line. Also bit-by-bit programming can be done. Phillips introduced micro-controllers with OTP (One time Programmable) memory. The main drawback is that, once the code has been burned in the chip it is not possible to erase the chip.
ATMEL AT89S8252 SPECIFICATIONS
Compatible with MCS-51™ Products
8K Bytes of In-System Re-programmable Downloadable Flash Memory
– SPI Serial Interface for Program Downloading
– Endurance: 1,000 Write/Erase Cycles
2K Bytes EEPROM
– Endurance: 100,000 Write/Erase Cycles
4.0V to 6V Operating Range
Fully Static Operation: 0 Hz to 24 MHz
Three-Level Program Memory Lock
256 x 8-bit Internal RAM
32 Programmable I/O Lines
Three 16-bit Timer/Counters
Nine Interrupt Sources
Programmable UART Serial Channel
SPI Serial Interface
Low Power idle and power down modes.
Interrupt recovery form Power Down
Programmable Watchdog Timer
Dual Data pointer
Power Off Flag
Download Data sheet here
PIN CONFIGURATION AT89S8252
PORTS
Ports are the channels through which a microcontroller communicates with the outside world. Out of the 4 ports available 2 ports are used in FIRE. Port 2 is used to control the 3 motors and are connected to the respective motor driver IC's. Port 3 is used for inputs from the obstacle and IR sensors.
INTERRUPTS
Interrupts are a very important feature of the microcontroller. These are signals which force the microcontroller to perform specific actions. The port 3 has 2 pins INT0 and INT1 for receiving external interrupt signals. These are the pins where the signals from the sensors are received.
PROGRAMMING
For a microcontroller to perform actions, program code has to be written onto the internal memory of the microcontroller. This can be done using hardware units called programmers.
Find the programmer used for the AT89S8252 in this link:
http://www.aec-electronics.co.nz .
Details on how to make your own programmer are given. The software for writing the code is also given. To write the code I use this software called UMPS (Universal Microprocessor Program Simulator). Using this, the program can be written and tested. It also supports many other microcontrollers.
After writing the code (.asm extension) , it is assembled using an assembler specific to the microcontroller (in this case an 8051 assembler). The output of this assembler is an hex file which can be written onto the chip using the In System programmer given in the above link.
ALGORITHM
FIRE has a fairly simple algorithm. Wait for obstacles. If encountered reverse and turn otherwise continue forward motion. Meanwhile the camera keeps looking at the direction of motion.
1. START
2. CAMERA LOOKING FORWARD (Manual)
3. FORWARD MOTION:
BOTH MOTORS FORWARD
3. SCAN PORT 3 FOR INTERRUPTS FOR OBSTACLES
4. IF INTERRUPT IRTL IS TRIGGERED GOTO STEP 5
5. REVERSE AND TURN RIGHT:
BOTH MOTORS STOP. IMMEDIATELY CAMERA TURNS 180 DEGREES FACING ROBOT SOUTH. IMMEDIATELY BOTH MOTORS REVERSE FOR 3 SECONDS.STOP.CAMERA MAKES 225 DEGREES FACING ROBOT NORTH-EAST. RIGHT MOTOR STOP, LEFT MOTOR HIGH SPEED FOR 2 SECONDS. STOP. CAMERA MAKES 315 DEGREES FACING ROBOT NORTH. STOP.
GOTO STEP 2
6. ELSE IF INTERRUPT IRTR IS TRIGGERED GOTO STEP 7
7. REVERSE AND TURN LEFT:
BOTH MOTORS STOP. IMMEDIATELY CAMERA TURNS 180 DEGREES FACING ROBOT SOUTH. IMMEDIATELY BOTH MOTORS REVERSE FOR 3 SECONDS.STOP. CAMERA MAKES 135 DEGREES FACING ROBOT NORTH-WEST. LEFT MOTOR STOP, RIGHT MOTOR HIGH SPEED FOR 2 SECONDS. STOP.
CAMERA MAKES 45 DEGREES FACING ROBOT NORTH. STOP.
GOTO STEP 2
9. ELSE GOTO STEP 2
10.END
CODE
Click here to download the assembly language code of FIRE
CIRCUIT
IMAGES
Top: Programmer, Bottom: Microcontroller board
![]()
© Copyright 2002-2008 Viswas Nair TK. All Rights Reserved.