Go Down

Topic: 74LS151 & Keypad (Read 3196 times) previous topic - next topic

tcox8

Something like this?

Might also have to connect Q6 to P6, Q7 to P7 & Q8 to P8.
I decided to try the CD4021 chips opposed to the Charlieplexing (I already had the chips and don't have enough diodes).

@PaulRB - Can you explain this schematic for me (I'm having trouble understanding it). Questions I have:
  • What size resistors to use?
  • Why is D5 hooked to Q8?
  • Are the diodes necessary?
  • What if I wanted to hook some switches up to make it 4x4 matrix?



I truly appreciate everyone's help on this!

PaulRB

#16
Mar 17, 2016, 08:47 pm Last Edit: Mar 17, 2016, 09:48 pm by PaulRB
I don't know if this will work, its just an idea. Don't have one of those chips, so can suggest some code but can't help you test it.

1. A few K, not critical. Try 10K
2. To allow the data read by the chip to be shifted into the Arduino
3. Yes, they prevent short-circuits between Q6, 7 & 8 when buttons are pressed.
4. You can't, not with this chip alone, but you could make 5x3 matrix. Use P5 to make 5th row, like the others.

The process would be:
1.Arduino sets chip into serial mode and sends out 8 bits to the chip. The 5 least significant bits don't matter, but the 3 most significant bits govern which column of buttons will be read. One should be zero and the other two should be one, so that only one column is read at a time.
2. Arduino changes chip back to parallel mode. The 3 most significant bits appear on the Q6, 7 & 8 outputs. For the outputs set to one/high, no current flows because of the diodes. For the one set to zero/low, current can be sunk if one of the buttons in that column is pressed.
3. The P1 to 5 inputs are normally pulled high by the resistors. If a button is pressed in the currently selected column, the corresponding P input is pulled low (by one of the Q outputs, through the diode).
4. Arduino sets chip back to serial mode. The levels at P1 to 5 inputs are captured by the chip.
6. Arduino shifts 8 bits in through D5. The button states are read from the 5 least significant bits.
7. Arduino repeats the process for the other two columns of buttons.

Any experts reading this care to comment on likely succes? Exact timing issues could be the downfall of the idea. Hence my suggestion of also connecting P6 to 8 to Q6 to 8, so that the output levels on Q6 to 8 are not disturbed at the instant when the chip switches back to serial mode.

That's my idea. But the charlieplexing one is better because it uses same number of Arduino pins, no extra chips, and has been tested and shown to work.

tcox8

Thanks for the fantastic explanation! I think you are right... I think I need to just stick with the Charlieplexing. I tested it out and it works great.

I truly thank you (and everyone else) for your help!

Go Up