Here’s a snap of the USBmidi2 4×4 fit on a lasercut half-rack proto panel (can you find it?):
The rack PC mount was another small side project. I have had that Nord Modular for some 13 years. Now finally I got its editor running in the place where it belongs, right next to the synth! The PC and screen are from ebay, with the PC hiding behind the display. The mount for buttons and the PC was manufactured Protocase. Some wires are still sticking out, the buttons are not hooked up yet.
USBmidi2 4×4 coming soon!
USBmidi2 is a USB MidiStreaming class-compliant device, in double. It connects your computer, over MIDI, to another computer.
USBmidi2 is also a component that you can embed in your own musical instruments. Add a USB MIDI device port to your project, along with the three standard MIDI jacks!
To skip to the end of the story, I built a few of them to share.
Drop me an email if you are interested in acquiring one at a reasonable price.
|USBmidi 1x1||Sold out!|
|USBmidi 4x4||Almost there!|
I got a few requests for a MIDI interface for the Raspberry Pi, so that the Pi could be used as a component in a hardware synth module. The point was that most MIDI interfaces only have a single USB device port for connecting to a computer, and that one is taken when you plug it to your Pi. Yet a synth should behave like a USB MIDI device itself, so there should be a second port for a laptop.
So two computers, talking to each other over MIDI over USB, both acting as USB hosts… no problem! Stijn had told me about these really really nice Kinetis KL26 microcontrollers with plenty of UARTs and a built-in USB interface. One USB interface, per chip.
The only MCU with two USB interfaces that could possibly fit this purpose was the NXP LPC43xx series that I used in the signal analyzer. But the LPC is massive – TQFP144 – while the KL26 is small and flexible. So it was clear: there should be two KL26’s, with one USB port each, connected together. And the overall design seems simple enough, this way:
The board appears as two MIDI ports on both computers. First port goes directly to the other USB host. The second one is connected to the MIDI jacks, and data is interleaved from both computers.
You can see the MIDI in/thru/out ports and the slave USB connector in the picture of the front of the device, at the top of this page. The backside has just the USB jack for the Pi, and looks like this:
This is how it works in practice:
I’m also working on the expanded version; since you read all the way down here, here’s a teaser ;-)
usbmidi 4×4 – not announced yet!
Mounting dimensions: See datasheet.
Further technical details: TBD
Source distribution: https://github.com/rpc-fw/usbmidi2
The KL26Z feels overall like a very nice MCU; the collection of features and the pin mapping that it provides works very well for me. The chip does USB natively, it has three serial ports, two SPI, two I2C, I2S, plenty of muxed ADC channels, and a DAC… The evaluation board is a scam, but can be converted into a cheap debugger with USBDM. And Erich Styger has made some really impressive work writing Processor Expert modules that also work with this chip. And the chip itself is tiny. I think I’ve found my new favorite microcontroller.
The ATtiny85 is one of the smallest microcontrollers in the AVR ATtiny series. In a SO-8 package it’s the size of a small opamp, perfect for tight boards. It’s not much of a beast though, with effectively only 5 free I/O pins, but surprisingly often that’s just enough.
Tiny MCUs like this come especially handy for prototyping, where you might just want to try something that needs a couple of control voltages, and the bulky Arduino is already hooked up to some other ongoing project. So I drew up some breakout boards and ordered them from DirtyPCBs. Leds and buttons come handy too, so I added one of each…
Since most forces will be exerted on the ISP connector and the button, I placed those in the middle of the pins. The ISP connector has the standard pin layout, and any AVR ISP programmer will work. Most components are 0603, only the 10uF cap has a bigger footprint.
If you like the boards, order the PCBs from DirtyPCBs!
Only one of the two resistors “RESET H” or “RESET L” should be placed; “H” pulls reset up to VCC, “L” down to GND. I used 10k for these. R1-R3 can be smaller, such as 1k ohm; these resistors are in place so that the ISP connector can work correctly when the board is connected to the prototype breadboard.
My breadboard prototypes invariably turn into these messy knots of wire… here the ATtiny85 drives an ENC28J60 ethernet controller (and some extra stuff):
The post for my tiny switching regulators wouldn’t be complete without some measurements. It’s easy to make a fake device that simply “does something” and still in the end doesn’t work like it’s supposed to. So here are some pictures of the regulator under load.
The input of the regulator is connected to a 9V power supply. The output goes into the blue/black box, which is my constant current load (more on these devices in a later post!), set to sink 800 mA. The voltage it’s showing is unfortunately too low; it’s measured at the end of all the wires, and thus includes wire losses. But the current is exact to the last digit. The regulator gives out 3.3V, and thus the total power consumed by the load is 3.3V * 0.8A = 2.64W.
According to its meters, the power supply is giving out 9V * 0.34A = 3.06W of power. notice that its current output is much less than 800 mA, so we’re indeed looking at a switching regulator. If we were measuring a linear 3.3V regulator, the power supply would have to also provide the full 800 mA, totaling 7.2W, and requiring a decent heat sink!
The efficiency of the switching regulator at this load is 2.64W / 3.06W = 86%. Nothing special there, at lower loads it improves a little bit, getting closer to 90%.
Here’s how the power output looks like on the oscilloscope. The ripple is at 13.6mV small enough to be difficult to measure on the Rigol oscilloscope, I couldn’t even get it to trigger correctly! The average voltage is very close to 3.3V.
The most important property of the regulator is of course its low heat dissipation, thanks to the high efficiency. The power was on for several minutes, and the regulator remained only slightly warm to touch. The power diode was the warmest individual spot. That concludes this wholly unscientific study. :-)
The protosynth front panel is shaping up nicely, and I’ve been looking for ways to make the design more modular and reusable. I tried first a fully modular design made of small sub-boards (with some 4 knobs or a couple of buttons+leds each) hooked to a master controller board, but it felt too fragile and would have required a lot of tricky wiring to finish. So instead of making the whole panel modular, I’m now going for a more conservative design consisting of just one large board, yet there’s still some room for reuse…
The logic level of the front panel board will be 3.3V, just like the rest of the processors on the synth. But since the front panel is at the end of a longish cable, and because it’ll likely boast plentiful leds that actually consume a measurable amount of power, I’d rather make use of the main 9V power input and regulate it down to the correct level separately. Having a dedicated regulator for the front panel board and its logic chips will hopefully result in less noise making its way to the DSPs and codecs on the main board.
There could easily be some 20-40 leds total on the panel, in addition to one or more microcontrollers, tens of potentiometers and encoders, and a bunch of logic ICs to probe all the controls. A linear regulator might be able to deal with this just fine, but since the panel will be quite crowded (the knobs are large), there won’t be much space for a heat sink. The voltage drop across the regulator would be some 5.7V, and thus the total power consumption for the regulator alone can be in the range of several watts. That’s a lot of heat…
So this time a linear regulator most likely won’t do, and switching regulators are the way to go. And for sure this won’t be the only time that they are useful. It would be very convenient to have a tiny regulator component that you could just drop in when needed, without having to worry every time about excess heat or careful routing.
I drew these tiny switching regulator boards loosely based on the LM22675 reference design. The result is a small “chip”, roughly 25x20mm in size, with the corner pins 900 mil apart. It leaves plenty of space even on a breadboard. And it’s light enough to be mounted by just soldering the pins to the main board.
The regulator is spec’d for 1.0 A, but since I used some leftover diodes, the practical maximum current output is some 0.8A at 3.3V. And the thing won’t even heat up noticeably above ambient temperature with such a load! The efficiency is a nice 90%.
The pinout is extermely simple: input, output, and enable. And the enable pin can be left floating, as it has an internal pull-up. Pulling it down will immediately cut the power.
The boards are intended to be soldered directly on top of a main board. The pins will separate the two boards by a bit more than a millimeter, so some small smd components, such as the 0603 SMD capacitors and resistor I mostly use, will easily fit in between them.
Here is the pinout:
And finally, the schematic.
I’ve built a few extra ones, send me email if you find interest in them.
The RPC is a MIDI controller and implements the age-old 1980s serial MIDI bus, and the Protosynth must be capable of interfacing with it. But in general use a USB device port is much more practical than the three ubiquitous MIDI ports; it allows connecting the synth directly to a laptop or other computer at any time. And USB host ports are starting to become popular in sequencers also. So that means I need an interface module that has both, and that can talk to the main synthesizer board over two serial buses. The mainboard processor must take care of interleaving the commands received over the two buses.
Standard MIDI ports are no problem, I had the basic circuitry working with the RPC and could simply lift it from there. The synth’s LPC1678 microcontroller has several UARTs, and it’s very easy to configure them according to the MIDI standard. USB was going to take some more work though. I didn’t have enough space on the DSP mainboard to make use of the LPC’s built-in USB controller, so I decided to keep it that way and went for an off-board solution. My approach was to build an external board that could speak MIDI over USB, and pass the data stream over an UART to the mainboard.
Luckily USB-capable microcontrollers are a dime a dozen these days, so it’s only a matter of choosing a suitable one for the purpose. A little bit of searching found me MocoLUFA, which is a complete implementation of a standard MIDI USB device for the ATmega, created by morecat_lab. The ATmega8u2 it was intended to be used with looked very nice, and its bigger brother ATmega32u2, while pin compatible, would have plenty of capacity for future expansions if necessary. The Arduino Uno is one example of the use of these chips; the Arduino team very successfully replaced the previous FTDI USB controller with an ATmega8u2 to reduce the cost of their boards. With inspiration from the Uno schematic and from the ATmega32u2 datasheet, I drew up the first version of the MIDI board.
The design was straight-forward. I used the 4N28 optocoupler and through-hole components for the MIDI side because I had those at hand. Except for the bypass capacitors. I have a lot of 0603 size 0.1uF caps now! :-) In the default configuration (F1 unpopulated in rev2 schematic) the device is self-powered: it will NOT draw its power off the USB bus. That means the it will disconnect from the computer when the it is powered off, as expected for a stand-alone device. It requires an external 3.3V power supply, and the signal voltage for all communication to and from the mainboard is 3.3V. The MIDI DIN5 connectors are very close to each other in the first revision of the board; while there are some DIN jacks that should fit, I dragged them a little bit apart for the second revision. Almost all of the GPIO pins on the ATmega are wired to am extra pin header next to it. Four are connected to SMD LEDs.
The ATmega8u2 does not have a dedicated VBUS pin for detecting whether it is connected to a USB host or not, and the MocoLUFA software can be configured to use some other GPIO pin for this purpose. In the end I left VBUS unconnected, because I wasn’t sure if the ATmega could handle overvoltage on the pins. The data sheet indicates this should be avoided. The USB firmware still works, albeit not completely according to the standard.
The two serial buses connecting the interfaces to the mainboard run at different bitrates. The real MIDI interface must be configured at 31250 bps. The USB interface doesn’t seem to have any such limitation, so I set it to 125 kbps. Just because it was a nice round number with the ATmega running by a 8 MHz clock. I’m not yet sure what kind of flow control the USB bus is capable of…
For programming the ATmega you will need an AVR programmer that can be hooked to the 6-pin ICSP port. I used a 5V Arduino Mega 2560 with the ArduinoISP firmware installed on it. The supply voltage of the Arduino is not an issue as long as you keep the MIDI board otherwise completely disconnected during programming. The MIDI ports are designed for a 3.3V power supply, so if they are powered by 5V they may fry any connected MIDI devices! During programming the board will draw power through the ISP port.
I will add the gerber files and BOM here later. Drop me an email if you’re interested in them or the Eagle source files (see bottom of page for the address). I have several rev1 PCBs left, and will most likely solder together at least a few more if all goes well. There are many possible interesting configurations of the board. For example, if the ATmega32u2 is sufficient for your application all by itself, the MIDI ports could be connected directly to it… How about a stand-alone arpeggiator board?