You are on page 1of 3

construction

Automatic Car Parking Space


Management System

mar
sunil ku

HiMAnSHu SHArMA
ar parking lots in buildings are
usually managed manually
with manned kiosks that allow the cars into the parking lot based
on the space available. These manual
control systems are now giving way to
automated car parking systems, which
are cost-effective and also reduce waiting time for cars. Automated car parking systems are mostly controlled by a
microcontroller.
Presented here is a microcontrollerbased car parking space management
system designed for a parking lot
with parking capacity of a hundred
cars. It does all the required work like
automatic counting, and opening and
closing of the gates without human
intervention.
The boom barriers at the gates

Fig. 1: Block diagram of automatic car parking space management system

can be powered by electric motors or


hydraulic system controlled through
a microcontroller. When the parking

space is full, the gate barrier does not


open and cars cannot enter the parking lot.

Fig. 2: Circuit for automatic car parking space management system

104

March 2012 | ElEctronics For You

www.EFYMag.coM

construction
Circuit description
Fig. 1 shows the block diagram of the automatic car parking space management
system. The circuit (shown in Fig. 2) consists of a microcontroller (AT89C51), an
LCD for displaying the number of parking spaces available, two infrared (IR)
LEDs as IR transmitters (TX1 and TX2),
two phototransistors (RX1 and RX2) as
sensors, voltage regulator IC 7805 (IC2)
and a few discrete components.
Microcontroller AT89C51 (IC1) is
at the heart of the system. It is an 8-bit
microcontroller with 4 kB of Flash
programmable and erasable read-only
memory (PEROM), 128 bytes of RAM,
32 input/output (I/O) lines, two 16-bit
timers/counters, a ive-vector two-level interrupt architecture, a full-duplex
serial port, on-chip oscillator and clock
circuitry.
Power-on reset for the microcontroller is provided by the combination
of resistor R2 and capacitor C3. Switch
S1 is used for
manual reset. A
11.0592MHz crystal along with two
22pF capacitors
provides the basic
clock frequency to
Fig. 3: Pin
microcontroller
conigurations of
AT89C51.
7805 and BC337
Parts List
Semiconductors:
IC1
IC2
T1, T2
T3
D1-D5
TX1, TX2
LED1, LED2
LCD

AT89C51 microcontroller
7805, 5V regulator
L14F1 photo-transistor
BC337 npn transistor
1N4007 rectiier diode
IR LED
5mm LED
16-character2-line LCD

Resistors (all -watt, 5% carbon):


R1
- 470-ohm
R2-R5
- 10-kilo-ohm
R6, R7
- 56-ohm
R8
- 2.2-kilo-ohm
R9
- 1-kilo-ohm
R10
- 100-ohm
VR1
- 10-kilo-ohm
Capacitors:
C1
C2
C3
C4, C5
Miscellaneous:
X1
S1
XTAL
RL1

1000F, 35V electrolytic


0.1F ceramic disk
10F, 16V electrolytic
22pF ceramic disk

- 230V AC primary to 12V,


500mA secondary
transformer
- Push-to-on tactile switch
- 11.0592MHz crystal
- 12V, 1 C/O relay

www.EFYMag.coM

Fig. 4: An actual-size, single-side PCB for the automatic car parking space management system

Fig. 5: Component layout for the PCB

Data pins D0 through D7 of the


LCD are connected to port pins P0.0
through P0.7 of the microcontroller. The
control pins of the LCDregister-select
(RS), read/write (R/W) and enable
(E)are connected to port pins P2.5,
P2.6 and P2.7 of the microcontroller,
respectively. Preset VR1 is connected
to pin 3 of the LCD for contrast control.
IR LED1 (TX1) and IR LED2 (TX2)
continuously transmit infrared signal,
which are received by photo-transistors
T1 and T2. Photo-transistors T1 and T2
drive into saturation and so their collectors are in low states. The collectors
of photo-transistors T1 and T2 are connected to the microcontrollers port pins
P1.0 and P1.1, respectively.
When the infrared signal is interrupted by a car, T1 and T2 stop
conducting, providing a high signal
to port pins P1.0 and P1.1 of the microcontroller, respectively, indicating the
presence of a vehicle between the IR
transmitter-receiver pair. Port pin P3.7

of the microcontroller is used to control the barrier gates arm. When port
pin P3.7 is high, it drives transistor T3
(IC BC337) into saturation. Relay RL1
energises to lift the barrier arm up and
allow the car inside the parking area.
Diode D5 connected across relay
RL1 acts as a free-wheeling diode.
To derive the power supply for the
circuit, the 230V AC mains is stepped
down by transformer X1 to deliver a
secondary output of 12V, 500mA. The
transformer output is rectiied by a
full-wave rectiier comprising diodes
D1 through D4, iltered by capacitor
C1 and regulated by IC 7805. Capacitor C2 bypasses the ripples present in
the regulated supply. LED1 acts as the
power indicator and R1 limits the current through LED1. Fig. 3 shows pin
coniguration of ICs 7805 and BC337.

Construction
An actual-size, single-side PCB for the
microcontroller-based automatic car
ElEctronics For You | March 2012

105

construction
parking space management system is
shown in Fig. 4 and its component layout
in Fig. 5. Assemble the circuit on a PCB
as it minimises time and assembly errors.
Carefully assemble the components and
double-check for any overlooked error.
Use IC base for the microcontroller.
Before inserting the IC, check the supply voltage. Orient the infrared LEDs
and photo-transistors such that these
directly face each other. House the
photo-transistors in suitable enclosures
to protect these from ambient light. Set
contrast-control VR1 for proper text
display on the LCD.

Functioning
One IR transmitter-receiver pair (TX1
and RX1) is mounted on walls before
the entry barrier gate (say, IN) and the

other transmitter-receiver pair (TX2


and RX2) on walls before the exit barrier (as shown in Fig. 1). The transmitter and receiver should be mounted
about two metres apart.
As the parking lot has the capacity
of a hundred cars, initially, the LCD
shows 100, indicating that the parking
lot has space available for a hundred
cars. When a car comes to interrupt the
IR signal between transmitter TX1 and
receiver RX1, the barrier opens and car
is allowed inside the parking lot. The
capacity count now decrements by one
and the LCD shows 99 along with
welcome message.
When a car leaves the parking lot
to intercept the infrared signal between
transmitter TX2 and receiver RX2, the
exit gate opens and the LCD shows

Bye-bye message. The microcontroller


updates the available space by incrementing the capacity counter by 1.
The number of parking spaces available is displayed on the LCD.

Software
The software for the microcontrollerbased parking system is written in
C language and compiled using Keil
Vision4 compiler. The generated hex
code is burnt into the microcontroller
using a suitable programmer.
EFY note. The source code of this
article is available on www.efymag.
com website.
The author is a B.Tech in electronics & communications engineering. He is a product developer at
Geotran, Uttarakhand. His interests include product designing and software programming

parkspace.c
#include<reg51.h>
#deine LCD P0
sbit rs = P2^5;
sbit rw = P2^6;
sbit en = P2^7;
sbit IN_COMING = P1^0;
sbit OUT_GOING = P1^1;
sbit POL = P3^7;
char z;
int TOTAL_CAR;
void MSDelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}
void lcdcmd(unsigned char value)
{
LCD = value;
rs = 0;
rw = 0;
en = 1;
MSDelay(1);
en = 0;
return;
}
void lcdwrt(unsigned char value)
{
LCD = value;
rs = 1;
rw = 0;
en = 1;
MSDelay(1);
en = 0;
return;
}
void LCD_INI()
{
lcdcmd(0x38);
MSDelay(1);
lcdcmd(0x01);
MSDelay(1);
lcdcmd(0x0C);
MSDelay(1);
lcdcmd(0x14);
MSDelay(1);
lcdcmd(0x80);
MSDelay(1);
}
void ADC(unsigned int value)
{
unsigned char x,d1,d2,d3;
x = value / 10;
d1 = value % 10;
d2 = x % 10;
d3 = x / 10;
lcdcmd(0xCA);
lcdwrt(d3 | 0x30);
lcdwrt(d2 | 0x30);
lcdwrt(d1 | 0x30);
return;
}
void main(void)

106

March 2012 | ElEctronics For You

{
const char code str1[] = WELCOME
TO
CAR;
const char code str2[] = PARKING WATCHER;
const char code str3[] = SCANNING WHOS
COMING AND GOING;
const char code str4[] = No. LEFT:;
const char code str5[] = Welcome ------>;
const char code str6[] = Bye Bye <------;
const char code str7[] = ------FULL-----;
P0
= 0xFF;
P1
= 0xFF;
P2
= 0xFF;
P3
= 0xFF;
IE
= 0x00;
LCD_INI();
TOTAL_CAR=100; //PARKING ALLOWED UPTO 100
CARS
POL=0;
for(z=0; z<17; z++)
{
LCD = str1[z];
lcdwrt(LCD);
}
lcdcmd(0xC0);
MSDelay(1);
for(z=0; z<15; z++)
{
LCD = str2[z];
lcdwrt(LCD);
}
MSDelay(200);
lcdcmd(0x01);
while(1)
{
if(IN_COMING==0 & OUT_GOING==0)
{
lcdcmd(0x80);
MSDelay(1);
for(z=0; z<31; z++)
{
LCD = str3[z];
lcdwrt(LCD);
}
lcdcmd(0x1C);
MSDelay(50);
}
if(IN_COMING==1)
{ //IF CAR IS COMMING
lcdcmd(0x01);
lcdcmd(0x80);
MSDelay(1);
for(z=0; z<17; z++)
{
LCD = str5[z];
lcdwrt(LCD);
}
lcdcmd(0xC0);
MSDelay(1);

}
}

for(z=0; z<9; z++)


{
LCD = str4[z];
lcdwrt(LCD);
}
while(IN_COMING==1)
{
ADC(TOTAL_CAR);
if(TOTAL_CAR>0) POL=1;
else {POL=0;
lcdcmd(0x80);
MSDelay(1);
for(z=0; z<17; z++)
{
LCD = str7[z];
lcdwrt(LCD);
}
}
if(OUT_GOING==1)
{
TOTAL_CAR = TOTAL_CAR-1;
if(TOTAL_CAR<0) TOTAL_CAR=000;
ADC(TOTAL_CAR);
while(OUT_GOING==1);
}
}
}
if(OUT_GOING==1)
{ //IF CAR IS GOING OUT
lcdcmd(0x01);
lcdcmd(0x80);
MSDelay(1);
for(z=0; z<17; z++)
{
LCD = str6[z];
lcdwrt(LCD);
}
lcdcmd(0xC0);
MSDelay(1);
for(z=0; z<9; z++)
{
LCD = str4[z];
lcdwrt(LCD);
}
while(OUT_GOING==1)
{
ADC(TOTAL_CAR);
if(TOTAL_CAR==100) POL=0;
else POL=1;
if(IN_COMING==1)
{
TOTAL_CAR = TOTAL_CAR+1;
if(TOTAL_CAR>100)TOTAL_CAR=100;
ADC(TOTAL_CAR);
while(IN_COMING==1);
}
}
}
POL=0;

www.EFYMag.coM