Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

REPUBLIC OF CAMEROON REPUBLIQUE DU CAMEROUN

Peace – Work – Fatherland Paix – Travail -Patrie


---------- --------
THE UNIVERSITY OF BAMENDA UNIVERSITE DE BAMENDA
-------- -----------
HIGHER TECHNICAL TEACHER TRAINING ECOLE NORMALE SUPERIEURE DE
COLLEGE OF BAMBILI L’ENSEIGNEMENT
--------- TECHNIQUE DE BAMBILI
DEPARTMENT OF ELECTRICAL AND POWER ----------
ENGINEERING DEPARTEMENT DU GENIE ELECTRIQUE

DEPARTMENT: ELECTRICAL AND POWER ENGINEERING


OPTIONS : ELECTROTECHNICS
LEVEL: 500

Course: DIGITAL SIGNAL PROCESSING (DSP)


CONTROL

QUESTION:

DESIGN OF A PASSWORD LOCK SYSTEM

PRESENTED BY:

1 NJINGOUN ROBERT PINGNUI 13T0311


2 BOUBA BELL BELLO SERGE 16TO895
3 BATJOCK ETIENNE WILFRED 16T0894
4 SHU MARSHAL SHU 16T0904
5 SUCCESS AFUMBOM YANGSI 16T0905
6 MBIADOU TCHIWO AURELIEN 16T0899
Course facilitator: Mr. TSOKEZO TSAKOU.

ACADEMIC YEAR 2017/2018


I. INTRODUCTION

This report deals with simulation of a keypad lock system which only grants access when the
entered password is correct. Different devices are used in the system such as a 4*3 keypad, a
microcontroller DSPIC 33FJ32GP204 and its peripherals, a 16*2 led display and LEDS to
denote our output.

I. OBJECTIVE

The objective or the aim of this project, “KEYPAD CODE ACCESS” is to turn on lamps
connected on the PORTB of the DSPIC P33FJ32GP204 when the password entered using a 4x3
keypad is correct. If the user enters wrong password more than three times, the system will be
locked, and one will need to reset the system by pressing the reset push.

DIFFERENT COMPONENTS USED

a) MICROCONTROLLER
The microcontroller used is the DSPIC 33F32GP204 which is a 32 bits The
program which shows how the system functions is loaded into the microcontroller
which is the brain of the system.
U1
19 21
RA0/CN2/VREF+/AN0 RB0/CN4/RP0/C2IN-/AN2/PGED1
20 22
RA1/CN3/VREF-/AN1 RB1/CN5/RP1/C2IN+/AN3/PGEC1
30 23
RA2/CN30/CLKI/OSCI RB2/CN6/RP2/AN4
31 24
RA3/CN29/CLKO/OSCO RB3/CN7/RP3/AN5
34 33
RA4/CN0/T1CK/SOSCO RB4/CN1/RP4/SOSCI
13 41
RA7/TCK RB5/CN27/RP5/ASDA1/PGED3
32 42
RA8/TDO RB6/CN24/RP6/ASCL1/PGEC3
35 43
RA9/TDI RB7/CN23/RP7/INT0
12 44
RA10/TMS RB8/CN22/RP8/SCL1
1
RB9/CN21/RP9/SDA1
25 8
RC0/CN8/RP16/AN6 RB10/CN16/RP10/PGED2
26 9
RC1/CN9/RP17/AN7 RB11/CN15/RP11/PGEC2
27 10
RC2/CN10/RP18/AN8 RB12/CN14/RP12/AN12
36 11
RC3/CN28/RP19 RB13/CN13/RP13/AN11
37 14
RC4/CN25/RP20 RB14/CN12/RP14/AN10
38 15
RC5/CN26/RP21 RB15/CN11/RP15/AN9
2
RC6/CN18/RP22
3 17
RC7/CN17/RP23 AVDD
4 16
RC8/CN20/RP24 AVSS
5
RC9/CN19/RP25
7
VCAP/VDDCORE
18
MCLR
DSPIC33FJ32GP204
b) 16*2 LED DISPLAY
The LED display makes the system more user friendly. It display 16 characters
per row of which these rows are 2. It helps the user visualise the password he/she is
entering. It also tells the user if the password entered is right or wrong.
LCD1
LM016L

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3

4
5
6

7
8
9
10
11
12
13
14
c) KEYPAD
The keypad just helps us to enter the password into the system. It is a 4*3 keypad
with digits from 0-9 and 2 extra-digits which are # and *.
1

A
1 2 3
B
4 5 6
C
7 8 9
D
0 #

d) LEDS
The leds used are of 2 colours. 1 yellow which shows our password is correct and
grants access to the system and a green one for the interrupt.

D2
R1
220
LED-YELLOW
D1
R4
220
LED-GREEN
II. CIRCUIT DIAGRAM

III. MIKROC DSPIC CODE

 The keypad is a 4x3,connected to PORTC


 The LCD is a 16x2,connected to PORTB
 The LEDs are connected on PORTB
 The DSPIC used is the P33FJ32GP204
 The default password is “1759”, store in a char array ( password[] );
 The entering password is also store in a char array of 4 ( txt[6] );

// LCD pinout settings

sbit LCD_D4 at LATB0_bit ;

sbit LCD_D5 at LATB1_bit ;

sbit LCD_D6 at LATB2_bit ;


sbit LCD_D7 at LATB3_bit ;

sbit LCD_RS at LATB4_bit ;

sbit LCD_EN at LATB5_bit ;

// Pin direction

sbit LCD_D4_Direction at TRISB0_bit ;

sbit LCD_D5_Direction at TRISB1_bit ;

sbit LCD_D6_Direction at TRISB2_bit ;

sbit LCD_D7_Direction at TRISB3_bit ;

sbit LCD_RS_Direction at TRISB4_bit ;

sbit LCD_EN_Direction at TRISB5_bit ;

// Keypad module connections

unsigned keypadPort at PORTC;

unsigned keypadPort_Direction at TRISC;

// End Keypad module connections

unsigned short key;

int comp,i=0,k, cnt=0, set=0;

char password[]="1759";

char txt[16];

unsigned short keypad()

key = 0;

do // Reset key code variable


key = Keypad_Key_Click(); // Store key code in key variable

while (!key);

// Prepare value for output, transform key to it's ASCII value

switch (key)

case 1: key = 49; break; // 1

case 2: key = 50; break; // 2

case 3: key = 51; break; // 3

case 4: key = 65; break; // A

case 5: key = 52; break; // 4

case 6: key = 53; break; // 5

case 7: key = 54; break; // 6

case 8: key = 66; break; // B

case 9: key = 55; break; // 7

case 10: key = 56; break; // 8

case 11: key = 57; break; // 9

case 12: key = 67; break; // C

case 13: key = 42; break; // *

case 14: key = 48; break; // 0

case 15: key = 35; break; // #

case 16: key = 68; break; // D

return key;

void main()
{

TRISA.F0=0;

ADPCFG = 0xFFFF;

Keypad_Init(); // Initialize Keypad

lcd_init();

L1:

lcd_cmd(_lcd_clear);

lcd_cmd(_lcd_cursor_off);

do

Lcd_Out(1, 3, "ENTER PASSWORD");

i=i+1;

key=keypad() ;

if(i<=4)

txt[i-1]=key;

Lcd_chr(2,i,txt[i-1]);

comp=memcmp(password,txt,4);

if(key==35)

key=0;

if(comp==0)
{

lcd_cmd(_lcd_clear);

Lcd_Out(1, 6, "WELCOME");

lcd_out(2,1,"ARTHUR GUINNESS");

PORTA.F0=1;

Delay_ms(10000);

PORTA.F0=0;

i=0;

goto L1;

else

lcd_cmd(_lcd_clear);

lcd_out(1,3,"WRONG PASSWORD");

Delay_ms(1000);

cnt=cnt++;

if(cnt==3)

set=1;

goto blocked;

else

i=0;

goto L1;
}

} while (1);

blocked:

while(set)

Lcd_Cmd(_LCD_CLEAR); // Clear display

lcd_out(1,1,"SYS IS BLOCKED!!");

lcd_out(2,2,"PLZ RESET...");

delay_ms(100);

} //Endless loop}
IV. SIMULATION RESULTS
When the system is put on

correct password entered


 Wrong password is entered
 Wrong password entered 3 times, we need to reset the system

CONCLUSION

To conclude, we were able to design our system and make it function the way we wanted. A single
password gave us access to the system and also when there is an interrupt, our system manages it
well.

You might also like