light rover full report
project report tiger|
Active In SP
Joined: Feb 2010
06-02-2010, 08:22 AM
finalcopy-lightrover.doc (Size: 489 KB / Downloads: 167)
A SEMINAR REPORT ON LightRover
GAURAV SHAHANE (4449)
TUSHAR WALE (4458)
ANAND WANKHEDE (4460)
LightRover is a robot that can sense and follow light. A user can shine a flashlight at its front and LightRover will respond by following the light source. LightRover uses a microcontroller for processing the sensor readings and responds by controlling the motors.
The robot is designed with two sensors in mind, a left and a right. So when more light is detected on the left side, the robot will move towards it by rotating the right motor forward and the left motor backwards. The robot will know to move forward when both sensors receive about the same (by a margin we specify) amount of light.
The robot has two bipolar motors attached to front wheels of the robot. While rear wheels donâ„¢t have any motor attached to them. The robot has two sensors fixed at its front panel separated by sufficient distance. It has a 9 V battery supply & microcontroller circuitry placed inside the LightRover.
We wanted to build a light sensing robot because microcontrollers are natural devices for sensing and responding to events. We felt that building a device able to react to its environment would be an excellent learning experience.
A creative visualization of LightRoverÂ¦
2.Block diagram & itâ„¢s working:
Fig. 1: Block Diagram
The robot will have two sensors fixed at its front side. Here we are using two sensors, a microcontroller, two H-Bridges & two bipolar stepper motors. The analog value of voltage produced by a light sensing circuit made by using sensors will be fed to ADCs of microcontroller. The microcontroller will convert this value in binary value. Now we have values from both sensors. If those values are greater than a threshold voltage value(default or calibrated by the robot when we start it), we assume they are at logic 1 & otherwise they are at logic 0.as stated in the following table.
Left sensor Right sensor Left motor Right motor Effect
0 0 No signal No signal No movement
0 1 Step forward Step backward Right turn
1 0 Step backward Step forward Left turn
1 1 Step forward Step forward Forward movement
Fig 2: Controls table
According to the logic presented by the sensors, appropriate instructions are passed to both bipolar stepper motors. If light falling on the both sensors is not equal then the robot will turn left or right according to the logic. It will keep turning in the same direction till the light falling on both sensors become same. Now that robot is aligned to the direction of the light source, it will move straight in the direction of light.
For reversing the direction of turning of the bipolar stepper motor we have to reverse the direction of current through its coil. This abrupt change in voltage may damage the microcontroller. For the protection of microcontroller we are implementing an H-bridge for each of the motors. We are using a 9 volt battery supply for the microcontroller circuitry.
This is how our Light Rover will work.
3.1 Bipolar Stepper Motor Control Circuit:
The bipolar stepper motor usually has four wires coming out of it. Unlike unipolar steppers, bipolar steppers have no common center connection. They have two independent sets of coils instead. You can distinguish them from unipolar steppers by measuring the resistance between the wires. You should find two pairs of wires with equal resistance. If youâ„¢ve got the leads of your meter connected to two wires that are not connected (i.e. not attached to the same coil), you should see infinite resistance (or no continuity).These motors have no center taps on their windings. Therefore, to reverse the direction of the magnetic field produced by a coil, we need to reverse the current through the winding.
Fig.3: Bipolar stepper motor
To control the stepper, we need to apply voltage to each of the coils in a specific sequence. The sequence would go like this:
Step wire 1 wire 2 wire 3 wire 4
1 High low high low
2 low high high low
3 low high low high
4 high low low high
3.2 Half H-bridge:
Fig.4: A Half H-Bridge Stepper Motor Control Circuit
The circuit above is a half H-bridge. It takes two of these circuits to control one motor. Point A and B are connected to one coil of the motor, say blue and red wires. Point X and Y are digital signals from the MCU, either at 5V or 0V. X xor Y is always 1, meaning their logic values are complementary of one another at all times. Next we will walk through two steps of the 4-step switching sequence to analyze the behavior of the circuit:
1. First X = 1: the base-emitter junction of Q2 is forward-biased. Current flows from the collector to the emitter via the base. - At the same time Y = 0: Q4 is off and current flowing from +V through the resistor to the base of Q3 has nowhere to go. This current therefore raises the voltage at the base of Q3, turning it on.
>> So for XY = 10, current flows from +V down Q3 to the coil from B to A and to ground via Q2.
2. Similarly, for XY = 01, current flows from +V down Q1 to the coil from A to B and to ground via Q4.
The next two steps operate on the other coil in a similar manner. Table below summarizes the 4-step switching sequence for counterclockwise rotation:
Step Blue Red White Yellow
1 0V 5V 5V 0V
2 5V 0V 5V 0V
3 5V 0V 0V 5V
4 0V 5V 0V 5V
Fig 5 & 6: A bipolar stepper motor with blue, red, white, yellow wires (left) & Switching sequence for counterclockwise rotation of the bipolar stepper motor (right).
In this circuit, diodes D1, D3, D4, and D6 provide protection for the circuit against inductive kicks caused by abrupt change in current when switching one step to another, given by the equation V = -L(dI/dt). For an abrupt change in current (transistor switching), dI/dt is very large, producing a large voltage across AB. When VA or VB is larger than +V, current is shorted to the positive terminal via diodes D1 or D4. When VA or VB is more negative than ground, current is shorted to ground via diode D3 or D6.
Fig.7: H-bridge IC SN754410NE interfaced with microcontroller & bipolar stepper motor.
3.3 CDST08 Photocell:
A cadmium sulfide (CdS) photocell is a passive component whose resistance decreases when light shines on it. CdS photocells can be used to detect when lights turn on, to orient things toward a light source (electronic sunflower), and to detect shadows passing across them.
Fig.8: A CDST08 photocell
To use a CdS photocell, you put it in series with a resistor and put a voltage across them. This form a voltage divider: the voltage at their junction is determined by the proportion of the two resistances. If you want brightness to increase the measured voltage, put the photocell on top; if you want darkness to increase the measured voltage, put the photocell on the bottom.
All that remains is to determine an appropriate value for the complementary resistor. Assuming you want output voltage to increase when brightness increases, the goal would be to make the output read as close to 0V as possible when itâ„¢s as dark as you expect it to be, and as close to your maximum voltage as possible when itâ„¢s as bright as you expect it to be.
3.4 Light Sensing Circuit:
The next module is the light sensing circuit. This circuit consists of two photocells mounted on either side of the vehicle. The photocell produces a variable resistance based on light intensity. We connect it in series with a fixed resistor between 5V and ground to make a voltage divider circuit as follows:
Fig. Light sensing circuit for one sensor. r = 330 ohms. Photocell = 500 ohms (light) ~ 1500 ohms (dark).
The photocell gives a low resistance under a bright light and a high resistance in the dark.
Ain = 5V(r/(R+r)) R is small (light), then Ain is large and vice versa.
Ain is connected to the MCU's A/D inputs to convert this voltage to a number between 0 and 255. If this number is larger than some threshold value, appropriate control signals are sent to the H-bridge circuits, actuating the motors.
3.5 ATmega32 microcontroller:
This is an 8-bit Microcontroller with 32K Bytes In-System Programmable Flash.
The AVR core combines a rich instruction set with 32 general purpose working registers. All the
32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two independent registers to be accessed in one single instruction executed in one clock cycle. The resulting architecture is more code efficient while achieving throughputs up to ten times faster than conventional CISC microcontrollers.
The ATmega32 provides the following features: 32K bytes of In-System Programmable Flash Program memory with Read-While-Write capabilities, 1024 bytes EEPROM, 2K byte SRAM, 32 general purpose I/O lines, 32 general purpose working registers, a JTAG interface for Boundaryscan,On-chip Debugging support and programming, three flexible Timer/Counters with compare modes, Internal and External Interrupts, a serial programmable USART, a byte oriented
Two-wire Serial Interface, an 8-channel, 10-bit ADC with optional differential input stage with programmable gain (TQFP package only), a programmable Watchdog Timer with Internal Oscillator, an SPI serial port, and six software selectable power saving modes. The Idle mode stops the CPU while allowing the USART, Two-wire interface, A/D Converter, SRAM, Timer/Counters, SPI port, and interrupt system to continue functioning. The Power-down mode saves the register contents but freezes the Oscillator, disabling all other chip functions until the next External Interrupt or Hardware Reset. In Power-save mode, the Asynchronous Timer continues to run, allowing the user to maintain a timer base while the rest of the device is sleeping. The ADC Noise Reduction mode stops the CPU and all I/O modules except Asynchronous Timer and ADC, to minimize switching noise during ADC conversions. In Standby mode, the crystal/resonator Oscillator is running while the rest of the device is sleeping. This allows very fast start-up combined with low-power consumption. In Extended Standby mode, both the main Oscillator and the Asynchronous Timer continue to run.
The device is manufactured using Atmelâ„¢s high density nonvolatile memory technology. The Onchip ISP Flash allows the program memory to be reprogrammed in-system through an SPI serial interface, by a conventional nonvolatile memory programmer, or by an On-chip Boot program running on the AVR core. The boot program can use any interface to download the application program in the Application Flash memory. Software in the Boot Flash section will continue to run while the Application Flash section is updated, providing true Read-While-Write operation. By combining an 8-bit RISC CPU with In-System Self-Programmable Flash on a monolithic chip, the Atmel ATmega32 is a powerful microcontroller that provides a highly-flexible and cost-effective solution to many embedded control applications.
The ATmega32 AVR is supported with a full suite of program and system development tools including: C compilers, macro assemblers, program debugger/simulators, in-circuit emulators, and evaluation kit.
VCC Digital supply voltage.
Port A (PA7..PA0) Port A serves as the analog inputs to the A/D Converter.
Port A also serves as an 8-bit bi-directional I/O port, if the A/D Converter is not used. Port pins can provide internal pull-up resistors (selected for each bit). The Port A output buffers have symmetrical drive characteristics with both high sink and source capability. When pins PA0 to PA7 are used as inputs and are externally pulled low, they will source current if the internal pull-up resistors are activated. The Port A pins are tri-stated when a reset condition becomes active, even if the clock is not running.
Port B (PB7..PB0) Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port B output buffers have symmetrical drive characteristics with both high sink and source Capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset condition becomes active, even if the clock is not running. Port B also serves the functions of various special features of the ATmega32.
Port C (PC7..PC0) Port C is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port C output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset condition becomes active, even if the clock is not running. If the JTAG interface is enabled, the pull-up resistors on pins PC5 (TDI), PC3 (TMS) and PC2 (TCK) will be activated even if a reset occurs. The TD0 pin is tri-stated unless TAP states that shift out data are entered. Port C also serves the functions of the JTAG interface and other special features of the
Port D (PD7..PD0) Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port D output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port D pins that are externally pulled low will source current if the pull-up resistors are activated. The Port D pins are tri-stated when a reset condition becomes active, even if the clock is not running. Port D also serves the functions of various special features of the ATmega32.
RESET Reset Input. A low level on this pin for longer than the minimum pulse length will generate a reset, even if the clock is not running.
XTAL1 Input to the inverting Oscillator amplifier and input to the internal clock operating circuit.
XTAL2 Output from the inverting Oscillator amplifier.
AVCC AVCC is the supply voltage pin for Port A and the A/D Converter. It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter.
AREF AREF is the analog reference pin for the A/D Converter.
Â¢ High-performance, Low-power AVRÃ‚Â® 8-bit Microcontroller
Â¢ Advanced RISC Architecture
â€œ 131 Powerful Instructions â€œ Most Single-clock Cycle Execution
â€œ 32 x 8 General Purpose Working Registers
â€œ Fully Static Operation
â€œ Up to 16 MIPS Throughput at 16 MHz
â€œ On-chip 2-cycle Multiplier
Â¢ High Endurance Non-volatile Memory segments
â€œ 32K Bytes of In-System Self-programmable Flash program memory
â€œ 1024 Bytes EEPROM
â€œ 2K Byte Internal SRAM
â€œ Write/Erase Cycles: 10,000 Flash/100,000 EEPROM
â€œ Data retention: 20 years at 85Ã‚Â°C/100 years at 25Ã‚Â°C
â€œ Optional Boot Code Section with Independent Lock Bits
In-System Programming by On-chip Boot Program
True Read-While-Write Operation
â€œ Programming Lock for Software Security
Â¢ JTAG (IEEE std. 1149.1 Compliant) Interface
â€œ Boundary-scan Capabilities According to the JTAG Standard
â€œ Extensive On-chip Debug Support
â€œ Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG Interface
Â¢ Peripheral Features
â€œ Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes
â€œ One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture Mode
â€œ Real Time Counter with Separate Oscillator
â€œ 8-channel, 10-bit ADC
8 Single-ended Channels
7 Differential Channels in TQFP Package Only
2 Differential Channels with Programmable Gain at 1x, 10x, or 200x
â€œ Programmable Serial USART
â€œ Master/Slave SPI Serial Interface
â€œ Programmable Watchdog Timer with Separate On-chip Oscillator
â€œ On-chip Analog Comparator
Â¢ I/O and Packages
â€œ 32 Programmable I/O Lines
â€œ 40-pin PDIP, 44-lead TQFP, and 44-pad QFN/MLF
Â¢ Operating Voltages
â€œ 2.7 - 5.5V for ATmega32L
â€œ 4.5 - 5.5V for ATmega32
Â¢ Speed Grades
â€œ 0 - 8 MHz for ATmega32L
â€œ 0 - 16 MHz for ATmega32
Â¢ Power Consumption at 1 MHz, 3V, 25Ã‚Â°C for ATmega32L
â€œ Active: 1.1 mA
â€œ Idle Mode: 0.35 mA
â€œ Power-down Mode: < 1 Ã‚ÂµA
ADC in ATmega32:
The ATmega32 features a 10-bit successive approximation ADC. The ADC is connected to an 8-channel Analog Multiplexer which allows 8 single-ended voltage inputs constructed from the pins of Port A. The single-ended voltage inputs refer to 0V (GND). The device also supports 16 differential voltage input combinations. Two of the differential inputs (ADC1, ADC0 and ADC3, ADC2) are equipped with a programmable gain stage, providing amplification steps of 0 dB (1x), 20 dB (10x), or 46 dB (200x) on the differential input voltage before the A/D conversion. Seven differential analog input channels share a common negative terminal (ADC1), while any other ADC input can be selected as the positive input terminal. If 1x or 10x gain is used, 8-bit resolution can be expected. If 200x gain is used, 7-bit resolution can be expected.
The ADC also contains a Sample and Hold circuit which ensures that the input voltage to the ADC is held at a constant level during conversion.
Features of ADC:
Â¢ 10-bit Resolution
Â¢ 0.5 LSB Integral Non-linearity
Â¢ Ã‚Â±2 LSB Absolute Accuracy
Â¢ 13 - 260 Ã‚Âµs Conversion Time
Â¢ Up to 15 kSPS at Maximum Resolution
Â¢ 8 Multiplexed Single Ended Input Channels
Â¢ 7 Differential Input Channels
Â¢ 2 Differential Input Channels with Optional Gain of 10x and 200x
Â¢ Optional Left adjustment for ADC Result Readout
Â¢ 0 - VCC ADC Input Voltage Range
Â¢ Selectable 2.56V ADC Reference Voltage
Â¢ Free Running or Single Conversion Mode
Â¢ ADC Start Conversion by Auto Triggering on Interrupt Sources
Â¢ Interrupt on ADC Conversion Complete
Â¢ Sleep Mode Noise Canceler
Light Rover has two modes of operation: calibration, and follow. These modes are controlled by the main state machine. This organization, combined with the need for timed motor, sensor, and LED control naturally lead to a timed based scheduler program. Only one ISR is necessary - Timer0 Clear on Compare Match, which interrupts every 1 ms and updates the timers used in the program.
The code will initialize various values, state variables, as well as Timer0 and the ADC upon booting. All these initializations are wrapped in the function initialize. When the initializations are complete, the code falls into the main while loop, where it stays for the remainder of the execution. Light Rover's first action is to begin in calibration mode, where it will attempt to adjust to its surroundings.
As previously mentioned, when the boot process concludes it enters Calibration Mode. This mode has three states: CALIB_INIT, CALIB_CHECK, and CALIB_DONE, and the state changes at 1.5 second intervals. Typically we begin in state CALIB_INIT to take an initial sensor reading and change to state CALIB_CHECK. 1.5 seconds later, in CALIB_CHECK, we take another sensor reading and compare it with the value previously obtained in CALIB_INIT. If the two results are deemed equivalent, the threshold value is calculated. We calculate the threshold light intensity to be 7% greater than the measured light. This requires a floating point multiply, which we are able to do because this mode is not time critical, and the states have a long 1.5 second interval. The read and comparison cycle is done first for the left sensor, then for the right; with LED's indicating the sensor. If the comparison fails (if there is a flickering light in the area, for example) then a retry counter is incremented and the process begins over again. However, if there are more than three consecutive calibration failures, the default threshold values are loaded and the program falls into Follow Mode.
Follow Mode is the major operating mode. The sensors are handled by the function sensors which output a result (DETECTED_BOTH, DETECTED_LEFT, DETECTED_RIGHT, DETECTED_NONE). Function motorControl will take in the result and send the control to the appropriate motor.
We can use two ADC channels (channel 0 for left, and channel 1 for right). Because it is not possible to perform two ADC conversions simultaneously, we take a reading and compare it with the previous reading of the opposing sensor. For example, if we were to read the left sensor, we would compare it with the right sensor's value taken from the previous cycle. The actual comparison is done by helper function compare. compare will check if the signal is above the threshold level then check to see if one reading is significantly greater than the opposite sensor's reading
This is our attempt to use light as a source to drive our application. The Light Rover can be useful in applications where human beings are unable to move. However, the Light Rover can be used to perform various tasks that are otherwise, tedious and time- consuming for the human being. Some of such applications are:-
The Light Rover can be used to carry and deliver boxes that are widely spread over a spacious factory godown. The controller just has to flash the light of the concerned container. Then the Rover will pick, carry and deliver the requested container to the control center.
Pipeline Flow Detector:
Sometimes, pipelines that are used to carry water in the city, or crude oil to refinery suffer a crack, they need to be repaired. The Light Rover can be handy in situations, since, it can easily follow light coming from the crack and trace back the location of the same to center while inside the pipeline.
The laborers that work to mend the steel containers on the harbor require toolkit. There is only a couple of feet space for them to carry the toolkit. In such cases, the worker can flash light of the Light Rover that is equipped with toolkit and get his tool automatically.
Â¢ The robot will turn towards the light source and move forward following it.
Â¢ The robot can reach to the places where a man cannot reach (under the ground, inside pipelines, etc.)
Â¢ The robot can be easily controlled just by flashing light at its front panel with the help of battery or any light source.
Â¢ Because of the use of stepper motors, the robot follows the light source accurately by turning in appropriate angle according to the deviation in the location of light source.
Â¢ The robot is applicable only for dedicated application.
Â¢ The robot cannot operate efficiently when there is a variable light in the surrounding, or when there are more than one moving light sources.
Â¢ The robot cannot work when the light falling on it is cut due down to some obstacle in its path.
The robot can be upgraded by..
Â¢ Using sensors for detecting obstacle ahead of it in order to avoid light being cut down by it. We can use IR LEDs & detectors for it.
Â¢ Using two more sensors at the rear panel of it so that the location of the source can be identified immediately & thus followed even if the light source moves itself rapidly to the backside of the robot.
Â¢ Using a remote control kit to control it by using remote also, so that we can also operate it as a general purpose robot (turning off the robot from light following mode.)
Â¢ The same design can also be implemented in boats, UAVs & other vehicles.
Index Description Qty
1 bipolar stepper motor 2
2 CDS-T08 Photocell 2
3 Atmel MEGA32 1
4 Prototype Board 1
5 Large solder board 1
6 H-bridge IC 2
7 Breadboard 1
8 NPN transistor, diode, resistor, capacitor ~
9 Wheels, rods, plastic box ~
1. Douglas W. Jones, "Control of Stepping Motors,"
2. ATmega32 Manual downloaded from
3. Jameco Part Number 163395 Datasheet,
4. ATmega32 development board manual v 1.0
5. Information and Instruction Manual for BiStepA06 Stepper Motor Controller
By Peter Norberg Consulting, Inc.
Table of contents
1. Introduction Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦.Â¦Â¦05
2. Block diagram & its descriptionÂ¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦..06
3. Hardware design
3.1 bipolar stepper motorÂ¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦....08
3.2 half H-bridgeÂ¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦.....09
3.3 CDST08 photocellÂ¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦..Â¦Â¦Â¦..Â¦.11
3.4 Light sensing circuitÂ¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦.Â¦.12
3.5 ATmega32 microcontrollerÂ¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦..Â¦.13
4. Program designÂ¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦..Â¦..18
8. Future scopeÂ¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦...Â¦Â¦Â¦Â¦Â¦.Â¦.21
9. List of componentsÂ¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦Â¦...Â¦...22