Could use some help with reverse engineering a typewriter PCB, for use with a Pro Micro and QMK.

Surpex

20 Sep 2019, 11:52

I bought an old typewriter at Goodwill and disassembled the main keyboard/pcb from the rest. It currently has two ribbon cables hanging off that at one point connected the keys to the logic portion of the machine.

Is it possible for me to trace the traces, and directly connect a pro micro to the already available headers, and program it as if I had hand wired the board to begin with?

Here is the keyboard, and it's traces. I've already gone about tracing the paths in Illustrator, so I can get an idea of how it's actually laid out. Anyone undertaken something like this? I'd prefer to not desolder/hand wire the board if I can help it.
Attachments
Typewriter keyboard
Typewriter keyboard
IMG_20190919_224251.jpg (4.97 MiB) Viewed 7432 times

Anakey

20 Sep 2019, 13:15

yes this is certainly possible as long as you have the matrix then you can indeed just wire up a teensy instead of the ribbon cables. might be worth confirming the matrix using a multimeter on continuity going between the ribbon cable and the switch pin but other then that you are good to go

Surpex

20 Sep 2019, 20:06

Anakey wrote:
20 Sep 2019, 13:15
yes this is certainly possible as long as you have the matrix then you can indeed just wire up a teensy instead of the ribbon cables. might be worth confirming the matrix using a multimeter on continuity going between the ribbon cable and the switch pin but other then that you are good to go
This is the first time I've undertaken a project of this caliber. Does it matter that the matrix doesn't seem to be "linear"? That is, each of the ribbon cable "inputs" seems to be associated with a random number or keys, as well as those keys being in random locations.

Findecanor

20 Sep 2019, 21:30

No, the electrical matrix does not have to follow the physical layout of the keyboard.
I think it also looks a bit more random than it really is, only because it is a one-sided circuit board and the designer had to be a bit clever with the routing to make everything fit with jumpers and all.

I wouldn't try to trace the traces, and instead rely more on the multimeter.

User avatar
swampangel

20 Sep 2019, 21:45

Surpex wrote:
20 Sep 2019, 20:06
This is the first time I've undertaken a project of this caliber. Does it matter that the matrix doesn't seem to be "linear"? That is, each of the ribbon cable "inputs" seems to be associated with a random number or keys, as well as those keys being in random locations.
The physical layout isn't too important.

Each key will end up being associated with 2 pins on the cable, and you'll have to work out which should be treated as rows, and which as columns.

Your matrix size will be (length of longest row) x (length of longest column), so on your teensy you'll need 1 pin for each row and each col. It doesn't matter that not every position in the matrix actually has a corresponding key.

Surpex

20 Sep 2019, 23:00

Findecanor wrote:
20 Sep 2019, 21:30
No, the electrical matrix does not have to follow the physical layout of the keyboard.
I think it also looks a bit more random than it really is, only because it is a one-sided circuit board and the designer had to be a bit clever with the routing to make everything fit with jumpers and all.

I wouldn't try to trace the traces, and instead rely more on the multimeter.
My main intention with tracing the traces was to get a better visual idea of where the pins were going. I'm definitely going to use a multimeter to double check all my work.

swampangel wrote:
20 Sep 2019, 21:45
Surpex wrote:
20 Sep 2019, 20:06
This is the first time I've undertaken a project of this caliber. Does it matter that the matrix doesn't seem to be "linear"? That is, each of the ribbon cable "inputs" seems to be associated with a random number or keys, as well as those keys being in random locations.
The physical layout isn't too important.

Each key will end up being associated with 2 pins on the cable, and you'll have to work out which should be treated as rows, and which as columns.

Your matrix size will be (length of longest row) x (length of longest column), so on your teensy you'll need 1 pin for each row and each col. It doesn't matter that not every position in the matrix actually has a corresponding key.
Oh, I see! Thanks for the info! Another question: I know lots of people use teensys, but I initially wanted to go with the Elite-C https://keeb.io/collections/frontpage/p ... atmega32u4 (pro micro replacement) that is sold on Keeb.io. Is there any reason why I shouldn't buy this one?

Anakey

20 Sep 2019, 23:32

if that controller has enough pins to cover both of the ribbon cables then you are ok. the reason to go with a Teensy++ is just the amount of pins that you have access to. if you are wireing a full sized board then often the matrix would have a greater number of pins that the smaller controller boards can't provide.

Surpex

21 Sep 2019, 09:26

Anakey wrote:
20 Sep 2019, 23:32
if that controller has enough pins to cover both of the ribbon cables then you are ok. the reason to go with a Teensy++ is just the amount of pins that you have access to. if you are wireing a full sized board then often the matrix would have a greater number of pins that the smaller controller boards can't provide.
So, I was going about using a multimeter to see what the pins connected to, and it seems that some of the pins cross? For example, the pin labeled "Y3" has continuity with the pins labeled "A2" and "A3". There are more crossovers with other pins. Does this effect anything for me? Do I misunderstand the way that this works?

Anakey

21 Sep 2019, 11:25

There may be traces like that because the pcb is not isolated to just the keyboard matrix. it may need the unnecessary traces to be cut for it to work correctly. You only need to wire upp the pins that correspond to the matrix itself

Surpex

21 Sep 2019, 18:47

I see. So I would just have to destroy the bridge between the two sets of traces? All should be well as long as each one of my keys is being represented SOMEWHERE along one of my pins?

User avatar
Muirium
µ

21 Sep 2019, 19:20

I would map out the matrix and see if any of those cross-connected pins even show up inside it. If they don’t, you can simply ignore them without any bad effect.

You definitely want to map the matrix so you know for sure how many rows and columns you need. If it’s a nice tightly optimised matrix, it will be harder to figure out but will use less pins, and could work with the little controller you want.

Surpex

23 Sep 2019, 09:42

I'm almost done mapping the matrix, and it seems that they don't cross connect anywhere, but instead it appears to be a way to consolidate many of the diode-sides of the pins into a single pin out. I'm not entirely sure how to deal with this, but I could just as easily chop the jumper that is between them. Also, it appears that both the shift keys, as well as the caps lock key, are on the same pin, but none of them have a diode between them? From what I understand, the diodes are to prevent ghost inputs right? Should I worry about this?

EDIT: It also appears that there are not diodes on the second level of the double action switches.

User avatar
Muirium
µ

23 Sep 2019, 09:58

Diodes are all about rollover, so you’re right to notice their absence on some keys. Hopefully, the designers were smart and chose these missing diodes wisely: perhaps you won’t be able to sense if *both* Shift keys are pressed together, for instance, or even tell them apart. That’s called masking (false negative) and is less worrying than ghosting (false positive) though still less than ideal.

The thing about rollover is it matters more in some contexts than others. For example: IBM Model Ms are all 2 key rollover, yet they’re well designed and I can use my SSK to do combos like Shift + Alt + Arrows just fine. What it can’t pick up is WASD pressed in certain combinations. It masks them. No false “ghost” keys, in my experience, but it will miss some when two others are already held down. IBM did not know what significance those keys were going to pick up in later years!

Findecanor

23 Sep 2019, 14:49

Surpex wrote:
21 Sep 2019, 09:26
For example, the pin labeled "Y3" has continuity with the pins labeled "A2" and "A3". There are more crossovers with other pins. Does this effect anything for me? Do I misunderstand the way that this works?
I guess that those could connect to the sliding switches on the left-hand side.
I would test continuity between Y3 and "C" under these switches, and between A2 and A3 to 65 to 70.
"C" is probably the "common" pin on each switch.
The fourth pin on each sliding switch is unconnected: so I think it would be either "C" (Common) or a third state, that is detected by one of the other states being not closed.
Surpex wrote:
23 Sep 2019, 09:42
Also, it appears that both the shift keys, as well as the caps lock key, are on the same pin, but none of them have a diode between them?
If my eyes don't deceive me, that pin is marked "+5" and also goes to the Caps Lock LED.
It is not unusual for modifier keys to be separate from the main matrix. Do check the other lines from them! The left Shift and Caps Lock seem to share only the +5.

Surpex

23 Sep 2019, 22:56

It looks like the "C" is indeed a common pin. Does this mean that the sliders on the side would count as one single "constant" pin, but with 9 different possible values? I'm not entirely sure how to conceptualize the sliders, honestly.

Also, when we say "map out the matrix," we do mean to write down which pins connect to which keys, right? I'm still very slightly confused about this part.

User avatar
Muirium
µ

23 Sep 2019, 23:02

Yes.

Take a look at this, to get the workflow:

viewtopic.php?p=450022#p450022

Ultimately, you want to reconstruct the keyboard's own logical grid of rows and columns, then populate the grid with all the keys. The exact process always varies a bit from PCB to PCB.

Here's a really gnarly one I worked out myself. And here's the final matrix diagram after all my work:

Image

Why are there two charts? Because in this case the matrix was a very different shape to the keyboard! That matrix is so weird I used a spreadsheet to translate it to a better shape I could more easily understand when programming my Teensy replacement controller. Don't be too surprised if you find your matrix is pretty weird, too. They often are, for PCB design reasons, and because they never intended them to be simple for us to hack!

Surpex

24 Sep 2019, 02:41

Oh wow! I thought I had a pretty good handle on how to go about this, but now I see I'm quite a ways off. I'm having trouble with really figuring out the matrix. I'll have to do some more research when I'm off work.

Another question, since you seem extremely knowledgeable about this kind of thing (thank you, by the way!): does it matter which pins I use as columns, and which as rows? It appears that they are sepersted in such a way that a pin will either be connected to diodes (which connect to the switch) OR they will be connected directly to the switch, but there is never any overlap. No pin has both diodes AND no diodes, it is exclusively one or the other. This seems important, and it seems to mimic the way a hand wired keyboard works. That is, the columns seem to lack diodes and the rows seem to include them.

Anakey

24 Sep 2019, 08:25

the diodes are designed to prevent ghosting see here wiki/Rollover,_blocking_and_ghosting so the matrix can only be scanned in the direction of the diode as its basically a one way system.
Last edited by Anakey on 24 Sep 2019, 10:22, edited 1 time in total.

User avatar
Muirium
µ

24 Sep 2019, 09:54

Indeed. Diode polarity is an issue to bear in mind when choosing your own new controller’s pin assignments. There’s a right way and a wrong way. Mind, you can swap them around in software for free so it’s not high risk. And I can’t honestly remember the right way around! If it doesn’t work: switch!

Soarer’s controller uses the terminology “strobe” and “sense” for its pins. I don’t know what Hasu or QMK does (I have used TMK for converters only so far, rather than controllers). But all this is easily configurable. And reconfigurable!

One thing to avoid: the Teensy’s LED pin. Don’t touch that one. You can wind up needing to destroy the LED / resistor or your own wiring. Silly bloody idea they had putting it on there.

Findecanor

24 Sep 2019, 10:50

In most keyboards, the strobe lines are pulled low in order, and the sense lines have pull-up resistors (to Vcc). Then a pressed key would be read as a 0 in the MCU's port register.
There might be keyboards that do it the other way around: pull the strobe lines high, use pull-down resistors (to GND) on sense lines and read a pressed key as a 1.
I think the sliding switches and Shift keys here are read in the latter way, because their common line is connected to +5.

The ATmega32u4 MCU that is in the Pro Micro and Teensy has internal pull-up resistors that only need to be enabled in firmware. If you would need pull-down resistors on the other hand, then those would have to be external.

Surpex

26 Sep 2019, 10:03

Hey, thanks for the help! Those two matrix images are really helping my brain comprehend this. I'm nearly through creating the actual matrix (as far as the intersections of rows/columns goes) but I seem to have hit another road block. It appears that two of my keys (in this case, the "16" key and the "18" key) both occupy the location at Y7xA1. It doesn't appear that the 16 key is actually actuated on those two pins though, since it is a double action key. Do I need to worry about this? It technically counts as two different keys, right?

User avatar
swampangel

26 Sep 2019, 14:15

What are keys 16 and 18 on the actual keyboard/keycaps? Wouldn't surprise me if it was something like "single backspace" and "repeat backspace"

Surpex

02 Oct 2019, 09:08

Hey, sorry about the absence, I've been on vacation. And it appears that the 16 and 18 keys aren't actually connected, it was simply an error on my part.

HOWEVER, it has proven that all of my double action keys (16, 32, 47, 60, 63) have their second action (hard press) aligned with the same combo of pins, along with key 62. 62 says "Repeat" on the key, so I'm lead to believe that it is supposed to be programmed as some kind of toggle? All of those keys connect with the pins A7xY7, so I can't really program them separately. Any suggestions on how to deal with this? Should (or could) I simply destroy the traces between the other double keys, thereby rendering the secondary action inoperable?

It also appears that I have 3 keys labeled as "35", that are all connected to the same pins: Ax+5. The keys are both of my shifts, and my caps lock. If each position on the matrix is associated with exactly one key, how the heck did the original engineers of this keyboard differentiate between shift and caps lock?
Nevermind, that part was wrong on my end.

Anakey

02 Oct 2019, 10:16

i think all that would have done is changed the repeat rate for those keys, so they would put out the same character just at a faster rate. You can cut the traces on the pcb for the second action and then wire the pins manually to the controller as a separate column that way you would be able to use the second activation as if it were a second switch.

Findecanor

02 Oct 2019, 10:42

I wouldn't cut any traces.

Are you sure there is nothing you'd want to use a secondary action for?
You could view the Repeat key as a Fn key, and put whatever you want on that layer, only that the first action will always be activated first when you press a double-action key, and deactivated when you release.
Normally, computer keyboard firmware would change the layer first and then accept new key presses on the new layer, but you could get the firmware modified to treat these keys differently.

I think that you could also modify an off-the-github firmware to just ignore the Repeat line's input when the first action is pressed.

Surpex

02 Oct 2019, 10:49

I would love to use them as an Fn key, but the problem is that they are all wired to the same location, so I (essentially) have 5 keys that would behave the same way on the second action, right?

Fkazim

02 Oct 2019, 11:09

Only thing you can do to make the keys register separately would be to cut the traces linking them I think. I'm quite new to this so I could be wrong.
Last edited by Fkazim on 02 Oct 2019, 12:30, edited 1 time in total.

Anakey

02 Oct 2019, 11:45

as all the double action switches are linked together it would mean only being able to have one action for all of them, which is why i said it would better to isolate them by cutting the traces and wiring them up separately, unless i am not understanding your proposal

Findecanor

02 Oct 2019, 12:24

Surpex wrote:
02 Oct 2019, 10:49
I would love to use them as an Fn key, but the problem is that they are all wired to the same location, so I (essentially) have 5 keys that would behave the same way on the second action, right?
I think you could theoretically get around that with clever firmware.
The keys provide the same input only on the second action - in addition to the first action, which is unique.
By detecting the combination of the first and second action, the controller could tell which key that is pressed to the bottom.

To make this proof from multiple key presses, the firmware would need to enforce that only one key would be able to trigger a second action at once. When one double-action key has triggered its second action, it would block second action on the others until it is released.
However, the Repeat key would have to be a Fn key to the second-action layer for this to work. (because of switch bounce there is a race condition if the key is pressed very hard: so you might not be able to tell which of the first and second actions on a key that triggered first.)

Now, to get that firmware written... Perhaps I could help you with that if you are not a programmer yourself.

Surpex

09 Oct 2019, 10:13

Findecanor wrote:
02 Oct 2019, 12:24
Now, to get that firmware written... Perhaps I could help you with that if you are not a programmer yourself.
Well, I've gotten the matrix completely finished, and I've gotten my hands on a Proton C controller! Now for the very hard part. I've been reading through all the QMK documentation, but it might be a bit beyond my extremely modest understanding of programming. I've read through the newbs guide, and the handwire guide, but I still don't know where to start on my firmware. Apparently I can't use the new_keyboard.sh script since ARM based controllers aren't supported through it? I'm honestly not sure how to proceed here, and I would love some of your programming knowledge.

Also, I just want to get a basic firmware up and running that will give me a proof of concept here. I'm going to worry about the double action keys much later on. If you could point me in the direction of a more thorough, idiot proof guide that starts from like step 0 of creating a firmware for a handwired build, based around a Proton C, I would SUPER appreciate it. I've bothered the guys on the QMK discord server too much already i think.

Post Reply

Return to “Keyboards”