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 CCS Technical Support

KEYPAD + LCD
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
thinkpositivex
Guest







KEYPAD + LCD
PostPosted: Tue Dec 29, 2009 6:15 pm     Reply with quote

I'm doing a project to measure the condition of the 12v battery and display at LCD using LCD VOLTMETER application. This part already done. After this part I want to implement a keypad part that capable the user enter the value of the rated voltage battery and display the voltage at LCD also.

My question is what kind of main command that I should used to interrupt the part of LCD voltmeter. I want to used the keypad 4x4 for this project. Can you all help me...
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

PostPosted: Wed Dec 30, 2009 11:02 pm     Reply with quote

I don't know what PIC you're using, and how many pins you have available, so here are two keypad drivers you can use. One is kbd.c, found in the CCS drivers directory, and the other is flex_kbd.c, which can be found here http://www.ccsinfo.com/forum/viewtopic.php?t=28022&start=14

In case you're looking for interrupt driven keys, use this link (also by PCM Programmer) to modify the driver http://www.ccsinfo.com/forum/viewtopic.php?t=39585&start=1.

Rohit
warriorfenix



Joined: 29 Dec 2009
Posts: 8
Location: España

View user's profile Send private message

PostPosted: Thu Dec 31, 2009 11:31 am     Reply with quote

I hope this code help you with your doubts, not exactly what you want but you will serve
Code:
#include <16f873a.h>
#include <lcd2.c>
#fuses XT, NOWDT
#use delay(clock=4000000)
const int escala = 255;
const float v_max = 5.0;
int valor;
float voltaje;

void calcula_voltaje (int val, float &voltaje)     //Funcion conversión pzra conseguir voltaje
{
voltaje=(val*v_max)/escala;
}
void conversor()
   {
   setup_adc(adc_clock_div_32);                    //Enciende conversor
   setup_adc_ports(ra0_ra1_ra3_analog);            //Selecciona los puertos
   set_adc_channel(3);                             //Selecciona canal
   valor=read_adc();                               //Conversión AD almacenada en valor
   calcula_voltaje(valor,voltaje);                 //Llamamos a la funcion de conversión
   setup_adc(adc_off);                             //Apaga el conversor
   setup_adc_ports(no_analogs);                    //Configura terminales como digitales
   }

   main()                                          //Programa principal
   {
   while(1)                                        //Bucle
   {
    conversor();                                   //Llamamos al conversor para realizar la medida y lo apagamos
    lcd_init();                                    //Inicializamos la lcd y representamos el valor
    lcd_putc("voltios = ");
    lcd_gotoxy(16,1);
    lcd_putc("V");
    lcd_gotoxy(11,1);
    printf(lcd_putc,"%1.2f",voltaje);
  }}
thinkpositivex
Guest







PostPosted: Thu Jan 07, 2010 8:39 pm     Reply with quote

I'm using PIC 16f877a, and ccs compiler 4.084 version.
For your information I already run 1 example program from this forum that consist of keypad and driver. My problem is why my lcd is active low after execute. I used the driver keypad and lcd from program files and loaded to this program.
Code:

#include <16f877a.h>
#fuses XT,NOWDT,PUT,NOBROWNOUT,NOLVP
#use delay(clock=4000000)

#include <LCD.C>
#include <KBD.C>

void main()
{
   char c;
   lcd_init();
   kbd_init();
   
   while(TRUE)
   {
      c=kbd_getc();
        if(c!=0)
          if(c=='*')
            lcd_putc('\f');
          else
            lcd_putc(c);
   }
}


The lcd connection:
Code:

RD0 - E
RD1 - R/S
RD2 - R/W
RD3 - no connection
RD4-D4
RD5-D5
RD6-D6
RD7-D7

For keypad connection I refer from keypad driver using port B, added with 10K resistor at row.
Code:

#define COL0 (1 << 5)
#define COL1 (1 << 6)
#define COL2 (1 << 7)
#define ROW0 (1 << 1)
#define ROW1 (1 << 2)
#define ROW2 (1 << 3)
#define ROW3 (1 << 4)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jan 08, 2010 1:55 pm     Reply with quote

In a previous thread, you said you're using Proteus. Post your Proteus
schematic on a free image posting website. Then post a link to it, so we
can look at it.
thinkpositivex23



Joined: 20 Dec 2009
Posts: 7

View user's profile Send private message

circuit picture
PostPosted: Wed Jan 13, 2010 8:46 am     Reply with quote

John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Wed Jan 13, 2010 10:10 am     Reply with quote

I compared that circuit diagram to the LCD wiring in one of my projects, and I had pin 1 of the LCD connected to GND, where you have it going to VCC. Are you sure this is right? Also, the 4-bit mode of operation of the LCD is fine and it's what I used, but you should connect the unused input pins to GND. And finally, I had an unpleasant surprise when I changed to a different brand of LCD. The display was invisible when the LCD pin 3 (contrast setting) was grounded. I had to wire up a voltage divider between GND and VCC before I could see anything. So beware.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 13, 2010 2:51 pm     Reply with quote

LCD's have internal pullups on the unused data bus pins (DB0-DB3), so
they're not floating. You don't have to connect them to ground.
Connect the Vdd pin on the LCD to power, and the Vss pin to ground.
Then it will probably work.
thinkpositivex
Guest







PostPosted: Wed Jan 13, 2010 9:41 pm     Reply with quote

I already try what you are suggest...but it could not operated also.
Can you help me? I think it caused by the coding. Maybe the driver for the LCD or KEYPAD must be altered before execute this circuit.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 13, 2010 9:52 pm     Reply with quote

You're using the CCS keypad driver, not the flex keypad driver.
In that case, you need to tell it to use Port B. The #define statement
must be above the #include statement for the KBD.C file.
Quote:

#include <16f877a.h>
#fuses XT,NOWDT,PUT,NOBROWNOUT,NOLVP
#use delay(clock=4000000)

#define use_portb_kbd TRUE
#include <LCD.C>
#include <KBD.C>

void main()
{
char c;
thinkpositivex
Guest







thanks...PCM programmer
PostPosted: Wed Jan 13, 2010 10:50 pm     Reply with quote

Thank you very much. I have 1 question, if I want to change the keypad to the 4x4 keypad, can you teach me how to alter the CCS keypad driver ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 13, 2010 11:08 pm     Reply with quote

There is a different 4x4 keypad driver here:
http://www.ccsinfo.com/forum/viewtopic.php?t=28022&start=14
thinkpositivex
Guest







keypad
PostPosted: Thu Feb 04, 2010 9:09 am     Reply with quote

I already learn the command for the keypad...
but I want to know the command which, the user capable to enter 2.54 v using keypad and display to LCD.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 04, 2010 2:32 pm     Reply with quote

See this thread and the link in it, for instructions:
http://www.ccsinfo.com/forum/viewtopic.php?t=38900
thinkpositivex
Guest







FLOATING KEYPAD
PostPosted: Thu Feb 04, 2010 9:04 pm     Reply with quote

I'm new to this forum but I am willing to learn. Rolling Eyes.

If user enter on the keypad:
12.50 ( 1 2 dot 5 0 )

- How to format entered number so that it's 12.50 and not 1 2 . 5 0 or something in this matter ?

I already search the link, and I do not understand the answer of this question.
Can you explain to me.....how can we determine either the keypad is floating keypad or normal keypad?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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