You are on page 1of 15

Building Low Cost Autonomous Robots

Building Low Cost Autonomous Robots


Chapter 2: ELECTRONICS FOR ROBOT

Sachitanand Malewar
Director, NEX Robotics
http://www.nex-robotics.com/sachitanand.php

www.nex-robotics.com 1
Building Low Cost Autonomous Robots
CHAPTER 2

ELECTRONICS FOR ROBOT


Circuit Board Assembly

Fitting PCB Board on the chassis:

In the previous chapter we mentioned that use of Glass epoxy general purpose PCB. This
board is very sturdy but almost twice expensive as compared to paper phonlic PCB. We
must use glass epoxy PCB because while assembling circuit board it will go through high
amount of stress. Also copper pads on this board won’t come as easily as paper phonlic
PCB.

First measure how much space is available on the robot for PCB. In this case it is 14cm X
14cm. First mark square on the PCB with marker pen and cut the board using hexa blade.
Make sure that you draw the cutting line on the holes and not in between the holes as
holes will act as guide line for cutting in straight line. Fix this board in wise. Place few
layers of paper between PCB’s copper side and wise to protect the copper pads. While
cutting make sure that your hexa blade is not making more than 10 degrees of angle. This
will result in smooth, straight and well finished cut. After cutting make PCB’s edges
smooth using file.

Figure 2.1: Cutting general purpose glass epoxy PCB

While cutting glass epoxy PCB switch off fan and keep your nose away from the
PCB. Small particles coming out of PCB are very hazardous to lungs.
Avoid hand contact with the raw PCB edges as particles can cause allergic
reaction.

www.nex-robotics.com 2
Building Low Cost Autonomous Robots

Figure 2.2: Allergic reaction and swelling on finger because of glass epoxy PCB dust

Figure 2.3: Marking for PCB mounting

Now place PCB board on robot chassis and mark suitable points for holes. Drill holes
using 3mm or 1/8inch drill bit. Place PCB board on robot chassis and mark holes on the
chassis. Drill holes on the chassis and mount 15mm studs using 6mm Philips bolts.

Figure 2.4: PCB mounted on the robot using 15mm studs

www.nex-robotics.com 3
Building Low Cost Autonomous Robots

Figure 2.5: Complete circuit diagram of the robot

www.nex-robotics.com 4
Building Low Cost Autonomous Robots
Circuit Assembly:

We are going to divide circuit in four sections


1. Power management system
2. Motion control
3. Microcontroller and other subsystems
4. White line sensors

1. Power management system


It is the most important system on the robot. Performance of your robot will be heavily
dependent on this block

Expectations from power management system:


• In socket battery charging (No need to unplug battery for charging)
• Connector for battery
• On / off switch with mutual exclusion between battery charging and power on /
off. (Robot should either remain in battery charge mode or power should be on.
At any instant robot should not able to turn on when battery is being charged.
• Battery charge indicator LED
• Protection from reverse polarity
• Fuse protection
• Fuse blown audio visual indication
• Power indication
• Battery voltage sensing
• Distinct separation between supply for motor and supply for logic system
• Capacitor bank for surge protection in motor supply and logic supply
• Generation of 5V, 1Amp supply for logic system

Figure 2.6: Circuit diagram of the power management system

In the above circuit diagram 10 pin FRC right angled connector is use for battery
charging and 4 pin relimate connector is used for battery connection. If you see carefully
each wire is connected to at least two pins of the connectors. This done in order to add
redundancy in the connections. LED9 will glow when battery charger is connected. As
battery charger will have pins 1, 2,9,10 shorted together. These are standard 5mm LEDs
which are rated at 5mA of current. Approximately 1.5 volts will be dissipated across
LED. Our battery will be requiring 13.8V charging voltage so minimum allowed series
resistor will be (13.80-1.5) / 5mA = 2.46Kohms. At 5mA current LED will glow so

www.nex-robotics.com 5
Building Low Cost Autonomous Robots
bright that you will not be able to see PCB properly for debugging so we have used
3.3Kohm resistor.

Switch S1 is a single pole double throw switch which is used for switching between
power on and battery charging. This switch makes sure that you can either charge battery
or switch on the robot but you can not do both at the same time. This is because if battery
is charged at the same time when robot is on robot will consume all the charging current
and also battery will also get discharged. Every time 12V lead acid battery goes below
10.8V it looses its 25% power storage capacity permanently. This switch will prevent
accidentally turning on for robot while battery is being charged.

Diode D1 and D2 are standard 1N4007 diodes. These diodes will protect further circuits
especially buzzer_1 from reverse polarity. These diodes are rated at 1Amp each. Robot
will consume maximum 900mA at peak load. If you buy made in China diodes ☺ they
will barely take 650 to 750mA and will become very hot. This is why everywhere we
have connected these diodes in parallel.

Fuse of 5 Amp gives protection from short circuit. Lead acid battery of small current
rating such as 0.8Ah can pump tens of Amps of current when shorted. Hence to protect
robot from catching fire fuse must be used. It gives you second chance to correct your
mistake. If fuse is blown all the current will pass through buzzer 1 and LED7. This will
give audio visual warning. LED10 will indicate power is coming till this stage.

Resistor R5 and R6 forms voltage divider bias for battery sensing. When battery is fully
charged at 13.8V voltage coming at this point will be 13.8V-0.65V = 13.15 because of
diodes D1 and D2. Battery voltage will be sensed by analog to digital converter (ADC) of
microcontroller. ADC can take up maximum of 5V.

Resistors R5 and R6 forms voltage divider and gives out voltage proportional to battery
voltage but scaled down by 1/3. In the robot because of frequent turning on and off of
motors current continuously fluctuates. To reduce the effect of this fluctuation on the
battery voltage sensing, capacitors C7 and C8 are connected in parallel to the R5 and R6.
Diodes D3 and D4 separates supply for the motors. Capacitor C9 acts as a very small
battery. Motor we are using takes about 250mA of starting current but when it is in
motion it roughly takes 50mA of current. When motor is suddenly turned on it produces
current surge. At this time capacitor acts as small battery. This improves battery run time
as you can run the battery till its voltage level reaches up to 11.2V instead of 11.8V. D5
separates supply for 5V logic supply. Again capacitor C10 is used to reduce noise and act
as small battery when sudden switching of motors produces current surges.

IC3 (7805) is used as voltage regulator. It is a linear voltage regulator i.e. if your supply
is 12V and output is 5V then 7805 will dissipate 7volts across it. For load current of
1Amp. To provide 5V output 7805 will have to dissipate 7V * 1Amp. = 7Watts of heat.
Hence 7805 must be connected with good heat sink to dissipate all the heat. This heat
sink must be mounted very firmly using bolt as it is very easy to knock off 7805 out of
the PCB when connected with heat sink. Again beware of made in China voltage

www.nex-robotics.com 6
Building Low Cost Autonomous Robots
regulators☺. Buy L7805 of national semiconductor or 7805 of ST microelectronics
which will be most probably made in Morocco. While buying 7805 look at the finishing
of heat sink. If it is shining like stainless steel then probably it is original. This is very
important because fake 7805 have slower response time and will give out 12V surge
before settling down to 5 volts. This will fry your microcontroller and other logic circuit.
Capacitor C11 is used to provide better noise suppression. LED6 indicate 5V logic power
status.

Figure 2.7: Assembled PCB up to power management system

2. Motion control:
Motion control circuit takes logic input from the microcontroller and controls motors.

We are using L293D IC for motor control. The L293D has quadruple high-current half-H
drivers. The L293D is designed to provide bidirectional drive currents of up to 600-mA at
voltages from 4.5 V to 36 V. Drivers are enabled in pairs, with drivers 1 and 2 being
enabled by the Enable pin. When an enable input is high (1), the associated drivers are
enabled and their outputs are active and in phase with their inputs.

Additionally the L293D includes the output clamping diodes within the IC for complete
interfacing with inductive loads. Each channel can drive up to 600mA load. Resistance of

www.nex-robotics.com 7
Building Low Cost Autonomous Robots
our motors is about 26 ohms i.e. its short circuit current will be around 0.46Amp which is
below the maximum current limit.

Direction of the motor is controlled by asserting one of the inputs to motor to be high (1)
and the other to be low (0). To move the motor in opposite direction just interchange the
logic applied to the two inputs of the motors. Asserting both inputs to logic high or logic
low will stop the motor.

To control motor velocity we can use pulse width modulation (PWM). To control
velocity we will give PWM input to the L293D’s enable pins.

To control the velocity of the motor, pulse width modulated (PWM) pulses are applied to
enable pins of L293 driver. PWM is the scheme in which the duty cycle of a square wave
output from the microcontroller is varied to provide a varying average DC output. What
actually happens by applying a PWM pulse is that the motor is switched ON and OFF at
a given frequency. In this way, the motor reacts to the time average of the power supply.

Figure 2.8: Velocity control of motor using PWM

www.nex-robotics.com 8
Building Low Cost Autonomous Robots

Figure 2.9: Circuit diagram of motor control circuit

IC1 and IC2 are L293D motor control ICs. IC1 will control left and right side motor. IC2
will control third motor which is used for moving ARM up or down.

IC L293D requires two types of supplies. One is for its logical operation and other is for
driving motors. Pin Vcc1 of IC1 and IC2 is connected to 5V logic supply and Vcc2 is
connected to 12V motor supply. Pin 4, 5, 13, and 14, are connected to ground.

Pins 1A, 2A, 3A, 4A gives direction commands to the IC while pins 1Y, 2Y, 3Y, 4Y
gives output for motor control. IC1 and IC2 have all the connections similar except for
pins 1-2EN and 3-4EN. In the case of IC1, 1-2EN and 3-4EN will be connected to PD4
and PD 5 of microcontroller which can drive left and right motor at independent pulse
width modulation. In the case of IC2, pins 1-2EN and 3-4EN are connected to PD6 and
PD7 out of these pins only PD7 can give PWM output.

LED11 to LED22 are used for displaying logical input given to the L293D from
microcontroller. Motors are connected between 1Y-2Y and 3Y-4Y pins of IC 1 and 2.
C1-C6 are 0.1uF capacitors used for noise suppression. LED1-LED6 are connected in

www.nex-robotics.com 9
Building Low Cost Autonomous Robots
opposite polarity with each other in pairs indicates direction of motor. All these LEDs
make debugging easy.

Figure 2.10: Assembled circuit with motion control and power management

3. Microcontroller and other subsystems

Expectations from microcontroller:


• Should be cheap and easily available in the market.
• Should have analog to digital conversion capability
• At least two PWM output for the motor control
• Easy to program
• Should have lots of I/O pins.

We are going to use ATMEGA16 microcontroller for this robot.


Main features of this microcontroller are:
• Up to 16 MIPS Throughput at 16 MHz
• 16K Bytes of In-System Self-Programmable Flash
• 512 Bytes EEPROM

www.nex-robotics.com 10
Building Low Cost Autonomous Robots
• 1K Byte Internal SRAM
• 32 Programmable I/O Lines
• In-System Programming by On-chip Boot Program
• 8-channel, 10-bit ADC
• Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes
• One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and
Capture
• Four PWM Channels
• Programmable Serial USART
• External and Internal Interrupt Sources

Figure 2.11: Block diagram for microcontroller port

Pin AVCC, AREF and VCC are connected to 5V logic supply and pins AGND and GND
are grounded. 8MHz crystal and two 22pF capacitors forms oscillator circuit. Resistor
R16 and C12 forms power on reset circuit. Port A is used for measuring analog values
from sensors. Port B is used for direction control of two L293D ICs. OC1A and OC1B
(pin PD5 and PD4) are used to control velocity of left and right motor using PWM. In
system programming port (ISP) is connected to MISO, MOSI, SCK and RESET pins.
Pizo buzzer BUZZER_2 is connected to PC3. LCD is interfaced to PortC. Variable
potentiometer R18 is used to control LCD contrast. R19 is used for adjusting backlight of
LCD. Switch S2 is a touch switch which was described in the previous chapter. Buzzer is
driven by NPN transistor BC548. Buzzer is connected to pin PC3 of the microcontroller
through jumper J1. Capacitor C15 is a filter capacitor for noise reduction.

www.nex-robotics.com 11
Building Low Cost Autonomous Robots

Figure 2.12: Completed board

4. White line sensors


White line sensor is the most critical part of the robot. It is basically a light intensity
sensor. It consists of infrared LED and photo diode. Infrared LED illuminates the surface
and photo diode senses the reflected light from the surface. We are using Infrared LED
because ir LED emits light at 940 nanometer and photo diode shows maximum
sensitivity at 940 nanometer wavelength. Before we build this sensor module we have to
build a test sensor to find how far sensor should be placed from the ground? What should
be the values of the resistors etc?

Figure 2.13: White line sensor

www.nex-robotics.com 12
Building Low Cost Autonomous Robots
Above figure shows basic white line sensor. Variable 10K potentiometer R30 is used for
varying current through infrared LED. R29 is used to protect IR led from high current in
case potentiometer is set to zero. Photo diode is connected in reverse bias. 100K
potentiometer R1 is connected in series of photodiode. It is used for varying sensitivity of
the photo diode. So we have three variables to make white line sensor. We can vary IR
LED’s intensity by decreasing series resistance or increase photo diode’s sensitivity by
increasing series resistor or by adjusting distance of sensor from the surface. If photo
diode is more sensitive it is more susceptible to ambient light. So trick is to make photo
diode least sensitive and IR LED set at optimal brightness. To do this we are going to
make a test jig.

Figure 2.14: Test white line sensor

In this line sensor by turning screws we can adjust the sensor height ad by tuning
potentiometers we can adjust light intensity or sensor sensitivity. First set sensor height
same as the caster wheels height so that we can use same size studs for sensor mounting.
After finding appropriate values for series resistors we will build final white line sensor.
After calibration I found that 47K is appropriate value for photo diode and 10K
potentiometer for light intensity adjustment. To follow white line two sensors sufficient
but to detect the node on the white line grid third sensor is required.

Figure 2.15: White line sensor final circuit

www.nex-robotics.com 13
Building Low Cost Autonomous Robots

Figure 2.16: Assembled line sensor

Mounting white line sensor on the robot:

Figure 2.17: Placing white line sensor for marking

Figure 2.18: Mounting studs for sensor

Figure 2.19: Fitting white line sensor

www.nex-robotics.com 14
Building Low Cost Autonomous Robots

Figure 2.20: Final PCB fitting on the robot

Till now we have assembled the circuit. In the next section we are going to fit wires and
start the robot.

www.nex-robotics.com 15

You might also like