Introduction: HX1-DM - the Upcycled Arduino DUE Powered DIY Drum Machine (made With a Dead Maschine MK2)
The Spec.
- Hybrid Midi controller / drum machine: Arduino DUE powered!
- 16 Velocity sensing pads with very low latency 1>ms
- 8 knobs user assignable to any Midi #CC command
- 16ch Built-in sequencer (no computer needed!!)
- MIDI in/out/thru functionality (can be used as a USB midi interface!)
- Partial MIDI clock & MTC support (working on MMC and DAW control)
This is definitely one the most complicated projects I’ve worked on, were talking 17 output shift registers, 6 input shift registers, 2x 16 channel multiplexers working on a circuit board I have no idea what is what and where plus I’ve never messed with shift registers / multiplexers before……
It started as an impulse buy off eBay, I really wanted a Native Instruments Maschine because Ive always liked the drum pads on them compared to the ones on the MPC studio I owned so when I saw a faulty one on eBay for £40 quid I thought I’d give a go at fixing it with the worst case scenario being ‘if I can’t fix it I’ve got an Arduino DUE and a few UNO’s lying around, I could always do some hack'
I really like those drum pads anyway!!!!
Supplies
1 x faulty Native Instruments Maschine MK2
1 x Arduino Due.
17 x SN74HC595’s - 8-bit output shift registers
6 x SN74HC165’s - 8-bit input shift registers
2 x 74HC4067 - 16 channel multiplexers.
2 x 3.2” 256x64 OLED displays.
some flat wire (old floppy cable will do)
Step 1: The Repair.
The eBay seller was kind enough to give an idea of what to expect in the description and had removed the USB port. The board had suffered an over voltage and didn’t power up. Cue the multimeter….
The board appeared to have a short.. ‘I’ve repaired countless motherboards with shorts before So how hard can it be!?!’ It turned out this over voltage (and probably in part the board design) , had taken out nearly EVERY component on the board including the main CPU. This board was in a really bad way!
I continued to prod & poke with my multimeter, did a bit of research on the components and figured out what each one does plus NI did a great job of making things pretty obvious with the various test points around the motherboard 👍🏾.
Step 2: The Hack.
Knowing I’m gonna need to replace everything bar the main CPU (which won't be needed) I turned to eBay.
Thankfully everything needed was cheap so ordering a load of them was fun. 😁
17 x SN74HC595’s - 8-bit output shift registers.
The 17 output shift registers are used to control the drum pad’s multi-coloured LEDs and all of the Button LEDs (136 to be exact!! ) These are really easy to use and quickly found a library using the Arduino IDE to save myself making one.. they are chained together.
6 x SN74HC165’s - 8-bit input shift register.
These input shift registers are great for multiple inputs on 1 channel. There are 48 buttons in total.
2 x 74HC4067 - 16 channel multiplexers.
We’ve got 16 pads and 8 knobs left these are analog also. I found it easier to use these as the ones on the board were 8channel and I had problems finding where to connect the data pins.. cue spaghetti junction….
2 x 3.2” 256x64 OLED displays.
It’s gotta have some screens!!! I couldn’t find any info on the original LCD screens that came in the NI Maschine and I couldn’t be bothered wasting anymore time trying to so I decided to order some from china… I used the UG8x8 library to get these working. The new screens were slightly smaller than the original so I just blanked off the 'bad bits'.
1 x Arduino Due.
I had this lying around for some time waiting on a project worthy enough for all that power!! There was a problem I encountered, It seems some revisions of these boards have a reset issue that meant I had to hit the reset button sometimes to get the thing to run after uploading a sketch. This was easily fixed with a 10K resistor (there is a post on the Arduino forum about this).
Step 3: The Code.
I was really impressed on how much support there is in the Arduino community, finding code examples and libraries for the various components was really simple and straight forward.
Getting the USB midi up and running was easy and took a few minutes. The LEDs took some time and I had to create a sketch that incrementally set each pin HIGH in 1 second intervals and took a note.. I made an array which held the PIN numbers to make it easier when it came to coding up everything.
I made 2 libraries to talk to the multiplexers, one handles the analog pads and the other the knobs. Again this was really simple. I've attached them feel free to use edit etc.
I wanted to have a sequencer and the ability to record without the need
of a computer, I found some information on how to convert BPM to ms and found a great Arduino DUE timer library.
Using the timer library I was able to set reading inputs and things in intervals:
Pads @ 1ms - I found this to give the best balance between response / de-bounce artifacts.
Buttons @ 40ms - I used a queue library so no presses were missed.
Processing is done in the main loop,you can’t do too much when your in an interrupt as this will lock up the Arduino.
Midi stuff @BPM (in ms) - for the sequencing, at the desired BPM a function is called that updates which notes ETC are to be played and increases the beat counter.
Step 4: Conclusion.
Not sure what I’ve made here but I’m quite proud, the pads respond excellent, I had to fiddle with the timing to get the right balance with responsiveness and debounce issues. The sequencing works great and once I figure out the DAW support I can fully integrate this thing into my workflow and are able to add things in a controller I’ve always wanted!.
This was a really fun project to work on and a great exercise in getting to grips with C, understanding reverse-engineering and how multiplexers, shift registers and MIDI sequencing works. I’m continuing to improve the main code and might release it one day as an open source rhythm designer.
TIPS:
I found how to change the USB name of the DUE by editing one of the header files in the Arduino/SAM folder.
MIDI-OX is a great tool for testing Midi functionality
LINKS:
https://www.usb.org/sites/default/files/midi10.pdf - USB MIDI Spec
http://midi.teragonaudio.com/tech/miditech.htm https://guitargearfinder.com/guides/convert-ms-mi... Some info on how to convert BPM to ms
https://travis-ci.com/SMFSW/Queue - For button inputs so we don't miss any presses!
https://github.com/olikraus/u8g2/wiki/u8x8referenc... - UG8 lib for LED/LCD Screens
https://github.com/ivanseidel/DueTimer/releases - Arduino DUE Timing lib
http://www.pjrc.com/teensy/td_libs_Encoder.html - Encoder Lib for the big knob
http://shiftregister.simsso.de/ - ShiftIn Register lib - Created by Henrik Heine, July 24, 2016
https://forum.arduino.cc/index.php?topic=57636.0 - MIDI Time Code stuff