Now Reading
Smallest USB-C MIDI Synth –

Smallest USB-C MIDI Synth –

2023-12-15 14:36:56

Back to Hardware15 Dec 2023
Progress: Full

A brand new entrant in my sequence of “smallest and worst” MIDI synthesizers. (I am not together with the flash synth in that checklist, which is not alleged to be the worst!)

This is a video of the creation:


The previous few weeks I have been dabbling round with the CH32V003, a 32-bit RISC-V microcontroller that is unbelievably low cost.

One of many first issues that occurred to me, once I observed it did not have {hardware} USB however the processor is clocked at 48MHz, is that it might be superior to put in writing a software program USB stack for it. I’ve wished, for a very long time, to dig deep and write a bit-banged USB library, simply because it is the easiest way to study. I enormously loved writing my ethernet bootloader in assembly. It is exhausting to justify writing a USB stack from scratch when one already exists, nonetheless, so once I noticed the CH32V003 I believed this was the proper time to do one thing each instructional and helpful.

Image my shock to seek out that CNLohr has already done it! I am unable to precisely complain, that is a improbable achievement and makes the chip much more helpful and spectacular than it already was.

The very least I can do is get some USB-MIDI engaged on the chip. On the time of writing, the USB-MIDI demo was unfinished, so I attempted it out by soldering a dev board collectively. It began out a bit smaller, however by the tip of the experimentation my board seemed like this:

Messy dev board creation

That is a TSOP20 breakout and a Micro-USB breakout, superglued along with another scrap circuit board. A regulator, capacitors and some resistors full the circuit. The 2 header pins are my programming header (although with the USB plugged in, we do not even want to attach the bottom pin, and will get away with only one pin to program).

On the suitable is a set of buttons. I configured the USB-MIDI system to play notes when these buttons are pressed.

On the backside is a piezo buzzer. Naturally, when MIDI information arrives on the chip, it produces a sq. wave. I did this with one of many {hardware} timers of the chip, outputting in differential mode to maximise quantity.

USB MIDI messages are 4 bytes, and our low-speed USB endpoint will be eight bytes, so we might (and usually would) ship two MIDI messages per packet. Nonetheless for this easy demo I simply blocked till the subsequent USB interrupt for every message.

A little bit of MIDI loopback on the host aspect, and now we have a very horrible toy keyboard!

USB dev board

There are a number of dev boards accessible for the CH32V003, but it surely would not seem like any of them wire up the USB pins, most likely as a result of there isn’t any {hardware} USB. I doubt that is the final USB undertaking I will do with it, so to keep away from having to repeatedly wire up that mess above, a easy dev board is so as. I attempted to make it as small as attainable.

KiCad screenshot of dev board

All the mandatory pins are damaged out, all pins are labelled on either side. The 1.5K resistor will be soldered in one among two positions, both to D5, or direct to VDD in case you do not want software program reconnection of USB and need to use D5 for one thing else. On the underside, the USB information strains will be minimize and sequence resistors will be added, if wanted.

The three pins within the high proper nook are 3V3, GND and D1, which is what I have been utilizing as a programming header. You’ll be able to both join all three (to program it with USB unplugged), or D1 and floor, or simply D1 if the programmer is on the identical machine that the USB is plugged into.

The pins across the edge are .1 inch pitch, and the board is 15.2mm by 20.3mm complete.

Clean dev board creation

This is the compulsory 3D mannequin of the board:

Sorry, your browser would not help embedded 3D fashions.

The KiCad design recordsdata for this board are printed here and here.

Extra USB, all of the USB

Given how low cost the half is and the way few supporting elements it wants (the USB stack even does the identical oscillator calibration body timing trick that V-USB does), I believed it is perhaps enjoyable to recreate a few of my USB ATtiny initiatives.

The stylocard involves thoughts first. I’ve carried out a number of unpublished redesigns of that board up to now, and the perfect enchancment was eliminating the analog enter technique which was a bit unreliable as soon as the factor received soiled, and switching to direct readout, which suggests a microcontroller with at the least 22 GPIO. Sooner or later I ought to publish all that. Sadly our CH32V003 would not have sufficient pins to learn the keyboard and do USB collectively.

We might simply go along with the identical as earlier than, a bunch of resistors and make the studying analog, or we might attempt to do one thing intelligent, and even simply add a shift register, but it surely then occurred to me that because the CH32V003 is so low cost, why not simply stick two of them on the board? It will be hilarious. Certainly one of them might learn half the keyboard, the opposite would learn the remaining and in addition do USB.

The probabilities aren’t unlimitless!

Recreating my smallest USB MIDI synth was the subsequent thought. One thing I’ve wished to do for some time is produce a skinny circuit board as they do for some dongles, sliding the skinny circuit board inside the USB-A plug, basically creating the circuit I did earlier than however in a approach that may be mass-produced and simply assembled.

However a extra fascinating concept was to carry the synth forwards by time into the age of USB-C. Electronically this simply means including a few resistors and becoming the suitable connector. You’ll be able to’t mount electronics inside a USB-C plug so simply although. I did discover some mid-mount USB-C plugs which can have labored, however after a bit extra looking I settled on this vertical mount sort, supposed for constructing docks.

Vertical mount USB-C plug

The half quantity is USB4151 though there are a number of related elements from completely different suppliers.

When USB-C was launched, loads of engineers complained concerning the issue of fanning out the connections. It appears the designers of the connector assumed that everybody could be utilizing excessive density boards with microvias. The footprint alone of this connector is technically past the spec of a regular 6/6mil course of, and that is earlier than we have added any traces.

Footprint for the USB-C connector from the datasheet

Footprint for the USB-C connector in KiCad

The plastic studs require a non-plated by gap in very shut proximity of a plated gap. For this joke undertaking I am not going to pay for tighter tolerances, so I made a decision to only ignore the DRC violation and if they are not in a position to manufacture the holes I can trim off the plastic studs with a knife.

Vertical mount USB-C plug underside

The issue of fanout on a two layer board is such that particular USB-C connectors can be found, that do not escape all the pins, if all you want is USB 2.0 or simply energy. Nonetheless, they are not accessible on this vertical format, and apart from I eat difficult routing issues for breakfast.


With the vertical-mount USB-C plug, our ambition is to make the smallest attainable circuit board beneath it, that may match inside the diameter of an abnormal piezo buzzer. The buzzer has a pin pitch of seven.62mm, or 0.3 inches, and the outer diameter is 13.8mm, however we wish our circuit to suit contained in the melancholy, that meniscus of the potting compound, which suggests a most diameter of about 12mm.

Piezo buzzer

There is no attainable orientation the place the piezo’s pins do not foul the USB help pins. To cope with this, I widened the footprint spacing. It ought to be tremendous to bend the pins outwards a bit, but when it would not match we will file them down too. Because the design iterated, I reshuffled this a number of instances, finally I received them down to only 8mm aside.

We needn’t join the USB 3 pins, that is the 4 superspeed pairs and the 2 SBU pins, however we do have to wire up CC1 and CC2, which totals 14 pins to attach. Retaining the copper annulus round every plated gap as small as attainable, it is simply attainable to have all the mandatory tracks escape.

KiCad screenshot

Naturally the tracks are rounded with teardrops, as a result of I’ve requirements to stay as much as.

Because the shielding pins are all linked, we might cheat and never join the grounds collectively on the board, however ultimately it was tremendous to route these all collectively too.

On the underside, routing is simply as tight, with the QFN half shoved off-centre to make sufficient room for the tracks. Fortunately it would not damage if we join unused GPIO to floor (or to different alerts actually), so we will conveniently route floor proper by the center of the chip as a substitute of going round.

KiCad screenshot

The regulator is an SC-70 bundle, that is just like the miniature model of SOT-23. You may get even smaller regulators but it surely did not look like it might be a problem. Equally, across the periphery I’ve used resistors and capacitors in 0603 format, simply because there isn’t any actual stress for house as soon as we’re outdoors of the piezo/USB/QFN footprint mess.

On the entrance aspect I put three take a look at pads, for energy, floor and D1 (SWIO) for programming. In actuality just one pad is required, I am simply going to plug the USB-C in with an extension cable and contact a single wire to the programming pad.


I wished to do the panel myself for 3 causes.

Once you get boards made which might be this small, and you propose to stencil solder paste onto them, it is extraordinarily fiddly to carry issues if you do not have a body. A 12mm circle could be very tedious to carry at the perfect of instances, however right here now we have elements on either side so after one aspect is soldered it will be virtually inconceivable to stencil the opposite.

Secondly, I particularly wished the panel to have specific symmetry. We use the body and the mounting holes to align the stencil. To avoid wasting on the tedium of doing this twice, I put down two copies of the design, with the second flipped over. The entire panel is symmetric, so we will stencil one aspect, flip the board and stencil the opposite.

KiCad screenshot of panel

The third cause to do the panel myself is that I wished to additionally use the body as a jig. There’s an oval gap within the center designed to be a decent match round a USB-C plug. As soon as the board is part-soldered and damaged out of the panel, it should be an actual ache to do something to it, so this at the least ought to give us a primary grip on the factor. We might have made a jig ourselves out of one thing else, however there aren’t many supplies that may be laser-cut and would survive the reflow oven. In a way, FR4 is the proper help materials.

Render of panel with piezos hidden

I ought to take this second to reward simply how helpful the 3D mannequin viewer is. I can keep in mind as soon as having a weird argument with a contractor who was a bit old-school and did not see the good thing about it. He’d grown up with OrCAD within the 90s and insisted that organising 3D fashions for half footprints was a waste of time, or on the very least, not his job. 3D modelling is for the mechanical engineer, he saved saying.

However having the ability to have a look at a practical render offers such an enormous security buffer towards foolish errors. Within the previous days, we used to spend hours poring over gerber recordsdata on the lookout for frequent errors as a result of in case you made one, it might set every part again by weeks. And so they occurred on a regular basis! Issues like lacking the soldermask aperture on a footprint, or exporting shapes onto the fallacious layers. Ever since we shifted to KiCad and made full use of the 3D viewer, I do not suppose I’ve ever made a kind of errors. I nonetheless verify the gerber recordsdata religiously, however the 3D viewer is a second layer of defence towards errors.

Within the render under, I’ve highlighted the piezo, and you may instantly see that the pins do not fairly line up with the footprint. It’s because I’ve deliberately altered the footprint within the hope that we will bend these pins outward a bit, as talked about above. But it surely’s precisely the type of factor that the 3D viewer will help you with, to get a visible on the interference and whether or not it seems to be like it should work. Or on the very least, it’d make you return and verify the 3D mannequin is right.

Render of panel, with piezo highlighted in green

This is an interactive 3D mannequin in case you’re particularly eager:

Sorry, your browser would not help embedded 3D fashions.


Should you get your boards made on the lowest tolerances they usually’re under a sure measurement, producers will subsidise the value. It is basically a promotional deal, they cost you virtually nothing as a result of it prices them virtually nothing to chuck tiny boards into the corners and crooks of different panels. I’m wondering what number of different individuals have tried to supply a board with a (nominally) USB 3.2 Gen 2 connector on a two layer, 6/6mil tolerance board.

See Also

Bare board in hand

They did not query my footprint in any respect, and it appears to have been produced with out issues.

The right order of meeting is to do the tiny elements first, and the USB connector final. The through-mount facet of the USB connector means it isn’t attainable to stencil the opposite aspect as soon as it is fitted.

One board assembled still in the panel

The USB connector comes with a plastic cap, to permit you to choose it up with a vacuum nozzle.

Close up of USB-C connector on board

I had deliberate to reflow a bunch of those, but it surely’s so small I ended up doing all of them with the warmth gun. It is attainable (and never that uncommon) to reflow a board with elements beneath already soldered. Even when the solder melts, floor pressure holds them in place. It is also attainable to make use of two completely different alloys of solder with completely different melting factors if it is a concern. However hitting it with the heatgun it is easy sufficient to direct the warmth solely to the place wanted.

If I had reflowed it although, the plan was to stencil and place elements on either side, then reflow the entire thing directly. One thing like the next image:

Mockup of how the panel could be used to support the board

The connector itself would poke by the grating that makes up the mattress of the reflow oven.

Anyway I did not do this, I simply soldered all of them in place because it was approach much less difficult than I might imagined.

Two boards being assembled

Rigorously snap them out of the panel and file the tough edges a bit.

Three assembled boards

After assembling them, I did marvel if maybe I ought to have gone with smaller capacitors in spite of everything. They’re the tallest single elements, and smaller caps are simply accessible. Oops, too late now.

Close up of the capacitors, board held between fingers

As anticipated, the buzzer pins had been a decent match, however there was sufficient play to jam them into place and get the board flush. I then trimmed them to size and delicately soldered the stubs.

Fully assembled

Comically I waited till this second to understand I did not have sufficient piezo buzzers in inventory. I ordered some extra and the brand new ones are a minutely completely different design, which was inevitable. By no means thoughts.

Fully assembled

That vertical-mount USB-C connector was designed to go inside a dock for a telephone or pill. It is alleged to poke by a moulded plastic case, which suggests it is a bit longer than it wanted to be. I did have a take into consideration 3D printing a bit plastic cowl to go over the circuit board and the bottom a part of the connector, however I doubt it might look excellent. We would not need to cowl that mitxela brand anyway.

USB-C extension cables are technically towards the spec, however that does not imply you’ll be able to’t purchase them and all types of different nonsensical cables and connectors. I’ve one which solely works in sure orientations, which is simply so distressing and the alternative of what USB-C was alleged to be, but it surely’ll do to provide us energy whereas I poke that SWIO pin with a probe. I flashed the 4 completely different synths with completely different system names, which helps us differentiate them in a DAW. And by DAW I imply the 1998 version of Cakewalk operating in wine.

Four silly USB-C synths

I then went out of my approach to purchase a four-port USB-C hub. Surprisingly tough to seek out, most of them flip USB-C into numerous extra useful connectors like USB-A, HDMI, SD card, and so forth.

Four silly USB-C synths

I’ve a bunch of the PCBs left, perhaps I ought to make one other handful and get much more hubs?

Apparently the design works with the hub, and it really works if I plug it into my telephone, but it surely would not enumerate if I plug it straight into my laptop computer. But it surely does enumerate on the tip of that noncompliant USB-C extension cable I’ve concocted. It is completely attainable I’ve wired up the USB-C port marginally fallacious, or maybe the resistors aren’t precisely the suitable worth – the kind of USB connection is set by the power of among the pull resistors. Both approach I do not suppose I care sufficient about this comedy synth to look into it a lot additional. It is simply one thing to remember for the subsequent USB-C system.

I’ve put the supply code for this undertaking within the usual places.

Source Link

What's Your Reaction?
In Love
Not Sure
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top