EB006 with PIC16F88 - Keypad problem

For E-blocks user to discuss using E-blocks and programming for them.

Moderators: Benj, Mods

Post Reply
Phaenix
Posts: 13
Joined: Tue Apr 10, 2012 3:39 pm
Has thanked: 4 times

EB006 with PIC16F88 - Keypad problem

Post by Phaenix »

I think I may just be doing it wrong, but I've been breaking my head over it for a while now... I was using this for this configuration/testing strategy: Keypad Board C & Assembly Strategy

Code: Select all

#include <system.h>

void setup_hardware(void)
{
	trisb = 0xF0;
	trisa = 0xE0;
	porta = 0x00;
}

void main(void)
{
	setup_hardware();

	while (1)
	{
		portb = 0x01;

		if ((portb & 0x10) > 0)
		{
			porta = 0x01;
		}
		else if ((portb & 0x20) > 0)
		{
			porta = 0x04;
		}
		else if ((portb & 0x40) > 0)
		{
			porta = 0x03;
		}
		else if ((portb & 0x80) > 0)
		{
			porta = 0x05; // '*' is pressed
		}
		
		portb = 0x02;
		
		if ((portb & 0x10) > 0)
		{
			porta = 0x02;
		}
		else if ((portb & 0x20) > 0)
		{
			porta = 0x05;
		}
		else if ((portb & 0x40) > 0)
		{
			porta = 0x08;
		}
		else if ((portb & 0x80) > 0)
		{
			porta = 0x00;
		}
		
		portb = 0x04;
		
		if ((portb & 0x10) > 0)
		{
			porta = 0x03;
		}
		else if ((portb & 0x20) > 0)
		{
			porta = 0x06;
		}
		else if ((portb & 0x40) > 0)
		{
			porta = 0x09;
		}
		else if ((portb & 0x80) > 0)
		{
			porta = 0x0B; // '+' is pressed
		}
	}
}
Only buttons 1 - 6 are being read, and buttons 1, 2 and 3 don't always read exactly right.

Puddy32
Posts: 7
Joined: Sat Mar 24, 2012 12:49 am
Has thanked: 1 time

Re: EB006 with PIC16F88 - Keypad problem

Post by Puddy32 »

Hi
Just a possibility, have you a ground wire on keypad
if you are getting different readings then some of your connection could be floating.

Phaenix
Posts: 13
Joined: Tue Apr 10, 2012 3:39 pm
Has thanked: 4 times

Re: EB006 with PIC16F88 - Keypad problem

Post by Phaenix »

There are no connectors on the keypad to ground it, not like the switch board has.

Phaenix
Posts: 13
Joined: Tue Apr 10, 2012 3:39 pm
Has thanked: 4 times

Re: EB006 with PIC16F88 - Keypad problem

Post by Phaenix »

Does anyone know...? :(

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: EB006 with PIC16F88 - Keypad problem

Post by Benj »

Hello,

Your not giving us much to go on. When you say don't always read exactly right how do you mean?

Are you using a Matrix Keypad E-block or your own hardware?

Phaenix
Posts: 13
Joined: Tue Apr 10, 2012 3:39 pm
Has thanked: 4 times

Re: EB006 with PIC16F88 - Keypad problem

Post by Phaenix »

I'm using the Matrix keypad. When I press a button, the corresponding LEDs are supposed to light up. It only does that when I press buttons 1 through 6, 7 to # don't work at all.

When I press buttons 1, 2 or 3 the LEDs lit up, but sometimes they're not the right ones, or too many lit up.

I'm sorry if I'm being confusing... :(

EDIT: this program's purpose was to test the functionality of the keypad. To see if all buttons were working, and to see how they worked exactly. I think I'm doing something wrong.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: EB006 with PIC16F88 - Keypad problem

Post by Benj »

Hello,

Please refer to the attached C file and it should help you to get the keypad working. I have replicated your setup with the keypad on PortB and the Digits being shown on PortA.
Attachments
keypad.c
(5.69 KiB) Downloaded 361 times

Phaenix
Posts: 13
Joined: Tue Apr 10, 2012 3:39 pm
Has thanked: 4 times

Re: EB006 with PIC16F88 - Keypad problem

Post by Phaenix »

Sorry to be a nuisance, but my school hasn't provided me with Flowcode and I don't think they're going to give me one of the licenses they have. Is it possible for you to give me a solution that doesn't require Flowcode headers?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: EB006 with PIC16F88 - Keypad problem

Post by Benj »

Hello,

The C file is just for an example so you can design your own functions. No Flowcode headers are required anywhere in the actual code.

Phaenix
Posts: 13
Joined: Tue Apr 10, 2012 3:39 pm
Has thanked: 4 times

Re: EB006 with PIC16F88 - Keypad problem

Post by Phaenix »

Ah, alright. Thanks a lot!

Post Reply