Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1
INTRODUCTION
1
CHAPTER 2
BLOCK DIAGRAM
2
IR Transmitter and receiver:
Controller:
Motor Driver:
Relay:
Used to run the vehicle as for the requirement. These are directly
connected to the back wheels of the vehicle for controlling purpose.
Software used:
3
Assembly level programming of AT8052 microcontroller.
CHAPTER 3
HARDWARE DESCRIPTION
Introduction to Microcontroller:
4
inexpensive as possible. Microcontroller chips are manufactured with
powerful capabilities and the end user determines exactly how the
device will function. Often this makes a dramatic difference in the cost
and complexity of a particular design.
5
flexible and cost-effective solution to many embedded control
applications.
6
Fig 3.2: Architecture of ATMEL 89C52
7
The AT89C52 provides the following standard features: 8K bytes
of Flash, 256 bytes of RAM, 32 I/O lines, three 16-bit timer/counters, a
six-vector two-level interrupt architecture, a full-duplex serial port, on-
chip oscillator, and clock circuitry. In addition, the AT89C52 is designed
with static logic for operation down to zero frequency and supports two
software selectable power saving modes. The Idle Mode stops the CPU
while allowing the RAM, timer/counters, serial port, and interrupt
system to continue functioning. The Power-down mode saves the RAM
contents but freezes the oscillator, disabling all other chip functions
until the next hardware reset.
Pin Description:
VCC:
Supply voltage, 6V DC.
GND:
Ground, 0V DC.
Port 0:
8
Port 1:
Port 1 is an 8-bit bi-directional I/O port with internal pull ups. The
Port 1 output buffers can sink/source four TTL inputs. When 1s are
written to Port 1 pins, they are pulled high by the internal pull ups and
can be used as inputs. As inputs, Port 1 pins that are externally being
pulled low will source current (IIL) because of the internal pull ups. In
addition, P1.0 and P1.1 can be configured to be the timer/counter 2
external count input (P1.0/T2) and the timer/counter 2 trigger input
(P1.1/T2EX), respectively, as shown in the table 3.1. Port 1 also
receives the low-order address bytes during Flash programming and
verification.
Port 2:
Port 2 is an 8-bit bi-directional I/O port with internal pull ups. The
Port 2 output buffers can sink/source four TTL inputs. When 1s are
written to Port 2 pins, they are pulled high by the internal pull ups and
can be used as inputs. As inputs, Port 2 pins that are externally being
pulled low will source current (IIL) because of the internal pull ups.
9
Port 2 emits the high-order address byte during fetches from
external program memory and during accesses to external data
memory that uses 16-bit addresses (MOVX @ DPTR). In this
application, Port 2 uses strong internal pull-ups when emitting 1s.
During accesses to external data memory that uses 8-bit addresses
(MOVX @ RI), Port 2 emits the contents of the P2 Special Function
Register. Port 2 also receives the high-order address bits and some
control signals during Flash programming and verification.
Port 3:
Port 3 is an 8-bit bi-directional I/O port with internal pull ups. The
Port 3 output buffers can sink/source four TTL inputs. When 1s are
written to Port 3 pins, they are pulled high by the internal pull ups and
can be used as inputs. As inputs, Port 3 pins that are externally being
pulled low will source current (IIL) because of the pull ups.
10
RST:
Reset input. A high on this pin for two machine cycles while the
oscillator is running resets the device.
ALE/PROG:
Address Latch Enable is an output pulse for latching the low byte
of the address during accesses to external memory. This pin is also the
program pulse input (PROG) during Flash programming.
In normal operation, ALE is emitted at a constant rate of 1/6 the
oscillator frequency and may be used for external timing or clocking
purposes. Note, however, that one ALE pulse is skipped during each
access to external data memory.
If desired, ALE operation can be disabled by setting bit 0 of SFR
location 8EH. With the bit set, ALE is active only during a MOVX or
MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the
ALE-disable bit has no effect if the microcontroller is in external
execution mode.
PSEN:
EA/VPP:
11
1 is programmed, EA will be internally latched on reset. EA should be
strapped to VCC for internal program executions.
XTAL1:
XTAL2:
12
Table 3.3: AT89C52 SFR Map and Reset Values
13
Timer 2 Registers:
Interrupt Registers:
14
Data Memory:
Timer 0 and 1:
15
Timer 2:
16
Capture Mode:
17
Figure 3.4 shows Timer 2 automatically counting up when DCEN
= 0. In this mode, two options are selected by bit EXEN2 in T2CON. If
EXEN2 = 0, Timer 2 counts up to 0FFFFH and then sets the TF2 bit
upon overflow. The overflow also causes the timer registers to be
reloaded with the 16-bit value in RCAP2H and RCAP2L. The values in
Timer in Capture ModeRCAP2H and RCAP2L are preset by software. If
EXEN2 = 1, a 16-bit reload can be triggered either by an overflow or by
a 1-to-0 transition at external input T2EX. This transition also sets the
EXF2 bit. Both the TF2 and EXF2 bits can generate an interrupt if
enabled. Setting the DCEN bit enables Timer 2 to count up or down, as
shown in Figure3.5. In this mode, the T2EX pin controls the direction of
the count. Logic 1 at T2EX makes Timer 2 count up. The timer will
overflow at 0FFFFH and set the TF2 bit. This overflow also causes the
16-bit value in RCAP2H and RCAP2L to be reloaded into the timer
registers, TH2 and TL2, respectively.
18
Logic 0 at T2EX makes Timer 2 count down. The timer
underflows when TH2 and TL2 equal the values stored in RCAP2H and
RCAP2L. The underflow sets the TF2 bit and causes 0FFFFH to be
reloaded into the timer registers. The EXF2 bit toggles whenever Timer
2 overflows or underflows and can be used as a 17th bit of resolution.
In this operating mode, EXF2 does not flag an interrupt.
19
Timer 2 is selected as the baud rate generator by setting TCLK
and/or RCLK in T2CON (Table 3.4). Note that the baud rates for
transmit and receive can be different if Timer 2 is used for the receiver
or transmitter and Timer 1 is used for the other function. Setting RCLK
and/or TCLK puts Timer 2 into its baud rate generator mode, as shown
in Figure 3.6.
20
(CP/T2 = 0). The timer operation is different for Timer 2 when it is used
as a baud rate generator.
21
Oscillator characteristics:
XTAL1 and XTAL2 are the input and output, respectively. Either a
quartz crystal or ceramic resonator may be used. To drive the device
from an external clock source, XTAL2 should be left unconnected while
XTAL1 is driven, as shown in Figure 3.7. There are no requirements on
the duty cycle of the external clock signal, since the input to the
internal clocking circuitry is through a divide-by-two flip-flop, but
minimum and maximum voltage high and low time specifications must
be observed.
Idle Mode:
In idle mode, the CPU puts itself to sleep while all the on chip
peripherals remain active. The mode is invoked by software. The
content of the on-chip RAM and all the special functions registers
22
remain unchanged during this mode. The idle mode can be terminated
by any enabled interrupt or by a hardware reset.
Power-down Mode:
23
Table 3.7: Status of external pins during idle and power down
modes
+5V
1K
IR
Fig 3.8: Connection from controller to sensors & motor driver
24
space is available and the remaining are to check whether or not the
free space is available.
25
If in case, after following the path given and the car receives the
signal indicating the availability of the free space, it will go and park in
that particular area using the fixed assembly code for it and after some
delay, using exactly opposite principle used in entry side, the car will
go back to the exit bay of the parking lot and stops at the exit.
3.3 IR transmitter:
Components used:
26
R2 1K POT
R3 1K ohms
RO1 150 ohms
RO2 20 ohms
Capacitor C1, C2 0.1Uf
Design:
Fig. 3.10 shows an astable 555 timer circuit. The astable 555
timer circuit outputs a series of pulses.
27
When the circuit is first turned on, the discharge pin is
disconnected from ground and output pin is set high because the
trigger pin is below 33% Vcc Voltage. The capacitor, C, starts to charge
through resistors R1 and R2. The threshold pin is used to detect when
the voltage across the capacitor reaches 66.6% Vcc voltage. When the
voltage across the capacitor reaches 66.6% Vcc voltage, the output pin
is set low and the discharge pin is connected back to ground. When the
discharge pin is connected back to ground, the capacitor starts
discharging though resistor R2. When the voltage across the capacitor
reaches 33.3% Vcc voltage, the cycle repeats and creates a series of
output pulses. An astable circuit triggers from previous output pulse
whereas a monostable circuit requires an externally applied trigger.
The duration the output pin stays low, tLOW, is given below:
28
pulse accumulator pin and create a seconds counter within the
microcontroller. The pulse accumulator will be covered in later in the
course.)
• Turn on and off an actuator at set time intervals for a fixed duration.
Working:
3.4 IR receiver:
29
Fig 3.11: Circuit Diagram of IR receiver
Components used:
30
Fig. 3.12 shows a monostable 555 timer circuit. The monostable
circuit outputs one pulse for each high to low transition of the trigger
pin.
31
capacity of the capacitor, C, and resistance, R. The length of the output
pulse, is:
Working:
32
When IR transmitter and receiver are not in line of sight,
transistor at the receiver side is turned on and a logic low signal is
applied to pin2 of timer555 (pin2 is grounded). It will trigger timer555
and the output at the receiver side will be high (LED is ON).
33
Figure 3.13: DC Motor Basics
34
single-throw switch. The direction switches at the top of Figure select
one of two connections, so they are double-throw switches.
35
Figure 3.14: Motor Controllers Using Manual Switches
3.6 RELAY (DPDT):
36
Fig 3.15: Schematic representation of relay connection
37
Fig 3.17: Relay Circuit
The relay coil is connected between the supply rail (+V) and the
input signal. This acts as load on the driver. When the input signal
coming into the relay subsystem is low, a potential difference across
the relay coil causes current to flow. It is this flow of current that
causes contacts to switch.
Connection from motor driver to the DPDT relay is as given in
fig.3.18. Output from the two points RLY1 and RLY1 are connected to
the same points of fig. 3.15. The remaining two points are connected
to same sets of another relay.
38
Fig 3.18: Connection from Motor driver to DPDT Relay
39
CHAPTER 4
SOFTWARE DESCRIPTION
Keil software is the leading vendor for 8/16 bit development tools
(ranked at first position in the 2004 embedded market study of the
embedded system and EE times magazine). Keil software is
represented worldwide in more than 40 countries. Since market
introduction is in 1988, the keil C51 compiler is the defacto industry
standard and supports more than 500 current 8051 device variants.
40
2. An execution profiler that measures time spent in each function,
source line and assembler instruction. Now developers can find
exactly where the program spends the most time.
41
Flow chart for Right subroutine:
42
Flow chart for Left subroutine:
43
Flow chart for Park subroutine:
44
CHAPTER 5
TESTING AND RESULT
Initially when the car is left at the entrance of the parking area, it
checks each and every parking area. The car will be kept in a fixed
track using the path following principle over a black path. The parking
areas which come near to the entrance will have higher priority. If a
parking space is free then the car receives a signal from the IR
transmitter, goes and parks over there by following a fixed subroutine.
After some delay, it will come back using exactly opposite routine
which has been followed while parking the car and goes to exit path.
45
CHAPTER 6
APPLICATION, ADVANTAGES AND
LIMITATIONS
6.2 Advantages:
46
6.3 Limitations:
47
CHAPTER 7
SCOPE FOR FUTURE IMPROVEMENTS
48
CHAPTER 8
CONCLUSION
This is a general purpose car and one can implement this project
on any car. By implementing this project, one can save the work and
time of the driver/owner of the vehicle. If the driver wants to park the
vehicle manually and does not want to use this system, then it can
switched off. This project will work only if both the parking lot as well
as the car has been mounted with required set of sensors and the
driving circuitry.
Thus the head ache of searching free space and the time of the
driver of the vehicle will be saved to the great extent by using this
project.
49
50