Summary

It's been just under a decade since my last write up here on Hack A Day and I am grateful that I was able to envision, plan, create and complete this USB MIDI adapter without too much hassle as a weekend project thanks to Chat GPT and the fantastic Arduino community, libraries and tooling.

Background

After eyeing off a cheap Roland digital piano for sale, I went to inspect it thinking that at least one or two keys were not going to be functioning. To my surprise all keys were working and it was in pretty good shape for what I later found out to be a 34 year old (1989) keyboard.

The feel of this keyboard is one of the best I have ever encountered, the action not unlike a high end acoustic grand piano and pretty soon I had put my 2 month old M-Audio controller keyboard aside focusing on using the Roland for my music production.

I ordered a cheap MIDI adapter from EBay for under $10 and forgot about using the keyboard until the adapter arrived.

First adapter failure

Once it arrived, I was eager to get it going, connected it and there was a constant blinking light flashing when connected to the MIDI out of the keyboard (active sensing) so that was a positive sign. Next firing up Reason (music production software) I found that the keyboard would sporadically work, with missing notes here and there. After some debugging, it seemed like it was only picking up one note at any given time (monophonic) even though the keyboard itself, with it's onboard sound canvas and amplifier was working correctly (polyphonic). There wasn't much more to do here, it just seemed like this adapter was no good.

Second adapter failure

I then read some forums online and opted for a more expensive MIDI adapter from M-Audio, for about 6x the price of the cheap EBay one. Surely now, with a reputable brand and less money in my wallet I was going to be able to use the Roland properly, but no. Surprisingly, the adapter behaved in exactly the same manner as the cheap one. Hmmm, this pointed to an issue with the keyboard instead... damn...

Keyboard Diagnosis

Going deeper, I opened the case and found that the PSU section was overheating and there were signs on the circuit board to support this. The incoming PSU (from Roland) was rated at 12V DC however I was measuring 17V DC going in. That seemed a little high so I decided to replace it. Of course Roland decided to "be different" and make their adapter with the center pole as GND instead of VCC. Annoying but not a blocker as I quickly reversed the polarity of an existing 12V DC adapter I had and then gave it another go.

It was better, the PSU components were no longer heating up as before and I had also changed a few of the capacitors in the PSU for good measure. I thought that would be the end of the repair, as we all know PSU problems present a large majority of faults seen in hardware.

Unfortunately I was wrong...

Reading the MIDI data

With the same issues persisting, it was time to bust out the oscilloscope and see exactly what was going on. I found some clock jitter in the main CPU and initially thought that was the source of my problems since naturally a non uniform clock signal would surely be interfering with the MIDI out signals. After some thought though, it was unlikely to be the case as the clock was running at 16MHZ and the MIDI baud rate is a very slow 31,250. That's quite a difference and even some shift in the 16MHZ (as seen) would not be affecting the output of such a slow protocol.

It was time to read the MIDI out data directly to analyse it. Luckily, there is a 74LS04 buffer IC used between the MCU and the MIDI out port so I could tap that to get some readings. My cheap digital scope gave me enough information to start to paint the picture of what was going on.

MIDI frames

For a single note (that worked fine), I could see three bytes being sent, with a start bit at the front. No problem here as a MIDI message for a Note On consists of:

[ Status...

Read more »