Melodicade MX
Project Code, CAD Files, and Build Guide
Melodicade MX - A portable 6+ octave MIDI keyboard using mechanical key-switches arranged in the Wicki-Hayden button layout.
Video demonstration: https://www.youtube.com/watch?v=v-SpIecfIZ0
Design started:
January 2021
Build published:
February 2022
Goals of this project:
Reduce the cost of the arcade button based Melodicade by using inexpensive Cherry MX compatible mechanical key-switches instead.
Increase the number of buttons on a single deck beyond what can be fit with large 24mm arcade buttons in a 300mm² print volume.
Create a more elegant higher resolution menu driven interface for on-the-fly device configuration, vs. the previous cryptic character LCD.
Experiment with options for per-key velocity detection.
Notes:
Overall, I'm happy with the way this project has turned out. Assembly is a bit more complicated than with simple arcade buttons, but the cost savings, and especially the per-key velocity detection, more than make up for it. With the extra row of buttons, the instrument is also brought up to nearly the range of a full 88-key piano, which is pretty fun considering that it easily fits in my backpack.
I think this is past the point where a sensible person would have designed and sent away for a PCB, but I rather like the idea of keeping things unrefined enough that a dummy like myself can assemble by hand with the help of a 3D printer and some off-the-shelf parts. I'm continuing to work on the software side with the on-board synth, and making tweaks to the menu system, but barring a massive redesign, hardware wise I'm comfortable with where this is right now.
The range comparison vs. an 88-key piano keyboard:
Development history:
(Click images to embiggen)
Prototype #1 - January 2021
Proof of concept that an instrument matching the playability of the Melodicade could be created using 3D printed keycaps, and mechanical key switches at about half the total cost of the original.
Prototype #3 - May 2021
After playing around with various options, settled on a stacked switch configuration for velocity detection, and added an additional TRS jack to Prototypes 1-3 for a work-in-progress internal PCM synth via Teensy's Audio library. Spent the next few months refining the keycaps once more, working on the synth component, and just playing.
Prototype #4 - November 2021
Changed the internal design to streamline switch assembly, and to replace the digital MIDI CC buttons with an analog stick for finer control. Also changed platform from the Teensy 3.6 to the Teensy 4.1 for increased speed and better audio out (at the unfortunate cost of two through-hole I/O pins, requiring use of the SMD pads on the bottom).
Melodicade MX - February 2022
Tweaked the internal design yet again to streamline assembly. After being unhappy with the imprecise analog stick for MIDI CC, returned to the two-position digital buttons for more accurate bends, and to reduce complexity, allowing all wiring to fit neatly in the through-hole pins of the Teensy 4.1 PCB once more.
Liability Disclaimer:
All information in this guide is provided "as is", with no guarantee of completeness, accuracy, timeliness or of the results obtained from the use of this information, and without warranty of any kind, express or implied, including, but not limited to warranties of performance, merchantability and fitness for a particular purpose.
By following this guide, you agree to be responsible for any decision made or action taken in reliance on the information given, or for any consequential, special or similar damages, even if advised of the possibility of such damages.
Arduino Sketch:
Tinkercad Model:
STL Files:
Note: This will require a 3D printer with a 300mm2 or larger build plate, such as the Creality CR-10.
Shopping list used for this build:
Note: The total BOM was around $350 USD for this project (without modifications), as built in early 2022. Actual cost is more like $180 if intending to use all of the remaining parts that can only be purchased in larger spools, kits or multi-packs. Expect to spend around 175 hours on (mostly unattended) printing, and 20 hours of labor for parts cleanup and assembly.
Microcontroller:
https://www.pjrc.com/store/teensy41.html
1 x Teensy 4.1 Development Board
Key-switches:
Faster Delivery: https://www.amazon.com/gp/product/B08NGNB54K
120 (buy spares) x Gateron Black Plate Mounted Mechanical Key Switch
OR
Lower Price: https://kbdfans.com/products/switches-x-100?variant=28965692670000
120 (buy spares) x Gateron Black Plate Mounted Mechanical Key Switch
Tact-switches:
120 (buy spares) x E-Switch LL1105AF065Q 5mm Long Life 0.6N Tact Switch
OLED Display:
https://www.amazon.com/gp/product/B08KY21SR2
1 x 0.96" SSD1306 I²C OLED Display Module
Rotary encoder:
https://www.amazon.com/gp/product/B07B68H6R8
1 x KY-040 360 Degree Rotary Encoder Module with Knob Cap
Potentiometers:
https://www.amazon.com/gp/product/B07B64MWRF
2 x 10K Ohm Potentiometers with Knobs
Panel mount jacks:
https://www.amazon.com/gp/product/B00CMXRLXM
1 x 1/4" Female TS Mono Panel Mount Jack
https://www.amazon.com/gp/product/B06XG3YTC4
1 x 3.5mm Female TRRS Stereo Panel Mount Jack
https://www.amazon.com/gp/product/B07G4XYJ5W
1 x Micro USB 5-pin Male to USB Type B 2.0 Female Extension Panel Mount Jack
https://www.amazon.com/gp/product/B01CJDJTSO
1 x 5-pin DIN Female Connector Panel Mount Jack
Wiring:
https://www.amazon.com/gp/product/B0979NWY94
1 x Spool 24 AWG Solid Tinned-Copper Bus Bar Wire
https://www.amazon.com/gp/product/B07TX6BX47
1 x Kit 22 AWG 6x30ft Solid Wire Kit - 6 Colors
https://www.amazon.com/gp/product/B06XB1R2NK
240 x 1N4148 Switching Diodes
https://www.amazon.com/gp/product/B072PCQ2LW
1 x Kit Heat Shrink Tubing
https://www.amazon.com/gp/product/B072BL2VX1
2 x 220 Ohm Resistors
Filament:
https://www.amazon.com/gp/product/B089S2QDHD
1 x Spool PLA Filament 1.75mm - Matte Black
https://www.amazon.com/gp/product/B089S1HB8K
1 x Spool PLA Filament 1.75mm - Matte White
https://www.amazon.com/gp/product/B07PDW8QWJ
1 x Spool PLA Filament 1.75mm - Space Gray
Miscellaneous:
https://www.amazon.com/gp/product/B07WRC6SDV
20 x Wood Screws (M4 x 25mm)
https://www.amazon.com/gp/product/B01GOPPHNY
4 x Clear Rubber Feet
https://www.amazon.com/gp/product/B07CYNKLT2
1 x Kit M3 x Various Size Bolts and Nuts Kit
https://www.amazon.com/gp/product/B08DHZHQ4M
1 x Kit Wire Nuts - Various Sizes
Optional:
https://www.amazon.com/gp/product/B07PFS2R12
1 x Spool PLA Filament 1.75mm - Red
https://www.amazon.com/gp/product/B07VFS3P2S
1 x Spool PLA Filament 1.75mm - Green
https://www.amazon.com/gp/product/B087QD8YVC
1 x Spool PLA Filament 1.75mm - Blue
Printing Instructions:
Note: Printing instructions are written for a Creality CR-10 with Cura 4.12 slicer software, however any slicing software in combination with an FDM printer with a 300mm² plate should suffice.
Printer settings:
Use a 0.4mm nozzle with all settings defaulted to Cura's Standard Quality - 0.2mm with the following universal changes (except where otherwise noted below):
Top Surface Skin Layers - 1
Z Hop When Retracted - Yes
Build Plate Adhesion Type - None
Plastics (in order of printing):
1 x Keybed (0.3mm layers, 3 top/bottom layers)
1 x Tool - Keybed Support Stand (100% infill)
1 x Tool - Tact-Switch Diode Bending Form (100% infill)
1 x Tool - Key-Switch Diode Bending Form (100% infill)
1 x Left Wall (0.3mm layers, brim)
1 x Right Wall (0.3mm layers, brim)
1 x Tool - Column Wire Bending Form (0.3mm layers)
2 x Tool - Wire Cable Comb (100% infill)
1 x Front Wall (0.3mm layers, brim, supports) - Sand inside wall flat after removing supports
1 x Rear Wall (0.3mm layers, brim, supports) - Sand inside wall flat after removing supports
1 x Top-Plate (100% infill)
1 x Bottom-Plate (100% infill, optional: 1.0mm nozzle with 0.55mm layers)
1 x Keybed Center Stand (brim, 100% infill)
60 x Black Keycap (100% infill) - Print extras
56 x White Keycap (100% infill) - Print extras
(Optional control key colors; substitute black/white/gray otherwise)
2 x Blue Keycap (100% infill) - Print extras
1 x Green Keycap (100% infill) - Print extras
1 x Red Keycap (100% infill) - Print extras
Tools Required:
3D printer and filament
Blue/Painter's tape
CA glue
Cordless drill
Dental picks
Drill bits in 3mm, 3.5mm, 4mm and 4.5mm
Diamond needle file set
Flush cutters
Hammer and 5mm flat punch tool
Hot-glue gun and glue sticks
Kapton tape
Key puller
Multimeter
Needle-nose pliers
Phillips bits
Razor knife
Sandpaper
Soldering iron, solder and flux
Wire strippers
Row/Column Layout and Numbering:
Note: View is from the underside of the Keybed.
Pinout:
// Device pinout:
// Name Teensy 4.1 Pin
//----------------------------------------
// (tact-switch columns)
// Col 0 0
// Col 1 2
// Col 2 3
// Col 3 4
// Col 4 5
// Col 5 6
// Col 6 7
// Col 7 8
// Col 8 9
// Col 9 10
// (key-switch columns)
// Col 0 11
// Col 1 24
// Col 2 25
// Col 3 26
// Col 4 27
// Col 5 28
// Col 6 29
// Col 7 30
// Col 8 31
// Col 9 32
// (shared rows)
// Row 0 16
// Row 1 15
// Row 2 14
// Row 3 41
// Row 4 40
// Row 5 39
// Row 6 38
// Row 7 37
// Row 8 36
// Row 9 35
// Row 10 34
// Row 11 33
// --
// Rotary encoder SW 17
// Rotary encoder DT 23(A9)
// Rotary encoder CLK 22(A8)
// --
// OLED I2C Clock 19(SCL)
// OLED I2C Data 18(SDA)
// --
// Pot (top) 21(A7)
// Pot (bottom) 20(A6)
// --
// 1/4" TS Jack (tip) 13
// 3.5mm TRRS (tip+ring) 12(MQSL)
// --
// DIN MIDI TX 1
Assembly Instructions:
(Click images to embiggen)
Step 1:
Print the Keybed so that assembly can start while other parts are printing. This is the longest single print job, and will take approximately 44 hours to complete.
The baked-in brim is recommended to prevent lifting. Cura's brim setting will interfere with the features on the underside, and is not suitable for this.
Step 2:
Once the Keybed print is finished and cleaned up, use a drill with a 4.5mm drill bit to cleanly round out all 120 key center-holes (detaching the small cylindrical supports in the process).
Clear out any remaining stray plastic in the key-switch and tact-switch recesses with a dental pick, needle nose pliers and/or flush cutter.
Step 3:
Bend/clip the four tact-switch legs using the photo as reference.
Unused - Remove leg with flush cutter.
Row Leg (shared) - Bend 180° to make contact with the key-switch row leg for later soldering.
Column Leg (tact-switch) - Leave untouched for later soldering to the tact-switch diode anode.
Row Leg (shared) - Bend 90° to reach the recessed channel for later soldering to the row wiring.
Step 4:
Using a small hammer and something that can serve as a ~5mm flat punch tool, carefully tap each of the 120 tact-switches into place using the printed Keybed Support Stand to support the other side of the board while striking.
The fit needs to be tight enough that the switches won't pop out from the force of the mechanical key-switch plunger pressing down from above.
Step 7:
Using a flush cutter, carefully trim the plunger cap from the bottom of each of the 120 key-switches. Wear eye protection!
Be careful not to press the key down while cutting, or you might cut the plunger stem as well.
Ensure that the plunger stem can protrude smoothly and fully from the hole in the bottom once the cap has been removed.
Step 8:
Insert the key-switches into their housings. You should feel the subtle click of the tact-switch activating when the key-switch is nearly bottomed out. If not, check to make sure the tact-switch is fully inserted and that there isn't any stray plastic lodged in the recesses.
Once installed, run a thin bead of hot glue along opposite sides of the key-switches where they meet the housing to hold them in place securely. The key-switches will now hold the diodes in place so that the board can be flipped over for soldering, and the left and right walls can be removed again.
Step 9:
Solder each key-switch row leg to their respective tact-switch row leg. The iron will melt the surrounding plastic a little, but use a hot iron with plenty of flux, work carefully and quickly, and it will not be a problem. The keybed will tolerate a fair amount of abuse; I've successfully de-soldered and replaced flakey key-switches after having completely finished assembly before. This is not ideal however, so work carefully.
Note that it's easiest to run through steps 9-12 for each row in sequence so that fewer diode legs are in your way while working.
Step 12:
Solder the uninsulated row wire to the tact-switch row legs using the recessed channels as a guide. Row wire should rest on top of the tact-switch leg for a solid connection, as the longer uninsulated wire will need to absorb more heat from the iron.
Blue tape is useful for holding the wire in place while soldering.
Step 13:
Using a multimeter in diode test mode, clip onto each row wire sequentially, and with the other probe, test each key-switch and tact-switch diode cathode leg to ensure that they read with the switches closed. Repeat the process until all 240 diodes have been tested. If any fail to read, check your solder joints, and re-solder if necessary.
When finished, stand the Keybed on its side to avoid contaminating the buttons, and clean the excess flux from the row wiring with an old toothbrush and some isopropyl alcohol.
Step 14:
Cover the exposed row wiring with an electrical insulator to prevent the column wires from making contact.
I've used hot glue in the past, which looks gross, but is extremely easy to work with. I've also used a 3D pen to entomb the row wiring in plastic (not recommended, as repairs are a nightmare). I tried Kapton tape this time, which I think looks neat, but was more fidgety than I expected due to the tape sticking to everything but the keybed. If all else fails use insulated column wire, but it's a pain to strip, and melting insulation is nasty.
Step 15:
With the help of the Column Wire Bending Form, bend 18 uninsulated column wires into zig-zags and solder to the tact-switch and key-switch diode cathode legs. The legs can be folded over to hold the column wire in place while soldering, and then trimmed when finished.
Due to the asymmetrical layout, the wires for column 0 (containing the control panel buttons) will need to be bent by hand. Try not to cross over anything conductive. Or screw up like I did, and just use hot glue to hold the wires apart.
Step 16:
Measure, cut and strip lengths of multicolor insulated wire that will be used to connect each of the 12 row, 10 tact-switch column, and 10 key-switch column wires to the microcontroller I/O.
Solder to the rows at their ends, and to the columns in convenient locations, and use the Wire Cable Combs to neatly hold the other ends in the correct order for later soldering to the microcontroller per the pinout above.
Step 17:
Screw the four walls together in a square, carefully center them over the bottom-plate, and hold everything in place securely with blue tape.
Using the screw holes in the walls as a template, drill 12 holes through the bottom-plate using a 3mm drill bit. Be sure to mark which side is front and back, as the holes won't necessarily line up if you change orientation.
Repeat this process for the 8 holes in the top-plate.
Step 18:
Use a 3.5mm, followed by a 4mm drill bit to widen out the holes in the top and bottom plates so that they comfortably accommodate the M4x25mm wood screws. Between each step, line the plate holes up with the wall holes to make sure they're completely centered. If not, use a round needle file to expand the holes out and over until they are.
The reason for all of this hassle vs. just printing the holes in place is that even a tiny amount of warping across any of the larger connected parts will cause the case to bend noticeably when fully assembled. If done correctly, this should mitigate the problem.
Step 19:
Insert screws along one edge of the bottom-plate, and place it just over the edge of your workbench. With a slot-tip soldering iron, heat while twisting each screw back and forth until it melts into the plastic, forming a countersink. Wait for it to cool, and remove the screws before repeating the process around each side. On low heat (and with some luck) you can create a smooth lip around the countersink holes which looks very nice.
Otherwise, just remove the excess melt with a flush cutter. Make sure that the inside surface (wall side) is completely flat in either case. Repeat the process with the top-plate.
Step 20:
Screw the four walls together, and then to the keybed. The front and rear walls should hinge at their lower screws. Ensure that they can be pushed flush against the keybed wall, and if not, sand away more plastic from their inside walls. Open a gap between the front wall and the keybed, and apply a bead of CA glue along the front of the keybed wall. Apply pressure to the keybed to ensure that it sits perfectly flush with the top of the front wall, then press and hold the wall against the keybed while the glue cures.
Repeat this process for the rear wall.
Step 21:
Apply pressure to the keybed to ensure that it sits perfectly flush with the top of the right wall, and on the underside where they touch, run a thick bead of hot glue along the length to securely attach the left wall to the keybed, and hold in place while the glue cools.
Repeat this process for the left wall.
Step 22:
Solder lengths of insulated wire to the rotary encoder CLK (white in the photo), DT (yellow), SW (green), +3.3V (red) and GND (black) pins.
And the potentiometer +3.3V (red), GND (black), and data (center) pins.
Attach the rotary encoder and potentiometers to the top-plate with the nuts and washers.
Step 23:
Solder lengths of insulated wire to the OLED display GND (black), +3.3V (red), SCL (yellow), and SDA (blue) pins.
Carefully line up and glue the OLED in place using hot glue through the PCB corner holes. Trim away any squeeze-out with a flush cutters to prevent it from getting pinched between the top-plate and the keybed/walls.
Once assembled and tested later, glue around and under the perimeter of the PCB as well to ensure that it stays in place.
Step 25:
Solder lengths of insulated wire to the 1/4" TS jack tip (+3.3V - red), and sleeve (data - yellow) legs.
Solder lengths of insulated wire to the 3.5mm TRRS jack tip+ring legs (MQSL - blue) and sleeve (GND - black) legs. Leave the remaining ring connector (mic) disconnected. The pinout of this specific connector is: 1 - GND, 2 - TIP/LEFT, 3 - RING/RIGHT, 4 - MIC
Attach the jacks to the rear wall with the nuts and washers.
Step 26:
Solder 220 Ohm resistors in line with pins 4 (+3.3V) and 5 (serial data) on the 5-pin DIN MIDI connector. Then solder lengths of insulated wire to the resistors for +3.3V (red), and serial data (green), and to the GND (black) pins.
Attach the to the rear wall with M3x20mm bolts. Cover the 3 DIN legs (and resistors) with heat shrink when finished to prevent them from making electrical contact with each other.
Step 29:
Trim the ends of the wires running through the cable comb so that they are all flush with each other. The case wall makes a convenient a straight-edge.
Strip the ends with your wire stripper, and carefully insert each wire into the appropriate through-hole in the microcontroller PCB using a needle-nose pliers. Bend the ends over to hold them in place while you work. Double-check your work before soldering.
Step 32:
Enable the hardwareTest() function in the program loop of the Arduino sketch, and upload the sketch to the Teensy. Use the serial monitor readout to test all of the key-switches, tact-switches, rotary encoder, pots, and foot pedal before continuing.
If anything fails to read, double-check with a multimeter, and re-solder if necessary.
Step 33:
Insert the Keybed Center Stand into its hole in the keybed. Place the instrument on a flat surface, and push the stand down from the top until it won't go down any further.
Once positioned, hot glue it in place from the top, and then the bottom to hold it in place securely. You can use CA glue as well, but hot glue is strong enough, and is also removable again in case it needs to be repositioned.
Step 34:
Screw the bottom-plate to the four walls.
If you find that the case is warped once the screws are tightened, double-check to make sure that the plate screw holes are completely centered on the wall holes. If they aren't too out of spec, you can carefully ream the holes and countersink walls with a round needle file and razor knife to bring them back into position.
Once satisfied, apply adhesive rubber feet to all four corners.
Step 35:
Clean up the 3D printed keycaps and attach them to the key-switches.
With tolerances this tight, even different filaments can cause the keycap to grip the cross stem too loosely, or too tightly.
If the keys are too loose, a tiny dot of CA glue in the cross hole will hold them securely while still being removable if needed. If they're too tight, using a spare key-switch as a reamer tool works well, and avoids putting undue stress on the instrument switches.