<<

University of Science and Technology

Faculty of Engineering

Department of Computer and Electronic Systems Engineering

A Research Submitted in Partial Fulfillment for the Requirements of the B.Sc.(Honors) Degree in Computer and Electronic Systems Engineering

SMART PARKING SYSTEM DESIGN

Prepared by:

Abdeen Yousif Albasher Abdelnabi

Supervised by:

Dr. Mohammed Elnour Abdallah

March-2016 االية

ِب ِب ِب ِب ِب ْس ي ا ِهَّللا ااِهَّلللْس َم ِب ااِهَّللل ي

ااِهَّلللْس َم ُن )1( َم ِهَّلليَم اْسا ُنْسل َمآ )2( َم َم َم

اْساِبْس َم َمآ )3( َم ِهَّللَم ُن اْسا َم َمَي َمآ )4( ﴾

صد االع ي

سورة اال اآلي ت)4-1(

I DEDICATION

To the fountain of patience and optimism and hope To each of the following in the presence of God and His Messenger. my mother dear To the big heart greatest cheerleader and he always pushed me to be the best I could be. And he always stood his ground. my dear father To those who have demonstrated to me what is the most beautiful of my brother’s life To the people who paved our way of science and knowledge All our

Teachers Distinguished To the taste of the most beautiful moments with

My friends

I especially appreciated and thanked:

Doctor ......

II ACKNOWLEDGMENT

Thanks first and last to ALLAH who enable me to conduct this study by grace of him and donated my strength. For all those

who have stood by me, and helped me in this thesis, we send

our thanks and deepest gratitude.

Special and deepest regards are due to my supervisor

Dr.Mohammed Al-Nour for his assistance and supervision, to

all friends who support me, Sincere thanks to everyone who

stood beside me and helped me with enthusiasm and great

faith, thank you all.

III Abstract

With the increase in car production and world's population, are requests more and more areas and parking facilities. In this project, a new parking cars are called smart car parking system (SPS) proposes to help drivers find vacant places in the parking lot in the shortest time. The new system uses ultrasonic (ultrasound) sensors to detect any occupancy parking lot. This system is designed to determine the correct path in which space is available to parking the car. RFID used to add a layer of security for this system, and communicating between the system and drivers happened through LCD screen that display the system status.

IV

المستخلص هغ الضيادة في إًتاج السياساث في الؼالن ، و صيادة تؼذاد السكاى الؼالوي , هٌالك صيادة في الطلب الهاكي و هٌشاءاث اليقاف السياساث. تقذهٌا في هزا الوششوع بؼول ًظام ركي لشكي الوشكباث لوساػذة السائقيي اليجاد اهاكي شاغشة لشكي الوشكباث باسهل الطشق الووكٌه , يقىم هزا الٌظام الجذيذ باستخذام تقٌيت الحساساث فى ق الصىتيت لوؼشفت االهاكي الشاغشة . هزا الٌظام صون لتحذيذ الوساس الصحيح الزي يتىفش به هكاى شاغش لشكي الوشكبت , كوا يقىم باستخذام جهاص التؼشف بالوىجاث الشاديىيت الضافت طبقت هي الحوايت لهزا الٌظام و يتن التىاصل هغ السائقيي ػبش شاشت ػشض تقىم بؼشض حالت الوىقف.

V

CONTENTS Page Subject number

I اآلية

Dedication II

Acknowledgment III

Abstract IV

V المستخلص contents VI

List of figures VIII

Lists of Tables XII

List of Abbreviations XIII

CHAPTER ONE: INTRODUCTION 1.1 Background 1

1.2 Problem Statement 1

1.3 Objectives 2

1.4 Methodology 2

1.5 Layout 3

I

CHAPTER TWO: CONTROL SYSTEM AND CONTROLLER 2.1 Introduction 4

2.2 Control system 4

2.3 Basic Components of a Control System 5

2.4 Classification of control systems 5

2.4.1 Open loop control system 5

2.4.2 Closed loop control system 6

2.4.3 Feedback 7

2.5 Controller 7

2.5.1 Basic Controller Types 8

2.5.2 Proportional Derivative (PD) Controller 8

2.5.3 Proportional Integral (PI) Controller 9

2.5.4 Proportional Integral Derivative (PID) 9 Controller

CHAPTER THREE: application and types

3.1 Introduction 11

3.2 Microcontroller main components 11

3.2.1 12

3.2.2 ROM 12

3.2.3 RAM 12

II

3.2.4 Input and Output Ports 12

3.2.5 Timer 13

3.2.6 Circuitry 13

3.2.7 Buses 13

3.3 Types of 14

3.4 Programming of microcontroller 15

3.5 Applications of microcontroller 15

3.6 Microcontroller features 16

3.7 Microcontroller 16

3.7.1 Power 17

3.7.2 Memory 17

3.7.3 Pin Description 17

CHAPTER FOUR: Smart Parking System Simulation

4.1 Introduction 19

4.2 System Simulation 19

CHAPTER FIVE: Smart Parking System Design and Operation

5.1 Introduction 24

5.2 Input unit 25

5.2.1 RFID Reader 25

III

5.2.2 RFID Tags 28

5.2.3 Ultrasonic 31

5.3 Output Unit 31

5.3.1 Liquid crystal display 16x2 31

5.3.2 Servo Motor 32

5.4 Circuit Implementation 33

5.5 Operation 34

5.6 Software Description 36

5.7 Flow chart 37

CHAPTER SIX: CONCLUSION AND RECOMMENDATIONS 6.1 Conclusion 40

6.2 Recommendation 40

References 41

Appendices Appendix A Code A1

Appendix B Arduino Datasheet B1

Appendix RFID Datasheet C1

Appendix D Ultrasonic Datasheet D1

IV

List of Figures

Page Figures Name of Figures Number

Figure(2.1) relationship of component 5

Figure(2.2) Open loop Control 6

Figure(2.3) closed loop control 6

Figure(3.1) Microcontroller main components 11

Figure(3.2) Arduino Microcontroller 17

Figure(4.1) Basic system simulation 19

Figure(4.2) case p1 orp2 or p3 20

Figure(4.3) case p1 or p2 20

Figure(4.4) case p1 or p3 21

Figure(4.5) case p2 or p3 21

Figure(4.6) case p1 22

Figure(4.7) case p2 22

Figure(4.8) case p3 23

V

Figure(4.9) full parking 23

Hardware Implementation of Smart Parking Figure(5.1) 24 System

Figure(5.2) RFID 25

Figure(5.3) ID Format 28

Figure(5.4) RFID Tag 29

Figure(5.5) Ultrasonic 31

Figure(5.6) LCD 16x2 pin description 32

Figure(5.7) servo 33

Figure(5.8) Circuit implementation 34

Figure(5.9) Smart Parking System Final Project 35

Figure(5.10) Arduino development environment 36

Figure(5.11) Flow Chart 39

VI

Lists of Tables

Page Table Name of Table Number

Table(5.1) Distance of different tag reader 26

Table(5.2) RFID pin description 27

VII

List of Abbreviations

AC Alternating Current

ALU Arithmetic Logic Unit

AREF Analog Reference

ASCII American Standard Code for Information Interchange CPU Central Processing Unit

D/A Digital to Analog converter

DC Direct Current

EEPROM Electrically Erasable Programmable Read- Only Memory GND Ground

I/O Input/Output

IC Integration Circuit

ID Identification

LCD Liquid Crystal Display

LED Light Emitting Diode

MISO Master In Slave Out

MOSI Master Out Slave In

PC Personal Computer

PD Proportional Derivative

PI Proportional Integral

PID Proportional Integral Derivative

PWM Pulse Width Modulation

R/W Read/Write

RAM Random Access Memory

VIII

RFID Radio Frequency Identification

ROM Read Only Memory

RS Register Select

Rx Receiver

SCK Serial Clock

SOUT Signal Out

SPI Serial Peripheral Interface

SS Slave Select

TTL Transistor-Transistor logic

TWI Two Wire Interface

Tx Transamination

USB Universal serial

VCC Voltage DC Input

VCR Videocassette recorder

IX

Appendix A Program code #include #include #include #include "Ultrasonic.h" Servo servoLock; Servo myservo; LiquidCrystal lcd(18, 19, 5, 4, 3, 2); #define RFID_Enabled_Pin 16 #define servoPin 17 #define LockedPos 100 #define UnlockedPos 10 buffer[100]; byte RFID_Master[10] = {'3', '8', '0', '0', '7', '1', '2', '4', 'D', '5'}; byte RFID_car1[10], RFID_car2[10], RFID_car3[10],RFID_car4[10]; byte i; byte i2; boolean DoorLocked; byte checkPosition; boolean RFID_Master_Correct; boolean RFID_car1_Correct, RFID_car2_Correct, RFID_car3_Correct, RFID_car4_Correct; boolean RFID_SaveNextRead; long duration, inches, cm,cm1,cm2,cm3 ,duration1,duration2,duration3; //======U1 const int pingPin = 14; const int echoPin = 15; //======U2 const int pingPin1 = 10; const int echoPin1 = 9;

A1

//======U3 const int pingPin2 = 8; const int echoPin2 = 11; //======U4 Ultrasonic ultrasonic(7); #define limit_min 10 void setup() { myservo.attach(12);

pinMode(13, OUTPUT); pinMode(RFID_Enabled_Pin, OUTPUT); RFID_Enable(false); EEPROM_Read_card(); PreLock(); RFID_Enable(true); Serial.begin(2400); i = 1; lcd.begin(16, 2); clear0(); lcd.print(" WELCOME TO"); clear1(); lcd.print(" SMART PARKING"); delay(100); } void loop() { if (Serial.available()) { if (buffer[0] != 0x0A) { buffer[0] = Serial.read(); } else {

buffer[i] = Serial.read(); if (buffer[i] == 0x0D) {

A2

Serial.print("RFID Tag scanned: "); RFID_Enable(false); RFID_Master_Correct = true; RFID_car1_Correct = true; RFID_car2_Correct = true; RFID_car3_Correct = true; RFID_car4_Correct = true; for (checkPosition = 0; checkPosition < 10; checkPosition++) { #if defined(ARDUINO) && ARDUINO >=100 Serial.write(buffer[checkPosition+1]); #else Serial.print(buffer[checkPosition+1], BYTE); #endif if (buffer[checkPosition+1] == RFID_car1[checkPosition] && RFID_car1_Correct == true) { RFID_car1_Correct = true; //car1 RFID tag is detected } else { RFID_car1_Correct = false; //car1 RFID tag is not detected } if (buffer[checkPosition+1] == RFID_car2[checkPosition] && RFID_car2_Correct == true) { RFID_car2_Correct = true; //car2 RFID tag is detected } else { RFID_car2_Correct = false; //car2 RFID tag is not detected } if (buffer[checkPosition+1] == RFID_car3[checkPosition] && RFID_car3_Correct == true) { RFID_car3_Correct = true; //car3 RFID tag is detected } else { RFID_car3_Correct = false; //car3 RFID tag is detected } if (buffer[checkPosition+1] == RFID_car4[checkPosition] && RFID_car4_Correct == true) {

A3

RFID_car4_Correct = true; //car4 RFID tag is detected } else { RFID_car4_Correct = false; //car4 RFID tag is not detected } if (buffer[checkPosition+1] == RFID_Master[checkPosition] && RFID_Master_Correct == true) { RFID_Master_Correct = true; //Master RFID tag is detected } else { RFID_Master_Correct = false; //Master RFID tag is detected } } Serial.println(""); if (RFID_SaveNextRead == false && (RFID_car1_Correct == true || RFID_car2_Correct == true || RFID_car3_Correct == true|| RFID_car4_Correct == true) && RFID_Master_Correct == false) { if (RFID_car1_Correct == true) { Serial.println("car1 Card Scanned"); } if (RFID_car2_Correct == true) { Serial.println("car2 Card Scanned"); } if (RFID_car3_Correct == true) { Serial.println("car3 Card Scanned"); } if (RFID_car4_Correct == true) { Serial.println("car4 Card Scanned"); }

if (DoorLocked == true) { //see if barrier is locked or not check(); delay(3000); PreLock(); clear0(); lcd.print(" WELCOME TO"); clear1(); lcd.print(" SMART PARKING"); delay(100); } delay(1000); } else if (RFID_Master_Correct == true && RFID_SaveNextRead == false) { Serial.println("Master Card Scanned - Programming mode Enabled");

A4

delay(1000); RFID_SaveNextRead = true; // Enable programming mode } else if (RFID_Master_Correct == false && RFID_SaveNextRead == true) {

if (RFID_car1[0] == 0) { // Is the car1 Card slot empty? for (checkPosition = 0; checkPosition < 10; checkPosition++) { RFID_car1[checkPosition] = buffer[checkPosition+1]; // Save the scanned card at Slot1 } Serial.println("RFID Card saved in: slot1"); delay(1000); } else if (RFID_car2[0] == 0) { // Is the car2 Card slot empty? for (checkPosition = 0; checkPosition < 10; checkPosition++) { RFID_car2[checkPosition] = buffer[checkPosition+1]; // Save the scanned card at Slot2 } Serial.println("RFID Card saved in: Slot2"); delay(1000); } else if (RFID_car3[0] == 0) { // Is the Slot3 Card slot empty? for (checkPosition = 0; checkPosition < 10; checkPosition++) { RFID_car3[checkPosition] = buffer[checkPosition+1]; // Save the scanned card at Slot3 } Serial.println("RFID Card saved in: Slot3"); delay(1000); } else if (RFID_car4[0] == 0) { // Is the Slot3 Card slot empty? for (checkPosition = 0; checkPosition < 10; checkPosition++) { RFID_car4[checkPosition] = buffer[checkPosition+1]; // Save the scanned card at Slot4 } Serial.println("RFID Card saved in: Slot4"); delay(1000);

A5

}else { Serial.println("No free Card slots"); RFID_Enable(true); //turns on the RFID reader delay(1000); RFID_Enable(false); //turns off the RFID reader delay(1000); } EEPROM_Save_card(); RFID_SaveNextRead = false; } else if (RFID_Master_Correct == true && RFID_SaveNextRead == true) { Serial.println("Master Card Scanned again - Removing all saved Cards"); delay(1000); // Remove all card Cards for (checkPosition = 0; checkPosition < 10; checkPosition++) { RFID_car1[checkPosition] = 0; } for (checkPosition = 0; checkPosition < 10; checkPosition++) { RFID_car2[checkPosition] = 0; } for (checkPosition = 0; checkPosition < 10; checkPosition++) { RFID_car3[checkPosition] = 0; } for (checkPosition = 0; checkPosition < 10; checkPosition++) { RFID_car4[checkPosition] = 0; } EEPROM_Save_card(); RFID_SaveNextRead = false; } else{ Serial.println("unrgisted car access denied"); clear0(); lcd.print(" UNRGISTED CAR"); clear1(); lcd.print(" ACCESS DENID"); delay(2000);

A6

clear0(); lcd.print(" WELCOME TO"); clear1(); lcd.print(" SMART PARKING"); delay(100); }

RFID_Enable(true); EmptySerialBuffer(); Serial.println("");

} i++; } } pinMode(pingPin, OUTPUT); digitalWrite(pingPin, LOW); delayMicroseconds(2); digitalWrite(pingPin, HIGH); delayMicroseconds(5); digitalWrite(pingPin, LOW);

pinMode(echoPin, INPUT); duration = pulseIn(echoPin, HIGH); //======pinMode(pingPin1, OUTPUT); digitalWrite(pingPin1, LOW); delayMicroseconds(2); digitalWrite(pingPin1, HIGH); delayMicroseconds(5); digitalWrite(pingPin1, LOW);

pinMode(echoPin1, INPUT);

A7

duration1 = pulseIn(echoPin1, HIGH); //======pinMode(pingPin2, OUTPUT); digitalWrite(pingPin2, LOW); delayMicroseconds(2); digitalWrite(pingPin2, HIGH); delayMicroseconds(5); digitalWrite(pingPin2, LOW);

pinMode(echoPin2, INPUT); duration2 = pulseIn(echoPin2, HIGH); //======// convert the time into a distance cm =ultrasonic.MeasureInCentimeters(); cm1 = microsecondsToCentimeters(duration); cm2 = microsecondsToCentimeters(duration1); cm3= microsecondsToCentimeters(duration2); if (cm > limit_min) { myservo.write(90); delay(100); }else { myservo.write(10); delay(4000);} if(cm1 < limit_min&&cm2 < limit_min&&cm3< limit_min){ clear0(); lcd.print(" Sorry No More "); clear1(); lcd.print(" Space"); delay(100); }else{ clear0(); lcd.print(" WELCOME TO"); clear1();

A8

lcd.print(" SMART PARKING"); delay(100);} } void EmptySerialBuffer() { while (Serial.available()) { Serial.read(); } for (i2 = 0; i2 <= i; i2++) { buffer[i2] = 0; } i = 0; } void PreLock() { servoLock.attach(servoPin); servoLock.write(LockedPos); delay(250); servoLock.detach(); DoorLocked = true; } void RFID_Enable(boolean enabled) { if (enabled == true) { digitalWrite(RFID_Enabled_Pin, LOW); digitalWrite(13, HIGH); } else { digitalWrite(RFID_Enabled_Pin, HIGH); digitalWrite(13, LOW); } } void EEPROM_Read_card() { byte EPROMaddr; for (EPROMaddr = 0; EPROMaddr < 10; EPROMaddr++) { RFID_car1[EPROMaddr] = EEPROM.read(EPROMaddr); } for (EPROMaddr = 10; EPROMaddr < 20; EPROMaddr++) { RFID_car2[EPROMaddr-10] = EEPROM.read(EPROMaddr);

A9

} for (EPROMaddr = 20; EPROMaddr < 30; EPROMaddr++) { RFID_car3[EPROMaddr-20] = EEPROM.read(EPROMaddr); } for (EPROMaddr = 30; EPROMaddr < 40; EPROMaddr++) { RFID_car4[EPROMaddr-30] = EEPROM.read(EPROMaddr); } } void EEPROM_Save_card() { byte EPROMaddr; for (EPROMaddr = 0; EPROMaddr < 10; EPROMaddr++) { EEPROM.write(EPROMaddr, RFID_car1[EPROMaddr]); } for (EPROMaddr = 10; EPROMaddr < 20; EPROMaddr++) { EEPROM.write(EPROMaddr, RFID_car2[EPROMaddr-10]); } for (EPROMaddr = 20; EPROMaddr < 30; EPROMaddr++) { EEPROM.write(EPROMaddr, RFID_car3[EPROMaddr-20]); } for (EPROMaddr = 30; EPROMaddr < 40; EPROMaddr++) { EEPROM.write(EPROMaddr, RFID_car3[EPROMaddr-30]); } } long microsecondsToInches(long microseconds) { return microseconds / 74 / 2; } //======long microsecondsToCentimeters(long microseconds) { return microseconds / 29 / 2; } void clear0(){

A10

lcd.setCursor(0,0); lcd.print(" "); lcd.setCursor(0,0); } void clear1(){

lcd.setCursor(0,1); lcd.print(" "); lcd.setCursor(0,1); } void check(){ if (cm1 > limit_min && cm2 > limit_min && cm3 > limit_min) { clear0(); lcd.print(" WELCOME GO TO"); clear1(); lcd.print(" P1 or P2 or P3"); delay(100); servoLock.attach(servoPin); servoLock.write(UnlockedPos); delay(500); servoLock.detach(); DoorLocked = false;

}else if(cm1 > limit_min&&cm2>limit_min &&cm3< limit_min) { clear0(); lcd.print(" WELCOME GO TO"); clear1(); lcd.print(" P1 or P2"); delay(100);

A11

servoLock.attach(servoPin); servoLock.write(UnlockedPos); delay(500); servoLock.detach(); DoorLocked = false;

}else if(cm1 > limit_min&&cm2< limit_min &&cm3< limit_min) { clear0(); lcd.print(" WELCOME GO TO"); clear1(); lcd.print(" P1"); delay(100); servoLock.attach(servoPin); servoLock.write(UnlockedPos); delay(500); servoLock.detach(); DoorLocked = false;

}else if(cm1 < limit_min&&cm2 < limit_min&&cm3< limit_min){ clear0(); lcd.print(" Sorry No More "); clear1(); lcd.print(" Space"); delay(100); }else if(cm1 > limit_min&&cm3 > limit_min&&cm2

A12

servoLock.write(UnlockedPos); delay(500); servoLock.detach(); DoorLocked = false;

} else if(cm2 > limit_min&&cm3 > limit_min&&cm1< limit_min) { clear0(); lcd.print(" WELCOME GO TO"); clear1(); lcd.print(" P2 or P3"); delay(100); servoLock.attach(servoPin); servoLock.write(UnlockedPos); delay(500); servoLock.detach(); DoorLocked = false;

} else if(cm2 > limit_min&&cm1 < limit_min&&cm3

A13

} else if(cm3 > limit_min&&cm2

A14

Appendix B Arduino Uno Datasheet

Technical specs

Microcontroller ATmega328P

Operating Voltage 5V

Input Voltage (recommended) 7-12V

Input Voltage (limit) 6-20V

Digital I/O Pins 14 (of which 6 provide PWM output)

PWM Digital I/O Pins 6

Analog Input Pins 6

DC Current per I/O Pin 20 mA

DC Current for 3.3V Pin 50 mA

32 KB (ATmega328P) of which 0.5 KB used by

SRAM 2 KB (ATmega328P)

EEPROM 1 KB (ATmega328P)

Clock Speed 16 MHz

Length 68.6 mm

Width 53.4 mm

Weight 25 g

B1

Programming

The Uno can be programmed with the Arduino Software (IDE). Select "Arduino/Genuino Uno" from the Tools > Board menu (according to the microcontroller on your board). For details, see the reference and tutorials.

The ATmega328 on the Uno comes preprogrammed with a bootloader that allows you to upload new code to it without the use of an external hardware programmer. It communicates using the original STK500 protocol (reference, C header files).

You can also bypass the bootloader and program the microcontroller through the ICSP (In-Circuit Serial Programming) header using Arduino ISP or similar; see these instructions for details.

The ATmega16U2 (or 8U2 in the rev1 and rev2 boards) firmware source code is available in the Arduino repository. The ATmega16U2/8U2 is loaded with a DFU bootloader, which can be activated by:

B2

 On Rev1 boards: connecting the solder jumper on the back of the board (near the map of Italy) and then rese ing the 8U2.  On Rev2 or later boards: there is a resistor that pulling the 8U2/16U2 HWB line to ground, making it easier to put into DFU mode.

You can then use Atmel's FLIP software (Windows) or the DFU programmer (Mac OS X and Linux) to load a new firmware. Or you can use the ISP header with an external programmer (overwriting the DFU bootloader). See this user-contributed tutorial for more information. Warnings

The Uno has a resettable polyfuse that protects your computer's USB ports from shorts and overcurrent. Although most computers provide their own internal protection, the fuse provides an extra layer of protection. If more than 500 mA is applied to the USB port, the fuse will automatically break the connection until the short or overload is removed.

Differences with other boards

The Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead, it features the Atmega16U2 (Atmega8U2 up to version R2) programmed as a USB-to-serial converter.

Power

The Uno board can be powered via the USB connection or with an external power supply. The power source is selected automatically.

External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The adapter can be connected by plugging a 2.1mm center-positive plug into the board's power jack. Leads from a battery can be inserted in the GND and Vin pin headers of the POWER connector.

B3

The board can operate on an external supply from 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may become unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts.

The power pins are as follows:

 Vin. The input voltage to the Uno board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin.  5V.This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7- 12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it.  3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA.  GND. Ground pins.  IOREF. This pin on the Uno board provides the voltage reference with which the microcontroller operates. A properly configured shield can read the IOREF pin voltage and select the appropriate power source or enable voltage translators on the outputs to work with the 5V or 3.3V.

Memory The ATmega328 has 32 KB (with 0.5 KB occupied by the bootloader). It also has 2 KB of SRAM and 1 KB of EEPROM (which can be read and written with the EEPROM library).

Input and Output

B4

See the mapping between Arduino pins and ATmega328P ports. The mapping for the Atmega8, 168, and 328 is identical.

Each of the 14 digital pins on the Uno can be used as an input or output, using pinMode(),digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can provide or receive 20 mA as recommended operating condition and has an internal pull-up resistor (disconnected by default) of 20-50k ohm. A maximum of 40mA is the value that must not be exceeded on any I/O pin to avoid permanent damage to the microcontroller.

In addition, some pins have specialized functions:

 Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.  External : 2 and 3. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details.  PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.  SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication using the SPI library.  LED: 13. There is a built-in LED driven by digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off.  TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire library.

The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and the analogReference() function. There are a couple of other pins on the board:

B5

 AREF. Reference voltage for the analog inputs. Used with analogReference().  Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields which block the one on the board.

Communication The Uno has a number of facilities for communicating with a computer, another Uno board, or other microcontrollers. The ATmega328 provides UART TTL (5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX). An ATmega16U2 on the board channels this serial communication over USB and appears as a virtual com port to software on the computer. The 16U2 firmware uses the standard USB COM drivers, and no external driver is needed. However, on Windows, a .inf file is required. The Arduino Software (IDE) includes a serial monitor which allows simple textual data to be sent to and from the board. The RX and TX LEDs on the board will flash when data is being transmitted via the USB-to-serial chip and USB connection to the computer (but not for serial communication on pins 0 and 1).

A SoftwareSerial library allows serial communication on any of the Uno's digital pins.

The ATmega328 also supports I2C (TWI) and SPI communication. The Arduino Software (IDE) includes a Wire library to simplify use of the I2C bus; see the documentation for details. For SPI communication, use the SPI library.

Automatic (Software) Reset

Rather than requiring a physical press of the reset button before an upload, the Uno board is designed in a way that allows it to be reset by software running on a connected computer. One of the hardware flow control lines (DTR) of the ATmega8U2/16U2 is connected to the reset line of the ATmega328 via a 100 nanofarad capacitor. When this line is asserted (taken low), the reset line drops long enough to

B6

reset the chip. The Arduino Software (IDE) uses this capability to allow you to upload code by simply pressing the upload button in the interface toolbar. This means that the bootloader can have a shorter timeout, as the lowering of DTR can be well-coordinated with the start of the upload.

This setup has other implications. When the Uno is connected to either a computer running Mac OS X or Linux, it resets each time a connection is made to it from software (via USB). For the following half-second or so, the bootloader is running on the Uno. While it is programmed to ignore malformed data (i.e. anything besides an upload of new code), it will intercept the first few of data sent to the board after a connection is opened. If a sketch running on the board receives one-time configuration or other data when it first starts, sure that the software with which it communicates waits a second after opening the connection and before sending this data.

The Uno board contains a trace that can be cut to disable the auto- reset. The pads on either side of the trace can be soldered together to re-enable it. It's labeled "RESET-EN". You may also be able to disable the auto-reset by connecting a 110 ohm resistor from 5V to the reset line; see this forum for details.

Revisions

Revision 3 of the board has the following new features:

 1.0 pinout: added SDA and SCL pins that are near to the AREF pin and two other new pins placed near to the RESET pin, the IOREF that allow the shields to adapt to the voltage provided from the board. In future, shields will be compatible with both the board that uses the AVR, which operates with 5V and with the Arduino Due that operates with 3.3V. The second one is a not connected pin, that is reserved for future purposes.  Stronger RESET circuit.

B7

B8

Appendix C RFID Reader

599 Menlo Drive, Suite 100 General: [email protected] Rocklin, California 95765, USA Technical: [email protected] Office: (916) 624-8333 Web Site: www.parallax.com Fax: (916) 624-8003 Educational: www.stampsinclass.com

RFID Reader Module (#28140) RFID 54 mm x 85 mm Rectangle Tag (#28141)

RFID 50 mm Round Tag (#28142)

C1

Introduction

Designed in cooperation with Grand Idea Studio (http://www.grandideastudio.com/), the Parallax Radio Frequency Identification (RFID) Reader Module is the first low-cost solution to read passive RFID transponder tags up to 1¾” - 3” inches away depending on the tag (see list below). The RFID Reader Module can be used in a wide variety of hobbyist and commercial applications, including access control, automatic identification, robotics navigation, inventory tracking, payment systems, and car immobilization.

• Fully-integrated, low-cost method of reading passive RFID transponder tags • Single-wire, 2400 baud Serial TTL interface to PC, BASIC Stamp® and other processors • Requires single +5VDC supply • Bi-color LED for visual indication of activity • 0.100 ” pin spacing for easy prototyping and integration

Module (#28140) The Parallax RFID Reader Module works exclusively with the EM Microelectronics-Marin SA EM4100-family of passive read-only transponder tags. A variety of different tag types and styles exist with the most popular made available from Parallax. Each transponder tag contains a unique identifier (one of 240, or 1,099,511,627,776, possible combinations) that is read by the RFID Reader Module and transmitted to the host via a simple serial interface.

Electronic Connections

The Parallax RFID Reader Module can be integrated into any design using only four connections (VCC, /ENABLE, SOUT,

C2

GND). Use the following circuit for connecting the Parallax RFID Reader Module to the BASIC Stamp microcontroller:

Pin Pin Name Type Function 1 VCC P System power, +5V DC input. 2 /ENABLE I Module enable pin. Active LOW digital input. Bring this pin LOW to enable the RFID reader and activate the antenna. 3 SOUT O Serial Out. TTL-level interface, 2400bps, 8 data bits, no parity, 1 stop bit. 4 GND G System ground. Connect to power supply’s ground (GND) terminal. Note: Type: I = Input, O = Output, P = Power, G = Ground

C3

Communication Protocol

Implementation and usage of the RFID Reader Module is straightforward. BASIC Stamp 1, 2, and SX28AC/DP code examples ( SX/B) are included at the end of this documentation.

The RFID Reader Module is controlled with a single TTL-level active-low /ENABLE pin. When the /ENABLE pin is pulled LOW, the module will enter its active state and enable the antenna to interrogate for tags. The current consumption of the module will increase dramatically when the module is active.

A visual indication of the state of the RFID Reader Module is given with the on-board LED. When the module is successfully powered-up and is in an idle state, the LED will be GREEN. When the module is in an active state and the antenna is transmitting, the LED will be RED.

The face of the RFID tag should be held parallel to the front or back face of the antenna (where the majority of RF energy is focused). If the tag is held sideways (perpendicular to the antenna) you'll either get no reading or a poor reading. Only one transponder tag should be held up to the antenna at any time. The use of multiple tags at one time will cause tag collisions and confuse the reader. The two tags available in the Parallax store have a read distance of approximately 3 inches. Actual distance may vary slightly depending on the size of the transponder tag and environmental conditions of the application.

When a valid RFID transponder tag is placed within range of the activated reader, the unique ID will be transmitted as a 12-byte ASCII string via the TTL-level SOUT (Serial Output) pin in the following format:

MSB LSB MSB

C4

Unique Start Unique Unique Unique Unique Unique Unique Unique Unique Unique Stop ID Byte ID ID ID ID ID ID ID ID ID Byte Digit (0x0A) Digit 1 Digit 2 Digit 3 Digit 4 Digit 5 Digit 6 Digit 7 Digit 8 Digit 9 (0x0D ) 10

The start byte and stop byte are used to easily identify that a correct string has been received from the reader (they correspond to a line feed and carriage return characters, respectively). The middle ten bytes are the actual tag's unique ID.

All communication is 8 data bits, no parity, 1 stop bit, non- inverted, least significant bit first (8N1). The baud rate is configured for 2400bps, a standard communications speed supported by most any or PC, and cannot be changed. The Parallax RFID Reader Module initiates all communication. The Parallax RFID Reader Module can connect directly to any TTL-compatible UART or to an RS232-compatible interface by using an external level shifter.

Absolute Maximum Ratings and Electrical Characteristics

Condition Value Operating Temperature -40 ºC to +85ºC Storage Temperature -55 ºC to +125ºC

Supply Voltage (VCC) +4.5 V to +5.5V

Ground Voltage (VSS) 0 V

Voltage on any pin with respect to VSS -0.3 V to +7.0V

Stresses above those listed under “Absolute Maximum Ratings” may cause permanent damage to the device. This is a stress rating

C5

only and functional operation of the device at those or any other conditions above those indicated in the operation listings of this specification is not implied. Exposure to maximum rating conditions for extended periods may affect device reliability. DC Characteristics

Test Specification Unit Conditions Min. Typ. Max. Parameter Symbol Supply Voltage VCC --- 4.5 5.0 5.5 V

Supply Current, Idle IIDLE ------10 --- mA

Supply Current, Active ICC ------90 --- mA

Input LOW voltage VIL +4.5V <= VCC <= +5.5V ------0.8 V

Input HIGH voltage VIH +4.5V <= VCC <= +5.5V 2.0 ------V

Output LOW voltage VOL VCC = +4.5V ------0.6 V

Output HIGH voltage VOH VCC = +4.5V VCC - 0.7 ------V

At VCC = +5.0V and TA = 25ºC unless otherwise noted

RFID Tags Available From Parallax

C6

Parallax provides two passive RFID tags from our on-line store. We’re stocking the tags because many suppliers have high minimums, yet many of our customers may only want a few tags for their basic experimentation.

• 54 mm x 85 mm Rectangle Tag (#28141) • 50 mm Round Tag (#28142)

Actual tag dimensions may vary. Contact Parallax for specific information. Optional Tag Information

Even though Parallax only carries a Round Tag and a Rectangle Tag the following values were obtained from different tags available in the market.

ISO Card: 6.3 cm (2.5") +/-

C7

10% World Tag 50mm: 6.8 cm (2.7") +/- 10% World Tag 30mm: 5.3 cm (2.1") +/- 10% Bobsleigh Keyfob: 5.3 cm (2.1") +/- 10% Tear shape: 4.0 cm (1.6") +/- 10% Wristband: 4.0 cm (1.6") +/- 10% RFID Technology Overview

Material in this section is based on information provided by the RFID Journal (www.rfidjournal.com).

Radio Frequency Identification (RFID) is a generic term for non- contacting technologies that use radio waves to automatically identify people or objects. There are several methods of identification, but the most common is to store a unique serial number that identifies a person or object on a microchip that is attached to an antenna. The combined antenna and microchip are called an "RFID transponder" or "RFID tag" and work in combination with an "RFID reader" (sometimes called an "RFID interrogator").

An RFID system consists of a reader and one or more tags. The reader's antenna is used to transmit radio frequency (RF) energy. Depending on the tag type, the energy is "harvested" by the tag's antenna and used to power up the internal circuitry of the tag. The tag will then modulate the electromagnetic waves generated by the reader in order to transmit its data back to the reader. The reader receives the modulated waves and converts them into digital data. In the case of the Parallax RFID Reader Module, correctly received digital data is sent serially through the SOUT pin.

C8

There are two major types of tag technologies. "Passive tags" are tags that do not contain their own power source or transmitter. When radio waves from the reader reach the chip’s antenna, the energy is converted by the antenna into electricity that can power up the microchip in the tag (known as "parasitic power"). The tag is then able to send back any information stored on the tag by reflecting the electromagnetic waves as described above. "Active tags" have their own power source and transmitter. The power source, usually a battery, is used to run the microchip's circuitry and to broadcast a signal to a reader. Due to the fact that passive tags do not have their own transmitter and must reflect their signal to the reader, the reading distance is much shorter than with active tags. However, active tags are typically larger, more expensive, and require occasional service. The RFID Reader Module is designed specifically for low-frequency (125 kHz) passive tags.

Frequency refers to the size of the radio waves used to communicate between the RFID system components. Just as you tune your radio to different frequencies in order to hear different radio stations, RFID tags and readers have to be tuned to the same frequency in order to communicate effectively. RFID systems typically use one of the following frequency ranges: low frequency (or LF, around 125 kHz), high frequency (or HF, around 13.56 MHz), ultra-high frequency (or UHF, around 868 and 928 MHz), or microwave (around 2.45 and 5.8 GHz). It is generally safe to assume that a higher frequency equates to a faster data transfer rate and longer read ranges, but also more sensitivity to environmental factors such as liquid and metal that can interfere with radio waves.

There really is no such thing as a "typical" RFID tag. The read range of a tag ultimately depends on many factors: the frequency of RFID system operation, the power of the reader, and interference from other RF devices. Balancing a number of engineering trade- offs (antenna size v. reading distance v. power v. manufacturing

C9 cost), the Parallax RFID Reader Module's antenna was designed with a specific inductance and "Q" factor for 125 kHz RFID operation at a tag read distance of up to 1¾” - 3” inches.

C10

Appendix D

Ultrasonic Ranging Module HC - SR04

Product features:

Ultrasonic ranging module HC - SR04 provides 2cm - 400cm non-contact measurement function, the ranging accuracy can reach to 3mm. The modules includes ultrasonic transmitters, receiver and control circuit. The basic principle of work:

(1) Using IO trigger for at least 10us high level signal, (2) The Module automatically sends eight 40 kHz and detect whether there is a pulse signal back. (3) IF the signal back, through high level , time of high output IO duration is the time from sending ultrasonic to returning. Test distance = (high level time×velocity of sound (340M/S) / 2,

Wire connecting direct as following:

5V Supply

Trigger Pulse Input

Echo Pulse Output

0V Ground

D1

Electric Parameter

Working Voltage DC 5 V Working Current 15mA

Working Frequency 40Hz Max Range 4m

Min Range 2cm MeasuringAngle 15 degree Trigger Input Signal 10uS TTL pulse Echo Output Signal Input TTL lever signal and the range in proportion

Dimension 45*20*15mm

D2

Vcc Trig Echo GND

DC Timing diagram

The Timing diagram is shown below. You only need to supply a short 10uS pulse to the trigger input to start the ranging, and then the module will send out an 8 cycle burst of ultrasound at 40 kHz and raise its echo. The Echo is a distance object that is pulse width and the range in proportion .You can calculate the range through the time interval between sending trigger signal and receiving echo signal. Formula: uS / 58 = centimeters or uS / 148 =inch; or: the range = high level time * velocity (340M/S) / 2; we suggest to use over 60ms measurement cycle, in order to prevent trigger signal to the echo signal.

DCI Attention:

The module is not suggested to connect directly to electric, if connected electric, the GND terminal should be connected the module first, otherwise, it will affect the normal work of the module.

When tested objects, the range of area is not less than 0.5 square meters and the plane requests as smooth as possible, otherwise ,it will affect the results of measuring.

D3

Chapter One Introduction Chapter One

Introduction

1.1 Background Parking system, techniques and equipment used to help the challenge for all drivers say amateurs or the experts. As the numbers of vehicles on the road are increasing tremendously from thousands to millions, the traffic problems are bound to exist. Almost all major cities are facing the parking problems, insufficient parking space cause traffic jams, air pollution, health hazards etc. The price for parking expansion is extremely high. Smart parking is a parking garage system that utilizes various technologies to efficiently manage the garage. In the near future the demand for the intelligent parking service will increase because the rapid growth in the automotive industries. The automatic management of parking lots by accurate monitoring and providing service to the customers and administrators is provided by such emerging services. A cost effective solution to this service can be provided by RFID which consists of radar and tag placed in area of interest or in existing parking lots expensive cabling and are capable of adjusting with the cheap and easily available sensors. An automatic car parking system is a solution to this ordeal. There has been a considerable amount of reduction in transaction costs and decrease in stock shortage with the use of Radio Frequency Identification (RFID) technology in automation. Most of the RFID networks include a wide range of automation technologies. These technologies are RFID readers, RFID writers, RFID barcode scanners, RFID smart sensors and RFID controllers. In this study, a solution has been provided for the problems encountered in parking-lot management systems

1

Chapter One Introduction via RFID technology. RFID readers, RFID labels, computers, barriers and software are used as for the main components of the RFID technology.

1.2 Problem Statement The SPS project is develop due to the problems stated as hard to search for an available parking space may have to drive through crowded parking area and compete for an available parking space, and timing wasting in searching parking space, the traffic congestion in the parking area.

1.3 Objectives - To design and implement smart parking system. -To reduce man power. -To reducing the material cost. -High efficiency with sensitive. 1.4 Methodology This project includes two part: hardware and software. The hardware phase is design and develop a smart parking system. Which is controlled by

(Arduino Uno) microcontroller. The software was written by Arduino -1.6.5. The insufficient parking space and traffic jams reduce by take advantage of RFID, ultrasonic sensors and microcontrollers. When the car come to the smart parking And when the car be close enough to RFID transmission it will make the RFID card circuit turn on and send the card information to RFID receiver. Then send the number to microcontroller to check the number for free space for car parking. if they are free space it will send text to LCD with the number of free space to park the car at the same time the microcontroller send signal to servo motor to open the barrier. Then the driver will go to the empty spot to park the car. When the car be above the parking spot it will intercept with sensor which it make these parking spot unavailable. This loop will do until the park it full. If the

2

Chapter One Introduction car come and the parking full this, massage well upper on LCD “Sorry No More Space”.

1.5 Layout

The research contain chapter: In Chapter two describes the control system and controllers, and the classification of control system

Chapter three include description of microcontroller applications and type, basic components of microcontroller

Chapter four include description of smart parking system simulation

Chapter five include description of input, output system and smart parking system design and operation.

The conclusion, and the recommendations proposed for the future work are presented in chapter six

3

Chapter Two Control System and Controllers

Chapter Two Control System and Controllers

2.1 Introduction Control engineering is based on the foundations of feedback theory and linear system analysis, and it is generates the concepts of the network theory and the communication theory. Accordingly, control engineering is not limited to any engineering discipline but is applicable to aeronautical, chemical, mechanical, environmental, civil, and electrical engineering. Modern control engineering practice includes the use of control design strategies to improve manufacturing processes, the efficiency of energy use, advanced automobile control, including rapid transit, among others.

2.2 Control System Control system engineering are concerned with understanding and controlling segment of their environment, often called systems, to provide a useful economic products for society. The twin goals of understanding and control are complementary because effective systems control requires that the system understood and modeled. Furthermore, control engineering must often consider the control of poorly understood systems such as chemical process systems. The present challenge to control engineers in the modeling and control of modern, complex interrelated systems such as traffic control systems, chemical processes, and robotic systems, however, simultaneously, the fortunate engineer has the opportunity to control many very useful and interesting industrial automation systems Perhaps the most characteristic quality of control engineering in the opportunity to control machines and industrial and economic processes for the benefit of society.

4

Chapter Two Control System and Controllers

2.3 Basic Components of a Control System The basic components of a control system can be described by:  Objectives of control.  Control-system components.  Results or outputs. The basic relationship of these three components illustrated in Figure 2.1. In more technical terms, the objectives can be identified with inputs, or actuating signals, u, and the results are called outputs, or controlled variables, y. In general, the objective of the control system is to control the outputs in some prescribed manner by the inputs through the elements of the control system [1].

Objective CONTROL Results SYSTEM

Figure 2.1: basic relationship of component

2.4 Classification of Control Systems The control system is classified into two types

2.4.1 Open loop control system It is very simple operation, when an input signal directs the control element to respond an output produced. Any physical system which does not automatically correct the variation in its output, is called an open loop system or control system in which the output quantity has no effect upon the input quantity are called open-loop control system. This means that the output is not feedback to the input for correction. At this research, we have use an open loop control we have use an ultrasonic which it have to Acuter a servomotor without use a feedback In open loop system, the output can be varied by

5

Chapter Two Control System and Controllers

varying the input. However, due to external disturbances the system output may change. When the output changes due to disturbances, it not followed by changes in input to correct the output. In open loop systems, the changes in output are corrected by changing the input manually.

Input Open loop output Control

Figure 2 .2: Open loop Control

2.4.2 Closed loop control system A closed loop control system is a system where the output has an effect upon the input quantity in such a manner as to maintain the desired output value. An open loop control system becomes a closed loop control system by including a feedback. This feedback will automatically correct the change in output due to disturbances. This is why a closed loop control system called as an automatic control system. The block diagram of a closed loop control system shown in Figure 2.3. Error Reference Dictation Output Controller System

Feedback

Figure 2 .3: closed loop control.

6

Chapter Two Control System and Controllers

In a closed loop control system, the controlled variable (output) of the system sensed at every instant of time, feedback and compared with the desired input resulting in an error signal. The feedback control system takes into account the disturbances also and makes the corrective action. These control systems are accurate, stable and less affected by noise. However, these control systems are sophisticated and hence costly. They are also complicated to design for stability, give oscillatory response and feedback brings down the overall gain of the control system.

2.4.3 Feedback Feedback is that characteristic of closed-loop control systems which distinguishes them from open-loop systems. Feedback is that property of a closed-loop system, which permits the output (or some other controlled variable of the system) to be compared with the input to the system (or an input to some other internally situated component or subsystem of the system). So that, the appropriate control action may be formed as some function of the output and input. More generally, feedback is said to exist in a system when a closed sequence of cause-and-effect relations exists between system variables.

2.5 Controller Controller is a device, historically using mechanical, hydraulic, pneumatic or electronic techniques often in combination, but more recently in the form of a microprocessor or computer, which monitors and physically alters the operating conditions of a given dynamical system. Typical applications of controllers are to hold settings for temperature, pressure, flow or speed.

7

Chapter Two Control System and Controllers

2.5.1 Basic Controller Types The controllers use a three basic behavior types P- Proportional, I- integrative and D - derivative. While proportional and integrative modes are also used as single control modes, a derivative mode is rarely used on it’ s own in control systems.

 Proportional Provide a contribution which depends on the instantaneous value of the control error. A proportional controller can control any stable plant, but it provides limited performance and nonzero steady state errors. This latter limitation is because its frequency response bounded for all frequencies.  Integral Action on the other hand, gives a controller output that is proportional to the accumulated error, which implies that it a slow reaction control mode. This characteristic is also evident in its low pass frequency response.

 Derivative Action acts on the rate of change of the control error. Consequently, it is a fast mode, which ultimately disappears in the presence of constant errors. It sometimes referred to as a predictive mode because of its dependence on the error trend. The main limitation of the derivative mode, viewed in isolation, is its tendency to yield large control signals in response to high frequency control errors, such as errors induced by set point changes or measurement noise [2].

2.5.2 Proportional Derivative (PD) Controller Derivative mode is used when prediction of the error can improve control or when it necessary to stabilize the system. From the frequency characteristic of D element it can be seen that it has phase lead of 90°. Often derivative is not taken from the error signal but from the system

8

Chapter Two Control System and Controllers

output variable. This is done to avoid effects of the sudden change of the reference input that will cause sudden change in the value of error signal. Sudden change in error signal will cause sudden change in control output. To avoid that it is suitable to design D mode to be proportional to the change of the output variable. PD controller is often used in control of moving objects such are flying and underwater vehicles, ships, rockets etc. One of the reason is in stabilizing effect of PD controller on sudden changes in heading variable y(t). Often a "rate gyro" for velocity measurement is used as sensor of heading change of moving object.

2.5.3 Proportional Integral (PI) Controller PI controller eliminate forced oscillations and steady state error resulting in operation of on-off controller and P controller respectively. However, introducing integral mode has a negative effect on speed of the response and overall stability of the system. Thus, PI controller will not increase the speed of response. It can expect since PI controller does not have means to predict what will happen with the error in near future. This problem can be solved by introducing derivative mode which has ability to predict what will happen with the error in near future and thus to decrease a reaction time of the controller. PI controllers are very often used in industry, especially when speed of the response is not an issue. A control without D mode is used when fast response of the system is not required large disturbances and noise are present during operation of the process there is only one energy storage in process (capacitive or inductive) there are large transport delays in the system

2.5.4 Proportional Integral Derivative (PID) Controller PID controller has all the necessary dynamics fast reaction on change of the controller input (D mode), increase in control signal to 9

Chapter Two Control System and Controllers

lead error towards zero (I mode) and suitable action inside control error area to eliminate oscillations (P mode). Derivative mode improves stability of the system and enables increase in gain K and decrease in integral time constant Ti, which increases speed of the controller response. PID controller is used when dealing with higher order capacitive processes (processes with more than one energy storage) when their dynamic is not similar to the dynamics of an integrator (like in many thermal processes). PID controller is often used in industry, but also in the control of mobile objects (course and trajectory following included) when stability and precise reference following are required. Conventional autopilot is for the most part PID type controllers.

10

Chapter Three Microcontroller applications and type Chapter Three

Microcontroller applications and type

3.1 Introduction A microcontroller is a self-contained system with peripherals, memory and a processor that can be used as an . Most programmable microcontrollers that are used today are embedded in other consumer products or machinery including phones, peripherals, automobiles and household appliances for computer systems. Due to that, another name for a microcontroller is "embedded controller." Some embedded systems are more sophisticated, while others have minimal requirements for memory and programming length and a low software complexity. Input and output devices include solenoids, LCD displays, relays, switches and sensors for data like humidity, temperature or light level, amongst others.

3.2 Microcontroller's main components The microcontroller has seven main components: Central processing unit, ROM, RAM, Input and Output units, Timer, Interrupt circuitry and Buses as show in figure 3.1

Figure 3.1 Microcontroller's main components

11

Chapter Three Microcontroller applications and type

3.2.1 Central processing unit One part of the CPU is responsible for performing calculations and executing instruction. This part is called arithmetic logic unit, or ALU. There are a variety of subsidiary components which support the ALU. These components include decoder, sequencer and a variety of registers. The decoder converts instructions stored in program memory in to codes which the ALU can understand. The sequencer manages the flow of data along the microcontroller’s data bus. Registers are used by the CPU to temporarily store vital data which are volatile: they can change during program execution.

3.2.2 ROM Is volatile program instructions if will execute when it is started or rest. Program instructions must be saved in non-volatile memory so that they are not affected by loss of power. The microcontroller usually cannot write data to program memory space.

3.2.3 RAM Random Access Memory (RAM) used to write and read data values as a program runs. RAM is volatile: if you remove the power supply its contents are lost. Any variables used in a program are allocated from RAM. The time to retrieve information from RAM does not depend upon the location of the information because RAM is not sequential, hence the term random access.

3.2.4 Input and Output Ports There are two main port types, parallel and serial, and two ports modes, synchronous and asynchronous. Parallel Input and Output require a data line for each bit, while serial Input and Output uses a single line and transfers bits in sequence. Synchronous Input and Output synchronized to a clock while asynchronous Input and Output is not. Microcontrollers most often have parallel Input and Output capability built is and serial Input and Output as a peripheral feature.

12

Chapter Three Microcontroller applications and type

3.2.5 Timer A timer is a counter that is incremented at affixed rate when the system clock pulses. There are several different types of timers available. A timer/counter can perform several different tasks. The CPU uses the timer to keep track of time accurately. The timer can generate a stream of pulses or a single pulse at different frequencies. It can be used to start and stop tasks at desired times.

3.2.6 Interrupt Circuitry An interrupt is an event that suspends regular program operation while the event is serviced by another program. Interrupt increase the response speed to external events. Different microcontrollers have different interrupt sources which can include external, timer and interrupts. There are two sources of interrupt: hardware and software. Hardware interrupts include a single to a pin, timer overflow, and serial port interrupts. Software interrupts are commends given by the programmer.

3.2.7 Buses A bus carries information in the form of signals. These are three main Buses: address, data and control the address bus is unidirectional and carries the address of memory location indicating where the data is stored. The number of wires in the address bus determines the total number of location memory. data bus is bi-directional and carries information between the CPU and memory or Input and Output devices. Computer often classified according to the size of their data bus. The number of wires in the data bus determines the number of bits that can be stored in each memory location. The control bus carries data, which controls system activity. Often this data includes timing signals, which synchronize the movement of their information.

13

Chapter Three Microcontroller applications and type

3.3 Types of microcontrollers There are several microcontroller architectures an, vendors including:

 ARM core processors (many vendors) ARM Cortex-M cores are specifically targeted towards microcontroller applications.

 Atmel AVR (8-bit), AVR32 (32-bit), and AT91SAM (32-bit).

 Cypress Semiconductor's M8C Core used in their PSoC (Programmable System-on-Chip).

 Free scale Cold Fire (32-bit) and S08 (8-bit).

 Free scale 68HC11 (8-bit).

.

 Infineon: 8-bit XC800, 16-bit XE166, 32-bit XMC4000 (ARM based Cortex M4F), 32-bit TRICOR and, 32-bit Aurix TRICOR Bit microcontrollers.

 MIPS.

 Microchip Technology PIC, (8-bit PIC16, PIC18, 16-bit dsPIC33 / PIC24), (32-bit PIC32).

 NXP Semiconductors LPC1000, LPC2000, LPC3000, LPC4000 (32-bit), LPC900, LPC700 (8-bit).

.

 PowerPC ISE.

(8-bit).

: RL78 16-bit MCU; RX 32-bit MCU; Super H; 32- bit MCU; H8; 16-bit MCU.

 Silicon Laboratories Pipelined 8-bit 8051 Microcontrollers and mixed-signal ARM-based 32-bit microcontrollers.

 STMicroelectronics STM8 (8-bit), ST10 (16-bit) and STM32 (32-bit).

 Texas Instruments TI MSP430 (16-bit) C2000 (32-bit).

 Toshiba TLCS-870 (8-bit/16-bit) [3].

14

Chapter Three Microcontroller applications and type

3.4 Programming of microcontroller To use a microcontroller in mechatronic system design, software must written, tested, and stored in the ROM of the microcontroller. Usually, the software is written and compiled using a Personal Computer (PC) and then downloaded to the microcontroller ROM as machine code. If the program is written in , the PC must have software called a cross- assembler that generates machine code for the microcontroller. An assembler is software that generates machine code for the microprocessor in the PC, whereas a cross-assembler generates machine code for a different microprocessor, in this case the microcontroller. Various software development tools can assist in testing and debugging assembly language programs written for a microcontroller. One such tool is a simulator, which is software that runs on a PC and allows the microcontroller code to be simulated (run) on the PC. Most programming errors can be identified and corrected during simulation. Another tool is an , which is hardware that connects a PC to the microcontroller in a prototype mechatronics system. It usually consists of a printed circuit board connected to the mechatronic system through ribbon cables. The emulator can be used to load and run a program on the actual microcontroller attached to the mechatronics system hardware (containing sensors, actuators, and control circuits). The emulator allows the PC to monitor and control the operation of the microcontroller while it is embedded in the mechatronics system.

3.5 Applications of microcontroller In addition to control applications such as the home monitoring system, microcontrollers are frequently found in embedded applications. Among the ma4ny uses that can be find one or more microcontrollers: automotive applications, appliances (microwave oven, refrigerators, television and VCRs, stereos), automobiles (engine control, diagnostics, climate control), environmental control (greenhouse, factory, home), instrumentation,

15

Chapter Three Microcontroller applications and type aerospace, and thousands of other uses. Microcontrollers are used extensively in robotics. In this application, many specific tasks might be distributed among a large number of microcontrollers in one system. Communications between each microcontroller and a central, more powerful microcontroller (or microcomputer, or even large computer) would enable information to be processed by the central computer, or to be passed around to other microcontrollers in the system. A special application that microcontrollers are well suited for is data logging. By stick one of these chips out in the middle of a cornfield or up in a balloon, one can monitor Introduction to Microcontroller and record environmental parameters (temperature, humidity, rain, etc). Small size, low power consumption, and flexibility make these devices ideal for unattended data monitoring and recording [4].

3.6 Microcontroller features Microcontrollers from different manufacturers have different architectures and different capabilities. Some may suit to a particular application while some others may be very unsuitable [5].

3.7 Arduino Microcontroller (ATmega328P) The Arduino Uno is a microcontroller board, which has 14 digital input/output pins (of which 6 can be used as Pulse Width Modulation (PWM) outputs), 6 analog inputs, a 16 MHz ceramic resonator, a Universal Serial Bus (USB) connection, a power jack, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with an AC to DC adapter or battery to get started as show in figure 3.2.

16

Chapter Three Microcontroller applications and type

Figure 3.2: Arduino Microcontroller

3.7.1 Power The Arduino Uno can powered via the USB connection or with an external power supply. The power source is selected automatically. External (non-USB) power can come from either an AC-to-DC adapter (wall-wart) or battery. The adapter can connected by plugging a 2.1mm center-positive plug into the board's power jack. Leads from a battery can inserted in the Gnd and VIN pin headers of the POWER connector. The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may be unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts.

3.7.2 Memory The ATmega328 has 32 KB (with 0.5 KB used for the boot loader). It also has 2 KB of SRAM and 1 KB of EEPROM (which can be read and written with the EEPROM library).

3.7.3 Pin Description • VIN. The input voltage to the Arduino board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this

17

Chapter Three Microcontroller applications and type

pin, or, if supplying voltage via the power jack, access it through this pin. • 5V.This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it. • 3.3V. A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA. • GND. Ground pins. • Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.

• External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value.

• PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output.

• SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication

• LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off.

• TWI. A4 or SDA pin and A5 or SCL pin. Support TWI communication

• AREF. Reference voltage for the analog inputs.

• Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields which block the one on the board [6].

18

Chapter Four Smart parking system simulation

Chapter Four

Smart parking system simulation

4.1Introduction System simulated using PROTEUS, and the software code was compiled using arduino IDE. ARDUINO acts as the core of the system, the system have three ultrasonic sensor to read state of the parking availability; and one ultrasonic sensor at the exit to open exit barrier and two servo motor one for open Entry barrier and the other open Exit barrier by move angle of servo to 90ᴼ; initially the system put both of servo1 and servo2 at default angle and then the system is ready to receive RFID tag and it is ready to run at normal state figure 4.1 shows the basic system simulation.

Figure 4.1: Basic system simulation

4.2 System Simulation The cases below show the simulation in different states: I. when a car comes the RFID reads the tag on the car, if the tag is registered in the system, the Entry servo will open the barrier and the LCD shows a "welcome go to p1or p2 or p3" message to guide the driver which parking is

19

Chapter Four Smart parking system simulation available to park his car (see figure 4.2). After the car parking in either p1 or p2 or p3, it will no longer be available as long as the car on it.

Figure 4.2 case p1 or p2 or p3

II. When a car comes the RFID reads the tag on the car, if the tag is registered in the system, the Entry servo will open the barrier and the LCD will show the available parking in these case p1 and p2 as show in Figure 4.3 After the car parking in either p1 or p2 the parking availability will be reduced.

Figure 4.3 case p1 or p2 III. When a car comes the RFID reads the tag on the car, if the tag is registered in the system, the Entry servo will open the barrier and the LCD 20

Chapter Four Smart parking system simulation will show the available parking in these case p1 and p3 as show in Figure 4.4 After the car parking in either p1 or p3 the parking availability will be reduced..

Figure 4.4 case p1 or p3 IV. When a car comes the RFID reads the tag on the car, if the tag is registered in the system, the Entry servo will open the barrier and the LCD will show the available parking in these case p2 and p3 as show in Figure 4.5 After the car parking in either p2 or p3 the parking availability will be reduced.

Figure 4.5 case p2 or p3 V. When a car comes the RFID reads the tag on the car, if the tag is registered in the system, the Entry servo will open the barrier and the LCD will show the

21

Chapter Four Smart parking system simulation available parking in these case p1 as show in Figure 4.6 After the car parking in p1 then the parking will be full.

Figure 4.6 case p1

VI. When a car comes the RFID reads the tag on the car, if the tag is registered in the system, the Entry servo will open the barrier and the LCD will show the available parking in these case p2 as show in Figure 4.6 After the car parking in p2 then the parking will be full.

Figure 4.7 case p2 VII. When a car comes the RFID reads the tag on the car, if the tag is registered in the system, the Entry servo will open the barrier and the LCD

22

Chapter Four Smart parking system simulation will show the available parking in these case p3 as show in Figure 4.6 After the car parking in p3 then the parking will be full.

Figure 4.8 case p3 VIII. When all parking filled up with cars, the LCD will show to the driver "sorry no more space" message, and the Entry barrier will not open as show in figure 4.9 if an unregistered car comes the barrier will not open to the driver to parking his car.

Figure 4.9 full parking

23

Chapter Five Smart parking system design and operation

Chapter Five

Smart parking system design and operation

5.1 Introduction Most Smart Parking Systems contains a processing element (a microprocessor or microcontroller), sensors, actuators, and display screen and in modern Smart Parking systems may include devices to be linked to the network. This system is building using the following hardware. The block diagram of the hardware implementation of the entire system shown in figure 5.1.

LCD

12 Servo1 18 19 5 4 Servo2 17 3 2 14 Arduino Uno 15 Ultrasonic1

10

9 Ultrasonic2

Ultrasonic3 RFID 8 0 11 16 Ultrasonic4 7

6

24

Chapter Five Smart parking system design and operation

Figure 5.1 Hardware Implementation of Smart Parking System

5.2 Input unit This unit concerns how to get the information to be deal with it. It consists of two units transmitting unit and receiving unit.

5.2.1 RFID Reader Radio Frequency Identification (RFID) Reader Module is read passive RFID Transponder tags up to 0.75 – 3 inches away depending on the tag (see Table 5.1). The RFID Reader Module can be used in a wide variety of hobbyist and commercial applications, including access control, automatic identification, robotics navigation, inventory tracking, payment systems, and car immobilization as show in figure 5.2.

Figure 5.2 RFID

25

Chapter Five Smart parking system design and operation

Table 5.1 Distance of different tag reader

Type Distance Fault percent World Tag 50mm 6.8cm (2.7") +/- 10% World Tag 30mm 5.3cm (2.1") +/- 10% Bobsleigh Key fob 5.3cm (2.1") +/- 10% Tear shape 4.0cm (1.6") +/- 10% Wristband 4.0cm (1.6") +/- 10%

 Features  Fully-integrated, low-cost method of reading passive RFID transponder tags  Single-wire, 2400 baud Serial TTL interface to PC, BASIC Stamp and other processors  Requires single +5VDC supply  Bi-color LED for visual indication of activity  0.100” pin spacing for easy prototyping and integration  125kHz read frequency.  Magnetic stripe emulation output.  Dimensions: 82.5x62.2x3.6mm.

 Electronic Connections The Parallax RFID Reader Module can be integrated into any design using only four connections (VCC, /ENABLE, SOUT, GND). Use the following circuit for connecting the Parallax RFID Reader Module to the BASIC Stamp microcontroller as show in table 5.2

26

Chapter Five Smart parking system design and operation

Table 5.2 RFID pin description

Pin Pin Name Type Function 1 VCC Power System power, +5V DC input. 2 ENABLE Input Module enable pin. Active LOW digital input. Bring this pin LOW to enable the RFID reader and activate the antenna. 3 SOUT Output Serial Out. TTL-level interface, 2400bps, 8 data bits, no parity, 1 stop bit. 4 GND Ground System ground. Connect to power supply’s ground (GND) terminal.

 Communication Protocol Implementation and usage of the RFID Reader Module is straightforward. The RFID Reader Module is controlled with a single TTL- level active-low /ENABLE pin. When the /ENABLE pin is pulled LOW, the module will enter its active state and enable the antenna to interrogate for tags. The current consumption of the module will increase dramatically when the module is active. A visual indication of the state of the RFID Reader Module is given with the on-board LED. When the module is successfully powered-up and is in an idle state, the LED will be GREEN. When the module is in an active state and the antenna is transmitting, the LED will be RED. The face of the RFID tag should held parallel to the front or back face of the antenna (where the majority of RF energy focused). If the tag is held sideways (perpendicular to the antenna), you will either get no reading or a poor reading. Only one transponder tag should held up to the antenna at any time.

27

Chapter Five Smart parking system design and operation

The use of multiple tags at one time will cause tag collisions and confuse the reader. The two tags available in the Parallax store have a read distance of approximately 3 inches. Actual distance may vary slightly depending on the size of the transponder tag and environmental conditions of the application. When a valid RFID transponder tag is placed within range of the activated reader, the unique ID will be transmitted as a 12-byte ASCII string via the TTL-level SOUT (Serial Output) pin in the format that show in figure 5.3.

MSB LSB MSB Unique Start Unique Unique Unique Unique Unique Unique Unique Unique Unique Stop ID Byte ID ID ID ID ID ID ID ID ID Byte Digit (0x0A) Digit 1 Digit 2 Digit 3 Digit 4 Digit 5 Digit 6 Digit 7 Digit 8 Digit 9 (0x0D ) 10

Figure 5.3 ID Format

The start byte and stop byte are used to easily identify that a correct string has been received from the reader (they correspond to a line feed and carriage return characters, respectively). The middle ten bytes are the actual tag's unique ID. All communication is 8 data bits, no parity, 1 stop bit, non- inverted, least significant bit first. The baud rate configured for 2400bps, a standard communications speed supported by most any microprocessor or PC, and cannot be changed. The Parallax RFID Reader Module initiates all communication. The Parallax RFID Reader Module can connect directly to any TTL-compatible

5.2.2 RFID Tags RFID tag is a microchip combined with an antenna in a compact package; the packaging is structured to allow the RFID tag to be attached to an object to be tracked. The tag's antenna picks up signals from an RFID reader and then returns the signal, usually with some additional data like a unique serial number or other custodies information see figure 5.4.

28

Chapter Five Smart parking system design and operation

Figure 5.4 RFID Tag

 Types of Tags There are two differentiating factors between Tags  According to the on board Power Source.  According to the Memory type.  According to the on Board Power Source There are three types:

 Active Tags contain on board power source such as battery, and it uses this power to transmit the information to the Interrogator (Reader) and this means that this tags can communicate with less powerful Interrogator, can transmit information over a larger range up to hundreds of feet and have larger memories up to 128 K bytes, beside that it has larger size, more complicated structure and more expensive than the Passive one. The advantages of an active tag it can be read at distances of one hundred feet or more, greatly improving the utility of the device. It may have other sensors that can use electricity for power. The disadvantages of an active tag The tag cannot function without battery power; it limits the lifetime of the tag; tag is more expensive; tag is physically larger which may limit applications;

29

Chapter Five Smart parking system design and operation

 Passive Tags have no power source on board but drive its power to transmit data from signal sent by the Interrogator, this made Passive tags smaller and less expensive than the active tags. The advantages of a passive tag The tag functions without a battery; and have a useful life of twenty years or more; tag is typically much less expensive to manufacture; tag is much smaller. The disadvantages of a passive tag the tag can be read only at very short distances. It may not be possible to include sensors that can use electricity for power.

 Semi-Passive tags are very similar to passive tags except for the addition of a small battery. This battery allows the tag IC to be constantly powered. This removes the need for the aerial to be designed to collect power from the incoming signal. Aerials can therefore be optimized for the backscattering signal. Semi-passive RFID tags are faster in response and therefore stronger in reading ratio compared to passive tags [7].

 According to the Memory type There are two main types:

 Read-Only Have memory that can be read only. Read-Only tags are similar to bar codes in that they are programmed once, by a product manufacturer for instance, and from there on cannot be altered, These types of tags are usually programmed with a very limited amount of data that is intended to be static, such as serial and part numbers, and are easily integrated into existing .

 Read/Write tag

Present the user with much more flexibility than Read-Only tags. They can store large amounts of data and have an addressable memory that is easily changed. Data on an Read/Write tag can be erased and re-written thousands of times, much the same way a floppy disk can be erased and re-written

30

Chapter Five Smart parking system design and operation at will.

5.2.3 Ultrasonic Ultrasonic Range Sensor use to calculate distances from objects. Ultrasonic Range Sensor it’s an IC that works by sending an ultrasound pulse at around 40 KHz. It then waits and listens for the pulse to echo back, calculating the time taken in microseconds you can trigger a pulse as fast as 20 times a second and it can determine objects up to 3 metres away and as nears 3cm. It needs a 5V power supply to run. Ultrasonic Range Sensor have only 4 pins to Power, Ground, Trigger and Echo see figure 5.5 [8].

Figure 5.5 Ultrasonic 5.3 Output Unit An output device is any piece of hardware equipment used to communicate the results of data processing carried out by an information processing system (such as a microcontroller) which converts the electronically generated information into human-readable form

5.3.1 Liquid crystal display 16x2 Liquid Crystal Display (LCD) screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and very commonly used in various devices and circuits. These modules are preferred over seven segments and other multi segment LEDs.

31

Chapter Five Smart parking system design and operation

The reasons being: LCDs are economical; easily programmable; have no limitation of displaying special and even custom characters (unlike in seven segments), animations and so on. A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD, each character displayed in 5x8-pixel matrix. This LCD has two registers namely, Command and Data as shown in Figure (5.4).

Figure 5.6: LCD 16x2 pin description

 LCD 16x2 pin description Vss: Ground. VCC: the supply voltage from +3.3 to +5V. VO: contrast adjustment. RS: Register Select (RS). RS=0: Command, RS=1: Data. Read/Write (R/W). R/W=0: Write, R/W=1: Read pin is optional due to the fact that most of the time you will only want to write to the LCD and not to read. Therefore, in general use, this pin will be directly connected to ground. Clock (Enable): Falling edge triggered. D0…D7: Data pins used for receiving the data to displayed. A+ and K-: used for illuminating the backlight LED.

5.3.2 Servo Motor A Servo is a small device that has an output shaft. This shaft can be positioned to specific angular positions by sending the servo a coded signal. As long as the coded signal exists on the input line, the servo will maintain the angular position of the shaft. As the coded signal changes, the angular position

32

Chapter Five Smart parking system design and operation of the shaft changes. In practice, servos are used in radio-controlled airplanes to position control surfaces like the elevators and rudders. They are also used in radio-controlled cars, puppets, and of course, robots. Servos are extremely useful in robotics. The motors are small, as show in figure 5.7, the motor have a built in control circuitry, and are extremely powerful for their size. It draws power proportional to the mechanical load. A lightly loaded servo, therefore, doesn't consume much energy.

Figure 5.7 Servo

5.4 Circuit Implementation The Smart parking system can be divided into three parts, input unit, control unit and the output unit. Input terminals are the peripherals that support the ARDUINO within an input signals that is required to do some processes. These devices, which used as Input terminal are RFID and four Ultrasonic sensor .The RFID is connected to pin (0 and pin 16). The RFID used as Identifier to identify the car owner and the Ultrasonic sensor connected to (pins 14, 15 and 10, 9 and 11, 8 and 6, 7 in series) to sense the availability of the parking. The output terminals – LCD and servo motors- are

33

Chapter Five Smart parking system design and operation peripherals used to handle the output signals from the ARDUINO. The LCD displays the parking availability depending on the signal comes from the ultrasonic sensors in the parking. The data pins of the LCD connected to pins

(2, 3, 4 and 5), RS to pin 19, enable to pin 18, the servo connected to (pin 17 and pin 12). The implementation of this project shown in Figure 5.8

Figure 5.8: Circuit implementation 5.5 Operation When the system powered up first, the ARDUINO presets its I/O and waits for a predefined period until the RFID module being ready to receive the signal, set each of Entry and Exit servo motors at default angle (close the gate). Now the RFID is ready, and the ARDUINO proceeds to examine the numerous sensors of ultrasonic that allocated in each parking spot by sending a pulse from the trigger and receives it by the Echo to measure the time taken by it from sending to receive (duration). This time duration converted in the code from time to distance (the distance between the ultrasonic and car). If the distance close enough, the ARDUINO reads this 34

Chapter Five Smart parking system design and operation parking as filled. Here, the system is ready to registrar a new car that built in RFID tag by swiping the master card above the RFID reader. master card has been already register at the code, and the serial monitor will display "Master Card Scanned - Programming mode Enabled", and then swipes the tag that we want to register it in the system, and the serial monitor will display which slot in EEPROM saved by the card. The maximum number that can registered is four cards (the maximum number of card can customized later). If a car came to parking, the RFID will read the car's tag, if it is not registered; the LCD will display "UNREGISTERED CARD ACCESS DENIED". Otherwise, the ultrasonic sensor will check the parking availability, if there is at least one free space, the barrier will opened by moving the angle of the servo from 0ᴼ to 90ᴼ, and displays on LCD the available space. If there is a car want to leave the parking, it will pass through the ultrasonic that it built in the ground at the Exit barrier, and then the barrier will open to this car, after the car leaves the parking. The ARDUINO waits for a predefined period, and then closes the barrier by move angle of servo to oᴼ. If the parking is full the LCD will display a massage tells the driver that there is no more space. Figure 5.9 shows the actual Smart Parking System.

35

Chapter Five Smart parking system design and operation

Figure 5.9: Smart Parking System Final Project

5.6 Software Description The software written in Arduino development environment contains a text editor for writing code, a message area, a text console, a toolbar with buttons for common functions, and a series of menus. It connects to the Arduino hardware to upload programs and communicate with them. In the Writing Sketches the software written using Arduino are call sketches. These sketches are write in the text editor. Sketches are save with the file extension (.ino).It has features for cutting, pasting, searching and replacing text. The bottom right hand corner of the window displays the current board and serial port. The toolbar buttons allow you to verify and upload programs, create, open, and save sketches, and open the serial monitor. We can write program the one assembly and one C function for writing to the EEPROM. The figure (5.10) show that the Arduino development environment.

36

Chapter Five Smart parking system design and operation

Figure 5.10 Arduino development environment

5.7 Flow chart

Start

Include RFID and LCD libraries

Config LCD pins

Config RFID pins

Config Ultrasonic sensor pin

I Read RFID

No fob J detected 37

Chapter Five Smart parking system design and operation

Yes

Read Ultrasonic

No U3>limit No U1>limit No U2>limit

Yes Yes Yes

A B C D E F G H LCD print "welcome go to A p1"

LCD print

"welcome go to B p2 "

LCD print "welcome go to C p3"

LCD print "welcome go to D p1 or p2or p3 "

38 LCD print "welcome go to E p1 or p3"

Chapter Five Smart parking system design and operation

J

Master I Detected No

Yes

Serial Monitor print "Master card Scanned "

Master Detected No

Yes

Remove All Card Save Card

END K

39

Chapter six CONCLOUSIONS AND RECOMMANDATIONS

Chapter Six

CONCLOUSIONS AND RECOMMANDATIONS

6.1 CONCLUSIONS The project is an smart parking with using RFID as authentication method to open the barrier using the servo motor, and LCD to direction the driver where the free space to park their car.

The information of availability of parking come from sensor that build in each park this project offered us many services we need to keep up with this age such as saving time and effort, solving problem of illegal parking, reduction of traffic jam and offering more safety parking which have high technique that helps to prevent accidents.

6.2 RECOMMANDATIONS In our project we used unshielded Ultrasonic and RFID with range 7cm, we recommend to use ultrasonic that can be shielded against dust and water and RFID with longest range. Also we recommend to apply CCTV to this project for more security and applying additional ultrasonic after exit barrier to make closed more efficiently.

40

References [1] Benjamin C. Kuo "Automatic Control Systems" Prentice-Hall, 1982.

[2]Salgado, Graham C. Goodwin, Stefan F. Graebe, Mario E. "Control System Design" Prentice Hall, 2001.

[3] https://en.wikipedia.org/wiki/Microcontroller [Accessed: march 2016]

[4] D.S. Yadav Arun Kumar Singh " Microcontroller: Features and Applications" New Age International, 2004.

[5] Dogan Ibrahim" Microcontroller-Based Temperature Monitoring and Control ,”Newnes, 2002

[6] Michael Mcroberts "Beginning Arduino"Apress, 2013

[7] Klaus Finkenzeller "RFID Handbook: Fundamentals and Applications in Contactless Smart Cards, Radio Frequency Identification and Near- Field Communication", John Wiley & Sons, 2010.

[8] T. Sato "Intelligent Autonomous Systems IAS-5" IOS Press, 1998.

43