Uploaded by knight Rider

MPMC project report (1)

advertisement
DECEMBER 27,
2021
MICRO-PROCESSOR AND MICROCONTROLLER
COMPLEX ENGINEERING
ACTIVITY
MUHAMMAD HASEEB & MUHAMMAD
BAQIR
MPMC
MICRO-PROCESSOR AND MICRO-CONTROLEER
Complex Engineering
Activity
GROUP MEMBERS:
 MUHAMMAD HASEEB SAQIB (190470)
 MUHAMMAD BAQIR (190472)
 MUNEEB-UR-REHMAN (190362)
SUBMITTED TO:
SIR AQIB
MUHAMMAD HASEEB & MUHAMMAD
BAQIR
1
MPMC
Objective:
The objective of this complex engineering problem is to carry out research, analysis,
Investigation and design of a real world Maze Solver Robot which has following attributes:
1. This problem does not have any obvious solution. It requires abstract thinking and
Originality in analysis to propose a suitable hardware design and software algorithm;
2. This problem requires research based knowledge about various line following and
Maze following techniques in this area.This problem can be practically implemented into a
finished commercial product;
MICRO-CONTROLLER:
A microcontroller (MCU for microcontroller unit) is a little PC on a solitary metal-oxidesemiconductor (MOS) coordinated circuit (IC) chip. A microcontroller contains at least one
CPUs (processor centers) alongside memory and programmable info/yield peripherals.
Program memory as ferroelectric RAMS, NOR is glimmer or OTP ROM likewise regularly
remembered for chip, just as a modest quantity of RAM. Microcontrollers are intended for
implanted applications, rather than the microchips utilized in PCs or other broadly useful
applications comprising of different discrete chips.
In current wording, a microcontroller is like, however less complex than, a framework on a
chip (SoC). A SoC might incorporate a microcontroller as one of its parts, yet generally
coordinates it with cutting edge peripherals like an illustrations handling unit (GPU).
MUHAMMAD HASEEB & MUHAMMAD
BAQIR
2
MPMC
Problem Statement
Design the hardware and software for a PIC-18F452 based Password protected door
lock that is capable of locking and unlocking a door if right password is fed. The
system consists of a 16×2 LCD, a keypad and a servo motor. The system details are
as follows:
1. The system should display “Please Enter Password” on LCD in idle state.
2. A user should be allowed to lock or unlock the door only if he/she enters the right
Password (8 characters long alpha numeric). Door locking and unlocking should be
Performed using DC servo motor.
3. The LCD should display “Password Matched”, “Password Incorrect”, “Locking” and
“Unlocking” statements as per the operation in progress.
4. If a user enters a wrong password for three times, the system should be held in
locked State for 1 minute showing “Please Try Again After 1 Minute” on LCD.
5. There should be a settings button which will allow the users to change password by
entering old password.
COMPONENTS:
 CONTROLLER:
 LCD:
MUHAMMAD HASEEB & MUHAMMAD
BAQIR
3
MPMC
 POTENTIOMETER:
 4*3KEYPAD:
 RESISTOR:
 CAPACITOR:
MUHAMMAD HASEEB & MUHAMMAD
BAQIR
4
MPMC
 CRYSTAL:
 SERVO MOTOR:
 2N2369:
MUHAMMAD HASEEB & MUHAMMAD
BAQIR
5
MPMC
USE OF COMPONENTS:
 CONTROLLER:
A microcontroller (MCU for microcontroller unit) is a small computer on a single metal-oxidesemiconductor (MOS) integrated circuit (IC) chip.
 KEYPAD:
It is used to input the numerical values.
 LCD:
It is used to display the results of our code on screen.
 Potentiometer:
It is used to set the contrast of the lcd.
MUHAMMAD HASEEB & MUHAMMAD
BAQIR
6
MPMC
Code:
unsigned short kp;
char actual_password[] = "190470";
char given_password[] = "000000";
int count;// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
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;
char keypadPort at PORTD;
void Password_prompt(){
Lcd_Cmd(_LCD_CLEAR);
// Clear display
Lcd_Out(1, 1, "Servo Motor is Off");
Lcd_Out(2,1,"and Locked");
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
// Clear display
Lcd_Out(1, 1, "Enter 6 digit no:");
MUHAMMAD HASEEB & MUHAMMAD
BAQIR
7
MPMC
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
// Cursor off
Lcd_Cmd(_LCD_SECOND_ROW);
}
void Init(){
Lcd_Init();
// Initialize LCD
Lcd_Cmd(_LCD_CLEAR);
// Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
// Cursor off
Lcd_Out(1, 1, "Welcome to");
Lcd_Out(2, 1, "Password Lock");
Lcd_Out(3, 2, "190470");
Lcd_Out(4, 5,"190472");
Delay_ms(500);
Password_prompt();
TRISB=0;
count=0;
Keypad_Init();
// Initialize Keypad
}
int Check_password(){
Lcd_Cmd(_LCD_CLEAR);
if(!memcmp(actual_password, given_password, 6)){
Lcd_Out(1, 1, "Password Matched");
Lcd_Out(2,1,"Motor is on");
return 1;
}
else{
MUHAMMAD HASEEB & MUHAMMAD
BAQIR
8
MPMC
Lcd_Out(1, 1, "Incorrect Password");
Lcd_Out(2, 1, "Try Again!");
Delay_ms(2000);
Password_prompt();
return 0;
//Enter_password();
}
count=0;
}
void main() {
Init();
do {
kp = 0;
// Reset key code variable
if(count==6)
{
PORTB.B7=Check_password();
//0/1 according to password check and drives the motor
count=0;
if(PORTB.B7==1){
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
//Lcd_Cmd(_LCD_FIRST_ROW);*/
Lcd_Out(1,1,"Press * to Off");
Lcd_Out(2,1,"and Lock again");
Lcd_Cmd(_LCD_CURSOR_OFF);
// Cursor off
do
kp = Keypad_Key_Click();
// Store key code in kp variable
while (kp!=13);
MUHAMMAD HASEEB & MUHAMMAD
BAQIR
9
MPMC
if(kp==13){
PORTB.B7=0;
Password_prompt();
}
}
}
do
kp = Keypad_Key_Click();
// Store key code in kp variable
while (!kp);
switch (kp) {
case 1: kp = 49;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 1
// Uncomment this block for keypad4x4
case 2: kp = 50;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 2
case 3: kp = 51;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 3
case 4: kp = 65;Lcd_Chr_Cp(kp); break; // A
case 5: kp = 52;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 4
case 6: kp = 53;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 5
case 7: kp = 54;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 6
case 8: kp = 66;Lcd_Chr_Cp(kp); break; // B
case 9: kp = 55;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 7
case 10: kp = 56;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 8
case 11: kp = 57;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 9
case 12: kp = 67;Lcd_Chr_Cp(kp); break; // C
case 13: kp = 42;Lcd_Cmd(_LCD_MOVE_CURSOR_LEFT);count--; break; // *
case 14: kp = 48;Lcd_Chr_Cp(kp);given_password[count]=kp;count++; break; // 0
case 15: kp = 35;Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);count++; break; // #
case 16: kp = 68;Lcd_Chr_Cp(kp); break; // D
}
} while (1);}
MUHAMMAD HASEEB & MUHAMMAD
BAQIR
10
MPMC
PROCEDURE:
 On the very first note, as far as software part is concerned ; we created a project in
MikroC software.
 The external oscillator which we selected is of 10MHz.
 Then the program displayed above is executed.
 The code was executed by keeping these steps in consideration which were to be
followed in the given manner.
Pin Configuration of LCD and Keypad
Declaration
Initialization
Interfacing of LCD and Keypad with Pic micro controller
Displaying Output result on the LCD.
 After the code was successfully build, an HEX file of the code was created.
 Then, a Proteus Simulation which is displayed on the upcoming pages was created.
 The HEX file created was loaded on to the circuit constructed on the Proteus.
 Now we will run the simulation.
 A prompt message would be displayed on the LCD, “Enter six digit number”.
 We will enter the password. A message would again be prompted on the LCD asking
if we want to turn the Servo Motor off, press “*”.
 If we entered a wrong password, a message would be prompted on the LCD saying,
“Wrong Password, Try again”.
 Then the same circuit is implemented on the Hardware and the results are cross
checked with the simulation.
MUHAMMAD HASEEB & MUHAMMAD
BAQIR
11
MPMC
Simulation:
When simulation is not running.
When simulation has started
MUHAMMAD HASEEB & MUHAMMAD
BAQIR
12
MPMC
Enter Password
MUHAMMAD HASEEB & MUHAMMAD
BAQIR
13
MPMC
When wrong Password is Entered.
When we enter the wrong password then LCD will display the message that motor is still
OFF
MUHAMMAD HASEEB & MUHAMMAD
BAQIR
14
MPMC
CONCLUSION:
In this project our main focus was to demonstrate our skills on MikroC as well as on the
hardware. In the given scenario, we were made to implement logic for automatic
password based door lock. To implement the following scenario the equipment that
were used are LCD, Micro-Controller, Keypad, Potentiometer and External Oscillator.
Using the following components we learned keypad interfacing, Pin configuration,
Initialization and Declaration of LCD and Keypad. Our main aim was to use our basic
knowledge of PIC micro controller and implement it on the software MikroC as well as
on the Hardware. The results of the Hardware were cross verified with that of the
Software .
MUHAMMAD HASEEB & MUHAMMAD
BAQIR
15
Download