LK202-25 Keypad read over i2c

LK/ELK/VK/PK/OK/MX/GLK/EGLK/GVK/GLT Series

Moderators: Henry, Mods

fitzi
LCD?
Posts: 8
Joined: Mon Feb 28, 2005 3:13 pm

LK202-25 Keypad read over i2c

Post by fitzi »

Hi,

i have a peck of trouble to get the correct Data over i2c which i read from keypad at LK202-25.

I atteched a 3x4 matrix Keypad to LK202-25. I tested the keypad with the Display Tuner and all works fine. After the first test was ok. I tried to writing and reading to the LK202-25 over i2c.

The follow settings are made before i test the i2c functionality:

1. i2c LK202-25 basic address was set to 0x50
2. auto transmit key presses was set to off so that a keypress would be put to the internal key buffer. (works fine over rs232 and poll mode)

After, all settings was made i wrote a character to the module and thereafter i sent a command (backlight off) to the module. All this works fine. But now to my problem the read process of the keypad over i2c.

I tried to read the data of a key press over i2c. Also i sent i2c_read(...) to address 0x51 and my i2c master
Tom
Matrix Orbital
Matrix Orbital
Posts: 1030
Joined: Mon Jul 19, 2004 4:43 pm
Location: Calgary
Contact:

Post by Tom »

Hi fitzi,

Thanks for posting at the forums.

Please refer to section 4.3 of the manual found at https://www.matrixorbital.com/files/LK202-25.pdf for a better explanation of the occurances.

If you have any further questions, please feel free to ask.

Best Regards,
fitzi
LCD?
Posts: 8
Joined: Mon Feb 28, 2005 3:13 pm

Post by fitzi »

the problem is:
I press different Buttons at the keypad and get at determined keys the same data back from module.
see above

////key 2 pressed
//data = 0x21

////key 3 pressed
//data = 0x21 //it is the same as key 2

a push to key 2 or key 3 deliver the same data (I can not differ in my program, which key was pressed)

i hope it is clearer now

greeting
Michael
Miles
Matrix Orbital
Matrix Orbital
Posts: 1105
Joined: Mon Mar 04, 2002 4:00 pm

Post by Miles »

What set of commands are you sending when you poll the keypad?? :-?
Miles Y.
Head of Technical Support
Product Manager
Matrix Orbital
fitzi
LCD?
Posts: 8
Joined: Mon Feb 28, 2005 3:13 pm

Post by fitzi »

My test programm has follow operational sequence.

snippets of my programm

Code: Select all

#define LK202_I2CADDR 0x50

//init 
i2c_init();	

//set AutoTransmitKey to off
char cmd[2] = {0xFE, 0x4F};
//generate start condition, send data, generate stop condition
i2c_write(LK202_I2CADDR, cmd, 2);

//Data buffer
char b[8]; 

//read 100 times
for(int i=0; i<100; i++) {
    i2c_read(LK202_I2CADDR | 0x01, b, 1); 
    printf("Data read from %X: %X", LK202_I2CADDR | 0x01, b[0] )
    Sleep(1500);
}//endfor

best regards
Michael
Tom
Matrix Orbital
Matrix Orbital
Posts: 1030
Joined: Mon Jul 19, 2004 4:43 pm
Location: Calgary
Contact:

Post by Tom »

Micheal,

Can I see the code where you poll the keypad?
fitzi
LCD?
Posts: 8
Joined: Mon Feb 28, 2005 3:13 pm

Post by fitzi »

#define LK202_I2CADDR 0x50
//init_i2c..
//AutoTransmitKey off..

{//loop

==============================
//My Poll command
char cmd[] = {0xFE, 0x26};
i2c_write(LK202_I2CADDR, cmd, 2);
===========================
..
..
//Read Data
//print Data
}



Best Regards
Michael

PS: It's non differentiated with or without polling command
Tom
Matrix Orbital
Matrix Orbital
Posts: 1030
Joined: Mon Jul 19, 2004 4:43 pm
Location: Calgary
Contact:

Post by Tom »

What is the purpose of Sleep(1500); - is this just for delay? Make sure that it does not put the micro to sleep and put the i2c hardware in some mode that would need restart/reset before you can use it again.
Tom
Matrix Orbital
Matrix Orbital
Posts: 1030
Joined: Mon Jul 19, 2004 4:43 pm
Location: Calgary
Contact:

Post by Tom »

Can you also try adding in the code the auto repeat code off. The code is [254][96] or [0xFE][60] .

Hopefully this works for you.

Best Regards,
fitzi
LCD?
Posts: 8
Joined: Mon Feb 28, 2005 3:13 pm

Post by fitzi »

the Speep(1500); command is only for delaying and does not disturb i2c communication.
I added also the "auto repeat off" [0xfe] [0x60] command to my code. But i get the same results than before.

greeting
Michael
Tom
Matrix Orbital
Matrix Orbital
Posts: 1030
Joined: Mon Jul 19, 2004 4:43 pm
Location: Calgary
Contact:

Post by Tom »

What debounce time are you using?
fitzi
LCD?
Posts: 8
Joined: Mon Feb 28, 2005 3:13 pm

Post by fitzi »

Hi,

the debounce time is set to "20". I set this value at Display Tuner.
This debounce time works fine if the keypad is polled over RS232 within the Display Tuner application.

At i2c mode i get the same results than before.

Best Regards
Michael
Miles
Matrix Orbital
Matrix Orbital
Posts: 1105
Joined: Mon Mar 04, 2002 4:00 pm

Post by Miles »

Are you having any other troubles communicating via the I2C protocol?
Miles Y.
Head of Technical Support
Product Manager
Matrix Orbital
fitzi
LCD?
Posts: 8
Joined: Mon Feb 28, 2005 3:13 pm

Post by fitzi »

the only thing that does not work is reading from the keypad over i2c.
My i2c Interface works fine with other devices, such as the Philips PCF8574AP (i2c I/O Expander). With this chip it is possible to read data from porst and write data to porsts.

greeting
Michael
fitzi
LCD?
Posts: 8
Joined: Mon Feb 28, 2005 3:13 pm

Post by fitzi »

Do you have any other suggestions, how to get the "keypad read" over i2c to run.

Best Regards
Post Reply