Where to begin

tedfs3

06 Oct 2018, 21:32

Not really sure if this is the correct spot for this, seems like the best fit between the choices to post in.

100% beginner here. My rabbit hole all started with wanting to find a decent, left handed Russian mechanical keyboard to learn the language with. Fast forward a month later and it pretty much seems like I'll need to design what I want but am very overwhelmed with the amount of data to sift through.

What I want to do seems simple enough. Make a left handed keyboard, even though I'm not left handed. Playing around with the KLE is straight forward. Everything needed to be done after that is a huge blur with information overload searching here. Simply trying to understand how to make the matrix is quite fuzzy. Then there's designing the plate, then the PCB. I can figure out KiCad easy enough, already designed a small project on it for holding Hakko solder tips. No traces required there.

Any pointers on which threads to read up on in what order ? I see plenty of 4 x 4 matrix or 60% ideas out there but I'm going with a full ANSI 104 that will have to be programmed for a custom layout. Trying to figure out how the 104 matrix would need to go isn't quite clear to me.

Seems simple enough but, as already stated, there's so much information to look at that it's overwhelming.
Design the layout
Design the Plate ( The switches I intend to use are plate mount )
Design the Matrix ( Best method and how ? )
Design the PCB ( Learning curve but once the matrix is set, this will be easier )

Haven't settled on the design below but only get to work on it a little bit during the week, so I get to step away and come back with fresh eyes on the weekends. This is pretty close but I do want caps lock and num lock LED indicators since I'm not a proficient typist by any means.

Just looking for some guidance, not a handout. Just feel a bit overwhelmed with where to start and what order would be best to do things in.
Attachments
Blank_Example.jpg
Blank_Example.jpg (161.94 KiB) Viewed 6654 times

User avatar
PlacaFromHell

07 Oct 2018, 00:37

I'll help you as much as I can, but before go to the moon you should make some experimental easier keyboards.

Design the layout

Dude, you already have it :lol:

Design the Plate

First at all you need to tell us what kind of swtiches are you using. Nothing more than see what kind of holes do you need to mount them and put the stabilizers, also the distance requiered between them. I can search some info if you show me what are you looking for.
I also found this if you are interested https://geekhack.org/index.php?topic=47744.0
Design the Matrix

They are two tools for noobs like us, you are already familiarized with one:

http://www.keyboard-layout-editor.com/

And the other one is this:

https://kbfirmware.com/

Just paste your layout in the second page and build the matrix if you can. If not, tell me and I'll explain you about how.
When you have your firmware already done, just load it into a Teensy ++
Scares a bit but it's simple, believe me.

Design the PCB

This goes hand in hand with the last two points. You need to have the matrix already done and see where are located the pins of the switches. Are you familiarized with PCB Wizard, Eagle or some other program like that?

User avatar
PlacaFromHell

07 Oct 2018, 00:44

.
Last edited by PlacaFromHell on 07 Oct 2018, 01:28, edited 1 time in total.

tedfs3

07 Oct 2018, 01:22

Switches are NovelKeys x Kailh BOX Thick Clicks Navy. Looking at the data sheet it seems they need square holes but I honestly have no idea how they are supposed to "mount" to the plate with the square hole. It appears they press fit between the small tabs on the body ?

I am familiar with KiCad as I've used that before for a totally different project for a simple Hakko solder tip holder. As stated, no traces required for that but was just an exercise to learn KiCad. Relearning 5.0 release now.

The PCB aspect doesn't phase me as much as figuring out the matrix right now. The way the keys angle in a ANSI 104 kind of throw me off as to how they should be connected to the matrix. Looking at matt3o's BrownFox wiring kind of gives me an idea but it's still unclear how to choose the right paths for the columns.

I grew up with all the old hardware and really wish I would have kept some of it now. Being able to reverse engineer or at least look at a design might help.
Attachments
Footprints.jpg
Footprints.jpg (264.86 KiB) Viewed 6609 times

User avatar
PlacaFromHell

07 Oct 2018, 01:36

I did a duplicated message by accident, sorry.
Most switches, if not all, clip in the plate by press.
If I remember well Kbfirmware gives you a sample matrix for your keyboard, if you are not doing something strange, should work fine. Do you know how the matrix itself works? It's a very important aspect before throw yourself into the pool if you want to use a different one. What do you mean with "the right paths"?

Image

tedfs3

07 Oct 2018, 02:08

I am not entirely sure how the matrix works but have a vague idea. Vague meaning I know when a switch or combination of switches is pressed, that results in a unique series of closed contact points being sent to the controller. Other then that, I'm lost.

My matrix would be slightly mirrored but not exactly. As you can see the numpad is on the left and is mirrored to reflect what I thought would be proper. There is a proper way to type and I'm not there yet but learning. This seemed like the right choice. This also leaves room at the upper left for the num lock and caps lock indicators I'd like to include.

The idea is to make this a left handed board, work the bugs out and learn how it's done properly. After that I'd like to do a full on Russian keyboard, but with some changes that I need to understand in order to program properly. An example would be replacing № with @. There's no way I'd be able to use a keyboard without the @ symbol in this day and age with email lol. Can't see a time how the № symbol is relevant yet in the language but the @ is a must.

Little details in symbol programming, key spacing and correct footprint placement on the PCB will also need to be learned. The default unit seems to be 19mm from center key to center key. I'll need to figure out the proper placement in KiCad and go from there. Maybe you are correct on starting out with something more simple but I honestly have no use for a 4 x 4 pad at this point. Might be a good way to learn with less information though but still wouldn't get me to the goal of a full 104 layout.

ETA: By Correct Paths I mean the correct way to connect the columns in the matrix. The ANSI 104 is angled the further in you get on each side. Making the choices unclear for me as to what switches are connected to each other.
Attachments
LH-Example.png
LH-Example.png (110.18 KiB) Viewed 6594 times

User avatar
PlacaFromHell

07 Oct 2018, 02:27

When you press an ohmic (contact) switch, one column and one row close a circuit between two pins of the IC or microcontroller. Every key is a unique combination of row + column and hence a shortcut between two pins.
Let's see a quick example, first I have this numpad:

Image

And his matrix:

Image

For example, * is the same as row 0 + column 2. Which is the same as B0 + B7.

Image

You only need to be sure that every key is a unique combination. The page builds the code for you, nothing more easy than that.

tedfs3

07 Oct 2018, 02:39

I guess that's where the confusion starts to set in. Where are B0 and B7 coming from, the pins on the controller ?

User avatar
PlacaFromHell

07 Oct 2018, 02:43

Yeah, they are physical pins of the controller, already defined. This will help you:

Image

tedfs3

07 Oct 2018, 02:54

Okay, so the web page is showing the corresponding layout with how it would match up to the pins on the controller ? That would make sense but it's little details like that that get lost when trying to search and getting a bazillion hits with the word Matrix in them.

That is a huge help if I understand it correctly.

Thank You !

User avatar
PlacaFromHell

07 Oct 2018, 03:16

You're right, when your entire layout is done, just flash the controller and connect the physical traces to the corresponding physical pins.
They are much more ways to "do" a keyboard, but this one is the easiest in my opinion.

tedfs3

07 Oct 2018, 03:58

Okay, so I'm clear.. In the example pic below, * on the left handed numpad would be
B2 + C0 on the board ( Row 2 + Column 1 ) ?
Attachments
LH_Matrix_Builder.jpg
LH_Matrix_Builder.jpg (382.08 KiB) Viewed 6548 times

User avatar
PlacaFromHell

07 Oct 2018, 04:01

I need to see what pins are you using first.

Image

tedfs3

07 Oct 2018, 04:03

I chose the AT90USB 1286, Teensy ++ 2.0

User avatar
PlacaFromHell

07 Oct 2018, 04:23

But I need to see what pins are you using for each row and column

tedfs3

07 Oct 2018, 04:42

This is where I'm lost. I had no idea you could choose the pins yourself ? Thought you had to pick pins in some sort of order ?

This is what makes it so confusing...

What would you put it for the layout below using the Teensy ++ 2 ? That's really the only way I'm going to understand this I guess.
Attachments
LH-Example.png
LH-Example.png (110.18 KiB) Viewed 6530 times

User avatar
PlacaFromHell

07 Oct 2018, 07:00

Just use the ones that the page gives to you. It's the safest way because these microcontrollers sometimes have oscilators or pins with weird outputs.
I couldn't tell you what combination was the key in the picture because I don't know what pins you have assigned by default (but also you can choose your pins if you want). When you are wiring your keyobard and you want to know what pin is what, you need to see the "PINS" tab. Pins are not necessary related with the row/column number and all of them work by the same way in two groups, which are rows and columns.
This is not related to the keyboard firmware, but will help you to understand some points. Every letter in a pin name is just a port, and the number is a bit from this port. For example, B5 is the bit Nº5 from port B. In the PIC era you were forced to use the entire port as input or output, if you were using a pin from the port B to turn on a LED, you were not able to use any other pin from this port as an entry. Fortunately (and not), in our era, in most microcontrollers you can independently define each pin as an input or as an output. For example, if you use a PIC for a keyboard (which I never seen before), you will need separate ports for columns and rows, because one sends current and the other receives it, I don't remember which one does what, but just think like "male" and "female" pins. This is why you will find rows and columns with the same letter and it will turn confusing, but do not panic, it's normal. Just be sure you don't have any pin repeating in somewhere. And also this explains why you can't connect two columns or two rows.

User avatar
Muirium
µ

07 Oct 2018, 12:31

I don’t think “pin gender” is a thing. Not when it comes to pin letters / ports. I have made keyboards with Soarer’s Controller before with success, running strobes and senses (his preferred terminology for rows vs. columns) without paying ports any attention. For example, I built this matrix and it works fine:

Code: Select all

matrix
	scanrate 1
	debounce 5
	blocking 0

	sense			PF7			PB6		PB5		PB4			PD7			PC7		PC6			PD3			PD2			PD1		PD0			PB7			PB3			PB2			PB1				PB0
	strobe	PF0		esc			1		2		3			4			5		6			7			8			9		0			minus		equal		back_quote	system_power	UNASSIGNED
	strobe	PF1		tab			q		w		e			r			t		y			u			i			o		p			left_brace	right_brace	UNASSIGNED	backspace		UNASSIGNED
	strobe	PF4		fn1			a		s		d			f			g		h			j			k			l		semicolon	quote		UNASSIGNED	enter		UNASSIGNED		UNASSIGNED
	strobe	PF5		lshift		z		x		c			v			b		n			m			comma		period	slash		UNASSIGNED	rshift		UNASSIGNED	FN2				UNASSIGNED
	strobe	PF6		lctrl		lalt	lgui	UNASSIGNED	UNASSIGNED	space	UNASSIGNED	UNASSIGNED	UNASSIGNED	rgui	ralt		UNASSIGNED	rctrl		UNASSIGNED	pad_enter		UNASSIGNED
end
What does matter: make sure every row and every column gets a unique, dedicated pin.
What doesn’t matter: the name of each of those pins. They are essentially arbitrary.

Oh and avoid that pesky LED pin. I’ve made that mistake more than once!

Findecanor

07 Oct 2018, 13:35

tedfs3 wrote: Switches are NovelKeys x Kailh BOX Thick Clicks Navy. Looking at the data sheet it seems they need square holes but I honestly have no idea how they are supposed to "mount" to the plate with the square hole. It appears they press fit between the small tabs on the body ?
Don't use BOX switches! The cruciform shapes are too thick and have been shown to break keycaps' stems! There are several threads about this.

Yes, the switches are supposed to clip into the plate with the small tabs on the north and south sides of the switch. These are (supposed to be) are on plastic springs that are part of the switch housing.
The use of the clips require the plate to be 1.5 mm thick. If it is too thick, they won't work and it will only be a press-fit (the tabs will be pressed in all the time).
tedfs3 wrote: The default unit seems to be 19mm from center key to center key.
Not quite. The unit is 3/4 of an inch, where an inch is 25.4 mm. That makes one key unit 19.05 mm.
It does not seem like much but when you have more switches and keys that are multiple units, it adds up.

Do use a scheme for labelling the logical rows and columns in the schematic. I suggest R0,R1,R2 ... and C0,C1,C2 ...
The convention is that each "column" is strobed and that each "row" is sensed.
The microcontroller strobes each column one at a time in series by shorting its pin to ground.
Of course, these are logical rows and columns, and your logical matrix does not have to correspond to your physical layout but it could make it easier to reason about and lay out.

You connect each switch in series with a diode. Which side of the switch the diode is on does not matter but it has to be "pointed" towards the column.
Diodes allow you to have n-key rollover. (This is so taken for granted in the community that people rarely mention it, but it wasn't already, so I do it just in case)
Muirium wrote: I don’t think “pin gender” is a thing. Not when it comes to pin letters / ports.
The pins on the AVR microcontrollers are capable of both input and output. There are some other microcontrollers where some pins are dedicated to input and others to output but because we don't use such a microcontroller that is not relevant. :)
I do think it would look clean if you would use different ports on the microcontroller for rows and columns.

However, a few pins on the microcontroller are capable of PWM output whereas most pins are not. You want to assign a PWM pin to an indicator LED instead of the matrix, if you have LEDs.
I am not sure but I think all the common free firmwares require each LED to be on a PWM pin. Some firmware may even have hardcoded which pin goes to which LED: you would have to check that.

tedfs3

07 Oct 2018, 14:45

Thank you for the explanation. I was under the impression you had to know what pins to use and had to manually assign them on the Pins page. That's what I get for over thinking.

I did read the thread on Box switches but have already bought them and kind of like the feel and sound the Navy's have. I won't be switching out caps on these, as the ones that will go on there will stay on. Possibly a little shaving with a razor blade and a small dab of lube would prevent the cracking but I'm not too concerned about it as the caps won't be very expensive and won't be taken off multiple times.

Looks like I'll have to figure out how to program the Russian as all the Cyrillic letters and words just say NO on the Keymap using the Keyboard Firmware Builder site.

Findecanor

07 Oct 2018, 17:47

The keyboard's firmware does not know what is printed on the keys, they work with a code for each physical key. They also don't care about the state of the Shift and Ctrl keys, or even the locking key. The keyboard just reports the keys to the host computer. The host computer maps key-codes to symbols, and then it tells the keyboard which LEDs to light up.

Keyboard firmwares and tools tend to use the corresponding US-ANSI (English) names of keys, so if you use another layout than that, you will have to keep track of which code in US-ANSI corresponds to which code in your layout.

User avatar
PlacaFromHell

07 Oct 2018, 18:18

Findecanor wrote:
tedfs3 wrote: Switches are NovelKeys x Kailh BOX Thick Clicks Navy. Looking at the data sheet it seems they need square holes but I honestly have no idea how they are supposed to "mount" to the plate with the square hole. It appears they press fit between the small tabs on the body ?
Don't use BOX switches! The cruciform shapes are too thick and have been shown to break keycaps' stems! There are several threads about this.

Yes, the switches are supposed to clip into the plate with the small tabs on the north and south sides of the switch. These are (supposed to be) are on plastic springs that are part of the switch housing.
The use of the clips require the plate to be 1.5 mm thick. If it is too thick, they won't work and it will only be a press-fit (the tabs will be pressed in all the time).
tedfs3 wrote: The default unit seems to be 19mm from center key to center key.
Not quite. The unit is 3/4 of an inch, where an inch is 25.4 mm. That makes one key unit 19.05 mm.
It does not seem like much but when you have more switches and keys that are multiple units, it adds up.

Do use a scheme for labelling the logical rows and columns in the schematic. I suggest R0,R1,R2 ... and C0,C1,C2 ...
The convention is that each "column" is strobed and that each "row" is sensed.
The microcontroller strobes each column one at a time in series by shorting its pin to ground.
Of course, these are logical rows and columns, and your logical matrix does not have to correspond to your physical layout but it could make it easier to reason about and lay out.

You connect each switch in series with a diode. Which side of the switch the diode is on does not matter but it has to be "pointed" towards the column.
Diodes allow you to have n-key rollover. (This is so taken for granted in the community that people rarely mention it, but it wasn't already, so I do it just in case)
Muirium wrote: I don’t think “pin gender” is a thing. Not when it comes to pin letters / ports.
The pins on the AVR microcontrollers are capable of both input and output. There are some other microcontrollers where some pins are dedicated to input and others to output but because we don't use such a microcontroller that is not relevant. :)
I do think it would look clean if you would use different ports on the microcontroller for rows and columns.

However, a few pins on the microcontroller are capable of PWM output whereas most pins are not. You want to assign a PWM pin to an indicator LED instead of the matrix, if you have LEDs.
I am not sure but I think all the common free firmwares require each LED to be on a PWM pin. Some firmware may even have hardcoded which pin goes to which LED: you would have to check that.
Well, I didn't explained myself very well. First, in a keyboard controller you will never use input and output in the same pin. Also, in the hypotethical case you first have to define the pin as the contrary state, it will never work like an input and an output at the same time.
I was just trying to make it easier but I turned it more confusing. Better leave this to native english speakers.

tedfs3

07 Oct 2018, 20:03

PlacaFromHell wrote: Well, I didn't explained myself very well. First, in a keyboard controller you will never use input and output in the same pin. Also, in the hypotethical case you first have to define the pin as the contrary state, it will never work like an input and an output at the same time.
I was just trying to make it easier but I turned it more confusing. Better leave this to native english speakers.
I understood what you were saying and really appreciate your helping me to understand all this.

User avatar
Muirium
µ

07 Oct 2018, 20:33

Indeed. And I’m Scottish, so things can always come out a bit “direct” even when unintended! Placa knows this stuff better than me on the technical level. Hopefully my simplification wasn’t over simplification! Anyway, pretty sure you’ll get to your keyboard in the end.

Now: the Russian part. Here’s the trick: keyboards aren’t language specific. The caps may look that way, but the codes they send to the computer are always the same, as I understand it. What you’ll need to make the Russian leap is select a Russian keyboard input mode on your computer. You’ll find that each key has a new equivalent. From there, you can reverse engineer your desired alterations.

There are no keyboard specific key codes for the Russian characters you seek. You task is to switch into Russian layout mode and find out what aliases you need to get there.

spongebob1981

08 Oct 2018, 16:01

Muirium wrote: I don’t think “pin gender” is a thing. Not when it comes to pin letters / ports. I have made keyboards with Soarer’s Controller before with success, running strobes and senses (his preferred terminology for rows vs. columns) without paying ports any attention.(...)
It shouldn't be a thing, but sometimes, it could.

I tried to flash QMK into a Teensy 3.2 but rushed to solder the diodes before testing the software. Of course, as you are now suspecting, I had the diodes the other way around. I could not make for the life of me make it work by switching them in software, and had to run to other software to allow me to flash the board without resoldering.
I suspect there's always a way, but YMMV and mine did.

WiCK

16 Oct 2018, 11:59

I just wanted to let you guys know how helpful this thread has been - I am also trying to put together a custom layout keyboard, and this has definitely answered some of my questions.
KB Layout.JPG
KB Layout.JPG (142.86 KiB) Viewed 6297 times
Do you all have any good resources for beginning with KiCad? I am very lost when it comes to the software portion of PCB design.

tedfs3

16 Oct 2018, 23:03

WiCK wrote: I just wanted to let you guys know how helpful this thread has been - I am also trying to put together a custom layout keyboard, and this has definitely answered some of my questions.
KB Layout.JPG
Do you all have any good resources for beginning with KiCad? I am very lost when it comes to the software portion of PCB design.
There's some good stuff on Youtube to get you familiar with KiCad. The one below was done with an older version of KiCad 4.0. They are currently on version 5. If you want to follow along with the playlist, I'd recommend downloading the older 4.0 version of KiCad so there won't be any confusion trying to learn the software. Once you are comfortable enough, I'd download the 5.0.1 release and keep an eye out for 5.0.2 soon.

tedfs3

17 Oct 2018, 00:42

What I'm wondering now is where to find information on spacing for proper placement of the footprints on the PCB to make sure the keys line up properly and don't touch each other.

I'd like the pcb footprint placements to match the hole placements of the plate that swillkb spits out.

tedfs3

21 Oct 2018, 00:13

Can anyone explain how the status LEDs are connected and assigned ? It's probably simple but I'm just not understanding what to select in the Keyboard Firmware Builder.

The first picture is a potential layout. The second picture is the wiring generated by Firmware builder. Third picture is the key map and the LEDs in question are highlighted. The builder seems to be treating these as keys with wiring and KC codes. What's confusing to me is where is the option to indicate they are LEDs and not keys in the builder ? Or am I just missing something altogether ?
Key-Map3.jpg
Key-Map3.jpg (404.24 KiB) Viewed 6225 times
Key-Map2.jpg
Key-Map2.jpg (265.17 KiB) Viewed 6225 times
Key-Map.jpg
Key-Map.jpg (200.02 KiB) Viewed 6225 times

Anakey

21 Oct 2018, 13:19

you do not need to include LEDS in the layout editor, you can set LED pins seperately at the bottom of the pins page

Post Reply

Return to “Workshop”