I'm trying to read a Keyboard Matrix that is connected so that I scan 4
input lines and pulse 4 output lines and when I pulse and check I find the
button that is pressed. I wrote an E-Mail about this before and I thank
everyone for that answer. Now my problem is when I press a button (Buttons
has a 270Ohm Pull up resistor) the BIT goes high, then when I let go of the
button the BIT stays high. Then after about a second or 2 it fades off.
This wasn't a good result.
This Buttons do not have an Normal Open Pull down resistor so I guess the
just float when disconnected. I tried to activate the internal pull ups.
This didn't help. This just made all the bits high all the time. I've been
Thinking of Toggling the TRISB state after a read to reset the Pins states,
but there must be an easier way.
Drive the output LOW to test for keys on a given row or column. You can
tell that a switch is pressed if the input is LOW. The pullup resistor will
cause the input to quickly return high after the output is turned off or the
switch is released.
Do NOT drive any of the outputs high because they could be shorted to the
output which is driven low if more than one key is pressed in the matrix.
Load the output latch with a "0" for each output bit and leave it that way.
Set the corresponding TRIS bit to "0" to drive a row or column output. Set
the TRIS bit back to a "1" to stop driving the row or column output.
If you can replace the 270 Ohm resistors with larger values (10k would be
nice) then the circuit would consume less power. The inputs would still
return high within a microsecond or two unless you have more than a coupple
hundred pF capacitance on them.
>I'm trying to read a Keyboard Matrix that is connected so that I scan 4
>input lines and pulse 4 output lines and when I pulse and check I find the
>button that is pressed. I wrote an E-Mail about this before and I thank
>everyone for that answer. Now my problem is when I press a button (Buttons
>has a 270Ohm Pull up resistor) the BIT goes high, then when I let go of the
>button the BIT stays high. Then after about a second or 2 it fades off.
>This wasn't a good result.
>
>This Buttons do not have an Normal Open Pull down resistor so I guess the
>just float when disconnected. I tried to activate the internal pull ups.
>This didn't help. This just made all the bits high all the time. I've
been
>Thinking of Toggling the TRISB state after a read to reset the Pins states,
>but there must be an easier way.
> Drive the output LOW to test for keys on a given row or column. You can
> tell that a switch is pressed if the input is LOW. The pullup resistor
will
> cause the input to quickly return high after the output is turned off or
the
> switch is released.
This is what I did and it seem to fix the problem. I make the Pins on the
OUTPUT like 0111 1011 1101 1110. Then when I connect to another Input Pin I
get a result that is LOW only at the time I'm on the scan for that button
and as soon as I release it goes back to HIGH cause if the internal pull
ups.
> Do NOT drive any of the outputs high because they could be shorted to the
> output which is driven low if more than one key is pressed in the matrix.
> Load the output latch with a "0" for each output bit and leave it that
way.
> Set the corresponding TRIS bit to "0" to drive a row or column output.
Set
> the TRIS bit back to a "1" to stop driving the row or column output.
This is what I can't understand? How will I know which pin is which if I
don't set the other 3 high when I'm checking my inputs. I realize the
situation if I press 2 keys on the same ROW at the same time I short out the
Outputs. Is this that bad? How else could I do it?
> If you can replace the 270 Ohm resistors with larger values (10k would be
> nice) then the circuit would consume less power. The inputs would still
> return high within a microsecond or two unless you have more than a
coupple
> hundred pF capacitance on them.
Noted for future designs.
Darren King
> Darren King wrote:
> >I'm trying to read a Keyboard Matrix that is connected so that I scan 4
> >input lines and pulse 4 output lines and when I pulse and check I find
the
> >button that is pressed. I wrote an E-Mail about this before and I thank
> >everyone for that answer. Now my problem is when I press a button
(Buttons
> >has a 270Ohm Pull up resistor) the BIT goes high, then when I let go of
the
> >button the BIT stays high. Then after about a second or 2 it fades off.
> >This wasn't a good result.
> >
> >This Buttons do not have an Normal Open Pull down resistor so I guess the
> >just float when disconnected. I tried to activate the internal pull ups.
> >This didn't help. This just made all the bits high all the time. I've
> been
> >Thinking of Toggling the TRISB state after a read to reset the Pins
states,
> >but there must be an easier way.
>> Do NOT drive any of the outputs high because they could be shorted to
>> the output which is driven low if more than one key is pressed in the
>> matrix. Load the output latch with a "0" for each output bit and
>> leave it that way. Set the corresponding TRIS bit to "0" to drive a
>> row or column output. Set the TRIS bit back to a "1" to stop driving
>> the row or column output.
> This is what I can't understand? How will I know which pin is which
> if I don't set the other 3 high when I'm checking my inputs.
Because the pull-ups will pull up any input that is not connected or
is connected to a strobe line that is open-circuit. That's what the
pull-ups are for.
> I realize the situation if I press 2 keys on the same ROW at the same
> time I short out the Outputs. Is this that bad?
Yes.
> How else could I do it?
Simply follow the instructions (above) given each time before by Ken
and myself.
--
Cheers,
Paul B.