Caught in the Net (Posts about mechanical keyboard)francescomecca.euenContents © 2018 <a href="mailto:francescomecca.eu">Francesco Mecca</a> Sat, 10 Nov 2018 17:14:03 GMTNikola (getnikola.com)http://blogs.law.harvard.edu/tech/rssMinidox, a guide for the Europeans and the Scroogesfrancescomecca.eu/blog/2017/10/2/minidoxguide/Francesco Mecca<div><p>This guide is adapted from the <a href="https://github.com/nicinabox/lets-split-guide/blob/master/assembly.md">Let's split guide</a>.</p> <p>It is tailored between the Scrooges like me and all the europeans that couldn't find some TRRS jacks.</p> <h3>Helpful references</h3> <ul> <li><a href="https://imgur.com/a/vImo6#Rfd586V">/u/that-canadian's original build log</a></li> </ul> <h3>Parts</h3> <ul> <li>PCBs - You will need two of them and you should participated in the group buy.</li> <li><strong>2</strong> ATmega32U4 - 5V/16MHz Pro Micros, you can find them easily on ebay or amazon. </li> <li><strong>36</strong> 1N4148 diodes, easy to source, even real world shops has them. </li> <li><s>2 TRRS or TRS jacks</s> our source of all problems, this build log will do without.</li> <li>Plate, from <a href="https://github.com/dotdash32/Cases/tree/master/Minidox">u/dotdash32</a> or <a href="https://github.com/pjones/minidox-case">pjones</a>, 3D printable.</li> <li><strong>36</strong> Switches of your choice</li> <li><strong>36</strong> Keycaps of your choice</li> <li><s> TRRS or TRS cable </s> No jacks, no cable.</li> </ul> <h3>Cost Breakdown</h3> <table> <thead> <tr> <th align="left">Cost</th> <th align="left">Part</th> </tr> </thead> <tbody> <tr> <td align="left">$8</td> <td align="left">PCB</td> </tr> <tr> <td align="left">€ 12-30</td> <td align="left">Pro Micros</td> </tr> <tr> <td align="left">€3-8</td> <td align="left">Diodes</td> </tr> <tr> <td align="left">€14-80</td> <td align="left">Switches</td> </tr> <tr> <td align="left">€14-180</td> <td align="left">Keycaps</td> </tr> </tbody> </table> <p>This is a very cheap build, mine was about 30 € given that I already had the keycaps.</p> <h3>Mount the Diodes</h3> <p>Diodes allow current to flow in one direction only. Mount the diodes with the black (negative, cathode) line facing the thicker line.</p> <p><img alt="" src="francescomecca.eu/wp-content/uploads/2017/minidox1.jpg"></p> <p><strong>Double check your work</strong>. </p> <blockquote> <p><em>Tip:</em> <strong>Lightly</strong> tack each diode in from the top. This will keep them snug against the surface once we flip it over and do the real soldering from the bottom. You only need a tiny amount of solder here and you should still be able to see through the hole.</p> </blockquote> <h3>Connect Jumpers</h3> <blockquote> <p>This part is not really needed, but you may want to do it in case you will mount the TRRS jacks in the future.</p> </blockquote> <p>On the <strong>underside</strong> of the PCB, right below the TRRS jack, you'll see two sets of 3 pads labelled VCC and GND. Jumper them like this:</p> <pre class="code literal-block"><span></span>VCC [x] [ ] VCC [x] [x] GND [ ] [x] GND </pre> <p>Do both PCBs the same.</p> <p><img alt="" src="https://i.imgur.com/AUT3VUd.png"></p> <h3>Mount Header Pins</h3> <p>You should have received header pins with your Pro Micro. Insert the short side into the bottom of PCB and solder them in.</p> <blockquote> <p><em>Tip:</em> To keep them aligned you can slip the Pro Micro over the pins but <strong>do not solder the Pro Micro at this time</strong>.</p> </blockquote> <p>Tack the pins on the end and inspect. If the pins are not quite aligned with the board, heat one side with your iron and press it in. It should make a satisfactory "click".</p> <p>Solder the rest of the pins (it won't take much solder here).</p> <p>The long part of the pins should be protruding from the bottom. We'll trim these later after soldering the Pro Micro, but you can leave them be for now.</p> <h3>Mount the Pro Micro</h3> <p><strong>Pay special attention on this step</strong>. There are several things that need to be done in the right order and orientation.</p> <blockquote> <p><em>Tip:</em> Flash your Pro Micro now before you mount it. You can test it by using a multimeter to measure the voltage between VCC and RAW. It should be around 5V. If it's bad it'll be a lot less headache than desoldering.</p> </blockquote> <h4>Mount the 2 switches under the Pro Micro</h4> <ol> <li>Grab two of your switches.</li> <li>Snap the switches into your plate in the spots that overlay the Pro Micro (on the left side that's column 2, and on the right that's column 5).</li> <li>Line up your PCB with the switches and solder them between the header pins</li> </ol> <h4>Mount the Pro Micro</h4> <p>You'll be working from the bottom of the board for this step.</p> <ul> <li>On the <strong>left PCB</strong> the Pro Micro should be <strong>smooth side up</strong> (facing you)</li> <li>On the <strong>right PCB</strong> the Pro Micro should be <strong>component side up</strong> (facing you)</li> </ul> <p>It gets easier if you notice that on the Pro Micros and the PCBs there is "RAW" printed. The raw pin must go through the hole with the same sign.</p> <p>If you made my same mistake, instead of desoldering without the right equipment you can try to just cut the dividers on the Pro Micro and detach it by breaking the header pins.</p> <p><img alt="" src="francescomecca.eu/wp-content/uploads/2017/promicro2.jpg"></p> <h3>Mount the rest of the switches</h3> <p>Home stretch. Gently snap in the rest of the switches and solder them.</p> <p>This would have been easier with a plate, I needed the help of a friend in order to have them aligned correctly.</p> <h3>Connect the Pro Micro</h3> <p>Given that sourcing the trrs jacks (even TRS if you go without leds) is a little bit difficult in Europe (I got mine from aliexpress), we are gonna connect the two Pro Micros directly.</p> <p>The Pro Micros just need communication between three of their pins.</p> <p>This means that the Minidox works if you connect the correct pins with a simple copper cable.</p> <p>The pins are:</p> <ul> <li>Data pin on the right (pin 6 in figure)</li> <li>VCC pin, left side (21)</li> <li>GND pin, just below the RAW pin (23)</li> </ul> <p><img alt="" src="francescomecca.eu/wp-content/uploads/2017/promicropinout.png"></p> <p><img alt="" src="francescomecca.eu/wp-content/uploads/2017/promicro4.jpg"></p> <p><img alt="" src="francescomecca.eu/wp-content/uploads/2017/promicro5.jpg"></p> <p>In my case I have used some old molex cable because raw copper wires tend to be very weak and break apart in a few days.</p> <h2>Troubleshooting</h2> <h4>Column 2 or column 5 doesn't work (under the controller)</h4> <p>If you're having trouble with a dead column right over your Pro Micro it could be that you've got a short from the switch pins. Try to get under there and bend them down.</p> <h4>One side isn't working</h4> <ul> <li>Double check if the copper wires are in working conditions and if you have connected the right pins.</li> <li>Check that the wires are insulated and that they do not touch the other pins.</li> </ul> <h2>End Result</h2> <p>Beautiful? <a href="https://en.wikipedia.org/wiki/Don%27t-care_term">W</a>.</p> <p><img alt="" src="francescomecca.eu/wp-content/uploads/2017/promicro3.jpg"></p></div>DIYmechanical keyboardMinidoxPesceWandafrancescomecca.eu/blog/2017/10/2/minidoxguide/Mon, 02 Oct 2017 00:00:00 GMTArduino Uno as HID keyboardfrancescomecca.eu/blog/2016/7/5/arduino_keyboard/Francesco Mecca<div><p>Turin is the hometown of Arduino. I have been at the <a href="http://fablabtorino.org/">fablab</a> multiple times but I had to come all the way to America to get my hands on a simple Arduino Uno.</p> <p>For 60$ I bought a cheap (but still good!) mechanical keyboard by Qisan, a clone of the Arduino Uno and a USB host shield.</p> <p>Given that is 3 years since I have been using a dvorak layout and it's a pain to change layout on every machine that you have to use. You can imagine that given this three pieces of hardware together I put together an hardware key mapper for the keyboard.</p> <p>I have never had experience with Arduino before but it was not that difficult to make it do simple things like blinking the led or send signal through to a serial monitor.</p> <p>It took me half an hour to wear down all my excitement: the USB Host Shield library broke all the compatibility with the similar project I found wandering online.</p> <p>In particular <a href="http://hunt.net.nz/users/darran/">this blog</a> has the most precious information and the guy wrote a HID driver that allows the Uno to be seen as a HID device.</p> <p>It was a noob error but I didn't checked the various arduino alternatives and I discovered late that just a few have the HID capabilities that would make this work easier. I should have bought and Arduino Due or Leonardo maybe.</p> <p>Also, the various guides about flashing with a dfu tool are specific to older models of the Uno and it took me some time to figure the name of the new components so that I could flash a new firmware.</p> <h3>A small journey in the Arduino world</h3> <p>It feels pretentious to write a little guide for this kind of work, given also the fact that I have roughly 10 hours of experience with the Arduino. But the other resources are really outdated so I hope this piece can be useful to someone out there.</p> <p>All the files I have used today are on <a href="http://francescomecca.eu:3000/pesceWanda/arduino_HID_keyboard">my repos</a> and I included also an outdated version of the USB Host Shield library that I used.</p> <p>The original code from this <a href="http://hunt.net.nz/users/darran/weblog/c6f35/Arduino_USB_Keyboard_Passthrough.html">blog post</a> works like a charm but just as a simple passthrough.</p> <p>It was not difficult at all to examine the code: during each loop of the iteration a char array gets read from the shield and if it is contains information Arduino with the Serial.Write method send the data to the host.</p> <p>The buffer array is a simple array of length 8 and the first two positions are reserved. In particular the first one represent the various modifier keys.</p> <p>The dvorak layout has the same pairs as the US layout but eventually I got used to having the '@' where at the same place of 'Q' (qwerty) and '"' over the '2'. Also, I am an avid vim user (I should thank Simone Basso for that) and I swapped some keys on the new 65 keys keyboard. The modifier bit at the beginning of the array came in handy for my code.</p> <p>An hardware key remapper is a simple but long switch C statement but I decided to consider also the modifier bit: in this way certain keys like the Window (UGH!) key is mapped to a different layer of keys. I got all the codes for the HID events <a href="http://www.freebsddiary.org/APC/usb_hid_usages.php">here</a>.</p> <p>The process of flashing the code on the Uno goes like this:</p> <ul> <li>write the looping code;</li> <li>push it to the Arduino using the IDE;</li> <li>shortcircuit the board so that it goes in DFU mode;</li> <li>flash the .hex HID firmware;</li> <li>try your code;</li> <li>repeat until it's right.</li> </ul> <p><img alt="Everything fits in one picture" src="francescomecca.eu/wp-content/uploads/2016/IMG_20160706_011304.jpg"></p> <h3>Flashing the firmware</h3> <p>The firmware is in my repo but I got it from (here)[http://hunt.net.nz/users/darran/weblog/a6d52/Arduino_UNO_Keyboard_HID_version_02.html]. The tool I used to flash it is dfu-programmer (version 0.62). Every time you want to flash a new firmware the Arduino must be put in DFU mode (you can see the difference with lsusb). To do that simply create a shortcircuit using a small metal wire on the two pins near the reset button and a led will blink. This <a href="https://www.youtube.com/watch?v=E8XyRwXQr8Q">video</a> shows the method briefly (no real need for a jumper). The commands are the following and there is no risk to brick the Uno:</p> <pre class="code literal-block"><span></span>dfu-programmer atmega16u2 erase dfu-programmer atmega16u2 flash Arduino-keyboard-0.2.hex dfu-programmer atmega16u2 reset </pre> <p>After each flashing the device needs to be disconnected once. Of course you can flash the original firmware back. It is included in my repo or on the official ones.</p> <p><img alt="Arduino and the shield" src="francescomecca.eu/wp-content/uploads/2016/IMG_20160706_011143.jpg"></p> <p>That's it, as you can see is not difficult at all. The worst part is gathering the various info that are left dormant in blogs or forums.</p></div>Arduinoarduino unoHID arduinomechanical keyboardPesceWandaprogrammingfrancescomecca.eu/blog/2016/7/5/arduino_keyboard/Tue, 05 Jul 2016 00:00:00 GMT