CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

3x4 Keypad and 2x16 LCD

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest3
Guest







3x4 Keypad and 2x16 LCD
PostPosted: Fri Apr 17, 2009 2:16 am     Reply with quote

Hi guys !

I am using one simulator software for simulating LCD and keypad.
http://tinypic.com/view.php?pic=29cxg6b&s=5

In this simulator I can define port's for each key.
ON/OFF is used as key press simulation.

So I took the flex_kbd driver as example for setting the port connection.

flex_kbd.c
Code:

#define col0 PIN_E1
#define col1 PIN_A5
#define col2 PIN_C0
#define row0 PIN_E0
#define row1 PIN_C2
#define row2 PIN_C1
#define row3 PIN_E2


I set first key ( col0,row0) but when I run this program nothing happens:
Code:

#include <16F877.H>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay (clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#include <LCD.c>
#include <flex_kbd.c>

void main() {
   char k;

   lcd_init();
   kbd_init();

   lcd_putc("\f *LCD is ON* ...\n");
   while (TRUE) {
      k=kbd_getc();
      if(k!=0)
        if(k=='*')
          lcd_putc('\f');
        else
          lcd_putc(k);
   }
}

What's wrong with this code ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 17, 2009 11:39 am     Reply with quote

Two weeks ago, you asked this same question. You were given good
answers to solve the problem. You ignored those answers.
Here is the thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=38401
Your schematic in your link above still has the same problem.
You are using pull-down resistors on the row pins, but they should be
pull-up resistors.
Guest3
Guest







PostPosted: Tue Apr 21, 2009 3:01 am     Reply with quote

You are absolutely correct. I asked the same question because i have to wait for new hw design. So i was thinking to make the program on the simulator. I apologize for "double posting" but it was in good manner.
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Tue Apr 21, 2009 10:13 am     Reply with quote

And I'll say again what I said in the other thread--you're wasting components if you use resistors at all. Use Port B and enable the internal pull-ups. That's exactly what they're for.
Guest








PostPosted: Wed Apr 22, 2009 3:58 am     Reply with quote

I agree with you and i will remove resistors in the next hardware design. In the meantime how to configure the program to read the keypad presented by simulator.

I can not change simulator settings, so i can't remove resistors.
All i can change are the ports settings.
gonlo82



Joined: 10 Dec 2010
Posts: 5

View user's profile Send private message Send e-mail MSN Messenger

Suggestions for Proteus simulations
PostPosted: Fri Dec 10, 2010 3:44 pm     Reply with quote

Hello,

i've tried a lot of time to run this example in Proteus_7.2_SP6 and i don´t success. The last time I've copied your code and it was compiled without errors. I copied the diagram too and the lcd doesn´t show anything.

could you give me some help?
_________________
I m working for me in electrical troobleshooting. Pic's Matter interest me a lot to improve my skills.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Dec 10, 2010 5:27 pm     Reply with quote

I don't have Proteus so there's no way for me to help you.
In other words, if Proteus has some bug, how can I see it ?

But I'll try anyway. Post your schematic.
gonlo82



Joined: 10 Dec 2010
Posts: 5

View user's profile Send private message Send e-mail MSN Messenger

The wiring diagram
PostPosted: Mon Dec 13, 2010 5:13 am     Reply with quote

I send you the wiring diagram from proteus environment.
I attach you the code too. (this is an example from a pdf found in taringa website useful for amaters.)

Code:


#include <16F876.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES XT                       //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES PUT                      //Power Up Timer
#FUSES NOPROTECT                //Code not protected from reading
#FUSES BROWNOUT                 //Reset when brownout detected
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES NOWRT                    //Program memory not write protected
#FUSES NODEBUG//,NOPBADEN                  //No Debug mode for ICD



#use delay(clock=4000000)

#define LCD_TYPE       2
#define use_portb_lcd TRUE
#define use_portb_kbd TRUE
#include <lcd.c>
#include <kbd.c>

#define LCD_ENABLE_PIN  PIN_C2                                   
#define LCD_RS_PIN      PIN_C1                                   
//#define LCD_RW_PIN      PIN_B6                                   
#define LCD_DATA4       PIN_C4                                   
#define LCD_DATA5       PIN_C5                                   
#define LCD_DATA6       PIN_C6                                   
#define LCD_DATA7       PIN_C7

void main()
{
   char k;
   int x;
   lcd_init();
   kbd_init();
   port_b_pullups(TRUE);
   lcd_putc("\fEscriba...\n");
   
   while (TRUE)
   {
   k=kbd_getc();//lcd envia caracteres en ASCII a k
   x=k-48;// se resta 48d=(0Ascii)=30hex
   
      if(k!=0)
      {
         if(k=='*')
         lcd_putc('\f');
         else
         lcd_putc(k);//imprime cararter
         
         delay_ms(500);
         
         printf(lcd_putc,"\f Car=%c",k);//imprime cararter
         delay_ms(500);
         
         
         printf(lcd_putc,"\f Car=%u",k);//imprime valor ASCII
         delay_ms(500);
         
         
         printf(lcd_putc,"\f Num=%u",x);//imprime valor numerico del caracter
         delay_ms(500);
         lcd_putc("\fListo...\n");
      }
   }

}


[img]
http://img697.imageshack.us/img697/9002/kbdlcdpic16f877.jpg
[/img]
_________________
I m working for me in electrical troobleshooting. Pic's Matter interest me a lot to improve my skills.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Dec 13, 2010 2:52 pm     Reply with quote

Your schematic shows that pins A and B on the keypad are connected
together by mistake. Edit your schematic and fix it.

Quote:
#define LCD_ENABLE_PIN PIN_C2
#define LCD_RS_PIN PIN_C1
//#define LCD_RW_PIN PIN_B6
#define LCD_DATA4 PIN_C4
#define LCD_DATA5 PIN_C5
#define LCD_DATA6 PIN_C6
#define LCD_DATA7 PIN_C7

What is this code doing in your program ? Your schematic shows all
connections go to Port B. Why do you have this code above, which shows
mostly connections to Port C ? Delete all of the above lines.
gonlo82



Joined: 10 Dec 2010
Posts: 5

View user's profile Send private message Send e-mail MSN Messenger

LCD+KEYBORD PIC16F876 ON PROTEUS
PostPosted: Mon Dec 13, 2010 8:25 pm     Reply with quote

The mistake on Proteus is corrected and the lines related with port c are erased. Do you have the same result during simulation? Persist the same error when the lcd doesn't show the value of each key.
In case of a bug in Proteus, do you have any suggestion to solve it?
_________________
I m working for me in electrical troobleshooting. Pic's Matter interest me a lot to improve my skills.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 14, 2010 2:00 pm     Reply with quote

Post your compiler version and I'll test the ex_lcdkb.c program in
hardware for your version.
gonlo82



Joined: 10 Dec 2010
Posts: 5

View user's profile Send private message Send e-mail MSN Messenger

Proteus_7.2_SP6the version
PostPosted: Tue Dec 14, 2010 2:41 pm     Reply with quote

the version is Proteus_7.2_SP6. I will follow trying because known people could fix it but in Assemble code.

Thanks from now
_________________
I m working for me in electrical troobleshooting. Pic's Matter interest me a lot to improve my skills.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 14, 2010 2:43 pm     Reply with quote

Not Proteus. The CCS compiler version.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group