Shop OBEX P1 Docs P2 Docs Learn Events
Does the 4X4 matrix keypad need diodes to install an extension cable? (Solved by work-around) - Page 2 — Parallax Forums

Does the 4X4 matrix keypad need diodes to install an extension cable? (Solved by work-around)

2»

Comments

  • Can't the 4020 be reset? I'm missing something. What's the difference between the 4020 and the 4040 besides 14 to 12?
    Either way I order some of both :-)
  • Both are binary counters.
    4040 has 12 bits that go to 12 pins.
    4060 has 14 bits but only 11 of them go to pins,
    And the missing bit pins are low bits so you can't use reset to skip them. They make the bit pins that aren't missing count slower.
    Overcounting can be avoided by reset but is not even a problem because unused high bits can be left unconnected and ignored as if they weren't even there.
    Overcounting can also be avoided by "just not doing it with your spin code", and make it reset the counter before it scan the keyboard.

    The missing bits are a second "useless extra counting" problem. The first "useless extra counting" only happens if you try to use a binary counter like a 4017. The 4017 is not a binary counter; it only counts from 0 to 9 and each number has its own pin. I didn't think you would really try directly connect binary counter to a matrix because you mentioned using a 74147. You know there are chips to convert binary numbers to pins. That's what I use 4051's for.
  • VIRAND wrote: »
    Both are binary counters.
    4040 has 12 bits that go to 12 pins.
    4060 has 14 bits but only 11 of them go to pins,
    And the missing bit pins are low bits so you can't use reset to skip them. They make the bit pins that aren't missing count slower.
    Overcounting can be avoided by reset but is not even a problem because unused high bits can be left unconnected and ignored as if they weren't even there.
    Overcounting can also be avoided by "just not doing it with your spin code", and make it reset the counter before it scan the keyboard.

    The missing bits are a second "useless extra counting" problem. The first "useless extra counting" only happens if you try to use a binary counter like a 4017. The 4017 is not a binary counter; it only counts from 0 to 9 and each number has its own pin. I didn't think you would really try directly connect binary counter to a matrix because you mentioned using a 74147. You know there are chips to convert binary numbers to pins. That's what I use 4051's for.

    Ok, very cool. Thank you.
    So you have me convinced on the 4040, good job. One question which I'm fairly certain though. With the 4040 can I set an output bit to the reset pin? So I can count to 8 to get my 7 scans plus the reset.

    I am aware of encoders and decoders, It's just that I apparently forgot that ripple counters existed until a few posts ago (stinky brain fart), rather I never considered the time phase of my scans and how to enact that in hardware.
  • MrBi11 wrote: »

    These are great. There are a few important factors to my project that may or may not have been listed. Cost is among the most important.
    Also these use too many pins.
    My design does 42 buttons on 6 wires without the need for software decoding. It does so by using the same wire for all inputs and a 3D matrix instead of 2D.
  • Yes, the 4040 resets to all zeros when a counting pin connected to reset becomes 1. But the reset happens instantly, the 1 disappears as soon as reset sees it and it doesn't stay until the next clock.

    If you want the reset to last until the next clock after 8 then use the bit pin for 8 to reset other things, and use logic of the pins for "8 AND 1" to reset the counter.
  • VIRAND wrote: »
    Yes, the 4040 resets to all zeros when a counting pin connected to reset becomes 1. But the reset happens instantly, the 1 disappears as soon as reset sees it and it doesn't stay until the next clock.

    If you want the reset to last until the next clock after 8 then use the bit pin for 8 to reset other things, and use logic of the pins for "8 AND 1" to reset the counter.

    Ahhhh, very good. Combine that with (8 xor 1) and 1 and I can still use the 1 pin without causing an erroneous scan on 1.
    Since the input pin can multiplex to 12 there is no reason to expand beyond 2D for my current application. 12 in x 4 out = 47 keys on 5 pins.
    I'm not going to but I could use a PCA9536 and split the clock line to take it down to a 2 wire i2c connection. I'll have to make one anyway, just to share it.
  • Please take a look at these and watch what they do.
    I can't explain better. Which can you use?

    4017, ten counter


    4040, binary counter


    All about shift registers


    I didn't find one for binary counter with multiplexers yet.
    Wait, here is a keyboard using 4051s.
    The binary counter is in the "pokey" chip.
    http://atariage.com/forums/uploads/monthly_07_2007/post-9683-1183297470.gif
  • The last link, this one, is very close to the schematic I couldn't post earlier. The only difference is that the six K lines go to a 4024 or a 4040, and the KR1 line goes to the propeller. All 64 keys get counted and checked from 000,000 to 111,111 (0 to 63) and if any are pressed, the propeller pin goes low. So 64 keys are multiplexed into one pin. This technique was used in an Atari computer keyboard. There are minor details that I will have trouble explaining unless you understand what the binary counter and the multiplexers are doing.

    http://atariage.com/forums/uploads/monthly_07_2007/post-9683-1183297470.gif

    If you look at the 4017 video you see how it counts differently than the 4040, and how the 4017 counter by itself can scan ten matrix lines. 5 lines out of the matrix can go to the propeller and that would simply give you 45 or 50 keys on 6 pins.

    It would be very unusual to use a 4040 all by itself to read a 12 x 4 matrix because it counts from 000000000 to 111111111 and you would have to ignore 4084 out of 4096 counts that don't have only one 1 in them and you can't avoid that with reset. That is why I wanted you to look at the videos.

    I noticed videos of 3D LED cubes run by a 4020 all by itself which were called "multiplexing", and thought maybe that is how you thought of 3D keyboard matrixes. I don't know whether that effect can be used to read every key in a 3D matrix or not, but if it can then I think most of the patterns it generates probably also need to be ignored

    The reason so many counts would need to be ignored when trying to multiplex with only a binary counter is that the matrix would output the same code for at least 2 different keys then, because too many active bits go to too many keys at the same time. The worst case of too many active bits is count 11111111111, when you may get the same code for pressing any keys in one row or even any keys on the whole keyboard. The purpose of multiplexing is to access one thing at a time, and the opposite of multiplexing is to access everything at the same time (which means everything either has its own pin (good) or mixes all together / does the same thing (bad) ).
  • VIRAND wrote: »
    Please take a look at these and watch what they do.

    I'm building it as a 12X4 right now. Should be finished tonight. My ICs arrive on Tuesday, and I'll integrate the 4040. Then, down to 5 wires.
    I appreciate you taking the time to share all this. It has helped expand my understanding of solid methods of communications.
    1629 x 1963 - 2M
  • VIRAND wrote: »
    Please take a look at these and watch what they do.

    Almost finished with the grid and the 4040 will be here in a few hours.
    3024 x 4032 - 938K
Sign In or Register to comment.