Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I use 3-to-8 demultiplexer to implement 20+8 layout with 24 pins? #1

Open
thesmallcreeper opened this issue May 20, 2023 · 4 comments

Comments

@thesmallcreeper
Copy link

First of all, great project! I found an old model M 122-keys and I want to restore it 😄

As you mention in README.md, 26 GPIO pins are not enough for driving 20+8 pins.
I looked at .cpp MatrixScanner::scan() and, as far as I understand, you set one column high and the other 7 discharged and floating.

void MatrixScanner::scan() {
uint64_t now;
bool temp;
// loop through each send pin and then check each read pin
for (uint8_t i = 0; i < NUM_ACROSS; i++) {
gpio_set_dir(across[i], GPIO_OUT);
gpio_put(across[i], 1);
sleep_us(30); // delay for changes to GPIO to settle
uint32_t readings = gpio_get_all();
setpininput(across[i]); // so that the send pin floats and won't cause a bus conflict

Can I drive the 8 columns with 4 GPIO + multiplexer? 3 GPIO pins select one of 2^3=8 pins and 1 GPIO drives the selected column. What you think? Can I have your opinion? 😄

@guruthree
Copy link
Owner

Always great to see more old stuff being re-used - I hope your 122 restoration goes well!

I looked at .cpp MatrixScanner::scan() and, as far as I understand, you set one column high and the other 7 discharged and floating.

Yes that's correct.

I've not done much with multiplexers, which is why in favour of keeping the circuit simple I went with a PGA2040. That aside, I think a multiplexer on the 8 output pins should work as long as the pins can still remain floating when not in use. My understanding is that this would be the case with a CD4051BE, which would give 8 outputs for 4, letting the circuit use 24 pins and fit on the Pico. The other alternative I think would be an GPIO expander for some of the 20 input pins, something like a MCP23017, giving 16 inputs for 2. I think the CD4051BE would probably be the more elegant of the two solutions, letting the code still use gpio_get_all() and having a faster response time than the MCP23017.

@thesmallcreeper
Copy link
Author

@guruthree Thank you for your reply!
Yes, looking at specs CD4051BE should do the trick.

I will keep you update 😄

@thesmallcreeper
Copy link
Author

Hey! Typing you from my Model M, using an Raspberry Pi Pico + your repo with some changes.
I will create an Pull Request soon to add support for using an CD4051BE.
Thank you so much for the time you put in for this script! Also thank you for adding F15+0 hotkey for getting in programming mode.

Some words about my hardware implementation.
I used a classic Pico and a CD4051BE. I got the membrane connector by force from original circuit and soldered them on an solder-able breadboard from behind the holes. Not great idea, because connectors wires where short, after breaking them, and didn't make good contact. I resorted at putting wires directly to some of connector pins. The result is kinda fragile but it works! For how long...? I don't know :P
CD4051BE have no problem working at 3.3V.

@guruthree
Copy link
Owner

Fantastic it's working! If the connectors go I believe you can get replacement FFC connectors from Te with part numbers 5-520315-8 and 7-520355-0. I looked into doing a PCB but ultimately decided to solder onto the back of the existing one myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants