+ All Categories
Home > Technology > ARM BASED 4bit coded locker

ARM BASED 4bit coded locker

Date post: 17-Aug-2015
Category:
Upload: shubham-kumar
View: 19 times
Download: 0 times
Share this document with a friend
Popular Tags:
63
ARM BASED 4 – BIT CODED LOCKER WITH ELECTRIC SHIELD A project report submitted in partial fulfilment of the requirements for the award of the degree of BACHELOR OF TECHNOLOGY In ELECTRONICS & COMMUNICATION ENGINEERING By B.V.S.ALEKHYA 10521A04A1 SHUBHAM KUMAR 10521A0487 D.V.Y.V.SUBBA RAO 11525A0403 ROHIT SOURABH 10521A0484 V.BHANU CHAITANYA 10521A04A4 Under the guidance of Asst. Prof. Depatment of Electronics & Communication Engineering VITAM College of Engineering (Affiliated to JNTU, Kakinada, A.P) Visakhapatnam – 531173 2010 - 2014
Transcript
Page 1: ARM BASED 4bit coded locker

ARM BASED 4 – BIT CODED LOCKER WITH ELECTRIC SHIELD

A project report submitted in partial fulfilment of the requirements for

the award of the degree of

BACHELOR OF TECHNOLOGY

In

ELECTRONICS & COMMUNICATION ENGINEERING

By

B.V.S.ALEKHYA 10521A04A1

SHUBHAM KUMAR 10521A0487

D.V.Y.V.SUBBA RAO 11525A0403

ROHIT SOURABH 10521A0484

V.BHANU CHAITANYA 10521A04A4

Under the guidance of

Asst. Prof.

Depatment of Electronics & Communication Engineering

VITAM College of Engineering

(Affiliated to JNTU, Kakinada, A.P)

Visakhapatnam – 531173

2010 - 2014

Page 2: ARM BASED 4bit coded locker

VISWANADHA INSTITUTE OF TECHNOLOGYAND MANAGEMENT(Affiliated to JNTU-Kakinada)

MINDIVANIPALEM, VISAKHAPATNAM - 531173

BONAFIDE CERTIFICATE

This is to certify that this project work entitled: “ARM BASED 4-BIT CODED LOCKERWITH ELECTRIC SHIELD” is the bonafide work of B.V.S.ALEKHYA (10521A04A1),

SHUBHAM KUMAR(10521A0487), D.V.Y.V.SUBBA RAO (11525A0403), ROHITSOURABH(10521A0484) and V.BHANU CHAITANYA (10521A04A4) of final year B.Tech.

ECE which they have submitted in partial fulfilment of the requirements for the award ofBachelor of Technology in ELECTRONICS AND COMMUNICATION ENGINEERING

during the academic period of 2013-2014.

PROJECT GUIDE HEAD OF THE DEPARTMENT

A.V.N.CHANDRA SEKHARAssistant professor Associative professor B.E, M.Tech.,(Ph.D )

INTERNAL EXMINER EXTERNAL EXAMINER

Page 3: ARM BASED 4bit coded locker

DECLARATION

I declare that this project entitled “ARM BASED 4-BIT CODED LOCKER WITH ELECTRIC SHIELD” has been carried out by me and contents have been presented in the form of dissertation in partial fulfilment of the requirements for the award of the degree of Bachelor of Technology in ELECTRONICS AND COMMUNICATION ENGINEERING.

Submitted By

B.V.S. ALEKHYA (10521A04A1)

SHUBHAM KUMAR (10521A0487)

D.V.Y.V. SUBBA RAO (11525A0403)

ROHIT SOURABH (10521A0484)

V. BHANU CHAITANYA (10521A04A4)

Page 4: ARM BASED 4bit coded locker

ACKNOWLEDGEMENT

We express our deep sense of gratitude to Smt. K. RAJA RAJESWARI madam, B.E,

M.E., Ph.D., Principal of VISWANADHA INSTITUTE OF TECHNOLOGY AND

MANAGEMENT, Visakhapatnam for permitting us to carry out this project work.

It is a pleasure to thank Sri. A.V.N.Chandra Shekhar, HOD, Associative Professor,

Viswanadha Institute of Technology and Management for permitting us to carry out this project

work and for guiding us throughout this endeavour and also helping us to take crucial decisions

at various stages.

We express our sincere thanks to Sri ravi , Assistant professor, VITAM

College, for his intelligent advices and his perpetual encouragement.

We pay homage to our parents, for the financial support and also for the moral support

they have given us throughout this project.

Finally, we are thankful to all the teaching and non – teaching staff of Department of ECE

for their constant co-operation throughout the project.

B.V.S. ALEKHYA (10521A04A1)

SHUBHAM KUMAR (10521A0487)

D.V.Y.V. SUBBA RAO (11525A0403)

ROHIT SOURABH (10521A0484)

V. BHANU CHAITANYA (10521A04A4)

Page 5: ARM BASED 4bit coded locker

CONTENTS

1. INTRODUCTION

Page 6: ARM BASED 4bit coded locker

LIST OF FIGURES

Page 7: ARM BASED 4bit coded locker

CHAPTER-1

INTRODUCTION

The aim of this project is to provide effective security measures for the users. Here the users can open their respective lockers by the specified user id and password. The main disadvantage of bulky, mechanical systems is their cost. This disadvantage of conventional lockers can be overcome by using electronic locker with electric shield. This locker is mainly designed for use in banks where the requirement of security for customer’s valuables is prominent.

If the user wants to access their locker, they should enter the valid 4 digit alphanumeric code. If the entered code matches the actual code, the lock opens resulting in the slow opening ofthe drawer. If the entered password is wrong, buzzer buzzes alerting the user for retyping the password.If the user is not able to type the correct password in their 3rd attempt,then an Audio Signal will be generated which can be obtained on a speaker.This audio signal will last for around 15 seconds , thus alerting the security personnel at a distance.The Locker will remain inactive for 30 more seconds after the Audio Signal stops, thus adding a high level of security in the whole system. After this period, the user can again try to enter their password, and the whole process repeats.If the burglar goes a step forward in breaking the locker then he will be subjectedto shock.

The basic units for this locker are:

1. Controlling unit

2. Locking unit

Controlling unit:

The controlling unit of the locker system plays the most important role in the operation of the locker system. It is heart and brain of the system. The control unit consists of ARM processor, crystal oscillator circuit, LCD display, PS2 connector and Audio Output Jack. All these components are available on a single board, “Blue Board-LPC2148”.

Blue board:

BlueBoard-LPC214X is an evaluation board for LPC2148 ARM7TMDI(-S) based

microcontroller. The LPC2148 microcontroller has 512KB of internal flash and

32+8K RAM. Following are the salient features of the board:

Page 8: ARM BASED 4bit coded locker

Power:

On-board linear regulators generate +3.3V/500mA and +5v/500mA from power

supply.

USB connector ( as alternate power source).

Connectors:

Extension headers for all microcontroller pins.

RS232 (2 ports),VGA ,PS/2,Audio Jack,JTAG,

SD/MMC,USB B-type with Link-LED,

All peripheral configurable via jumpers.

Other Peripherals:

Audio power amplifier.

2 line X 16 character LCD with back light control(using 10K POT).

Configurable for manual and automatic program download(ISP) via serial port.

8 controllable LEDs on SPI using 74HC595,Buzzer,10K POT connected to ADC line

1 user input button connected to interrupt line.

The LPC2141/2/4/6/8 microcontrollers are based on a 32/16 bit ARM7TDMI-S CPU with

real-time emulation and embedded trace support, that combines the microcontroller with

embedded high speed flash memory ranging from 32 kB to 512 kB. A 128-bit wide

memory interface and a unique accelerator architecture enable 32-bit code execution at

the maximum clock rate. For critical code size applications, the alternative 16-bit Thumb

mode reduces code by more than 30 % with minimal performance penalty.

Page 9: ARM BASED 4bit coded locker

BlueBoard-LPC2148 Visual Overview

Page 10: ARM BASED 4bit coded locker

Microcontroller NXP LPC 2148 Pin diagram:

The complete IC Layout with other peripherals involved in the project:

Page 11: ARM BASED 4bit coded locker
Page 12: ARM BASED 4bit coded locker
Page 13: ARM BASED 4bit coded locker

ARM7TDMI(-S) Registers Involved in the Project:

DACR

-(Digital-Analog Conversion)

IODIR

-(Data Direction Register for various Pins)

IOSET

-(Register to set Pin HIGH)

IOCLR

-(Register to set Pin LOW)

IOPIN

-(Register to check the status of the Pin)

PINSEL

-(To define the function of a Pin for a relevant task)

Page 14: ARM BASED 4bit coded locker

EXTMODE

-(The External Interrupt Mode Register controls whether each pin is edge- or level sensitive)

EXTPOLAR

-(The External Interrupt Polarity Register controls which level or edge on each pin will cause an

Interrupt)

EXTINT

-(The External Interrupt Flag Register contains interrupt flags for EINT0, EINT1, EINT2 and EINT3)

VICIntSelect

-(Interrupt Select Register. This register classifies each of the 32 interrupt requests as contributing to FIQ or IRQ)

VICVectAddr

-(Vector Address Register. When an IRQ interrupt occurs, the IRQ service routine can read this register and jump to the value read)

VICVectCntl

-(vectorControl Registers 0-15 each control one of the 16 vectoredIRQ slots. Slot 0 has the highest priorityand slot 15 the lowest)

Pins Involved:

There are 48 GPIO (General Purpose Input Output) Pins available in this microcontroller.

There are 2 ports in ARM7TDMI(-S) core viz., Port 0 and Port 1.

There are 32 GPIO pins in Port 0 from P0.0 to P0.31 and 16 pins in Port 1 from P1.16 to P1.31.

These pins can be used for various input and output functions like Keyboard interfacing, LCD interfacing, Buzzer Connectivity, LED Connectivity, driving Relay, etc.

Due to the availability of large number of pins, various Lockers can be connected to a single Blueboard NXP LPC 2148 microcontroller module like this.

Page 15: ARM BASED 4bit coded locker

Locking unit:

Locking unit of the locker controls the closing and opening of the drawer. The locking unit consists of a geared motor, relay circuit, and shock circuit (whose terminals are further connectedto an LED circuit which indicates the safety of usage for the locker).

The geared motor is used in locking system to push the drawer open at the mention of valid password and it also pulls the drawer inward to lock state also after the mention of correct password. The geared motor gets the supply from the supply circuit connected against it.

The relay circuit is used as a switch between shock mode and open/close mode of locker. The relay circuit is driven from one of the GPIO pins of the microcontroller. The relay used in this case also has SPDT switch which ensures the opening and closing of drawer.

The shock circuit is also connected to relay and it is placed inside the walls of the drawer and it is insulated. The shock circuit’s main purpose is to subject anyone,who tries to break into the locker without giving the valid password, to shock. The shock circuit typically can subject a manto a shock of 230volts. However, due to the potential damage it causes, we have used only 12 volts shock.

Operation Of the Microcontroller Module:

Peripherals Needed:

•An External QWERTY Keyboard attached to the PS2 port of the microcontroller

•A 2X 16 character LCD pre-attached with the BlueBoard

•A speaker connected to the Audio Jack of the BlueBoard

Page 16: ARM BASED 4bit coded locker

Operation:

There is a pre-stored 4-bit alphanumeric password in the ROM of the microcontroller. This password is used to open/close the Lock in this project. Whenthe user enters a password using the Keyboard attached to the Blueboard, then the logic built in the Embedded C program checks it with the pre-stored password.

If both the passwords match, then the LCD displays the “ Correct Password” message and after 2 seconds instructs the user to toggle up/down the Red Switch connected to the relay by displaying a message “Toggle Red Switch”. The Up toggling ensures the Locker comes out and the Down toggling ensures that it goes in. After toggling the Red Switch ,the Pin 0.8 gives a HIGH voltage of 3.3 V for the next 50 seconds. The Locker requires this much amount of time for opening/closing. After 50 seconds, the LCD displays the message as “Operation Over”.The user needs to do the same set of actions for the reverse operation also.

If the password entered by the user is wrong, then the LCD will display the message as “Password Wrong, Try Again” by alarming with a buzzer attached to the Blueboard and gives the user 2 more chances of entering the correct password. If the user still fails to type the correct password in their 3rd attempt,then the LCD displays the message as “Security Alarm” and the microcontroller will send a Security alarm signal by generating an audio signal for 15 seconds which will be played on the speaker. This audio signal will be of very high volume and can be heard from a very long distance, thus enabling the Security Personnel to take some actions and check the Locker for security measures. After the security alarm, the LCD displays the message as “Maximum Attempts Made, Try after 30 seconds” and the Buzzer sounds repeatedly for the next 30 seconds and the Microcontroller deactivates the Keyboard Peripheral for this much amount of time. After 30 seconds the Keyboard console gets reactivated, the user can try to enter the Password again, and the whole process goes on like this.

Visual Outputs:

Page 17: ARM BASED 4bit coded locker

1.Keyboard attached with the BlueBoard-LPC2148

Page 18: ARM BASED 4bit coded locker

2. The Normal display on the LCD when no password has been entered

Page 19: ARM BASED 4bit coded locker

3. When the user enters the correct password, the LCD diplays the following message

Page 20: ARM BASED 4bit coded locker

After 2 seconds, the message on the LCD appears as

Page 21: ARM BASED 4bit coded locker

After 3 seconds, the Locker starts opening and the LCD displays the following message

Page 22: ARM BASED 4bit coded locker

4. If the user enters wrong password in their 3rd attempt, then LCD displays the following message

Page 23: ARM BASED 4bit coded locker

Then a security alert message on the LCD appears with audio signal on the speaker

Page 24: ARM BASED 4bit coded locker

Block diagram:

Page 25: ARM BASED 4bit coded locker

RELAY CIRCUIT:

A relay is an electrically operated switch. Current flowing through the coil of the relay creates a magnetic field which attracts a lever and changes the switch contacts. The coil current can be on or off so relays have two switch positions and they are double throw (changeover) switches.

There are 5 Pins in a relay. Two pins A and B are two ends of a coil that are kept inside the relay.The coil is wound on a small rod that gets magnetized whenever current passes through it.

COM/POLE is always connected to NC(Normally connected) pin. As current is passed throughthe coil A, B, the pole gets connected to NO(Normally Open) pin of the relay.

Electronic lock:

Page 26: ARM BASED 4bit coded locker

The electronic lock is made by using a geared motor.We have used the actuator technology for improvising the locking system and designed a special structure. As per the correct password, thelocking system will work. If the correct password is entered the drawer will get automatically opened. In case of wrong password, it will give 2 more chances.If the user is not able to type the correct password in the next 2 chances,then an alarming audio signal will be generated which lasts for 15 seconds and the system will be deactivated for the next 30 seconds after the completion of the Alarm Audio signal . After this time is elapsed, the whole process begins again.

Page 27: ARM BASED 4bit coded locker

Geared motor:

Geared motors are complete motive force systems consisting of an electric motor and a reductiongear train integrated into one easy-to-mount and –configure package. This greatly reduces the complexity and cost of designing and constructing power tools, machines and appliances calling for high torque at relatively low shaft speed or RPM. The gear assembly helps in increasing the torque and reducing the speed. Using the correct combination of gears in a gear motor, its speed

Page 28: ARM BASED 4bit coded locker

can be reduced to any desirable figure. This concept where gears reduce the speed of the vehicle but increase its torque is known as gear reduction.

Operation principle:

Most synchronous AC electric motors have output ranges of from 1,200 to 3,600 revolutions per minute. They also have both normal speed and stall-speed torque specifications. The reduction gear trains used in gear motors are designed to reduce the output speed while increasing the torque. The increase in torque is inversely proportional to the reduction in speed. Reduction gearing allows small electric motors to move large driven loads, although more slowly than larger electric motors. Reduction gears consist of a small gear driving a larger gear. There may beseveral sets of these reduction gear sets in a reduction gear box.

Applications of gear motors:

Garage door openers, stair lifts, timer cycle knobs on washing machines, power drills, electromechanical clocks. These all use various integrations of gear motors to drive a large force from a relatively small electric motor at a manageable speed. In industry, gear motor applications in jacks, cranes, lifts, clamping, robotics, conveyance and mixing are too numerous to count.

Dpdt switch:

we used this dpdt switch for opening and closing of the locker, if we want the drawer to come out it should be toggled to upwards for going inside it should be toggled downwards. The

Page 29: ARM BASED 4bit coded locker

internal connections will be shown as given below:

The model view of dpdt toggle switch

Electric shield:

The most exciting feature that which we are adding in this locking system is electric shield which protects the valuables in the locker, the electric field will be passed in the conductor which is placed inside the walls of the drawer, this will be on all the time but during the correct password is given the shock will goes off and drawer gets opened automatically, the danger light indication will be shown by using LED light indication circuit which is in red color.

Page 30: ARM BASED 4bit coded locker

Power supply:

The total system works under 12v dc supply so we have attained the subsequent voltage by usingfollowing circuit

Circuit:

Components required: Quantity

Transformer(230 to12)v step down 1

Bridge rectifier 1A 1

IC1 7812 1

IC2 7805 1

Resistor 4.7k 1

Capacitor0.1uf 3

Electrolyte capacitor2200uf 1

Electrolyte capacitor10uf 1

LED 1

Page 31: ARM BASED 4bit coded locker

Buzzer 1

Speaker 1

Softwares Required:

1. Keil uVision 4.6 IDE (For writing and compiling the program in Embedded C)

2. Flash Magic (For flashing the microcontroller with Bootloader)

Programs in Embedded C:

(main.c)

#include "lcd.h"

#include "ps2kbd.h"

#include <lpc21xx.h>

int main (void)

{

init_lcd();

init_keyboard();

while (1)

{

if(keyhit())

{

init3_lcd();

init_keyboard();

}

}

}

Page 32: ARM BASED 4bit coded locker

(LCD_DAC.C)

// This program is for LCD display and Digital-Analog Conversion for Audio Output

#include <LPC214x.H> /* LPC214x definitions */

#include "lcd.h"

#include "utils.h"

#define LCD_BACK_LIGHT_TIMEOUT 1000

#define LCD_BACKLIGHT (1 << 21)

#define LCD_BACK_LIGHT_DIR IO1DIR

#define LCD_BACK_LIGHT_SET IO1SET

#define LCD_BACK_LIGHT_CLR IO1CLR

#define LCD_DATA_DIR IO0DIR

#define LCD_DATA_SET IO0SET

#define LCD_DATA_CLR IO0CLR

#define LCD_CTRL_DIR IO1DIR

#define LCD_CTRL_SET IO1SET

#define LCD_CTRL_CLR IO1CLR

#define LCDRS (1 << 24)

#define LCDRW (1 << 23)

#define LCDEN (1 << 22)

#define LCD_D4 (1 << 10)

#define LCD_D5 (1 << 11)

#define LCD_D6 (1 << 12)

#define LCD_D7 (1 << 13)

#define LCD_DATA_MASK (LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7)

#define LCD_BUSY_FLAG LCD_D7

#define LCD_CONTROL_MASK 0x01C00000

Page 33: ARM BASED 4bit coded locker

extern int flag=0;

extern int i=0;

void lcd_putstring( unsigned char line,unsigned char string[10] );

void lcd_putchar(unsigned char c[10]);

#define DAC_BIAS 0x00000000

void DAC_test(void)

{

int i=0,j=0;

int k=0;

for(k=0;k<80000;k++)

{

DACR = (i << 8) | DAC_BIAS;

i++;

for(j = 5000; j > 1; j--);

if ( i == 1024 )

{

i = 0;

}

}

}

void DACInit( void )

{

/* setup the related pin to DAC output */

PINSEL1 |= 0x00080000; /* set p0.225 to DAC output */

return;

}

/**

Page 34: ARM BASED 4bit coded locker

********************************************************************************************

Function Name : wait_lcd()

Output : Void

Note :

********************************************************************************************

*/

void wait_lcd( void )

{

IO1CLR |= (1 << 24); //LCDRS

IO1SET |= (1 << 23) |(1 << 22); //LCDRW |LCDEN

while(IO1PIN & LCD_BUSY_FLAG); /* wait for busy flag to become low */

IO1CLR |= (1 << 22) |(1 << 23); // LCDEN | LCDRW;

IO0DIR |= LCD_DATA_MASK;

delay(100);

}

/**

********************************************************************************************

Function Name : lcd_command_write()

Output : Void

Note :

********************************************************************************************

*/

Page 35: ARM BASED 4bit coded locker

void lcd_command_write( unsigned char command )

{

unsigned char temp=0;

unsigned int temp1=0;

temp=command;

temp=(temp>>4)&0x0F;

temp1=(temp<<10)&LCD_DATA_MASK;

IO1CLR = (1 << 24); //LCDRS

IO1SET = (1 << 22); //LCDEN

IO0CLR = LCD_DATA_MASK; //(LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7)

IO0SET = temp1;

delay(10000);

IO1CLR = (1 << 22); //LCDEN

temp=command;

temp&=0x0F;

temp1=(temp<<10)&LCD_DATA_MASK; // (LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7)

delay(100*2);

IO1CLR |=(1<<24); // LCDRS

IO1SET |=(1<<22); // LCDEN

IO0CLR = LCD_DATA_MASK; //(LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7)

IO0SET = temp1;

delay(10000);

IO1CLR |= (1<<22); //LCDEN

wait_lcd();

Page 36: ARM BASED 4bit coded locker

}

/**

********************************************************************************************

Function Name : set_lcd_port_output()

Output : Void

Note :

********************************************************************************************

*/

void set_lcd_port_output( void )

{

IO1DIR |= ((1<<22)|(1<<24)|(1<<23));

IO1CLR |= ((1<<22)|(1<<24)|(1<<23));

IO0DIR |= LCD_DATA_MASK;

}

/* *

********************************************************************************************

Function Name : lcd_clear()

Output : Void

********************************************************************************************

*/

void lcd_clear( void)

{

lcd_command_write( 0x01 );

}

/**

Page 37: ARM BASED 4bit coded locker

********************************************************************************************

Function Name : lcd_gotoxy()

Output : Void

Note :

********************************************************************************************

*/

int lcd_gotoxy( unsigned int x, unsigned int y)

{

int retval = 0;

if( (x > 1) && (y > 15) )

{

retval = -1;

} else {

if( x == 0 )

{

lcd_command_write( 0x80 + y ); /* command - position cursor at 0x00 (0x80 + 0x00 ) */

} else if( x==1 ){

lcd_command_write( 0xC0 + y ); /* command - position cursor at 0x40 (0x80 + 0x00 ) */

}

}

return retval;

}

/**

Page 38: ARM BASED 4bit coded locker

********************************************************************************************

Function Name : lcd_data_write()

Output : Void

Note :

********************************************************************************************

*/

void lcd_data_write(unsigned char data)

{

char temp=0;

int temp1=0;

temp=data;

temp=(temp>>4)&0x0F;

temp1=(temp<<10)&LCD_DATA_MASK;

IO1SET |= (1<<22)|(1<<24); //LCDEN|LCDRS

IO0CLR = LCD_DATA_MASK;

IO0SET = temp1;

IO1CLR |= (1<<22); //LCDEN

temp=data;

temp&=0x0F;

temp1=(temp<<10)&LCD_DATA_MASK;

IO1SET |= (1<<22)|(1<<24);

IO0CLR = LCD_DATA_MASK;

IO0SET = temp1;

Page 39: ARM BASED 4bit coded locker

IO1CLR |= (1<<22); //LCDEN

wait_lcd();

}

/**

********************************************************************************************

Function Name : lcd_putchar()

Output : Void

Note :

********************************************************************************************

*/

void lcd_putchar(unsigned char * c)

{

int i=0;

lcd_data_write(c[i]);

}

/**

********************************************************************************************

Function Name : lcd_putstring()

Output : Void

Note :

********************************************************************************************

Page 40: ARM BASED 4bit coded locker

*/

void lcd_putstring( unsigned char line,unsigned char *string )

{

unsigned char len = 16; //MAX_CHAR_IN_ONE_LINE

lcd_gotoxy( line, 0 );

while(*string!= '\0' && len--)

{

lcd_putchar((unsigned char*)string);

string++;

}

}

/**

********************************************************************************************

Function Name : lcd_backlight_on()

Output : Void

********************************************************************************************

*/

void lcd_backlight_on()

{

IO1DIR |= (1 << 21); //LCD_BACKLIGHT

IO1SET |= (1 << 21); //LCD_BACKLIGHT

}

/**

Page 41: ARM BASED 4bit coded locker

********************************************************************************************

Function Name : turn_off_lcd_back_light()

Output : Void

********************************************************************************************

*/

void turn_off_lcd_back_light_cb(void)

{

IO1DIR |= (1 << 21); //LCD_BACKLIGHT

IO1CLR |= (1 << 21); //LCD_BACKLIGHT

}

/**

********************************************************************************************

Function Name : init_lcd()

Output : Void

Note :

********************************************************************************************

*/

void init_lcd( void )

{

set_lcd_port_output();

delay(100*100);

lcd_command_write(0x28); /* 4-bit interface, two line, 5X7 dots. */

lcd_clear() ; /* LCD clear */

Page 42: ARM BASED 4bit coded locker

lcd_command_write(0x02); /* cursor home */

lcd_command_write(0x06); /* cursor move direction */

lcd_command_write(0x0C) ; /* display on */

lcd_gotoxy(0, 0);

lcd_clear();

lcd_putstring(0,"Enter Password");

}

void init2_lcd( void )

{

IO0DIR|=(1<<31);

IO0DIR|=(1<<8);

set_lcd_port_output();

delay(100*100);

lcd_command_write(0x28); /* 4-bit interface, two line, 5X7 dots. */

lcd_clear() ; /* LCD clear */

lcd_command_write(0x02); /* cursor home */

lcd_command_write(0x06); /* cursor move direction */

lcd_command_write(0x0C) ; /* display on */

lcd_gotoxy(0, 0);

lcd_clear();

lcd_putstring(0,"Correct Password");

delayy(450);

lcd_gotoxy(0, 0);

lcd_clear();

lcd_putstring(0," Toggle ");

lcd_putstring(1," Red Switch ");

delayy(300);

lcd_gotoxy(0, 0);

Page 43: ARM BASED 4bit coded locker

lcd_clear();

lcd_putstring(0,"Please Wait...");

IO0CLR|=(1<<31);

IO0SET|=(1<<8);

delayy(7500);

IO0SET|=(1<<31);

IO0CLR|=(1<<8);

}

void init4_lcd( void )

{

lcd_gotoxy(0, 0);

lcd_clear();

lcd_putstring(0," Operation Over ");

delayy(200);

init_lcd();

init_keyboard();

}

void init5_lcd( void )

{

lcd_gotoxy(0, 0);

lcd_clear();

lcd_putstring(0,"please wait...");

}

void init6_lcd( void )

{

lcd_gotoxy(0, 0);

lcd_clear();

lcd_putstring(0," Operation Over");

Page 44: ARM BASED 4bit coded locker

lcd_putstring(1," Press Reset");

}

void init3_lcd( void )

{

DACInit();

IO1DIR|=(1<<25);

flag+=1;

if(flag==3)

{

lcd_gotoxy(0, 0);

lcd_clear();

lcd_putstring(0,"maximum attempts ");

lcd_putstring(1," made ");

delayy(300);

lcd_gotoxy(0, 0);

lcd_clear();

lcd_putstring(0,"Security Alert");

DAC_test();

delayy(300);

lcd_gotoxy(0, 0);

lcd_clear();

lcd_putstring(0," try after 30 ");

lcd_putstring(1," seconds ");

while(i!=30)

{

IO1CLR|=(1<<25);

delayy(100);

Page 45: ARM BASED 4bit coded locker

IO1SET|=(1<<25);

delayy(70);

i++;

}

i=0;

flag=0;

goto a;

}

lcd_gotoxy(0, 0);

lcd_clear();

lcd_putstring(0," Wrong Password ");

lcd_putstring(1," Try again ");

IO1CLR|=(1<<25);

delayy(100);

IO1SET|=(1<<25);

a:init_lcd();

init_keyboard();

while (1)

{

if(keyhit())

{

init3_lcd();

init_keyboard();

}

}

}

Page 46: ARM BASED 4bit coded locker

(Keyboard.c)

//This Program is for connecting the PS2 Keyboard and contains logic for the operation of work to bedone when the password is right/wrong

#include "ps2kbd.h"

#include "lpc_vic.h"

#include "scancodes.h"

#include <LPC214x.H> /* LPC214x definitions */

#include "utils.h"

/**

*****************************************************************************

Function Name : extISR1()

******************************************************************************

*/

void extISR0(void) __irq;

U8 keyBuf[KBUFFSIZE]; //KBUFFSIZE=4.....PS2 Keyboard buffer, the register to store characters key in

U8 keyIn; //Index into PS/2 key buf where next scan code will be inserted

U8 keyOut; //Index into PS/2 key buf where next scan code will be removed

U8 keyRead; //Number of keys read from the PS/2 keyboard

U8 bitcount; // 0 = neg. 1 = pos.

unsigned char key[11];

/**

*****************************************************************************

Function Name : init_keyboard()

Page 47: ARM BASED 4bit coded locker

******************************************************************************

*/

U8 init_keyboard(void)

{

IO0CLR = KB_CLK; //KB_CLK=BIT16=0x00010000..P0.4=1.....hold keyboard clock line untill ready

EXTMODE |= 0x01; /* EINT0_EDGE..... INT0 edge trigger */

EXTPOLAR |= 0x0; /* INT0 is falling edge by default */

PINSEL1 |= 0x00000001; //KBD_PINSEL=1.16=PS2 data

/* initialize the interrupt vector */

VICIntSelect &= ~ (1<<14); //VIC_BIT(VIC_EINT0)..... pg.56 datasheet..EINT0 selected as IRQ

VICVectAddr2 = (unsigned int)extISR0; // address of the ISR

VICVectCntl2 = (1<<5|14); //VIC_ENABLE | VIC_EINT0..pg.57 datasheet

VICIntEnable = (1<<14); //VIC_BIT(VIC_EINT0)..... EINT0 interrupt enabled

bitcount = 0;

keyIn =0;

keyOut=0;

keyRead=0;

EXTINT = EINT0;

/* clear interrupt */

return(1); //1=TRUE

}

Page 48: ARM BASED 4bit coded locker

/**

*****************************************************************************

Function Name : decode()

******************************************************************************

*/

void decode(U8 sc)

{

static unsigned char is_up=0, shift = 0; //, mode = 0;

unsigned char i;

if (!is_up) /* Last data received was the up-key identifier */

{

switch (sc)

{

case BREAKCHAR : /* The up-key identifier */

is_up = 1;

break;

case NONUMCODE :

break;

case LEFTSHIFT :

shift = 1;

break;

case RIGHTSHIFT:

shift = 1;

break;

default:

if (!shift) /* If shift not pressed */

Page 49: ARM BASED 4bit coded locker

{

// do a table look-up

for (i = 0; unshifted[i][0]!=sc && unshifted[i][0]; i++);

if (unshifted[i][0] == sc)

{

putkeybuf((unshifted[i][1]));

}

}

else

{

/* look-up */

for (i = 0; shifted[i][0]!=sc && shifted[i][0]; i++);

if (shifted[i][0] == sc)

{

putkeybuf((shifted[i][1]));

}

}

break;

}

}

else

{

is_up = 0;

switch (sc)

{

case LEFTSHIFT :

case RIGHTSHIFT:

shift = 0;

Page 50: ARM BASED 4bit coded locker

break;

}

}

}

/**

*****************************************************************************

Function Name : putkeybuf()

******************************************************************************

*/

void putkeybuf (U8 key)

{

if (keyRead <8) //KBUFFSIZE=4..make sure that we don't overflow the buffer

{

keyRead++; //Increment the number of keys read

keyBuf[keyIn++] = key; //Store the scan code into the buffer

if (keyIn >=8) //KBUFFSIZE..Adjust index to the next scan code to put in buffer

{

keyIn = 0;

}

}

if(keyBuf[0]=='a' && keyBuf[1]=='b' && keyBuf[2]=='1' && keyBuf[3]=='2')

{

init2_lcd();

init4_lcd();

}

}

Page 51: ARM BASED 4bit coded locker

/*

*****************************************************************************

Function Name : keyhit()

******************************************************************************

*/

U8 keyhit(void)

{

unsigned char hit;

hit = (unsigned char)(keyRead >4)? 1 : 0;

return(hit);

}

/**

*****************************************************************************

Function Name : xgetkey()

******************************************************************************

*/

char xgetkey(void)

{

unsigned char key=0;

if (keyRead > 0)

{

keyRead--; /* Decrement the number of keys in the buffer */

key = keyBuf[keyOut]; /* Get scan code from the buffer */

keyOut++;

Page 52: ARM BASED 4bit coded locker

if (keyOut >= 4) //KBUFFSIZE

{

keyOut = 0;

}

}

return (key); /* return the scan code of the key pressed */

}

(utils.c)

//This program contains all the important functions required for the keyboard connectivity along with different delay functions used in other programs.

/*

USB Firmware Upgrader

Copyright © 2006 Yuri Tiomkin

All rights reserved.

Permission to use, copy, modify, and distribute this software in source

and binary forms and its documentation for any purpose and without fee

is hereby granted, provided that the above copyright notice appear

in all copies and that both that copyright notice and this permission

notice appear in supporting documentation.

THIS SOFTWARE IS PROVIDED BY THE YURI TIOMKIN AND CONTRIBUTORS ``AS IS'' AND

ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

ARE DISCLAIMED. IN NO EVENT SHALL YURI TIOMKIN OR CONTRIBUTORS BE LIABLE

Page 53: ARM BASED 4bit coded locker

FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL

DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS

OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)

HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT

LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY

OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF

SUCH DAMAGE.

*/

#include <LPC214x.H> /* LPC214x definitions */

#include "type.h"

#include "string.h"

typedef void (*IAP)(unsigned int [],unsigned int[]);

//----------------------------------------------------------------------------

void * s_memset(void * dst, int ch, int length)

{

register char *ptr = (char *)dst - 1;

while(length--)

*++ptr = ch;

return dst;

}

//----------------------------------------------------------------------------

void * s_memcpy(void * s1, const void *s2, int n)

Page 54: ARM BASED 4bit coded locker

{

register int mask = (int)s1 | (int)s2 | n;

if(n == 0)

return s1;

if(mask & 0x1)

{

register const char *src = s2;

register char *dst = s1;

do

{

*dst++ = *src++;

}while(--n);

return s1;

}

if(mask & 0x2)

{

register const short *src = s2;

register short *dst = s1;

do

{

*dst++ = *src++;

}while( n -= 2);

Page 55: ARM BASED 4bit coded locker

return s1;

}

else

{

register const int *src = s2;

register int *dst = s1;

do

{

*dst++ = *src++;

}while (n -= 4);

return s1;

}

}

U8 s_strncmp(U8 *s1,U8 *s2, U32 num)

{

U8 retval=0;

U32 i=0;

for(i=0;i<num;i++)

{

if(*(s1+i) != *(s2+i))

{

retval = 1;

Page 56: ARM BASED 4bit coded locker

break;

}

}

return retval;

}

int divide(int a, int b)

{

int result = 0;

int temp = b;

while (temp >= b)

{

temp = a - b * result++;

}

return result-1;

}

void reverse(char s[])

{

int c, i, j;

for (i = 0, j = strlen(s)-1; i<j; i++, j--) {

c = s[i];

Page 57: ARM BASED 4bit coded locker

s[i] = s[j];

s[j] = c;

}

}

void u_itoa( int n, char s[] )

{

int i, sign;

if(( sign = n ) < 0 )

n = -n;

i = 0;

do

{

s[i++] = n % 10 + '0';

} while(( n /= 10 ) > 0 );

if( sign < 0 )

s[i++] = '-';

s[i] = '\0';

reverse( s );

}

/**

**************************************************************************

****1111

Page 58: ARM BASED 4bit coded locker

Function Name : delay()

Description :This function suspends the tasks for specified ticks.

Input : ticks:no of ticks in multiple of 1 usec

task: task to be suspended

Output : void

*******************************************************************************

*/

void delay(int count)

{

int j=0,i=0;

for(j=0;j<count;j++)

{

/* At 60Mhz, the below loop introduces

delay of 10 us */

for(i=0;i<35;i++);

}

}

void delayy(unsigned int t)

{

int i,j;

for(j=0;j<t;j++)

for(i=0;i<50000;i++);

}

Page 59: ARM BASED 4bit coded locker

(extISR.C)

//This program contains the instruction sets for the hardware interrupts required when a keyhit is made from the keyboard.

#include <LPC214x.H> /* LPC214x definitions */

#include "ps2kbd.h"

#include "utils.h"

#define kbDAT (IO1PIN & (KB_DAT))

#define kbCLK (IO0PIN & (KB_CLK))

#define K_STARTBIT 1

#define K_PARITYBIT 10

#define K_STOPBIT 11

extern unsigned char bitcount;

/**

*****************************************************************************

Function Name : extISR0()

******************************************************************************

*/

void extISR0(void) __irq

{

static U8 key_data; // Holds the received scan code

U32 clkstat;

Page 60: ARM BASED 4bit coded locker

U32 datstat;

U32 paritystat;

clkstat = IO0PIN & (IO0PIN & 0x00010000); //kbCLK=(IO0PIN & BIT16=0x00010000)=>P0.4=1.....check CLK pin state;

datstat = kbDAT; //kbDAT=(IO1PIN & (KB_DAT))...P1.16=>PS2 data..check DAT pin state;

bitcount++;

if (bitcount==1) //K_STARTBIT

{

if (datstat || clkstat) bitcount=0;

key_data=0;

paritystat=0;

}

else if (bitcount==10) //K_PARITYBIT

{

paritystat = datstat;

}

else if (bitcount==11) //K_STOPBIT

{

decode (key_data);

bitcount=0;

}

else

{

// For all bits from 2, 3...9 (total 8-bit)

key_data= key_data >> 1;

Page 61: ARM BASED 4bit coded locker

if (datstat)

{

key_data = key_data | 0x80;

}

}

EXTINT = 0x01; //clear interrupt

VICVectAddr = 0;

}//extISR

Steps to be performed for typing the complete program in Keil uVision 4.6 IDE:

1. Go to Project-> New uVision Project.

2. Save the project in some folder with the extension *.uVproj

3. Then Select the Microcontroller being used. In our Project, we have selectedNXP LPC 2148.

4. Add all the files to the Project after writing programs in separate files.

5. Now go to Flash->Configure Flash Tools,then go to the Target tab and select the on-chip I-ROM 1 area address from 0x2000. It has been done so because the flashed Bootloader program occupies the area upto 0x2000 address.

6. Under the User tab tick the check box Run #1 and type in the box the following: fromelf --bin .\Obj\PS2KBD_LCD.axf -o .\Obj\a.bin

This is done in order to create a .Bin Object file from .C file.

AXF refers to Arm Executable Format. It changes the format from .axf to .bin which can then be saved into the ROM of the microcontroller using the Bootloader functionality where the microcontroller can just behave like a

Page 62: ARM BASED 4bit coded locker

removable mass storage device and we can copy and paste the generated .binfile into the mass storage device.

7. Now click on Project->Rebuild All Target Files. The Program will get compiled and .bin file will be created inside the Obj folder as mentioned above. .Bin file will be created only when there are no errors in the program.

Advantages involved in the project:

• Highly Secure due to the presence of multilevel security

• The development board requires just 3.3 V of power supply and hence power consumption and dissipation are very low.

• Security alarm with the help of DAC is possible,thus alerting the security personnel if any unauthorized repeated access is made more than thrice.

• Inability for any unauthorized user to access the locker due to the presence of all-time electric shock.

• One-minute blocking of the whole system if any unauthorized access is made more than thrice.

• Made on a low budget of Rs. 4200 which is quite low as compared to the similar type of system available in the market ranging from Rs. 15,000- Rs. 20,000.

Page 63: ARM BASED 4bit coded locker

Recommended