|
|
View previous topic :: View next topic |
Author |
Message |
williamho Guest
|
keypad output no stable |
Posted: Wed Jun 29, 2005 5:11 am |
|
|
Hi, I have connected 7 pins from 3x4 keypad to portD1 to 7.
D4,5,6,7 connected to rows with 10K pullup resistor.
I can get reading from RS232 but reading not stable:-
for example : row 1 with '1', '2' and '3'.
Whenever I press key '1', output will change rendomlly 1 or 2 or 3.
If i press any key from row 2 ('4','5' and '6'), output appeared to be 4 or 5 or 6.
what is wrong with the code or the hardware connection?
Thanks
Code: | #fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, parity=N, Bits=8, xmit=PIN_C6, rcv=PIN_C7,stream=COM_1)
#include <can-18xxx8.c>
#include <lcd.c>
#include <kbd_mdy.c>
void main()
{
kbd_init();
printf("ready");
while(TRUE) {
k=kbd_getc();
if(k!=0)
{
putc(k);
}
}
} |
|
|
|
Ttelmah Guest
|
|
Posted: Wed Jun 29, 2005 8:22 am |
|
|
Without seeing your keyboard code, nobody can help...
Presumably you have modified the standard 'kbd.c'?.
The pull up resistors need to be on the input lines, not the lines that drive the keyboard. The way you are talking about three possible outputs being generated, suggests that there are four drive lines, and three inputs?. If so, put the resistors on the other lines.
Best Wishes |
|
|
Guest
|
|
Posted: Wed Jun 29, 2005 6:45 pm |
|
|
thanks, I will reconnect the pullup resistor again. |
|
|
Guest
|
|
Posted: Wed Jun 29, 2005 8:29 pm |
|
|
Quote: | I can get reading from RS232 but reading not stable:- |
Wrong clock value?
Are you using the internal or a external oscillator? Sounds like your clock may be out, causing the problem you describe.
If using the internal osc, try using a crystal instead see if it clears it up. |
|
|
Guest
|
|
Posted: Wed Jun 29, 2005 8:30 pm |
|
|
Quote: | I can get reading from RS232 but reading not stable:- |
Wrong clock value?
Are you using the internal or a external oscillator? Sounds like your clock may be out, causing the problem you describe.
If using the internal osc, try using a crystal instead see if it clears it up. |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Thu Jun 30, 2005 7:59 am |
|
|
As for the RS232, If you have a ground in common to PC and circuit under test the serial will be much more stable.
I don't know if you can change your circuit or not.
But if you can, I like this circuit.
http://a330.g.akamai.net/7/330/2540/20050519160504/www.edn.com/contents/images/601828f1.pdf
note that is has a irq pin. That way you don't have to poll all the time. Just set a flag on irq. read the keypad when flag is set. It also has a 2.2uF cap that adds a hardware debounce. |
|
|
|
|
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
|