LeoStar
Member level 2
Hello Everyone!
I am trying to interface a keypad with PIC18F452 and trying to make a alphanumeric keyboard with CAPSLOCK, BACKSPACE, SPACE and ENTER capabilities.
The problem is that it works well in proteus but the hardware doesnt seem to pick the pace to keep with the code.
The dimension of the keypad is 8*5 i.e. there are 40 buttons.
I am trying to work on column 1 first, which has capslock button.
The work should go on like this: On every press, an alphabet will be displayed on the 20*4 LCD and a variable should increment with it. And after every 20 presses the cursor should go to the next line but this seems to work well on proteus but not on the hardware.
Please help me. I direly have to finish this today itself. the code and the circuit diagram are attached as well.
Here is the code.
Here is the picture.
As you can see the character goes to the second line itself but on the hardware nothing like this happens. Everything gets displayed but the microcontroller fails to follow the logic in the enter() functrion.
Please help meee.
- - - Updated - - -
I started with PIC16F877A but that was not even able to make the CAPSLOCK logic to work. Then I changed the microcontroller and used PIC18F452 and the CAPSLOCK logic now work but it has not been able to realize the enter() logic.
This is the onnly hurdle that I have to pass.
Please help meee.
- - - Updated - - -
I am counting on you people. This is nothing for you guys!
- - - Updated - - -
Guys check this code out. Even this doesnt work.
I am very perplexed. Please reply soon.
- - - Updated - - -
The microcontroller doesn't seem to be able to increment the variable q and check the if statement below. It just ignores it.
Whereas on Proteus, it seems to work perfectly.
Please help me soonnnn.
- - - Updated - - -
Guys look at this code, it is not even able to perform this as well.
Please suggest me something guys. I need help. Please help me.
[/quote]
- - - Updated - - -
Here is the updated post.
Now can you please help me Brother!
- - - Updated - - -
Come on guys please help me.
I am trying to interface a keypad with PIC18F452 and trying to make a alphanumeric keyboard with CAPSLOCK, BACKSPACE, SPACE and ENTER capabilities.
The problem is that it works well in proteus but the hardware doesnt seem to pick the pace to keep with the code.
The dimension of the keypad is 8*5 i.e. there are 40 buttons.
I am trying to work on column 1 first, which has capslock button.
The work should go on like this: On every press, an alphabet will be displayed on the 20*4 LCD and a variable should increment with it. And after every 20 presses the cursor should go to the next line but this seems to work well on proteus but not on the hardware.
Please help me. I direly have to finish this today itself. the code and the circuit diagram are attached as well.
Here is the code.
Code:
sbit LCD_RS at portb.b7;
sbit LCD_EN at portb.b6;
sbit LCD_D4 at portb.b5;
sbit LCD_D5 at portb.b4;
sbit LCD_D6 at portb.b3;
sbit LCD_D7 at portb.b2;
sbit LCD_RS_Direction at TRISb.b7;
sbit LCD_EN_Direction at TRISb.b6;
sbit LCD_D4_Direction at TRISb.b5;
sbit LCD_D5_Direction at TRISb.b4;
sbit LCD_D6_Direction at TRISb.b3;
sbit LCD_D7_Direction at TRISb.b2;
sbit S1 at portd.b0;
sbit S2 at portd.b1;
sbit S3 at portd.b2;
sbit S4 at portd.b3;
sbit S5 at portd.b4;
sbit S6 at portd.b5;
sbit S7 at portd.b6;
sbit S8 at portd.b7;
sbit C1 at portc.b0;
sbit C2 at portc.b1;
sbit C3 at portc.b2;
sbit C4 at portc.b3;
sbit C5 at portc.b4;
sbit CAPLED at porte.b0;
int aa,x,q,rr,dd;
void enter()
{
delay_ms(100);
q++;
if(q==20)
{
delay_ms(10);
x++;
if(x==1)
{
delay_ms(10);
lcd_cmd(0xC0);
}
if(x==2)
{
delay_ms(10);
lcd_cmd(0x94);
}
if(x==3)
{
delay_ms(10);
lcd_cmd(0xD4);
}
if(x==4)
{
delay_ms(10);
Lcd_Cmd(_LCD_CLEaR);
lcd_cmd(0x80);
x=0;
}
q=0;
}
}
void col1()
{
S1=S2=S3=S4=S5=S6=S7=S8=1;
delay_ms(160);
S1=0;
if(C1==0)
{
if(aa==1)
lcd_chr_cp('A');
else
lcd_chr_cp('a');
enter();
}
S1=1;
S2=0;
if(C1==0)
{
if(aa==1)
lcd_chr_cp('B');
else
lcd_chr_cp('b');
enter();
}
S2=1;
S3=0;
if(C1==0)
{
if(aa==1)
lcd_chr_cp('D');
else
lcd_chr_cp('d');
enter();
}
S3=1;
S4=0;
if(C1==0)
{
if(aa==1)
lcd_chr_cp('G');
else
lcd_chr_cp('g');
enter();
}
S4=1;
S5=0;
if(C1==0)
{
if(aa==1)
lcd_chr_cp('K');
else
lcd_chr_cp('k');
enter();
}
S5=1;
S6=0;
if(C1==0)
{
delay_ms(10);
if(aa==1)
lcd_chr_cp('P');
else
lcd_chr_cp('p');
enter();
}
S6=1;
S7=0;
if(C1==0)
{
if(aa==1)
lcd_chr_cp('U');
else
lcd_chr_cp('u');
enter();
}
S7=1;
S8=0;
if(C1==0)
{
aa++;
CaPLED=1;
if(aa>1)
{
aa=0;
CaPLED=0;
}
}
}
void main()
{
ADCON1=0x06;
trisc=0x1F;
trisd=0x00;
trise=0x00;
lcd_init();
Lcd_Cmd(_LCD_CLEaR);
CaPLED=0;
delay_ms(100);
lcd_cmd(0x82);
delay_ms(100);
lcd_out_cp("INTER-ACTIVE");
delay_ms(100);
lcd_cmd(0xc2);
delay_ms(100);
lcd_out_cp("KEYBOARD");
delay_ms(100);
lcd_cmd(0x94);
delay_ms(100);
lcd_out_cp("Made by: RAJNI");
delay_ms(100);
lcd_cmd(0xd6);
delay_ms(100);
lcd_out_cp("and VARINDER");
delay_ms(100);
delay_ms(2000);
lcd_cmd(_LCD_CLEAR);
delay_ms(100);
lcd_cmd(_LCD_BLINK_CURSOR_ON);
delay_ms(110);
while(1)
{
S1=S2=S3=S4=S5=S6=S7=S8=0;
if(C1==0)
col1();
}
}
As you can see the character goes to the second line itself but on the hardware nothing like this happens. Everything gets displayed but the microcontroller fails to follow the logic in the enter() functrion.
Please help meee.
- - - Updated - - -
I started with PIC16F877A but that was not even able to make the CAPSLOCK logic to work. Then I changed the microcontroller and used PIC18F452 and the CAPSLOCK logic now work but it has not been able to realize the enter() logic.
This is the onnly hurdle that I have to pass.
Please help meee.
- - - Updated - - -
I am counting on you people. This is nothing for you guys!
- - - Updated - - -
Guys check this code out. Even this doesnt work.
I am very perplexed. Please reply soon.
Code:
// Lcd pinout settings
sbit LCD_RS at Portb.b7;
sbit LCD_EN at Portb.b6;
sbit LCD_D7 at PortB.b2;
sbit LCD_D6 at PortB.b3;
sbit LCD_D5 at PortB.b4;
sbit LCD_D4 at PortB.b5;
// Pin direction
sbit LCD_RS_Direction at TRISB.B7;
sbit LCD_EN_Direction at TRISB.B6;
sbit LCD_D7_Direction at TRISB.B2;
sbit LCD_D6_Direction at TRISB.B3;
sbit LCD_D5_Direction at TRISB.B4;
sbit LCD_D4_Direction at TRISB.B5;
int aa,x,q,rr,dd;
void main()
{
lcd_init();
lcd_cmd(_LCD_CURSOR_OFF);
lcd_cmd(0x84);
delay_ms(100);
lcd_out_cp("Varinder");
delay_ms(100);
lcd_cmd(0xc7);
delay_ms(100);
lcd_out_cp("Kaur");
lcd_cmd(0x98);
delay_ms(100);
lcd_out_cp("RAJNI");
delay_ms(100);
lcd_cmd(0xd8);
delay_ms(100);
lcd_out_cp("KAUSHAL");
delay_ms(1000);
lcd_cmd(0x80);
lcd_cmd(0x01);
while(1)
{
lcd_chr_cp('a');
delay_ms(250);
q++;
if(q==20)
{
delay_ms(50);
x++;
if(x==1)
{
delay_ms(50);
lcd_cmd(0xC0);
}
if(x==2)
{
delay_ms(50);
lcd_cmd(0x94);
}
if(x==3)
{
delay_ms(50);
lcd_cmd(0xD4);
}
if(x==4)
{
delay_ms(50);
Lcd_Cmd(_LCD_CLEaR);
lcd_cmd(0x80);
x=0;
}
q=0;
}
}
}
- - - Updated - - -
The microcontroller doesn't seem to be able to increment the variable q and check the if statement below. It just ignores it.
Whereas on Proteus, it seems to work perfectly.
Please help me soonnnn.
- - - Updated - - -
Guys look at this code, it is not even able to perform this as well.
Please suggest me something guys. I need help. Please help me.
Code:
// Lcd pinout settings
sbit LCD_RS at Portb.b7;
sbit LCD_EN at Portb.b6;
sbit LCD_D7 at PortB.b2;
sbit LCD_D6 at PortB.b3;
sbit LCD_D5 at PortB.b4;
sbit LCD_D4 at PortB.b5;
// Pin direction
sbit LCD_RS_Direction at TRISB.B7;
sbit LCD_EN_Direction at TRISB.B6;
sbit LCD_D7_Direction at TRISB.B2;
sbit LCD_D6_Direction at TRISB.B3;
sbit LCD_D5_Direction at TRISB.B4;
sbit LCD_D4_Direction at TRISB.B5;
int aa,x,queue=0,rr,dd;
void main()
{
lcd_init();
while(1)
{
lcd_chr_cp('a');
delay_ms(250);
aa++;
if(aa==20)
{
delay_ms(1000);
lcd_cmd(0x01);
aa=0;
}
}
}
- - - Updated - - -
Here is the updated post.
Now can you please help me Brother!
- - - Updated - - -
Come on guys please help me.