Author Topic: [advice needed] making kb from ground up  (Read 4121 times)

0 Members and 1 Guest are viewing this topic.

Offline alexofthewest

  • Thread Starter
  • Posts: 59
[advice needed] making kb from ground up
« on: Mon, 20 April 2015, 22:10:33 »
So I have an idea for a 2 part split 60% keyboard that I would like to put into action, but long before that I have some important very basic questions.

the basics
-on a standard keyboard with a pcb, what do you need to add to it besides switches, a microcontroller,and a case?
-what are diodes (and where do they go?)?
-what are resisters (and where do they go?)?

seperately from that
I have been told that keyboards do not need pcbs and can be hand wired, is this extremely difficult or is it just time consuming or really costly?  Where can I learn more about this?




Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: [advice needed] making kb from ground up
« Reply #1 on: Tue, 21 April 2015, 03:10:35 »
So I have an idea for a 2 part split 60% keyboard that I would like to put into action, but long before that I have some important very basic questions.

the basics
-on a standard keyboard with a pcb, what do you need to add to it besides switches, a microcontroller,and a case?
For a first build I would go with a Teensy so you don't have to do the SMD soldering required for the controller.  If you don't (or if you want the controller located other than at the top somewhere) you'll also need a USB mini or micro socket to go on the edge.  As you're doing a two part you will also need some way of connecting the halves, and probably an IO expander in one of them so you don't have to run as many wires between the two.

Quote
-what are diodes (and where do they go?)?

Diodes are one way resistors.  They go between each switch and the controller so the controller doesn't get confused what keys you're pressing.  If you only type one key at a time you don't actually need them, but they are cheap so use them.

Quote

-what are resisters (and where do they go?)?

Resistors on a keyboard are only used around the controller or to adjust the current going to LEDs - worry about the keys first, you can add LEDs later.
Quote
seperately from that
I have been told that keyboards do not need pcbs and can be hand wired, is this extremely difficult or is it just time consuming or really costly?  Where can I learn more about this?
PCBs are just wires fixed to a board for convenience, so not needed.  If you want to handwire you will need a plate which is a holy sheet of metal or acrylic to hold the switches.

Hand wiring is not difficult or expensive but it is time consuming especially if you're worried about it looking nice.  Basically you connect each switch to the ones next to it and above/below - pictures say it all so here's a very nicely done handwire.  Note the black vertical wires are insulated so they don't short with the exposed diode legs. 

Before you do this you need to think about firmware as the diodes need to be in the right direction.
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline tjweir

  • * Exquisite Elder
  • Posts: 1039
  • Location: Toronto
Re: [advice needed] making kb from ground up
« Reply #2 on: Tue, 21 April 2015, 08:46:23 »

Offline alexofthewest

  • Thread Starter
  • Posts: 59
Re: [advice needed] making kb from ground up
« Reply #3 on: Tue, 21 April 2015, 21:07:50 »
First I want to say thanks a ton for such informative replies, I really appreciate it! (and thank you for bearing with my extremely new and limited knowledge on this).

the controller:
-you reccomended a teensy because it does not require smd soldering.
-what is SMD soldering compared to regular soldering?
-What seperates one controller from the next or is teensy pretty much the gold standard?

Wires:
-So what I got from my understanding of those articles you 2 posted where that diodes are parts of the wires that connect to the left peg of every switch?
-you also mentioned the right direction of diodes, do they have to point a certain way?
-so resistors are just for leds? If i dont use leds at all I wont need to bother with them whatever they are?

keyboard bridge
can you elaborate on what an io expander is? I havnt fully thought out how i was planning on connecting the 2 halves yet.

firmware
-is this available to acquire easily or do I have to manually code the thing myself?

The PLATE and the case...
-I suspect this will be the hardest part...
-FIRSTLY--> how do people typicly design layouts for this, is there a software program that allows for this easily?
-secondly... I dont at all know the process for creating holed plates and cases, but I imagine it requires very very expensive machinery?

Offline technomancy

  • Posts: 134
Re: [advice needed] making kb from ground up
« Reply #4 on: Wed, 22 April 2015, 02:12:24 »
-what is SMD soldering compared to regular soldering?
-What seperates one controller from the next or is teensy pretty much the gold standard?

SMT (or SMD) means Surface Mount Technology/Device. Basically any soldering with pins that are super tiny and really close together. As a beginner you want to stick with thru-hole soldering, which uses larger pins. SMT is typically done by robots, which makes it more economical at large scale. All mechanical switches are through-hole anyway, because you can't miniaturize keyboard switches.

The Teensy is the most popular controller for keyboards, but any dev board with an AtMega32u4 chip will work just as well, as long as there are enough pins. I use the A-Star Micro for mine: https://www.pololu.com/product/3101 But you might need more pins; I only have 4 rows and 11 columns.

Wires:
-So what I got from my understanding of those articles you posted where that diodes are parts of the wires that connect to the left peg of every switch?
-you also mentioned the right direction of diodes, do they have to point a certain way?
-so resistors are just for leds? If i dont use leds at all I wont need to bother with them whatever they are?

Diodes keep the flow of current going from high to low pins on the controller. Basically all your input pins are high normally, and when a switch is pressed an electrical connection is created from the input pins to the row pins, which are brought low when that row is activated. You'll definitely want to read up on how the matrix scanning process works, since this is the whole foundation of the keyboard's operation. I have an article that describes the process from the perspective of the firmware at http://atreus.technomancy.us/firmware

When you're putting together your keyboard, first just wire together one key in each row and one key in each column when you're starting out. You might even test it after soldering one or two switches in. That way if you get the diodes in backwards it's only a few you need to fix instead of the whole thing.

You can leave out diodes (early keyboards had none) but you would get spurious key presses when you have two keys in different rows and columns pressed at the same time. This is called Ghosting. It's a bit subtle to understand how it happens but you don't really need to grok it completely: http://www.tomshardware.com/reviews/mechanical-switch-keyboard,2955-6.html

Yeah, putting in LEDs is probably not a great idea for your first design. Not worth the hassle.

can you elaborate on what an io expander is? I havnt fully thought out how i was planning on connecting the 2 halves yet.

An IO expander is a chip that has a bunch of IO pins and communicates to your main controller using a protocol like I2C which only takes a handful of pins. The scan rate is slower, (probably still below the threshold of human perception) but it gives you a lot of flexibility. The main downside is it introduces more complexity in the firmware. However, if you use the same one as the Ergodox, you might be able to just re-use the Ergodox firmware.

If you don't have an IO expander, you can run wires across from the side with a controller to the one without, but you need one wire per row plus one wire per column, so it can get awkward.

The simplest way to go is to just put a separate controller in each hand and just treat them as independent keyboards. The only downside here is that on Mac OS X, you can't press shift on one hand and have it affect key presses on the other hand. (Other OSes work fine.)

-is firmware available to acquire easily or do I have to manually code the thing myself?

As long as you use an AtMega32u4 chip, you can use the TMK firmware, which is very featureful. You just have to teach it what pins you've got connected to which rows/columns.

  https://github.com/tmk/tmk_keyboard/

If you know C and have a solid understanding of the keyboard matrix, writing your own is not a big deal. It can be done in a weekend with about 100 lines of code. But it's nice to be able to use a pre-existing firmware so you can type on your keyboard as soon as it's constructed and not have to wait to finish your own firmware.

-FIRSTLY--> how do people typicly design layouts for this, is there a software program that allows for this easily?
-secondly... I dont at all know the process for creating holed plates and cases, but I imagine it requires very very expensive machinery?

I did it using Inkscape, which is a vector illustration program that's pretty easy to learn. Take a look at some existing cases from OSS keyboards (Ergodox and my own Atreus, for instance) and copy/paste from there to tweak to your liking. (Of course if your design is a derivative of an existing OSS design, you need to honor the licensing it uses.) Typically you'll have at least three layers: a switch plate, a spacer, and a bottom plate to keep dust out.

  http://p.hagelb.org/case.svg
  https://github.com/bishboria/ErgoDox/tree/master/ErgoDox%20Acrylic%20Case/ErgoDOX%20Acrylic%20Case%20-%20Designed%20by%20Litster/Standard/Left

If you live in a major US city, you can take your design into a laser cutting shop and have it cut on wood or acrylic. If you want it cut in steel or aluminum you'll have to look a bit harder to find shops that will make that cut, and it will cost a lot more and be way heavier, but it'll look pretty cool.

Offline tjweir

  • * Exquisite Elder
  • Posts: 1039
  • Location: Toronto
Re: [advice needed] making kb from ground up
« Reply #5 on: Wed, 22 April 2015, 09:03:52 »
Really great post @technomancy!

Offline vvp

  • Posts: 887
Re: [advice needed] making kb from ground up
« Reply #6 on: Wed, 22 April 2015, 10:48:43 »
A nice article about different ways how to scan keyboard matrix:
http://www.openmusiclabs.com/learning/digital/input-matrix-scanning/
There are much more options than IO Expander or Single Multiplexed mentioned before.

Offline Rakanishu2199

  • Posts: 28
Re: [advice needed] making kb from ground up
« Reply #7 on: Wed, 22 April 2015, 15:51:47 »
Great piece of advice, will be very useful for me, thanks a lot.  :))

Offline alexofthewest

  • Thread Starter
  • Posts: 59
Re: [advice needed] making kb from ground up
« Reply #8 on: Thu, 23 April 2015, 15:18:49 »
What an incredibly informative bunch of replies, thanks guys! So what Im getting so far is this, microntrollers only have a few pins so matrix scanning is used to connect multiple keys to fewer pins which is done through firmware coding. (I have never done any coding at all. How complicated is it to learn this or do you reccomend  just using someone elses firmware entirely?)  I see that IO expanders are 1 way of connecting two sides but there are apparently other ways of doing it. ( I looked at the chart but I didnt really understand what those different terms were).

Programming Firmware and designing the exterior seem to be the only two challenging parts of this, though they do seem difficult.

I am really excited about trying to make a prototype frame. So the most efficient method is creating a desgin through an art program (though I have also heard of cad, but I believe cad programs are very expensive) and then giving it to a company that does lazer cutting to cut the frame and case out of a solid piece of acrylic plastic?

-I dont really inteand this but If I wanted to mass produce something like this, what would the method being for this? still using a service for lazer cutting or does a machine like that cost a lot?  Or are there ways of just making a mold and mass producing it more cheaply?

*I looked at your atreus you posted and I never knew such a beautiful board existed till just now! I feel foolish that I just ordered a poker3 when I would much rather have one of those... Anyways, this made me wonder something else: In a compact portable keyboard how hard would it be to implement BLE technology into it if I am building it from the ground up? Would I need a different microcontroller and if so does that mean I have to create my own new unique firmware rather than using someone elses?

Offline shaymdev

  • Posts: 56
  • Location: SLC, UT
Re: [advice needed] making kb from ground up
« Reply #9 on: Thu, 23 April 2015, 15:44:44 »
I am really excited about trying to make a prototype frame. So the most efficient method is creating a desgin through an art program (though I have also heard of cad, but I believe cad programs are very expensive) and then giving it to a company that does lazer cutting to cut the frame and case out of a solid piece of acrylic plastic?

I'm new to all this stuff too and have a pretty similar goal: 2-part split ergonomic 60%ish board with thumb clusters. I'll share a few of my findings. I've found many of the tools here are very helpful: https://geekhack.org/index.php?topic=69582.0  Specifically the online leopard layout editor http://www.leopard-layout-editor.com/ then using it's output to use swill's plate building tool: http://builder.swillkb.com/  I'm making a few small tweaks to the output from swill using LibreCAD which is a free cad program. Swill has also worked with BigBlueSaw to do a bunch of the lasercutting/waterjetting so that might be a great route to take.

I'm also prototyping in cardboard (print layout on paper as a guide) just to get a feel for the layout that I'm making. A few people have mentioned this strategy, especially if you're like me and want to make triple certain that things will work the first time around.

Offline technomancy

  • Posts: 134
Re: [advice needed] making kb from ground up
« Reply #10 on: Fri, 24 April 2015, 10:11:18 »
I have never done any coding at all. How complicated is it to learn this or do you reccomend  just using someone elses firmware entirely?

It's not difficult if you have done other types of programming, but I would say it would not be a good way to learn programming. Working with a microcontroller is tedious when you are still learning since you don't get immediate feedback; as a beginner you want your programs to run on the PC so you can develop them interactively.

I am really excited about trying to make a prototype frame. So the most efficient method is creating a desgin through an art program (though I have also heard of cad, but I believe cad programs are very expensive)

There are plenty of good free/OSS CAD programs; Inkscape happens to be one that can be used for graphics but is also great for 2D CAD (each layer of a layered case can be thought of as a 2D shape) and there are other good CAD programs that are good for 3D design (if you decide you want to have it 3D printed or milled) and there are free CAD programs that are good for circuit board design too. The determining factor shouldn't be price since there are lots of open source options, but rather it should be determined by how you want to construct your case.

Doing a 3D case design is going to require learning a much more complicated tool set; Inkscape is comparatively simple. In my opinion it's also much less practical; a 3D-printed case is going to be weaker and much less precise than a laser-cut case. Unless you own your own printer it would probably be more expensive too. Opinions vary on this, but I would recommend against it.

Even with a 2D layered-acrylic case I'd still recommend making a few smaller practice cuts with a laser cutter just to get a feel for what to expect and how your files translate to physical objects. I made a space station for my kids to play with as I was learning: http://p.hagelb.org/ds9.svg (These were traced from bitmaps but still helped me learn the laser process.) Cut in birch ply: https://www.flickr.com/photos/technomancy/12894236484

Thanks for the kind words about the Atreus. It's obviously not a one-size-fits-all board, but people seem to really have taken a shine to it, which is great and somewhat surprising considering I designed it solely for myself. But I was very intentional to ensure the license is open so that others can learn from what I've done, just the same as I learned from those before me!

Offline alexofthewest

  • Thread Starter
  • Posts: 59
Re: [advice needed] making kb from ground up
« Reply #11 on: Mon, 27 April 2015, 20:27:43 »
would an arduino work as the microcontroller?  I really want to learn every aspect to this and I feel there is a giant amount of information around the arduino.

Offline vvp

  • Posts: 887
Re: [advice needed] making kb from ground up
« Reply #12 on: Tue, 28 April 2015, 05:32:19 »
You can use arduino hardware but sooner or later you will want to replace arduino libraries (and arduino bootloader) with LUFA or something else. For that you will need an ISP programmer. You can buy one or use a DIY programmer. You can built a dirt cheap DIY programmer from a parallel (or serial) port plug. These DIY programmers will be slow but good enough to replace bootloarder with e.g. a HID bootloader. After that you can upgrade firmware again through USB.

Offline technomancy

  • Posts: 134
Re: [advice needed] making kb from ground up
« Reply #13 on: Tue, 28 April 2015, 07:09:09 »
You can use arduino hardware but sooner or later you will want to replace arduino libraries (and arduino bootloader) with LUFA or something else. For that you will need an ISP programmer.

I agree that the Arduino IDE and libraries are limiting in the long run, but the Arduino bootloader is completely serviceable. I would strongly advise against going down the DIY programmer route; it simply is not necessary.

The key thing to watch for if you buy an Arduino is to get one with an atmega32u4 chip, like the Pro Micro or the Leonardo (but the Leonardo is probably too big) since it has native USB. The Teensy and A-Star Micro are essentially Arduino clones that use this chip; most of the advantages of the Arduino still apply to them, and they're nice and small and cheap. The A-Star Micro can even be used directly in the stock Arduino IDE by telling the IDE that you're using a Leonardo. The Teensy can be used in the Arduino IDE too, but you have to install a few drivers.

Anyway, if you've got something that works in the Arduino IDE, most of the available documentation and literature about the Arduino platform will apply. It's a bit confusing because "Arduino" means a bunch of different things; it's an IDE, it's a collection of hardware boards, it's a set of libraries you can use from your code, it's a dessert topping, it's a floor wax, etc. For example, existing firmwares like TMK and friends will work with some Arduino hardware but don't use any Arduino libraries or the IDE.

Offline vvp

  • Posts: 887
Re: [advice needed] making kb from ground up
« Reply #14 on: Tue, 28 April 2015, 10:31:48 »
Arduino Micro is a good option.
And here is some info about available bootloaders:
  http://deskthority.net/workshop-f7/bootloaders-t7608-30.html
I did not even try to use the arduino bootloader without the arduino environment.