Sie sind auf Seite 1von 69

FACULTY OF INDUSTRIAL TECHNOLOGY. DEPARTMENT OF ELECTRONIC ENGINEERING.

FINAL

YEAR

PROJECT.

ELECTRONICS LABORATORY SECURITY SYSTEM.


Name : Tinotenda Zwavashe.

Student Number

: N004 1143A.

Supervisors

: Mr. S.Komichi. Mrs. M. B.Nheya.

Academic Year

: 2009 2010.

THIS IS A DESIGN PROJECT DONE IN PARTIAL FULLFILMENT OF THE HONOURS DEGREE IN ELECTRONIC ENGINEERING AT THE NATIONAL UNIVERSITY OF SCIENCE AND TECHNOLOGY.

Electronics security

Acknowledgements.

This project would not have been a success without the support of the following people to whom I sincerely extend my gratitude and appreciation for the job well done. All my family members, especially my brothers and their families for all the financial support considering these trying and harsh economic times. Among these special mention goes to Sabhuku ,Jabell, Simbarashe, Munyaradzi and Clayton. God bless you all! Special mention goes to my project supervisor Mr. Komichi for the valuable knowledge he impacted into me and the guidance he gave me throughout the project design and implementation. I would also like to thank the departmental chairman of the Electronics department and the rest of the staff for the support they rendered and the conducive learning environment.

To my classmates Taurayi and Robson I dont know how Im supposed to thank you for all your patience and help you offered at every needing moment .you also made me believe in myself so as to carry out my project with confidence. Also mention goes to Concie, Mpokiseng and Jenica for all the resources and lighter moments .You surely proved to be good friends.

Electronics security

Abstract.

The project was to design and implement an intelligent access control system that simulates the operation of a real world door. The access is for the Electronics Computer Laboratory so it will grant access to Electronics students and staff members only.

The technique used to meet the design specifications was to use the programmable PIC16F873 and a database on a personal computer to make the intelligent decision of granting access through the door.

The system should also keep track of the time of entry and time of moving out for the sake of security. The host computer which has a bar code scanner connected to its USB/ serial port will be containing the database that will be used to store students information in Ms Access and a visual basic user interface would be used to add or delete students details/records.

In addition the system should be able to record history of people that would have entered the door in an entrance register which can always be viewed by the laboratory administrator. An incidence of someone who is inside, giving his/her ID to someone outside through the window for him to gain access also, is eliminated by use of two doors. For one to gain access into lab he/she has to pass through both doors. Thus the system should be able to identify whether someone is already in the lab or out of the lab, details of which are explained in the main body of this report.

Electronics security

---------------------------------------Table of contents----------------------------------------------Chapter 1 Introduction. 1.1 System background 7 1.2 Review of design specifications.. .8 Chapter 2 Literature Review 2.1 Theory of bar code scanners15
2.1.1 Principles of bar code reading. 2.1.2 Types of bar code scanners.

2.2 Theory of PIC16F873..16


2.2.1 2.2.2 2.2.3 Port setup. Data memory organization. Pin out diagram of 16F873.

Chapter 3 Modular Design. 3.1 3.2 3.3 3.4 Power supply sub-system....23 Alarm sub-system....25 Motor sub-system....25 ILX232 subsystem28

Chapter 4 Software Development. 4.1 Microchip language.31


4.1.1 Port allocation. 4.1.2 Delay flow charts.

4.2 Visual basics design.39 Chapter 5 Complete Circuit implementation. 5.1 The output section .46 5.2 PIC receiving flow chart.. .47 5.3 Testing and results....... .49 Chapter 6 - Conclusion....... .52

Appendix A - Abbreviations.. .55 Appendix B - Project cost analysis........ .56 Appendix C -Transistor 2N3053 characteristics......... .57 Appendix D -ILX 232 characteristics .58 Appendix E -Microchip code for PIC ..60 References 69 -----------------------------------t1zvavashe----------------------------------------------------------

Electronics security

Chapter 1.

INTRODUCTION.

Electronics security

1.1 System background. The Electronics department Computer Laboratory is one of the central learning areas for the Electronic Engineering students. Due to the much activity which occurs in the lab it has been discovered that students from other departments frequently have been found using the premises. This has resulted in the damage and missing of some property in the laboratory without any accountability as to how and who has caused all the misses and losses. In the previous years it was discovered that this can be reduced by use of a security guard who constantly monitors activities in the laboratory. The same person would also be responsible for seeing that everyone who enters has a valid Electronic Engineering Student identity card. This improved the services of the computer laboratory as students could use the laboratory up to around 9 oclock in the evening with the computer lab administrator knowing that everything was secure even in his absence. Unfortunately in the previous few months the guard was dismissed from the monitoring process and the administrator was left to safeguard the lab on his own. However sometimes he will be away for lectures .This, as a result drew us to the situation of insecurity of the lab. The lab also exhibited inefficient usage since it closed at 4pm when the administrator went home. This was made worse by the fact that sometimes there will be electric power cuts from morning; say up to 2pm with the students having only two hours to use the lab. This adversely affected the learning process. Taking this into account, the author therefore took the initiative to design a system which monitors the laboratory. The system which uses a barcode scanner would make sure only students bearing Electronics student identity cards would gain access into the lab. The self monitoring system would also log in the time of entry of each user and also log out his/her time of exit. Thus anything which occurs during a known period of time can be traced as to who were in the lab during the period. Even if someone gives his/her ID to someone not supposed to be using the lab and something negative occurs, the owner of the ID will be held accountable. This can thus allow complete usage of the laboratory even if the administrator goes home. Electronics security 7

1.2 Review of design specifications. The Electronics computer lab security system is to employ a bar code reader to scan I D cards and offer restricted entrance into the computer laboratory. Bar code reader scans identity card bar code. The code is sent to the personal computer where it is interpreted by a visual basic code. The code distinguishes between authorized and unauthorized laboratory users. The PC sends specific signals to the microcontroller if identity of the user is known and permitted to use the lab and a different signal if identity of user is unknown. For known users the system sends a signal which is different for someone already in the lab and someone who is coming from outside Microcontroller drives the circuit to open and close the door to allow access only to authorized laboratory users. A visual interface installed on administrators computer enables the laboratory administrator to view and know all the people who have been using the lab all day.

Electronics security

Possible configurations which can be used 1.1.1 Configuration A. This is shown in the diagram below. The bar code reader is connected through the PIC.There is communication between the PIC and the PC through the serial communications port. The communication between the PIC and the PC is bi-directional since the PC has to verify data from PIC and send a signal to PIC to tell it to open or not to open for the respective user. Drawbacks of this design include. A long code has to be developed which runs the PIC since the PIC is the one which first detects the bar code and also it receives data back from PC. A code has to be developed for communications from PIC to PC and from PC to PIC. A visual basic code has to be developed at the database of the PC.This is the one to verify user details and also provide user interface to the administrator. It is difficult to connect the scanner directly to the PIC since there will be need for drivers and complicated circuitry. Generally the configuration gives to much work on the side of the PIC and the author.

Figure 1.1: Configuration A setup.

Electronics security

The microcontroller is awakened from the waiting state by an interrupt signal generated when the user presses the start button. This interrupt will cause the microcontroller to enter the bar-code monitor state. This state may be characterized by the green Light Emitting Diode which commences to flash. The bar code scanned will be stored in the data area of RAM. The microcontroller then compares the code with the list of codes stored in the programme area of memory.

Electronics security

10

START

WAIT STATE

N IS START PRESSED?

Y N IS ACCEPT REG LOADED?

STORE SCANNED BARCODE

COMPARE WITH STORED CODES

LIGHT RED LED AND SOUND BUZZER.

IS SCANNED CODE=ANY STORED?

OPEN DOOR AND LIGHT GREEN LED

DELAY 5 SECONDS

CLOSE DOOR

Figure 1.2: Flow chart showing scanning process for Configuration A. 1.1.2 Configuration B. Here the bar code scanner communicates with the microcontroller directly and the database in use is that of the microcontroller. Again the problem which was likely to be

Electronics security

11

faced was the difficulty in connecting the bar code scanner to the microcontroller. There was a tendency that a complex driving circuitry would be needed to interconnect the scanner and the microcontroller.

Figure 1.3: Diagram showing configuration B arrangement. 1.1.3 Configuration C. In this configuration the bar code reader communicates directly with the PC database scrutinizing the read code. If the code of the user is of an allowed user then the PC communicates, through serial port, with the PIC sending a signal to open the door and showing particular display on the LED indicators. Generally the PIC here does less work of opening and closing and showing particular indicators. Much of the work is done by the visual basic user interface. Thus we have unidirectional data flow between the PC and the PIC.

Figure 1.4: Diagram showing configuration C arrangement.

Electronics security

12

The configuration C looked more friendly and practical. Bar code scanners come as plug and play devices and can be connected to a personal computer with relative ease, ie, direct connection of the bar code scanner to the personal computer is very feasible since the scanner is a plug and play device. The only work will be to interface it to the visual basic environment. Thus this is the configuration which the author adopted for his purposes.

Electronics security

13

Chapter 2.

LITERATURE REVIEW.

Electronics security

14

2.1 Theory of bar code scanners.

Bar codes are just another data input method. The use of bar coding has been growing dramatically over the last 25 years. With the adoption of UPC as the standard for retail grocery stores in the late 70's, bar codes have become an everyday experience for most people. Bar codes are a fast, easy, and accurate data entry method. The correct use of bar codes can decrease employee time required and increase an organization's efficiency.

The data in a bar code is just a reference number which the computer uses to look up associated computer disk record(s) which contain descriptive data and other pertinent information.

2.1.1 Principles of bar code reading.

A bar code consists of white and black bars. Data retrieval is achieved when bar code scanners shine a light at a bar code, capture the reflected light and replace the black and white bars with binary digital signals. Reflections are strong in white areas and weak in black areas. A sensor receives reflections to obtain analog waveforms. The analog signal is converted into a digital signal via an A/D converter. (Binarization) Data retrieval is achieved when a code system is determined from the digital signal obtained. (Decoding process).

2.1.2 Types of bar code scanners.

CCD method.

Electronics security

15

This method uses a semiconductor device called CCD(Charge Coupled Device), which converts light signals into electric signals. A bar code is captured once, allowing fast reading. There are no movable parts and impact resistance is excellent.

Laser method.

Laser light is shone on the label surface and its reflection is captured by a sensor (laser photo detector) to read a bar code. A laser beam is reflected off a mirror and swept left and right to read a bar code. Using laser allows reading of distant and wide bar code labels.

Pen method.

This method only has a LED light source and a sensor to capture its reflection. Since a person moves a scanner to read a bar code, practice is required for operation.

The mechanism is simple, making this method inexpensive.

2.2 Theory of the PIC 16F873.

Part of the brain of the processing unit was done using the PIC 16F873.This was chosen due it its availability, simple structure, affordability, ease of use, availability of USART, memory size and availability of its details. Some of the salient features of the PIC 16F873 include low current consumption, 4k program flash memory, 20 input/output lines with current consumption of 25mA,5V power supply and most instructions executed in a single cycle. The features of PIC16F873 Pico-controller are shown in the table below:

Electronics security

16

Figure 2.1: Key features of PIC 16f 873.

2.2.1 Port setup.

The twenty input /output standard ports are the mean by which the micro controller communicates with the external environment and manipulates the peripherals. For this to be accomplished successfully the ports have to be configured to being input or output before communication begins. In some cases it can both be desired and required for a port to be split into half input, half output. This configuration can be accomplished by setting up the TRIS registers. The TRIS registers are data direction registers responsible for setting up data direction of the ports. Every port has a corresponding TRIS register, i.e., Port A is controlled by TRISA; port B by TRIB and so on. Setting the bits in a TRIS register to binary 1 will set the corresponding port pins to input, while setting them to 0 (clearing) configures the corresponding pins to outputs. A combination of input / output is allowed. For example setting TRISA to 00001111 will set B0-B3 to be inputs whilst B4-B7 will be set to outputs. The diagram below shows the pin configuration of the PIC 16F873.

Electronics security

17

Figure 2.2: Pin configuration of the PIC 16F873. Legend: I I/O O P TTL ST -- input -- input/output. -- Output. -- Power. -- TTL input. -- Not used -- Schmitt Trigger input

Note 1: This buffer is a Schmitt Trigger input when configured as the external interrupt. Electronics security 18

2: This buffer is a Schmitt Trigger input when used in Serial Programming mode. 3: This buffer is a Schmitt Trigger input when configured in RC oscillator mode and a CMOS input otherwise.

2.2.2 Data memory organization.

The data memory is partitioned into multiple banks which contain the General Purpose Registers and the Special Function Registers. Bits RP1 (STATUS<6>) and RP0 (STATUS<5>) are the bank select bits.

RP1:RP0 00 01 10 11

Bank 0 1 2 3

Each bank extends up to 7Fh (128 bytes). The lower locations of each bank are reserved for the Special Function Registers. Above the Special Function Registers are General Purpose Registers, implemented as static RAM. All implemented banks contain Special Function Registers. Some frequently used Special Function Registers from one bank may be mirrored in another bank for code reduction and quicker access.

Electronics security

19

Figure 2.3: file register map for 16F873

2.2.3 Pin out diagram of PIC 16F873.

The diagram below illustrates the structure of the 28 pin configuration of the PIC16F873.

Electronics security

20

Figure 2.4: Pin layout of the PIC 16F873.

Electronics security

21

Chapter 3.

MODULAR DESIGN.

Electronics security

22

3.1 Power supply subsystem.

A 5 volt power supply is to provide power to the micro-controller and ILX 232 chip. The microcontroller and ILX 232 are both powered using stabilized 5V D.C voltage.

Figure 3.1: Circuit diagram of a 5 volts power supply.

The microcontroller is a very delicate integrated circuit functioning over a very limited voltage range of between 3V-6V.Thus careful consideration had to be taken into account to design a supply mainly centered at around 5V output regulated voltage. This was accomplished by using the positive voltage regulator LM78L 05 as the heart of the power supply. A 15 volt transformer was used and its output rectified and smoothed before being fed to the regulator. The regulator is also surrounded by biasing capacitors which help in stabilizing the output voltage. Rectification was accomplished by using the 1N4007 rectifying diodes in a full bridge circuit. The table which follows shows the electrical characteristics of the LM7805 voltage regulator.

Electronics security

23

Figure 3.2: Electrical characteristics of the 78L05 regulator.

A power supply was also designed to cater for the relays. The relays used were all 12 volt powered. Thus the 15 volt transformer also provided power to the circuit consisting of a 12 volt regulator.

Figure 3.3: Circuit diagram of a 12 volts power supply.

Electronics security

24

3.2 Alarm Subsystem.

The alarm subsystem comes into play when someone who is not possessing entry rights tries to use the premises. Thus it is an audible warning telling him/her that he/she has been denied access. The author could have connected the alarm circuit directly to the 2N3053 transistor without incorporating a relay; however he discovered that the alarm circuit needs a lot of current which cannot be easily supplied by the direct connection.

PIC to Alarm interface.

Figure 3.4: Diagram for PIC to alarm interface.

3.3 Motor Subsystem.

The author researched on many ways in which the doors into the laboratory can be securely and electronically be controlled. Among them was the use of a magnetic door locks, stepper motors, and/or DC motors.

Electronics security

25

Magnetic door lock. The locking mechanism would consist of an aluminum bar, a spring and a solenoid. It may be powered by 240V ac at 60 Hz. In the locked state the armature spring pushes the aluminum bar into the wall or door frame thereby locking the door. When the solenoid is powered by 240V ac it attracts the bar into it. This compresses the spring and pulls the bar out of the door, thus unlocking the door. However the author found it difficult and expensive (considering the other expenses he had accumulated) to acquire the required solenoid.

Stepper motors. Grant access by making angular steps. The step sizes can be controlled thus giving the advantage of reasonable speed when opening or closing the door. The stepper motor rotation and delays can be tested simply by using LEDs to flash sequentially.

DC motors.

Due to financial constraints the author had to opt for the more affordable and readily available DC motors which he finally implemented in his project work.

DC motor functionality.

The author had to use two DC motors each driving its separate door. The motors are to function in opening and closing the doors. Relay switches were used so that any size of motors ranging from DC to AC voltage supply can still be used to drive the doors. For the first motor one terminal of the DC motor is controlled by pin RB4 of microcontroller whilst the other motor input is controlled by pin RB5.When RB4 is set to high state the motor is turned ON and rotates, say, in the clockwise direction for a period set by delayMotor.The delay is very short, approximately 1second, since the DC motor rotates at a very high speed after which pin RB4 is cleared to stop motor from running and

Electronics security

26

leaving the door open. At this point a delay of 6 seconds (as set by delayLong) is allowed so that person can gain access through the door.

After that pin RB5 is then set to high state, thus activating the motor in an opposite direction assumed to be the anticlockwise direction. Also pin RB5 is kept high for approximately 1second (as set by delayMotor) so that motor makes the same number of rotations as before to completely close the door. A delay set by DelayMotor was chosen after testing the motor and seeing that the number of turns it makes in that period will reasonably open the door so that someone can freely move into or out of the laboratory. The second motor is controlled by pins RC4 and RC5 of PORT C. The same principles apply for both motors driving the two doors on the system. Another delay called delayShort of approximately 3 seconds was also used when one door closes and the person waits for the other door to open. All delay flowcharts are outlined under the microchip subsection.
Testing the D.C motor.

The DC motor tests were mainly to establish and set the required time delays in line with the speed of the crystal oscillator which was used to clock the microcontroller circuit. A 4.5 MHz crystal was used and the delays were calculated accordingly. The LEDs were used to blink and for the author to establish if the set delays were accurate. LED D2 should light for approximately 1 second when pin 25 i.e. RB4 is set high. Both LEDs should then switch OFF for the next 6 seconds after which LED D1 will then light for 1 second after pin 25 i.e. RB5 is set high. The connection of the LEDs is shown in the diagram below.

Electronics security

27

Figure 3.5: Testing DC motor functionality.

3.4 The ILX 232 Subsystem. The chip is responsible in the interfacing between the personal computer and the Pico controller. Generally the chip converts RS232 voltages to TTL/CMOS voltages or vice versa. A standard serial interfacing for PC, ILX 232C,requires negative logic,i.e.logic 1 is -3V to -12V and logic 0 is +3V to +12V.To convert a TTL logic,say,TxD and RxD pins of the microprocessor chips, thus need a converter chip. A family of the converter chip which is in common use, but performing a similar function is the Max232 chip. A Max232 chip has long been used in microprocessor boards. It provides 2-channel RS232C port and requires external 10uF capacitors. There is need to carefully check the polarity of capacitor when connecting the chip. However for the ILX 232 chip the capacitors needed are 0, 1 uF.

Electronics security

28

Figure 3.6: ILX 232 pin connections.

Electronics security

29

Chapter 4.

SOFTWARE DEVELOPMENT.

Electronics security

30

4.1 Microchip language

The PIC 16F873 was programmed using the microchip MPLAB language. This is the software program which is to control the hardware devices when the microcontroller receives the appropriate signal from the computer via the serial port. According to design specification the microcontroller should sit in an endless loop doing nothing except lighting the orange LED waiting for the signal which prompts it to perform some certain action. The two actions which it can perform are either to grant entry by opening the doors or to deny entry by not opening the doors and giving appropriate alarm signals. The orange LED is to signify that the microcontroller is ready to perform the next action it will be signaled to perform.

For the microcontroller to grant or deny entry it will receive a specific number, in our case, 50 , 51 or 52 hexadecimal which is transmitted from the PC.When it receives a 50 it means that the person who has been scanned doesnt have the right to use the lab. So upon receiving the 50 it lights a red LED and sound a buzzer. When the PIC receives a 51 it knows that someone is already inside and needs to move out. It then lights the green LED at the same time driving the motor which opens the inside door first in one direction and delaying for a period delayLong so that one gains entry through first door. System then closes inner door and delays for DelayShort and opening the outer door and the person then moves out. When PIC receives a 52 it knows that someone is outside and needs to move into the Lab. It then opens the outer door first following the same procedure like before. After closing outer door it then opens inner door. Thus basically the microchip code developed for the PIC is to fulfill the above operations on the system.

4.1.1 Port allocation.

Electronics security

31

The ports of the microcontroller which will control the output devices are allocated as in the following table. All the output devices are allocated to Port B of the microcontroller showing that our design did not exhaust a large number of port pins of the PIC.

Pin number.

Allocation.

RB0

Orange light emitting diode.

Red LED indicator. RB1

RB2

Green LED indicator.

RB3

Buzzer.

RB4

D.C motor.

RB5

D.C motor.

RC4

D.C motor2

Electronics security

32

RC5

D.C motor2

The program fragment below shows part of the code for the PIC receiving through the USART.

The program fragment above performs the following functionality: Bit 0 of PORT B is set so that the orange light emitting diode turns ON. The LED is to show that the system is in a ready state waiting for a person to scan his identity card. System then continuously monitors bit number 5 of the PIR1 register, i.e. the RCIF (Receive Interrupt Bit).The bit is set when anything is received on the USART receive pin. The instruction btfss specifies that the next instruction should be skipped if bit RCIF is set, thus the program counter goes to instruction movf RCREG,W where contents of receive register are moved into a working file The instructions which follow deal with the processing of the received data.

Electronics security

33

When RCIF bit is not set it means that nothing has been received and the system continues to monitor the receive port by testing the RCIF bit.

4.1.2 Delay flow charts.

The author employed a delay subroutine as a means of controlling D.C motors direction. The motor turns in one direction thereby opening the door. It then stops for a specific duration for which a person is expected to enter which is the delay duration. After that the motor is again activated this time in the other direction thereby closing the door.

Had it been that resources permitted, the author intended to use passive infra-red sensors as a means of detection whether or not a person has passed through. After detection of some motion the motor will then be activated in an opposite direction thus closing the door. Thus in such a case the delay subroutine will not be necessary.

The delay flow charts have the following functions: DelayLong Time duration for which someone is expected to gain entrance through a door. DelayMotor duration for which the motors are expected to be switched on when opening or closing the doors. The delay was set by the rate at which the motor rotates. DelayShort time duration when the first door closes and the person waits for the second door to open. The duration also governs the time it will take the red LED to light and alarm to ring when someone with no access rights scans his/her barcode.

Electronics security

34

Figure 4.1: Flowchart for DelayLong.

Electronics security

35

Figure 4.2: DelayShort flow chart.

Electronics security

36

The delayShort flow chart helped me to come up with the following piece of code which was compiled in microchip language and programmed into the microcontroller.

Electronics security

37

Figure 4.3: Delay Motor flowchart.

Electronics security

38

4.2 Visual Basics Design.

Much of the software design which was done was to develop the visual basic code which does the comparison of the scanned bar code and the one stored in the database. The code also provides the user interface to the administrator who monitors movement into and out of the Laboratory. Thus basically the visual basic design should provide the following services: Do the comparison of the scanned bar code to the ones stored in the Ms Excel database. Provide the administrator with the interface form where he can view movement which has been occurring in and out of the Laboratory. Provide the administrator with the opportunity where he/she can view all the students stored in the database. Give the administrator the privilege to add new members to the database, edit existing members and remove users from the system. Be able to communicate via the serial port and ILX 232 with the microcontroller unit.

Thus the author had to create the necessary interface forms, come up with the compliant code and also link the VB code with the Access database. The forms have all the necessary components for communicating with the serial port as well as the database, so the database is updated in real time. After receiving a number from reader it runs a query to check for any matches in the database. If there are matches it sends a number, 51 or 52 hexadecimal, to the Ms Comm. output control function which in turn passes the number to the PIC and this will trigger an interrupt handler which will set Port RB4 or RC4 driving the motor circuit to open door and lighting the green LED by setting port RB2.If in the database no matches are found it sends a number, 50, to Ms Comms control function and the number is passed to the PIC so as to light a red LED by setting Port RB1 and sounding an alarm by setting pin RB3. Some of the fields used in creating the database are: First Names. Surnames. Student number.

Electronics security

39

Barcode Number. Academic Year. Status. Below is the structure of the entrance register for logging in and out students.

Form 4.1: Structure of the entrance register interface. The diagram below will also show the structure of the interface form which is used in the entering of new members, editing and deleting of student details.

Electronics security

40

Form 4.2: Interface used to enter students into the database.

Existing members can always be known since the administrator is equipped with the interface where he/she can view the students already in the database. This is done using the software interface shown in the table of form 4.3.

Electronics security

41

Form 4.3: Interface used to view the entries of the database.

System Security.
The system is also equipped with security such that when the administrator runs the program he/she is first prompted to enter a password before running the program. Another username and password prompt which is different from the first one is also used when someone wants to manage database, and or change passwords.The usernames and passwords have their own database which can be entered many passwords for different administrators and the passwords can easily be altered. As such no person not authorized can easily alter the student details in the database. Such an interface is shown in the forms below:

Electronics security

42

Form 4.4 : The password2 procedure for database access.

Electronics security

43

Form 4.5: The logging in procedure.

The scanning process.


For the scanning process an interface is provided where when someone scans his/her identity card the code scanned is received into a text box. The system searches for the code in the main database and if code is not found an appropriate signal is sent to the PIC via serial port. If the code is found the details of the entrant are displayed in the shown text boxes and the details and time when the event has occurred is sent to the entrance register where they are stored.

Form 4.6: The scanning procedure.

Electronics security

44

CHAPTER 5.

COMPLETE UNIT IMPLEMENTATION.

Electronics security

45

5.1 Output section.

The diagrammatic layout of how the output devices were connected to the microcontroller is as shown in the diagram which follows:

Figure 5.1: Connections of output devices to PIC.

The circuit however shows the connection of just one motor. The other motor is connected on port C on RC4 and RC5 likewise.

5.2 The PIC receiving flow chart.

Electronics security

46

START

MONITOR USART RECEIVE

ANYTHING RECEIVED? DELAY 3 SECS

IS RECEIVED= 50DECIMAL?

SET RB1 FOR RED LED & RB3 TO SOUND BUZZER.

IS RECEIVED= 51 DECIMAL?

OPEN INNER DOOR

OPEN OUTER DOOR

DELAY 7 SECS & CLOSE INNER DOOR

DELAY 7 SECS & CLOSE OUTER DOOR

DELAY 3 SECS

DELAY 3 SECS

OPEN OUTER DOOR

OPEN INNER DOOR

DELAY 7 SECS & CLOSE OUTER DOOR

DELAY 7 SECS & CLOSE INNER DOOR

DELAY 1 SEC

Figure 5.2 PIC receive flow chart.

Electronics security

47

Connecting the two relays running DC motor.

Figure 5.3: Connection of the two relays to run a single motor. For the motor to run it needs that one of its terminals is connected to positive supply and the other terminal grounded. But the coils of the two relays are energized at different instants such that when coil of relay 1 is energized, that of relay2 two is not. As a result the above connection provides Vcc and Gnd when each relay is energized.

When relay 1 is energized due to the high signal from microcontroller its switch moves to point C thereby completing a circuit providing Vcc. Relay 2 is not energized and its switch is at point E providing ground .Thus motor turns, say anticlockwise.

When relay 2 is now energized its switch moves to point F thus completing the Vcc circuitry. Relay 1 is now not energized and the switch is at point D which provides ground for the motor to turn this time in a clockwise direction.

Four relays were thus needed, two controlling each DC motor and the connections were identical as shown in the above diagram.

Electronics security

48

5.3 TESTING AND RESULTS.

Door driving circuitry. The door driving circuit consisting two DC motors and a model house representing the lab worked and tested according to design specifications. The diagrammatic layout of how the doors are positioned is shown in the diagram below:

When The PIC received a 51 the sequence of events followed the following order: The outer door opens and the motor driving it runs for a period dictated by delayMotor. The motor then stops for a period set by delayLong ,approximately 6 seconds, and outer door remains open for the person to get in. The outer door then closes after the motor runs for the same period as before.

Electronics security

49

A time delay of almost 3 seconds follows as set by delayShort, after which inside door opens after motor rotate for delayMotor Another time delay of 6 seconds follows for someone to enter after which the door closes. System returns to waiting state waiting for the next person to scan his/her barcode.

When The PIC received a 52 the sequence of events followed the following order: The inside door opens and the motor driving it runs for a period dictated by delayMotor. The motor then stops for a period set by delayLong, approximately 6 seconds, and inner door remains open for the person to get in. The inner door then closes after the motor runs for the same period as before. A time delay of almost 3 seconds follows as set by delayShort, after which outer door opens after motor rotate for delayMotor Another time delay of 6 seconds follows for someone to enter after which the door closes. System returns to waiting state waiting for the next person to scan his/her barcode.

This section tested well and the opening and closing of the doors and the necessary delays were quite distinct.

Visual Basics Tests. The visual basics interface was designed and successfully implemented. As planned in the design specifications the author managed to fulfill these design specifications and at the end of the project work his visual basic design managed to perform the following functions: Provide an interface where the scanning process is processed i.e. where barcodes are captured and processed.

Electronics security

50

Provide a way of storing the processed entrants into an entrance register. Create a student database which can be easily modified by the administrator. Provide security to the system so that the database and system are not easily tempered with especially by students. The system managed to send necessary signals to the PIC via the serial port as required by the author.

Electronics security

51

CHAPTER 6.

CONCLUSIONS.
6.1 Discussion. The system was designed, tested and implemented until a working product was achieved. However challenges came here and there as the author trod on with his design. The main challenge the author faced was financially oriented. Due to the high cost of living and also the high educational costs, the author managed to acquire many of the components but it was a big challenge. As a result the authors progress in his design was greatly reduced. The bar code scanner was also difficult to acquire locally since the technology is slowly taking root locally, so when the author finally acquired it at a local till dealer the price was so unbearable.

Although the author finally managed to acquire the scanner he had to opt for the one he had no intensions to use. In the first place he had intensions of using a slot badge scanner where one can easily swipe his/her identity card, thus more user friendly. The scanner was also supposed to be connected to the RS 232 serial port. For demonstration purposes the author had to revert to the keyboard wedge scanner which has the following disadvantages: When you scan a bar code, the cursor has to be in the correct input data field, and in the correct application otherwise the bar code data will end up in whatever application that is active. This can cause all sorts of problems. The keyboard output is limited, in the sense that you cannot modify the data in any way before sending it into the program in the computer. For example, if you needed to parse a bar code message into multiple pieces or remove some of a bar code messages, you can not.

Difficulties were also encountered in the procurement of many other resources, for example, the programmer for programming the microcontroller chip. The progress was also hampered by the frequent power cuts which are affecting the country.

Electronics security

52

Also the author intends to use magnetic door locks to implement a practical system. The use of motors for demonstration was only due to limited resources. When magnetic door locks are used LEDs will also be incorporated to show that the door is now unlocked.

6.2 System advantages

The system which the author designed inhibits some of the following advantages: There is a constant monitoring of the premises with records of premise entrants at any time being available. There is more utilization of the lab as the lab can continue to function even in the absence of administrator. Elimination of a guard who monitors the lab is also achieved and this has advantages in terms of paying that employee. Thus although system seems to have high installation costs, it has long term advantage financially. The use of a scanner as compared to other methods of entering personal identification like use of pin number is more accurate since errors in entering code are eliminated. Also incidences where someone forgets his/her pin number are eliminated. A problem occurs only when someone loses his/her identity card. The system can be easily manipulated to perform other functions like the borrowing of resources from the department. These resources can include electronic components, project reports and other resources from the department. From the entrance register the departmental administration can easily see as to which academic year frequently uses the lab during certain periods and also how busy the laboratory is during the course of the day. This can help since a situation where the lab is always full might indicate a shortage of computers.

6.3 System expansion. The author had to discover ways of expanding on the system as a way of increasing on the security capabilities of the system. Some of the expansion ways include:

Electronics security

53

Use of infrared sensors especially at the doors which identify that a single person has entered. If the system senses that for a single scan two or more people have entered the first door it will not open the second door and will ring an alarm in the process. However it will open the first door for the people to move out. Likewise if two people want two move out of the lab for a single scan then the same procedure happens. The author implemented Microsoft access as his database. However we can see that the system is to be implemented on a premise consisting many students, thus the author will have to opt for a bigger database, say, mysql database. In the on run cameras can also be used to monitor the lab and see what exactly will be happening in the lab. This will help in faster discovery of missing gadgets from the lab.

Electronics security

54

Appendix A.

Abbreviations.

PIC PC UPC USB VB USART LED -

Peripheral Interface Controller. personal computer. universal Product Code. Universal Serial Bus. Visual basics. Universal Synchronous Receiver and Transmitter. Light Emitting Diode. National University of Science and Technology. Laboratory. Identity Card

NUST LAB ID -

Electronics security

55

Appendix B.

Project cost analysis.

Component type.

Unit price. ($US).

Units used.

Total amount.

1. Microcontroller. 2. IC seaters. 3. Max 232. 4. RS23femaleconnector. 5. Vero board. 6. 7805/7812 regulators. 7. Transistor 2N3053. 8. 15 volt transformer. 9. RJ 12 connector. 10. Capacitors. 11. Resistors. 12. Crystal oscillator. 13. Relay. 14. DC motor. 15 LEDs & other diodes 16 Glue 17 solder wire 18 barcode scanner

$14.00 $2.00 $4.00 $1.00 $5.00 $2.00 $2.00 $5.00 $2.00 $1 for 2. $1 for 4. $1.00 $3.00 $5.00 $1 for 2 $2

1 2 1 1 1 2 5 1 1 15 15 1 5 2 19 1

$14.00 $ 4.00 $ 4.00 $ 1.00 $ 5.00 $ 4.00 $10.00 $ 5.00 $ 2.00 $ 7.50 $3.75 $ 1.00 $15.00 $10.00 $ 9.50 $ 2.00 $ 5.00

$133.33

Total cost = $236.58

Electronics security

56

Appendix C.

Transistor 2N3053 characteristics.

Electronics security

57

Appendix D.

ILX 232 characteristics.

IC ILX232 is purposed for application in high-performance information processing Systems and control devices of wide application. Input voltage levels are compatible with standard CMOS levels.

Output voltage levels are compatible with input levels of K-MOS, N-MOS and TTL integrated circuits. Supply voltage : 5V . Low input current: 1.0 uA; 0.1 uA at T = 25 degC Output current 24 mA. Latching current not less than 450 mA at T = 25 degC. Tolerable value of static potential not less than 2000V.

Electronics security

58

Electronics security

59

Appendix E.

Microchip code for microcontroller.

;********************************************************************** ; ; ; ; ; ; ; ; ;********************************************************************** ; ; Remarks: Blessed thou art oh Lord, for mysterious are the Ways of thy salvation ; ; ; ; ;********************************************************************** List #include p=16f873 <p16f873.inc> ; list directive to define processor ; processor specific variable definitions Notes: * * * * * * * Author Company : Tinotenda Zvavashe : NUST Filename Date : Electronics Computer Lab Security.asm : June 2010 * * * * * * * *

File Version : V1R2

__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _WRT_ENABLE_OFF & _LVP_OFF & _CPD_OFF

; '__CONFIG' directive is used to embed configuration data within .asm file. ; The labels following the directive are located in the respective .inc file. ; See respective data sheet for additional information on configuration word.

Electronics security

60

VARIABLE ;***** VARIABLE DEFINITIONS ; W_temp ; Status_temp EQU EQU 0x7E 0x7F ; variable used for context saving ; variable used for context saving

RxByte delay1 delay2 Delay8 Delay9 Delay10 Cont3 delay3 delay4 delay5 delay6 delay7 tempWorkingReg tempStatusReg Inputs INDATA

EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU

0x21 0x30 0x31 0x32 0x3b 0x3c 0x3d 0x3e 0x33 0x34 0x35 0x36 0x20 0x3f 0x40 0x22

;********************************************************************** ORG 0x00 ; processor reset vector

goto org

init 0x04

; go to beginning of program

;**********************************************************************; ; ; ;Initialization

Electronics security

61

; ; ;**********************************************************************;

init: BANKSEL clrf BANKSEL clrf BANKSEL clrf ;ANKSEL ;movlw ;movwf BANKSEL movlw movwf BANKSEL movlw movwf BANKSEL movlw movwf PORTA PORTA PORTB PORTB PORTC PORTC ADCON1 H'80' ADCON1 TRISA 0x00 TRISA TRISB 0x00 TRISB TRISC H'80' TRISC ;sets all port C pins as outputs except for portc.7 ;sets port B as outputs ;Value used to initialize data direction ;Set all pins as outputs ;Configure all pins ;as analog inputs ;Initialize PORTC by clearing output data latches ;Initialize PORTB by clearing output data latches ;Initialize PORTA by clearing output data latches

;Setting up the baud rate

BANKSEL movlw movwf BANKSEL

SPBRG 0x1C SPBRG TXSTA ;9600 baud rate and 4.5Mhz crystal. High speed BRGH=1

Electronics security

62

bcf bsf bcf bcf BANKSEL bsf bsf BANKSEL movlw ; movwf

TXSTA,TX9 TXSTA,BRGH TXSTA,SYNC TXSTA,TXEN RCSTA RCSTA,SPEN RCSTA,CREN INTCON B'11001000' INTCON

;selecting 8 bit transmission

;selects asynchronous transmission ;disables transmission

; ;enables reception

; original value without faults H'C0' ; enable the global interrupt and the peripheral

; interrupts BANKSEL ; bsf BANKSEL bcf bcf PIE1 PIE1, RCIE PIR1 PIR1,RCIF PIR1,TXIF ; clear receive interrupt flag ; clear transmit interrupt flag ; enable the receive interrupt

;**********************************************************************; ; ; ; ; ; ; ;**********************************************************************; Main program

main banksel movlw movwf bsf PORTB B'00000001' PORTB RCSTA,CREN ;enables reception ;orange LED set for wait state at portB0 ,ie 000010

Electronics security

63

recieve btfss goto movf movwf movlw subwf

PIR1,RCIF recieve RCREG,W INDATA d'50' INDATA,1 ;subtracts 50 from number in INDATA and ;result stored in INDATA as specified by the 1 ;getting input data.

btfss goto

STATUS,Z Secondtest

;Z flag set if remainder is zero. ;result not zero so its 1 or 2 since ;PC sends 50,51 or 52 decimal

goto

RedLed

Secondtest

movlw subwf

d'01' INDATA,1

;moves the literal value into W i.e. working reg ;A 1 is subtract from contents of INDATA & ; result put in INDATA ; INDATA contains either a 1 or a 2

btfss

STATUS,Z

;if set it means 51 was sent and someone ; needs to move out.

goto

EnergMotor2

;meaning number sent was not 50 and is not 51,its

;52 and one needs to move out of lab. goto EnergMotor1 EnergMotor1 ;specifies that the out door opens first

EnergMotor1

banksel movlw movwf call movlw movwf

PORTB B'00010100' PORTB delayMotor B'00000100' PORTB ;setting bit 2 and of port B,ie 00000100 ;setting bit 2 and 4 of port B,ie 00010100

Electronics security

64

call movlw movwf call movlw

delayLong B'00100100' PORTB delayMotor B'00000100' ;clear all other bits except bit 2 of port B. ;setting bit 2 and 5 of port B,ie 00110000

movwf call banksel movlw movwf call movlw movwf call movlw movwf call movlw movwf call goto

PORTB delayShort delayShort PORTC B'00010000' PORTC delayMotor B'00000000' PORTC delayLong B'00100000' PORTC delayMotor B'00000000' PORTC delayShort delayShort main ;clear all bits of port C,ie 00000000 ;setting bit 5 of port C,ie 00100000 ;clear all bits of port C,ie 00000000 ;setting bit 4 of port C,ie 00010000

EnergMotor2

banksel movlw movwf banksel movlw movwf call movlw

PORTB B'00000100' PORTB PORTC B'00010000' PORTC delayMotor B'00000000' ;clear all bits of port C,ie 00000000 ;setting bit 4 of port C,ie 00010000 ;setting bit 2 of port B,ie 00000100

Electronics security

65

movwf call movlw movwf call movlw movwf call banksel movlw movwf call movlw movwf call movlw movwf call movlw movwf call goto

PORTC delayLong delayLong B'00100000' PORTC delayMotor B'00000000' PORTC delayShort delayShort PORTB B'00010100' PORTB delayMotor B'00000100' PORTB delay5sec B'00100100' PORTB delayMotor B'00000100' PORTB delayShort main ;clear all other bits except bit 2 of port B,ie 00000100 ;setting bit 2 and 5 of port B,ie 00110000 ;setting bit 2 and of port B,ie 00000100 ;setting bit 2 and 4 of port B,ie 00010100 ;clear all bits of port C,ie 00000000 ;setting bit 5 of port C,ie 00100000

RedLed

banksel movlw

PORTB B'00001010' ;setting bit 1 on port B to light red LED ; and 3 for buzzer.

movwf call

PORTB delayShort delayShort

Electronics security

66

goto

main

delayLong

movlw movwf loop4 movlw movwf loop3 movlw movwf loop2 movlw movwf loop1 decfsz goto decfsz goto decfsz goto decfsz goto return

0xFF delay1 0xCF delay2 0x11 delay3 0x02 delay4 delay4,1 loop1 delay3,1 loop2 delay2,1 loop3 delay1,1 loop4

delayShort

movlw movwf loop7 movlw movwf loop6 movlw movwf loop5 decfsz

0xFA delay5 0xFB delay6 0x0A delay7 delay7,1

Electronics security

67

goto decfsz goto decfsz goto

loop5 delay6,1 loop6 delay5,1 loop7

return

delayMotor

movlw movwf loop10 movlw movwf loop9 movlw movwf loop8 decfsz goto decfsz goto decfsz goto

0x85 Delay8 0x86 Delay9 0x05 Delay10 Delay10,1 loop8 Delay9,1 loop9 Delay8,1 loop10

return

end

Electronics security

68

References.

Sanchez J and Canton M.P (2007), Microcontroller programming, CRC Press, London

Predko M (2005), 123 PIC microcontroller Experiments, McCraw-Hill, USA.

Bates M (2006), Interfacing PIC microcontrollers, Elsevier, United Kingdom.

Nuenomos J, Serial communications basics.

Crystallone G, Visual Basic fundamentals.

Prof M Collier, Introduction to Microcontrollers and Pico controllers.

Microchip Cooperation (2001), PIC 16F873 datasheet, Microchip, USA. . Edwards V.D (2009), Barcode scanner operation training guide, USA.

Electronics security

69

Das könnte Ihnen auch gefallen