1. INTRODUCTION
1.1EMBEEDED SYSTEM: An embedded system is a special-purpose computer system designed to perform one or a few dedicated functions, often with real-time computing constraints. It is usually embedded as part of a complete device including software and hardware parts. In contrast, a general-purpose computer, such as a personal computer, can do many different tasks depending on programming. Embedded systems have control many of the common devices in use today. Embedded system is dedicated to do specific tasks, design engineers can optimize it, reducing the size and cost of the product, or increasing the reliability and performance. Some embedded systems are mass-produced, benefiting from economies of scale. Physically, embedded systems range from portable devices such as digital watches and MP3 players, to large stationary installations like traffic lights, factory controllers, or the systems controlling nuclear power plants.
Complexity varies from low, with a single
microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a large chassis or enclosure. In general, "embedded system" is not an exactly defined term, as many systems have some element of programmability. For example, Handheld computers share some elements with embedded systems such as the operating systems and microprocessors which power them are not truly embedded systems, because they allow different applications to be loaded and peripherals to be connected.
1.2 ROBOTICS: A robot is a virtual or mechanical artificial agent. In practice, it is usually an electromechanical system which, by its appearance or movements, conveys a sense that it has intent or agency of its own. The word robot can refer to both physical robots and virtual software agents, but the latter are usually referred to as bots. There is no consensus on which machines qualify as robots, but there is general agreement among experts and the public that robots tend to do some or all of the following: move around, operate a mechanical limb, sense and manipulate their environment, and exhibit intelligent behavior, especially behavior which mimics humans or other animals.
1.3 TRACK FOLLOWING ROBOT: The line follower is a self operating robot that detects and follows a line that is drawn on the floor. The path consists of a black line on a white surface (or vice versa). The control system used must sense a line and maneuver the robot to stay on course, while constantly correcting the wrong moves using feedback mechanism, thus forming a simple yet effective closed loop System. The robot is designed to follow very tight curves. The robot initializes in seek mode, where it searches for a black line to track. Wheel synchronization, during seek mode, allows the robot to travel in a straight line without guidance. Once a black line is found, the robot tracks the line. Sensing a line and maneuvering the robot to stay on course, while constantly correcting wrong moves using feedback mechanism forms a simple yet effective closed loop system. Practical applications of a line follower: Automated cars running on roads with embedded magnets; guidance system for industrial robots moving on shop floor etc.
1.4 OBJECTIVE: The aim of the line following robot is to search for a black line on the terrain. Once the line is found, the robot tracks the line from end to end. Four infrared sensors have been mounted under the robot and connected to the port of the AT89C51 do line sensing. The line follower is a classic introductory robot design and requires a minimal amount of resources. These line follower robots can use microcontroller or simple digital or analog control systems and are highly visual and entertaining to watch. A great event for reprogrammed Mini-Sumos.
1.5 MOTIVATION: As we are searching for a project using microcontroller for an automated machine, we found this project. The usage of sensor, relay and microcontroller motivated us to do this project. Here the sensors are used to steer the wheel of this track following robot a writing program on microcontroller for this stipulated task is very interesting. The working method of track follower, the role played by the IR sensor and microcontroller motivated us to do this project.
2. HARDWARE DESCRIPTION:
2.1 MICROCONTROLLER DESCRIPTION:
2.1.1 INTRODUCTION TO MICROCONTROLER: A Microcontroller consists of a powerful CPU tightly coupled with memory RAM, ROM or EPROM, various I /O features such as serial ports, Parallel Ports, Timer/Counters, Interrupt Controller, Data Acquisition interfaces-Analog to Digital Converter, Digital to Analog Converter, everything integrated onto a single Silicon Chip. It does not mean that any microcontroller should have all the above said features on-chip. Depending on the need and area of application for which it is designed, the on-chip features present in it may or may not include all the individual section said above. Any microcomputer system requires memory to store a sequence of instructions making up a program , parallel port or serial port for communicating with an external system, timer / counter for control purposes like generating time delays, baud rate for the serial port, apart from the controlling unit called the Central Processing Unit. ADVANTAGES OF MICROCONTROLLER If a system is developed with the microcontroller, the designer has to go for the external memory such as RAM, ROM or EPROM and peripherals and hence the size of the PCB will be large enough to hold all the required peripherals. But, the microcomputer has got all these peripheral facilities on a single chip so development of a similar system with a microcontroller reduces PCB size and cost of the design.
2.1.2 PINOUT DIAGRAM:
2.1.3 ATMEL MICROCONTROLLER:
SERIES TECHNOLOGY
: 89C51 Family : CMOS
FEATURES OF ATMEL 89C51
8 Bit optimized for control applications
Extensive Boolean processing (Single – bit Logic) Capabilities
On - Chip Flash Program Memory
On - Chip Data RAM
Bi-directional and individually addressable I/O Lines
Multiple 16-Bit Timer/Counters
Full Duplex UART
Multiple Source / Vector / Priority Interrupt Structure
On – Chip Oscillator and Clock circuitry
On – Chip EEPROM
SPI Serial Bus Interface
2.1.4 POWER MODES OF ATMEL 89C51 MICROCONTROLLER: To exploit the power savings available in CMOS circuitry, Atmel’s Flash microcontrollers have two software-invited reduced power modes. They are, Idle Mode: The CPU is turned off while the RAM and other on-chip peripherals continue to operating. In this mode current draw is reduced to about 15 percent of the current drawn when the device is fully active. Power down Mode: All on-chip activities are suspended while the on-chip RAM continues to hold its data. In this mode, the device typically draws less than 15 Micro Ampere and can be as low as 0.6 Micro Amps. Power on Reset: When power is turned on, the circuit holds the RST pin high for an amount of time that depends on the capacitor value and the rate at which its charges. The oscillator start-up time depends on the oscillator frequency. For a 10 MHz crystal, the start-up time is typically 1ms. With the given circuit, reducing Vcc quickly to 0 causes the RST pin voltage to momentarily fall below 0V. However, this voltage is internally limited and will not harm the device.
2.1.5 MEMORY ORGANIZATION: All Atmel Flash microcontrollers have separate address for program and data memory. The logical separation of program and data memory allows the data memory to be accessed by 8 bit address, which can be more quickly stores and manipulated by an 8 bit CPU. Nevertheless 16 Bit data memory addresses can also be generated through the DPTR register. Program memory can only be read. There can be up to 64K bytes of directly addressable program memory.
The read strobe for external program memory is the program store Enable Signal. Data memory occupies a separate address space from program memory. Up to 64K bytes of external memory can be directly addressed in the external data memory space. The CPU generates read and write signals, RD and WR, during external data memory accesses. External program memory and external data memory can be combined by applying the RD and PSEN signals to the inputs of AND gate and using the output of the fate as the read strobe to the external program/data memory.
2.1.6 DATA MEMORY: The Internal Data memory is dived into three blocks namely, The lower 128bytes of Internal RAM. The Upper 128bytes of Internal RAM. Special Function Register.
Internal Data Memory addresses are always 1byte wide, which implies an address space of only 256bytes. However, the addressing modes for internal RAM can in fact accommodate 384bytes. Direct addresses higher than 7Fh access one memory space and indirect addresses higher than 7Fh access a different memory space. The lowest 32 bytes are grouped into 4 banks of 8 registers. Program instructions call out these registers as R0 through R7. Two bits in the Program Status Word select which register bank in use. This architecture allows more efficient use of code space, since register instructions are shorter than instructions that use addressing. The special function Register includes Port latches, timers, peripheral controls etc. Direct addressing can only access these register. In general, all Atmel microcontrollers have the same SFRs at the same addresses in SFR space as the AT89C51 and other compatible microcontrollers. However, upgrades to the AT89C51 have additional SFRs. Sixteen addresses in SFR space are both byte and bit addressable. The bit Addressable SFRs are whose address ends in 000B. The bit addresses in this area are 80h through FFh.
2.1.7 OSCILLATOR AND CLOCK CIRCUIT: XTAL1 and XTAL2 are the input and output respectively of an inverting amplifier which is intended for use of a crystal oscillator in the pierce configuration, in the frequency range of 1.2 MHz to 12MHz. XTAL2 also the input to the internal clock generator.
To drive the chip with an internal oscillator, one would ground XTAL1 and XTAL2. Since the input to the clock generator is dividing by two flip flop there are no requirements on the duty cycle of the external oscillator signal. However, minimum high and low times must be observed. The clock generator divides the oscillator frequency by 2 and provides a two phase clock signal to the chip. The phase 1 signal is active during the first half to each clock period and the phase 2 signals are active during the second half of each clock period.
CPU TIMING A machine cycle consists of 6 states. Each stare is divided into a phase half, during which the phase 1 clock is active and phase 2 half. Arithmetic and Logical operations take place during phase1 and internal register to register transfer take place during phase 2.
2.2 IR SECTION DESCRIPTION:
Symbol:
Description: Each opto-coupler has one emitter (IR LED) and one receiver (IR LED). If the white surface is present beneath the IR LED, IR rays are reflected and are sensed by the receiver, while in case of black surface, the light gets absorbed and hence receiver does not sense IR rays.
Principle of Operation: A photodiode is a PN junction. When a photon of sufficient energy strikes the diode, it excites an electron, thereby creating a mobile electron and a positively charged electron hole. If the absorption occurs in the junction’s depletion region, or one diffusion length away from it, these carriers are swept from the junction by the built-in field of the depletion region. When the diode is powered up it continuously emits the Infra Red (IR) rays.
The Theory: The theory behind line tracking is actually pretty simple. An infrared LED is paired with an infrared detector. The LED is illuminated and directed to the surface where the line is to be detected. The detector is biased on and fed into a comparator to clean up the signal. The resistance of the sensor decreases when IR light falls on it. A good sensor will have near zero resistance in presence of light and a very large resistance in absence of light. In order to keep the electronics as simple as possible a 7404 hex inverter will replace the comparator circuitry. The very high input impedance, built in hysteresis and low parts count makes the CMOS version an excellent alternative.
FEATURES:
High reliability
High radiant intensity
Peak wavelength
2.54mm Lead spacing
Low forward voltage
Pb free
The product itself will remain within RoHS compliant version.
APPLICATIONS:
Free air transmission system
Infrared remote control units with high power requirement
Smoke detector
Infrared applied system
Photo conductors
Receivers for remote controls in VCRs and televisions.
2.2.1 TL082 General Purpose J-FET Dual Operational Amplifiers The TL082, TL082A and TL082B are high speed J-FET input dual operational amplifiers incorporating well matched, high voltage J-FET and bipolar transistors in a monolithic integrated circuit. The device features high slew rates, low input bias and offset current, and low offset voltage temperature coefficient.
PIN CONNECTIONS (top view)
FEATURES:
Internally trimmed offset voltage:
15mv
Low input bias current:
50pA
Low input noise voltage:
16nv
Low input noise current:
0.01pA
Wide gain bandwidth:
4 MHz
High slew rate:
13v/µs
Low supply current:
3.6mA
High input impedance:
10^12Ω
2.2.2 IC 7404 – HEX INVERTER The IC 7404 is 14-pin DIP. The chip contains six one-input NOT gates. Each gate uses one pin for input and another pin for its output, and the remaining two contacts power supply (+5V) and connect the ground. In digital logic, an inverter or NOT gate is a logic gate which implements logical negation. This represents perfect switching behavior, which is the defining assumption in Digital electronics. In practice, actual devices have electrical characteristics that must be carefully considered when designing inverters.
Symbol:
Pin Configuration:
Pin Number
Description
1
A Input Gate 1
2
Y Output Gate 1
3
A Input Gate 2
4
Y Output Gate 2
5
A Input Gate 3
6
Y Output Gate 3
7
Ground
8
Y Output Gate 4
9
A Input Gate 4
10
Y Output Gate 5
11
A Input Gate 5
12
Y Output Gate 6
13
A Input Gate 6
14
Positive Supply
FEATURES:
Output Drive Capability – 10 LSTTL loads
Outputs Directly Interface to CMOS, NMOS and TTL
Large Operating Voltage Range
Low Input Current
High Noise Immunity
2.3 RELAY SECTION Relay:
Relay Symbol:
A relay is an electrical switch that opens and closes under the control of another electrical circuit. In the original form, the switch is operated by an electromagnet to open or close one or many sets of contacts. Because a relay is able to control an output circuit of higher power than the input circuit, it can be considered to be, in a broad sense, a form of an electrical amplifier.
2.3.1 Basic Design and Operation A simple electromagnetic relay, such as the one taken from a car in the first picture, is an adaptation of an electromagnet. It consists of a coil of wire surrounding a soft iron core, an iron
yoke, which provides a low reluctance path for magnetic flux, a moveable iron armature, and a set, or sets, of contacts; two in the relay pictured. The armature is hinged to the yoke and mechanically linked to a moving contact or contacts. It is held in place by a spring so that when the relay is de-energized there is an air gap in the magnetic circuit. In this condition, one of the two sets of contacts in the relay pictured is closed, and the other set is open. Other relays may have more or fewer sets of contacts depending on their function. The relay in the picture also has a wire connecting the armature to the yoke. This ensures continuity of the circuit between the moving contacts on the armature, and the circuit track on the Printed Circuit Board (PCB) via the yoke, which is soldered to the PCB. When an electric current is passed through the coil, the resulting magnetic field attracts the armature and the consequent movement of the movable contact or contacts either makes or breaks a connection with a fixed contact. If the set of contacts was closed when the relay was deenergized, then the movement opens the contacts and breaks the connection, and vice versa if the contacts were open. When the current to the coil is switched off, the armature is returned by a force, approximately half as strong as the magnetic force, to its relaxed position. Usually this force is provided by a spring, but gravity is also used commonly in industrial motor starters. Most relays are manufactured to operate quickly. In a low voltage application, this is to reduce noise. In a high voltage or high current application, this is to reduce arcing. If the coil is energized with DC, a diode is frequently installed across the coil, to dissipate the energy from the collapsing magnetic field at deactivation, which would otherwise generate a voltage spike dangerous to circuit components. Some automotive relays already include that diode inside the relay case. Alternatively a contact protection network, consisting of a capacitor and resistor in series, may absorb the surge. If the coil is designed to be energized with AC, a small copper ring can be crimped to the end of the solenoid. This "shading ring" creates a small out-of-phase current, which increases the minimum pull on the armature during the AC cycle. By analogy with the functions of the original electromagnetic device, a solid-state relay is made with a thyristor or other solid-state switching device. To achieve electrical isolation an optocoupler can be used which is a light-emitting diode (LED) coupled with a photo transistor.
2.3.2 Pole & Throw
Since relays are switches, the terminology applied to switches is also applied to relays. A relay will switch one or more poles, each of whose contacts can be thrown by energizing the coil in one of three ways:
•
Normally-open (NO) contacts connect the circuit when the relay is activated; the circuit is disconnected when the relay is inactive. It is also called a Form A contact or "make" contact.
•
Normally-closed (NC) contacts disconnect the circuit when the relay is activated; the circuit is connected when the relay is inactive. It is also called a Form B contact or "break" contact.
The following designations are commonly encountered: •
SPST - Single Pole Single Throw. These have two terminals which can be connected or disconnected. Including two for the coil, such a relay has four terminals in total. It is
ambiguous whether the pole is normally open or normally closed. The terminology "SPNO" and "SPNC" is sometimes used to resolve the ambiguity. •
SPDT - Single Pole Double Throw. A common terminal connects to either of two others. Including two for the coil, such a relay has five terminals in total.
•
DPST - Double Pole Single Throw. These have two pairs of terminals. Equivalent to two SPST switches or relays actuated by a single coil. Including two for the coil, such a relay has six terminals in total. The poles may be Form A or Form B (or one of each).
•
DPDT - Double Pole Double Throw. These have two rows of change-over terminals. Equivalent to two SPDT switches or relays actuated by a single coil. Such a relay has eight terminals, including the coil.
The "S" or "D" may be replaced with a number, indicating multiple switches connected to a single actuator. For example 4PDT indicates a four pole double throw relay (with 14 terminals).
2.4 DC MOTOR
A DC motor works by converting electric power into mechanical work. This is accomplished by forcing current through a coil and producing a magnetic field that spins the motor. The simplest DC motor is a single coil apparatus, used here to discuss the DC motor theory. The voltage source forces voltage through the coil via sliding contacts or brushes that are connected to the DC source. These brushes are found on the end of the coil wires and make a temporary electrical connection with the voltage source. In this motor, the brushes will make a connection every 180 degrees and current will then flow through the coil wires. At 0 degrees, the brushes are in contact with the voltage source and current is flowing. The current that flows through wire segment C-D interacts with the magnetic field that is present and the result is an upward force on the segment. The current that flows through segment A-B has the same interaction, but the force is in the downward direction. Both forces are of equal magnitude, but in opposing directions since the direction of current flow in the segments is reversed with respect to the magnetic field. At 180 degrees, the same phenomenon occurs, but segment A-B is forced up and C-D is forced down. At 90 and 270-degrees, the brushes are not in contact with the voltage source and no force is produced. In these two positions, the rotational kinetic energy of the motor keeps it spinning until the brushes regain contact.
One drawback to the motor is the large amount of torque ripple that it has. The reason for this excessive ripple is because of the fact that the coil has a force pushing on it only at the 90 and 270 degree positions. The rest of the time the coil spins on its own and the torque drops to zero. The torque curve produced by this single coil, as more coils are added to the motor, the torque curve is smoothed out. The resulting torque curve never reaches the zero point and the average torque for the motor is greatly increased. As more and more coils are added, the torque curve approaches a straight line and has very little torque ripple and the motor runs much more smoothly.
2.5 POWER SUPPLY DESCRIPTION:
Starting with an ac voltage, a steady dc voltage is obtained by rectifying the ac voltage, then filtering to a dc level and finally, a regulating to obtain a desired fixed dc voltage. The regulation is usually obtained from an IC voltage regulator unit, which takes a dc voltage and provides a lower dc voltage, which remains the same even if the input dc voltage varies or the output load connected to the dc voltage changes. The ac voltage, typically 120V rams, is connected to a transformer, which steps that ac voltage down to the level for the desired dc output. A diode rectifier then provides a full wave rectified voltage that is initially filtered by a simple capacitor filter to produce a dc voltage. This resulting dc voltage usually has some ripple or ac voltage variation. A regulator circuit can use this dc input to provide a dc voltage that not only has much less ripple voltage but also remains the same dc value even if the input dc voltage varies somewhat, or the load connected to the output dc voltage changes. This voltage regulation is usually obtained one of a number of popular voltage regulator IC units.
WORKING PRINCIPLE The potential transformer will step down the power supply voltage (0-230V) to (0-6V) level. Then the secondary of the potential transformer will be connected to the precision rectifier, which is constructed with the help of op-amp. The advantages of using precision rectifier are it will give peak voltage output as DC, rest of the circuits will give only RMS output.
2.5.1 Bridge Rectifier: When four diodes are connected as shown in the circuit diagram is called as bridge rectifier. The input to the circuit is applied to the diagonally corners of the network, and the output is taken from the remaining two corners. Let us assume that the transformer is working properly and there is a positive potential, at point A and a negative potential at point B. The positive potential at point A will forward bias D3 and reverse bias D4. The negative potential at point B will forward bias D1 and reverse D2. At this time D3 and D1 are forward biased and will allow current flow to pass through them; D4 and D2 are reverse biased and will block current flow. The path for current flow is from point B through D1, up through RL, through D3, through the secondary of the transformer back to point B. This path is indicated by the solid arrows. Waveforms (1) and (2) can be observed across D1 and D3. One advantage of a bridge rectifier over a conventional full-wave rectifier is that with a given transformer the bridge rectifier produces a voltage output that is nearly that of the conventional full-wave circuit.
Three-terminal Voltage Regulators: Below figure shows the basic connection of a three-terminal voltage regulator IC to a load. The fixed voltage regulator has an unregulated dc input voltage, Vi, applied to one input terminal, a regulated output dc voltage, Vo, from a second terminal, with the third terminal connected to the ground. For a selected regulator, IC device specifications list a voltage range over which the input voltage can vary to maintain a regulated output voltage over a range of load current. The specifications also list the amount of output voltage change resulting from a change in load current (load regulation) or in input voltage (line regulation).
Fixed Positive Voltage Regulators: The series 78 regulators provide fixed regulated voltages from 5 to 24V. While the input voltage may vary over some permissible voltage range, and the putput load may vary over some acceptable range, the output voltage remains constant within specified voltage variations limits. These limitations are spelled out in the manufacturer’s specification sheets. A table of positive voltage regulated 7800 series ICs are shown as.
IC Part
Output Voltage
Minimum Vi
(V)
(V)
7805
+5
7.3
7806
+6
8.3
7808
+8
10.5
7810
+10
12.5
7812
+12
14.6
7815
+15
17.7
7818
+18
21.0
7824
+24
27.1
But actually the power is provided by the 12V NiCad Battery pack for this project. Because it reduces the area of the transformer and rectifier in this project.
3.0 CIRCUIT DESCRIPTION
3.1 BLOCK DIAGRAM
3.2 CIRCUIT DIAGRAM
3.2.1 Microcontroller Section:
3.2.2 IR SECTION
3.2.3 RELAY SECTION
3.2.4 POWER SUPPLY:
3.3 Basic Operation: Capture line position with optical sensors mounted at front end of the robot. For this a combination of IR transmitter and IR receiver is used. The line sensing process requires high resolution and high robustness. Steer robot to track the line with a suitable steering mechanism. To achieve this we use two motors that govern the motion of the wheels on either side. The project mainly includes three sections. They are microcontroller, IR section and relay section. The microcontroller section includes IC Atmel 89C51. The microcontroller IC is the heart of the circuit. The IR section includes IR transmitter and IR receiver. The IR transmitter continuously emits the IR rays. The emitted rays received by the IR receiver. The IR receiver section includes operational amplifiers that are TL082. The TL082 is the high speed J-FET input dual operational amplifiers. The output from the TL082 is fed to the transistor BC547. It amplifies the incoming signal and it is applied to the hex inverter that is IC7404. The IC 7404 is a NOT gate that inverts the incoming signal. Thus the analog signal is converted into digital signal. Then that signal is fed to the port of the microcontroller IC. The relay section consists of four relays. The output of the relay circuit is connected to two DC motors. The corresponding output from the IR sensor fed to the ports of the microcontroller triggers the relay which is connected to the DC motors. If the left sensor is sensing the black line then the left DC motor turns on and running in forward direction, while the Right DC motor running in the reverse direction. This friction allows the robot to turn the left. In the same way if the right sensor sensing the black line then the right DC motor turns on and running in forward direction, while the Left DC motor running in reverse direction. This friction allows the robot to turn the right.
Robot Specifications:
The robots must be autonomous.
The maximum robot width is 8.500 inches (216 mm). (5 inches for alumni and grad students.)
The maximum robot length is 11.000 inches (279 mm). (8.5 inches for alumni and grad students.)
The robot must have a working and easily accessible on/off switch. Connecting and disconnecting the battery to perform this function is unacceptable.
A reset switch is recommended for better control of the robot.
The robot can start in any orientation, but must follow the path in specified direction.
There are no constraints on the motors or gearboxes.
There are no constraints on the sensor array.
There are no constraints on battery types.
There are no constraints on robot weight.
There are no constraints on chassis materials.
There are no constraints on wheels.
TRACK SPECIFICATIONS:
The track will be constructed of cells that are 12.000 inches (305 mm ) in length and width, 3mm.
The cell surface will be finalized very soon. Lack paper with a white line will be used as an alternative if this is not possible.
The track surface may have discontinues, not to exceed 3mm.
The course line will be ¾-inch (19 mm ) wide, nch (19 mm ) wide 3mm
The course line will be either white vinyl or constructed from white paper.
The course line may have discontinues, not to exceed 3mm.
The course line may be curved, with a centerline radius of 6.000 inches (152 mm ).
3.3.1 Arrangement of Sensors:
IR RECEIVER
IR TRANSMITTER
IR RECEIVER
IR TRANSMITTER
An array of sensors arranged in a straight row pattern is bolted under the front of the robot. It is used to locate the position of line below the robot. We can use any number of sensors. If we have lesser number of sensors then the robot movement will not be smooth and it may face problems at sharp turns. If we use higher number of sensors robot movement will become smooth and reliable for sharp turns, however it requires complex programming and more hardware. Thus we must choose optimum number of sensors.
The distance between the sensors depends on 1. Number of sensors used 2. Width of straight line 3. Distance between sensors may not be constant (it depends on the logic).
3.3.2 Mounting the Tracker Sensor: The sensor can be mounted to the underside of a robot chassis toward the front of the vehicle. Position the sensor close to the floor. The sensor will operate in an extremely wide range from about 0.5” from the floor to almost touching the surface. The sensor appears to be immune to normal ambient lighting, although it may be necessary to shield the sensor extremes.
4. SOFTWARE SECTION
4.1 KEILC51 LANGUAGE EXTENSIONS: Even though the C51 compiler is ANSI compiled, some extensions were added to support the facilities of 8051 micro processor. The C51 compiler includes extensions for, 1) Data types 2) Memory models 3) Pointers 4) Reentrant functions 5) Interrupt functions
Data types: The C51 compiler supports all the scalar data types in C. in addition to these scalar types variables may be combined into structures, unions and arrays. Except us noted pointers may be used to assess these data types. Bit, s-bit, sfr and sfr-16 are the data types specific to the 8051 hardware and the C51 and C251 compilers. They are not a part of ANSI C and cannot be accessed through pointers. The s-bit, sfr and sfr-16 data types allows to access special function registers that are available on the 8051.
Memory types: The C51 compiler supports architecture of 8051 and its derivatives and provides access to all memory areas of 8051. Accessing the internal data memory is considerably faster than accessing the external data memory. For these reasons, frequently used variables in external data memory. Using SMALL memory model most easily does this. By including a memory type specified in the variable declaration, specify where variables are stored. As with the signed and unsigned attributes memory type specifies may be included in the variable.
Debugging: The simplest embedded systems are capable of performing only a single function or set of functions to meet a single predetermined purpose. In more complex system the functioning of the embedded system is determined by an application program, which enables the embedded system to be used for a variety of different purposes. In some cases a microprocessor may be designed in such a way that application can be added to the basic software in a second process, after which it is not possible to make further changes: the application software on such processors is sometimes referred to as firmware.
4.2 Cx51 Introduction The Keil Software 8051 development tools listed below are programs you use to compile your C code, assemble your assembly source files, link and locate object modules and libraries, create HEX files, and debug your target program. The Cx51 ANSI Optimizing C Cross Compiler creates reloadable object modules from your C source code. The Cx51 Compiler User's Guide contains information about how to use the Keil C51 and CX51 Compilers. The Cx51 Compiler creates object modules from the C files you write and compile. Object modules created may be added into a library or may be linked with other object modules and libraries to form a program. The C programming language is a general-purpose programming language that provides code efficiency, elements of structured programming, and a rich set of operators. C is not a big language and is not designed for any one particular area of application. Its generality combined with its absence of restrictions, makes C a convenient and effective programming solution for a wide variety of software tasks. Many applications can be solved more easily and efficiently with C than with other more specialized languages.
The Cx51 Optimizing C Compiler is a complete implementation of the American National Standards Institute (ANSI) standard for the C language. The Cx51 Compiler is not a universal C compiler adapted for the 8051 target. It is a ground-up implementation, dedicated to generating extremely fast and compact code for the 8051 microprocessor. The Cx51 Compiler provides you with the flexibility of programming in C and the code efficiency and speed of assembly language. The C language on its own is not capable of performing operations (such as input and output) that would normally require intervention from the operating system. Instead, these capabilities are provided as part of the standard library. Because these functions are separate from the language itself, C is especially suited for producing code that is portable across a wide number of platforms.
Advanced Programming This advanced programming topic presents information that experienced software engineers will find invaluable. Knowledge of these topics is not necessary to successfully create an embedded 8051 target program using the Cx51 Compiler. However, the following topics provide insight into how many non-standard procedures are accomplished. Advanced programming discusses the following topics:
Files you may alter to customize the startup procedures
Files you may alter to customize run-time execution of library routines
Conventions the Cx51 Compiler uses to name code and data segments
How to interface Cx51 functions to assembly routines
Data storage formats for the different Cx51 data types
Different optimizing features of the Cx51 Compiler
4.3 Ax51 Introduction This manual describes the macro assemblers and utilities for the classic 8051 and extended 8051 microcontroller families and explains the process of developing software in assembly language for these microcontroller families. In this overview, the differences between the classic 8051, the extended 8051 variants and the 251 processors are described.
Macro Processor A macro processor enables you to define and to use macros in your assembly programs. When you define a macro, you provide text (usually assembly code) that you want to associate with a macro name. Then, when you want to include the macro text in your assembly program, you provide the name of the macro. The assembler replaces the macro name with the text specified in the macro definition. Macros provide several advantages when writing assembly programs.
The
frequent
use
of
macros
can
reduce
programmer-induced
errors.
A macro allows you to define instruction sequences that are used repetitively throughout your program. Subsequent use of the macro faithfully provides the same results each time. A macro reduces the likelihood of errors introduced in repetitive programming sequences. Of course, introduction of an error into a macro definition causes that error to propagate through the program wherever the macro is used.
The scope of symbols used in a macro is limited to that macro. You need not be concerned about using a previously used symbol name.
Macros are well-suited for creating simple code tables. Producing tables by hand is both tedious and error-prone.
A macro may be thought of as a subroutine call with the exception that the code that would be contained in the subroutine is included in–line at the point of the macro call. Macros should not be used to replace subroutines. Each invocation of a subroutine requires only the code necessary to call the subroutine. Each invocation of a macro includes the assembly code associated with the macro in–line in the assembly program. This can cause a program's size to grow rapidly if a large macro is used frequently. In a static environment, a subroutine is a better choice since program size can be considerably reduced. But in time-critical, dynamic programs, macros speed the execution of algorithms or other frequently-called statements without the penalty of the procedure calling overhead. We can use the following guidelines when deciding between macros or subroutines:
Subroutines are best used when certain procedures are frequently executed or when the use of memory must be kept to a minimum.
Macros are best when maximum processor speed is required and when the amount of memory consumed is less important.
Macros reduce the amount of typing required to enter short, repetitive blocks of assembly code.
Error Messages
All errors recognized by the Ax51 Assembler are output to the listing file. Two classes of errors exist: fatal and non-fatal.
Fatal Errors indicate an unrecoverable problem and cause the assembler to immediately halt. These types of errors are usually caused by a disk problem or access problem.
Non-Fatal Errors do not halt assembly but may indicate a problem that prevents correct or valid assembler output. These types of errors are typically caused by syntax or semantic errors in the source file.
4.4 OHx51 INTRODUCTION The OHx51 Object-HEX Converter creates Intel HEX files from absolute object modules. The OH51 Object-HEX Converter creates an Intel HEX file from an absolute object file generated by the BL51 LINKER Program code stored in the absolute object file is converted into hexadecimal values and is stored in a file in Intel HEX file format. An EPROM programmer or emulator may then use the Intel HEX file to program a device.
The OH51 Object-HEX Converter may be invoked and controlled by:
The Command Prompt,
The µVision IDE.
Intel HEX File Format
The Intel HEX file is an ASCII text file with lines of text that follow the Intel HEX file format. Each line in an Intel HEX file contains one HEX record. These records are made up of hexadecimal numbers that represent machine-language code and/or constant data.
Intel HEX files are often used to transfer the program and data that would be stored in a ROM or EPROM. Most EPROM programmers or emulators can use Intel HEX files.
4.5 C CODING
#include d:\mc51\8051io.h #include d:\mc51\8051reg.h extern register unsigned char speedleft,speedright; register unsigned char high,low,flag,time;
main() { P1=0x40; P3=0xff; high = 80; low = 30; flag = 0; time = 50; Start(); while(1) { P3|= 0x0f; Run();
} }
Start() { char exit,key; exit =1; while(exit) { key = P1; if((key & 0x40)==0) exit=0; } }
Run() { char sensors; sensors = (P3 &=0x0f);
if((sensors & 0x01)==0) { TurnRight(); flag = 1;
}
else if((sensors & 0x08)==0) { TurnLeft(); flag = 2;
}
else if(sensors == 0x09)
{
Forward(high); flag = 0;
}
else if(((sensors==0x0b)||(sensors==0x0d))&&(flag==0)) Forward(low);
}
Forward(char speed) { P1=0x64; speedright = speed+10; speedleft = speed; delay(time); }
TurnRight() { P1=0x68;
speedright = low+5; speedleft = low; delay(time); }
TurnLeft() { P1=0x54; speedright = low+5; speedleft = low; delay(time); }
CONCLUSION The designed equipment is working properly and it can be enhanced to use it for more applications in future without any major modifications. The project done was on overall success. The track following robot detects and follows a line that is drawn on the floor. The path consists of a black line on a white surface or a white line on a black surface. It is used in guidance system for industrial robots moving on shop floor The successful completion of the project is related in faster data processing, best user friendly, data validation and for easy installation. Some of the major accomplishments during this project throughout the semester are,
SUCCESSES: It travels the 112inches long course (black tape on white board) in 8.5 seconds. Automate the things as requested.
KNOWLEDGE ACQUIRED: Microcontroller programming.
Automation
FUTURE ENHANCEMENT
The “TRACK FOLLOWING ROBOT” is just a hint. To do the development, the students of interest in this field can dig deep into the technology behind the automation technique and controller of all kind and throw light in these advancements in technology. This project will be the ladder to climb this booming and sniff its features. We know our present scenario world is enriched with the automation technology in all the fields. So, the improvements in this technique with the advanced technology are not too far. The scope for the future enhancement is wide. Some of the scopes are,
Speed can be increased It can be implemented to follow the zigzag path in short duration.
Future development depends on how effectively these technologies are integrates with each other to develop the ultimate automation and robotics technologies.
BIBLIOGRAPHY
IC’S AND IT’S APPLICATIONS
- B.L.THERAJA
8051 MICROCONTROLLER AND INTERFACING
- AYALA
REGULATED POWER SUPPLY CIRCUITS:http://www.hobbycircuits.net
BASIC ELECTRONICS
http://www.knowledgehound.com/topics/electron.html
HARDWARE DETAILS
http://www.hobbycircuits.net
IR SENSORS DETAILS
http://hobbycircuits.net/?page_id=223