CCS Software
We use CCS software to
program for microcontroller PIC. The program is the integration of three
separate compliers for three different PIC families:
- PCB for PIC 12-bit opcodes
- PCM for PIC 14-bit opcodes
- PCH for PIC 16 and 18-bit
PIC 16F877a is a PIC
14, so we can use the CCS software to program for it with C language.
The basic structure of
the program when using C language:
#include, #device, #use, #fuse….//
pre-processor directives.
#define, int8
..........// data definitions, declare constant, variable…
Void Function
() {} // function
definition
Void main () {// main program.}Algorithm Block Diagram
Significant Code
void Scan_keyboard()
{
PORTB=0xfe; // 1111 1110 Checking row 1 pressed.
if(RB4==0) { program;while(RB4==0) {do nothing} }
if(RB5==0) { program;while(RB4==0) {do nothing}
}
if(RB6==0) { program;while(RB4==0) {do nothing}
}
if(RB7==0) { program;while(RB4==0) {do nothing}
}
PORTB=0xfd; // 1111 1101 Checking row 2 pressed.
if(RB4==0) { program;while(RB4==0) {do nothing}
}
if(RB5==0) { program;while(RB4==0) {do nothing}
}
if(RB6==0) { program;while(RB4==0) {do nothing}
}
if(RB7==0) { program;while(RB4==0) {do nothing}
}
PORTB=0xfb; // 1111 1011 Checking row 3 pressed.
if(RB4==0) { program;while(RB4==0) {do nothing}
}
if(RB5==0) { program;while(RB4==0) {do nothing}
}
if(RB6==0) { program;while(RB4==0) {do nothing}
}
if(RB7==0) { program;while(RB4==0) {do nothing}
}
PORTB=0xf7; // 1111 0111 Checking row 4 pressed.
if(RB4==0) { program;while(RB4==0) {do nothing}
}
if(RB5==0) { program;while(RB4==0) {do nothing}
}
if(RB6==0) { program;while(RB4==0) {do nothing}
}
if(RB7==0) { program;while(RB4==0) {do nothing}
}
}
------------------------------------------------------------------------------------------------
Void
check()
{
lcd_putcmd(line_1);
printf(LCD_PutChar,"CHECKING........");
delay_ms(600);
for(j=0;j<=8;j++)
if(read_eeprom(0x00+j)-b[j]!=0)
{
write_eeprom(0x09,read_eeprom(0x09)+1);
wrong();
}
else count=count+1;
if (count==9)
{
LCD_PutCmd(Clear_Scr);
lcd_putcmd(line_1);
RC6=1;RC7=0;;i=0;
write_eeprom(0x09,0);
printf(LCD_PutChar,"OPENING.....");
}
}
The code and simulation file of the project can be downloaded with the following link:
Conclusion
With the
system operating in our
project, from simulation in Proteus software program, we can produce the real
system.
Because of working in prototype, if we use
the high-power motor to pull the door opening or closing, we will calculate so
much. To apply for reality, our system needs to adjust to increase the
stability and connect with the mechanical part.
Nowadays, the other digital lock systems
have used many
modern modes: card, finger print… However, the price is not cheap. Thus, our
system still has certainly applications, so we will afford to finish
completely our project to suitable with the reality demand.