KEY PAD
Moderator: Benj
KEY PAD
HI
Can anybody help me to find the problem with the attached flowcode file.When I simulate it in flowcode simulater it works perfect.But when I tried it in real hardware it just keeps displaying random digits without even pressing any keys on the keypad.I wonder my keypad connections are wrong.Ihave used pullup resistors of 10K for each column, And the rows are connected direct to the pic.Any suggestions will be appreciated.
Thanks
Mario
Can anybody help me to find the problem with the attached flowcode file.When I simulate it in flowcode simulater it works perfect.But when I tried it in real hardware it just keeps displaying random digits without even pressing any keys on the keypad.I wonder my keypad connections are wrong.Ihave used pullup resistors of 10K for each column, And the rows are connected direct to the pic.Any suggestions will be appreciated.
Thanks
Mario
- Attachments
-
- keypad.fcf
- (7.5 KiB) Downloaded 290 times
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: KEY PAD
Hi Mario,mario1 wrote: the rows are connected direct to the pic.
That's your problem. If you connect rows directly to pic, then i/p's will be floating with no key pressed. Since i/p resistance will be very high, anything can cause the i/pt o go from logic 0 to logic 1 (including a finger fairly near!) if using a pin as i/p there must always be a pull up or pull down component, e.g a resistor or internal weak pull-ups enabled.
My advice would be to look at the eblock datasheet for keypad, and wire yours in the same manner. See
http://www.matrixmultimedia.com/datashe ... 4-30-1.pdf
If not got enough resistors, you could try connecting the resistors you have got to ground (rows only).
For the columns you can configure the chip for weak pull-ups.
If you need help with that, I can edit your flowchart for you.
Martin
Martin
Re: KEY PAD
Thanks for the reply Martin.As you have mentioned I would like to have a edited flowchart.
Thanks
Mario
Thanks
Mario
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: KEY PAD
I have edited your Flowchart to enable weak pull-ups. Keypad Columns must be connected to portB, since weak pull-ups are only available for that port.
You can connect the rows to rest of port B or port C etc.
Hint: If you plan on using ICD, then connect rows to portC.
Just make sure you set up the keypad connections for correct port within Flowcode 1st
I have altered your flowchart so you name is displayed for 1st 3 seconds.
That way you will know if there is a problem, at least it's not LCD if you can see your name appear on the display.
Without that in place, if nothing appears on LCD, you wont know if it's a LCD, Keypad, or other hardware or configuration issue.
if you press * the 1st line will clear of numbers.
I have also included a routine that stops the same number printed, if keypad is pressed for too long, and a de-bounce delay.
Hope it works for you, as I have not got the same hardware as you to test.
Can you let us know how you get on please.
Martin
You can connect the rows to rest of port B or port C etc.
Hint: If you plan on using ICD, then connect rows to portC.
Just make sure you set up the keypad connections for correct port within Flowcode 1st
I have altered your flowchart so you name is displayed for 1st 3 seconds.
That way you will know if there is a problem, at least it's not LCD if you can see your name appear on the display.
Without that in place, if nothing appears on LCD, you wont know if it's a LCD, Keypad, or other hardware or configuration issue.
if you press * the 1st line will clear of numbers.
I have also included a routine that stops the same number printed, if keypad is pressed for too long, and a de-bounce delay.
Hope it works for you, as I have not got the same hardware as you to test.
Can you let us know how you get on please.
Martin
- Attachments
-
- keypad_Edited_for_WPU.fcf
- (8.5 KiB) Downloaded 294 times
Martin
- Eric Brouwer
- Posts: 20
- Joined: Sat Oct 30, 2010 10:17 am
- Has thanked: 3 times
- Been thanked: 11 times
- Contact:
Re: KEY PAD
I had a look at your code, and can not see anything wrong. The problem on the hardware can be sorted out as follow:mario1 wrote:HI
Can anybody help me to find the problem with the attached flowcode file.When I simulate it in flowcode simulater it works perfect.But when I tried it in real hardware it just keeps displaying random digits without even pressing any keys on the keypad.I wonder my keypad connections are wrong.Ihave used pullup resistors of 10K for each column, And the rows are connected direct to the pic.Any suggestions will be appreciated.
Thanks
Mario
- Rows are the Keypad inputs to the PIC
- Columns are the Keypad "control lines", and are set up as outputs on the PIC.
- All the Keypad Rows must be connected to 0V via pull-down resistors. I use 10K resistors for this.
- All Keypad Columns must have a resistor to prevent damage to the PIC if more than one keypad button is pressed at the same time. I use 1K5 for this.
I hope this will assist you.
- Attachments
-
- Keypad Connections
- KEYPAD.JPG (63.92 KiB) Viewed 6960 times
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: KEY PAD
Sorry Mario,
Thinking about it, I was wrong Eric has a good point.
Thanks Eric.
Therefore the resistors must indeed be connected between the columns and the pins of the chip.
as Eric suggested.
It is very risky connecting the keypad columns directly to ports B0 - B2
Because if you either press more than one key simultaneously (as Eric suggested.) Or ports B4 - B7 are accidently set up as o/ps then there will be a short circuit from O/P's B0 - B2 and GND or +5V
So I don't think its worth the risk as mistakes do happen!
So when I said about connecting the the same as eblock datasheet for keypad, and thats the same as Erics diagram is the wisest way.
Also using Weak pull-ups won't work, as I have gone more deeply into the way the keypad routine works.
If I'm correct B0 - B2 are assigned as outputs.
B4 to B7 are assigned as inputs.
Martin
Thinking about it, I was wrong Eric has a good point.
Thanks Eric.
Therefore the resistors must indeed be connected between the columns and the pins of the chip.
as Eric suggested.
It is very risky connecting the keypad columns directly to ports B0 - B2
Because if you either press more than one key simultaneously (as Eric suggested.) Or ports B4 - B7 are accidently set up as o/ps then there will be a short circuit from O/P's B0 - B2 and GND or +5V
So I don't think its worth the risk as mistakes do happen!
So when I said about connecting the the same as eblock datasheet for keypad, and thats the same as Erics diagram is the wisest way.
Also using Weak pull-ups won't work, as I have gone more deeply into the way the keypad routine works.
If I'm correct B0 - B2 are assigned as outputs.
B4 to B7 are assigned as inputs.
Martin
Martin
Re: KEY PAD
Hi Martin & Eric
Thanks for your time & effort. I tried the exact connections which Eric suggested but unfortunatly still the key pad doesnt read .My key pad has built in resistors around 35 Ohms for each key and I wonder this effects the operation.Also I was thinking whether the key pad scanning process used for the "getKeyNo" macro in flowcode is different.
Thanks
Mario
Thanks for your time & effort. I tried the exact connections which Eric suggested but unfortunatly still the key pad doesnt read .My key pad has built in resistors around 35 Ohms for each key and I wonder this effects the operation.Also I was thinking whether the key pad scanning process used for the "getKeyNo" macro in flowcode is different.
Thanks
Mario
- Eric Brouwer
- Posts: 20
- Joined: Sat Oct 30, 2010 10:17 am
- Has thanked: 3 times
- Been thanked: 11 times
- Contact:
Re: KEY PAD
I have tested your original code on a breadboard, and it is working correct. I did not change any settings or configs.mario1 wrote:Hi Martin & Eric
Thanks for your time & effort. I tried the exact connections which Eric suggested but unfortunatly still the key pad doesnt read
Due to your delays in the routines, key pressed can only be detected after 500ms. I have included a modified version which takes care of this. You should double check your keypad connections, as well as those of the LCD.
My hardware setup is as follow:
Crystal: 4Mhz low profile
Crystal capacitors: 15pf (refer to datasheet for correct values)
100K resistor between pin 1 (MCLR) and +5V
10K pull-down resistors to 0V on RC4..7
2K2 resistors in series with keypad columns and RC0..2
Also, remember to connect R/W pin of LCD to 0V. I have included a 10K pot on the LCD for adjusting of the contras. Pot between 0V and +5V, pot wiper to pin 3 on LCD. See drawing. Pin 16 of the LCD can be connected directly to 0V, the transistor in the drawing is used when the LCD backlight is controlled from the PIC.
Attached, some more info on my test, as well as my code.
- Attachments
-
- Keypad.zip
- Keypad File & Photo
- (197.2 KiB) Downloaded 309 times
Re: KEY PAD
Hi Eric
Thanks for your support.Everything works fine now.It happened to be the port C of my pic is faulty.When I changed to Port B it works fine.
Thanks again.
Thanks for your support.Everything works fine now.It happened to be the port C of my pic is faulty.When I changed to Port B it works fine.
Thanks again.
- Eric Brouwer
- Posts: 20
- Joined: Sat Oct 30, 2010 10:17 am
- Has thanked: 3 times
- Been thanked: 11 times
- Contact: