The
major constituents devised in this project are: AT89C51 microcontroller IC to
control the rest of the blocks and to perform collision detection and
avoidance, 555 timer IC for the sake of triggering the IR LEDs. TSAL 6200 IR
LEDs, used as infrared emitter and TSAL 1738 IR sensor, used to receive the
reflected IR waves.
2.3 TIMER IC
The
555 timer IC has become a mainstay in electronics design. The timer produces a
pulse when a trigger signal is applied to it. The pulse length is determined by
charging and discharging a capacitor connected to the timer. The 555 timer can
operate in a monostable (one-shot) or astable (oscillatory) or time-delay mode.
Here the astable mode of operation is opted for the project. The IC looks as
given in Figure 2.3.
Figure 2.3: 555 Timer Pin Details
As output pin
oscillates from high to low creating a series of output pulses, the duration
for which output stays high is tHIGH=0.67.C.(R1+R2) and the
duration for which it stays low is tLOW= 0.67.C.R2. Then
the frequency for the series of pulses will be (Figure 2.4):
The IR sensor can detect IR
signal of 38 kHz so components has to be rigged in such a way so that the
frequency of the output signal (in turn the IR wave) will be 38 kHz only for
the train of IR pulses get detected accurately.
Figure 2.4: Astable Mode Circuit
2.4 MICROCONTROLLER
The Atmel 89C51 microcontroller
is used for controlling the peripherals and the relevant program is written in
assembly level language. Figure 2.5 shows the pin details of this dual inline
package.
Figure 2.5: AT89C51 Pin Details
CHAPTER III:
HARDWARE & THEORY
The
discussion of hardware and the underlying theory is broadly classified into two
major parts: transmitter section (IR LED and related triggering issues) and
receiver section (IR sensor and microcontroller functionality). The transmitter
section is more or less independent, because it is triggered using 555 timer IC
and only thing to do with this is to tune its frequency to 38 kHz to be exact.
And there onwards its job is to emit IR waves of that frequency.
Comparatively,
the receiver section seems to be a little complicated because it has to do sack
full of jobs and that too with sheer precision: like sensing the reflected IR
wave and then forwarding it to the microcontroller. The microcontroller by
means of duly coded program interprets the data and makes the decision on
behalf of the robotic cart.
3.1 TRANSMITTER SECTION
The IR based
emitter circuit is illustrated in Figure 3.1. Values of R1, R2 and C has to be
such that frequency of the modulated infrared light wave equals 38 kHz (Formula
mentioned in section 2.4 are used for the calculation). Despite of all the
calculation, discrepancies may arise. To avoid that, the 10 KΩ POT has to be
tuned to get the exact value on a CRO first then that resistance value can be
used for the transmitter.
Figure 3.1: Transmitter Section
As we can see in Figure 3.1,
there are three IR LEDs used here one is for any obstacle coming on the right
side another two are for left sided and central object detection.
3.2 RECEIVER SECTION
The receiver circuit is depicted
in Figure 3.2. Two TSOP1738 IR demodulator is used to monitor the three IR LEDs
distinctly. Accordingly the sensor outputs are fed to the Port pins 3.4 and 3.5
(T0 and T1 respectively) of the microcontroller which are then used for
decision making purpose and to control the movement of the robot’s wheels
connected via unipolar stepper motors. Depending upon the sensed data, the
microcontroller notifies the motor’s wheel controller through Port pins 1.0 and
1.1 in the form of an interrupt whether a turn has to be taken or not. In case
of a turn, it notifies the motor controller about the turn’s direction by
raising the respective Port 1 pin high. Accordingly the motor’s controller will
adjust the stepper motor’s rotation to perform a turn in the correct direction
to avoid the probable collision.
Figure 3.2: Receiver Section
CHAPTER IV: ALGORITHM &
CODING
This chapter highlights the
algorithm of sensing any obstacle coming on the way and making the cart’s wheel
to take a turn for the sake of avoiding collision with that obstacle along with
the assembly level code to implement the algorithm.
4.1 FLOW DIAGRAM
4.2 CALCULATION AND PRESUMES
We know that the operating
frequency of TSOP1738 is 38 kHz. So, the time period for a single pulse will be
its inverse: T=1/f =0.026315789 ms.
Let there be 80 such pulses in a single burst, bringing the burst length to B =80 x T=2.105263158 ms.
In the presence of an obstacle there will be pulses at the detector output, let
the pulse detection threshold be 50 pulses per burst. So, 51 or more pulses in
a single burst will invoke a turning action. Considering the fact that due to
the presence of noise in the surroundings there will be around 30 pulses
received by the detector for every burst. There will be an inter burst gap of
40 cycles. This concept holds good for a single IR sensor. To implement more
than one sensors all we have to do is just to switch from one sensor to another
after every burst (with an inter burst gap obviously) and this operation has to
be performed continuously in a cyclic manner on every IR demodulator.
4.3 CIRCUIT DIAGRAM
The
following circuit diagram comprises both the transmitter and receiver section
along with the power supply module also.
4.4 ASSEMBLY LANGUAGE PROGRAM
The following
code is written for the prototype in the standard assembly programming language
for 8051 series of microcontrollers. This assembly coding conforms to the
design stated above but due to dependency on other module such as the motor
controller, the delay value required for that module to perform turning
operation has to be calculated separately and should be fed to the DELAY
entitled portion for its proper functionality.
ORG
0000H
MOV P1,#00H ; port 1
as output
//for left side obstacle checking//
RPT:
MOV TMOD,#15H ; timer1= timer, timer0= counter
SETB P3.4 ; p3.4=
input for counter 0
MOV TL0,#00H ; initialize
counter
MOV TH0,#00H ;
MOV TL1,#6BH ; time delay
for one burst
MOV TH1,#0F8H ;
SETB TR1 ; start
timer 1
BACK1:
JNB TF1,BACK1 ; check for timer 1 overflow
CLR TF1
CLR TR1 ;
stop timer 1
MOV A,TL0 ; take
count value and do collision
CLR C ;
check for left side obstacle
SUBB A,#1FH ;
JNB PSW.2,ROTRYT ;
CLR PSW.2 ;
ACALL DELAY1 ; inter burst
delay
//for right side obstacle checking//
MOV TMOD,#51H ; timer0= timer,
timer1= counter
SETB P3.5 ; p3.5=
input for counter 1
MOV TL1,#00H ; initialize
counter
MOV TH1,#00H ;
MOV TL0,#6BH ; time delay
for one burst
MOV TH0,#0F8H ;
SETB TR0 ; start
timer 0
BACK2:
JNB TF0,BACK2 ; check for timer 0 overflow
CLR TF0 ;
CLR TR0 ;
stop timer 0
MOV A,TL1 ; take
count value and do collision
CLR C ;
check for right side obstacle
SUBB A,#1FH ;
JNB PSW.2,ROTLFT ;
CLR PSW.2 ;
ACALL DELAY2 ; inter burst
delay
SJMP RPT ; repeat
the same
END
//delay for left side obstacle case//
DELAY1: MOV TMOD,#10H ; inter burst delay for left check
MOV TL1,#35H ; it is
half of the burst length
MOV TH1,#0FCH ;
SETB TR1 ;
BACK3:
JNB TF1,BACK3 ;
CLR TF1 ;
CLR TR1 ;
RET
//delay for right side obstacle case//
DELAY2:
MOV TMOD,#01H ; inter burst
delay for right check
MOV TL0,#35H ; it is
half of the burst length
MOV TH0,#0FCH ;
SETB TR0 ;
BACK4:
JNB TF0,BACK4 ;
CLR TF0 ;
CLR TR0 ;
RET
//right turn for left side
obstacle//
ROTRYT:
SETB P1.0 ; if
obstacle on left
ACALL DELAY ; raise p1.0 high
CLR P1.0 ;
to perform
RET ; right turn
//left turn for right side obstacle//
ROTLFT:
SETB P1.1 ; if
obstacle on left
ACALL DELAY ; raise p1.1 high
CLR P1.1 ;
to perform
RET ; left turn
//delay for motor controller to do its
job//
DELAY:
MOV R1,#IMM_VAL1 ; let the motor
controller
HERE1:
MOV R2,#IMM_VAL2 ; module do its job
HERE2: DJNZ
R2,HERE2 ;
delay value is calculated
DJNZ R1,HERE1 ; on the
basis of that code
RET