Prototyping a Midi to CV module with more functionality than existing offerings

Hi again all,
I’m looking for a handy solution to conveniently buffer six gate signals from my Arduino, and I think I might be onto something. I remembered I have some of these laying around:
The CD4050BE

I believe this chip was originally intended for logic level shifting, but if I’m not mistaken, I can literally just connect the chip to 5V and GND, connect the Arduino pins to the inputs, and get buffered signals at the output without so much as a resistor involved. This should also boost the level from 3.3v on the teensy 3.2 to 5v for the gate signal, and all six gates can be run through a single chip.

Is anyone familiar with this IC, or aware of a reason why this might be a good/bad idea? I saw in one demo that for some reason the chip was causing interference with the power rail, which did make me raise an eyebrow (here is the link: Drive LEDs Without Resistors - Hex Buffer CD4050B Has A Trick Up Its Sleeve - Simply Put - YouTube). For $0.62 a whack though, I could see this being a handy circuit building block for a lot of folks if it does what I think it ought to.

Looks kind of like the CD4504 though with some differences in how the level shifting works. The 4504 is used in the 1007 Midimuso to level shift the PWM signals.

If you have a corporate or academic email address, you can access free samples of most of the Microchip products here. The website is a little tricky to navigate as you have to make an account, log in to the main website, then the samples website. The MCP4822 is under Data Converters/Analogue to Digital Converters/MCP4822. Click the tiny grey button next to the correct package(double check!) Then to increase the amount from 2 to 5 you have to go to manage cart/change amount to 5/update cart.
In the UK at least, it usually takes around 2 weeks to arrive.

I have a few of these; I tied the reference pin to the 5v rail with no issues.

Hope that made sense :grinning:

Interesting hack, Sonosus, I might give it a try at some point.

To anyone interested - I’m making some progress on this circuit, and I think I may have found a nice workaround for the loss of resolution when using volt-per-octave outputs for a midi CC. I noticed that the MCP4922 has an internal gain setting of 1 or 2, which I believe can be toggled any time by the Arduino. This means if I make proper use of the Vref and op-amp gain to get volt-per-octave at a gain of 2, I can simply toggle the DAC to unity gain to halve the range and double the resolution with no need to switch hardware. Should be quite handy, although I’m still figuring out how negative pitch bend voltages are going to work, or if I should even try.

1 Like

at 12 bit, I can hardly imagine that the “steppiness” in a control voltage other than v/oct would be perceivable. I would worry more about the pitch signals.

If you would want to cover a full 10 octave range, a 12 bit DAC gives you (10 oct * 12 semitones/oct * 100 cent/semitone) / (2^12 bit) = 3 cent resolution. I’d consider this on the verge of acceptable, anything above 5 cents will generally be perceived as ‘out of tune’.

This is, however, considering a perfect DAC. The MCP4922 has a maximum INL of 4*LSB, giving you a 12 cent difference at worst.

1 Like

Yes, and Elkayem’s earlier DIN MIDI to CV, which is what my MCVI is based on, does make use of that (that’s the “different modes of the DAC (selected by the software)” I mentioned) in addition to different output gains.

My understanding is that pitch differences of 3 cents are the limit of what a trained ear can distinguish, so I’d call it definitely acceptable. (Though even smaller pitch differences can lead to audible differences in beat frequencies between two notes played simultaneously; if you’re worried about that, then you need probably at least 16 bit resolution.)

Right, and there was some discussion of that elsewhere. In principle, you can map the nonlinearity of a particular DAC and correct for it in software. Something I want to consider for MCVII. (In fact you can even map and correct for the nonlinearity of a particular DAC/VCO combination, if you want — compensating for VCO nonlinearity too.)

Add: Also, as pointed out here, if you pick just the right voltage reference value for the DAC, it’s possible to get 0 cents maximum resolution error (for MIDI notes, not for arbitrary pitches)! You lose about half an octave of range if you do that, though. And it probably doesn’t work with nonzero nonlinearity. Not really worth it.


This is a lot to take in, but I really appreciate everyone weighing in. I’d probably be willing to tolerate a slight reduction in range to get better accuracy, but I think I need to get everything up and running before I worry about all that. After this build I’m gonna need a break from building to just play some music!


Hi all,
I’ve made a lot of progress on this project and I am ready to start posting some updates, but there is one problem I just can’t seem to track down - my 5 pin midi input circuit is just NOT working for some reason. Here is a snippet of my layout, specifically for the midi in circuit (Midi out works fine):
midi troubleshooter capture
The big long ICs are a stand-in for a Teensy 3.2.

Here is the circuit it is supposed to represent:

A-49 is the Teensy 3.2 ground
B-49 is RX1
C-49 is TX1 (working fine)

A-55 is VIN (5 volt)
C-55 is regulated 3.3V out

I can’t think of any earthly reason why this doesn’t work, and I’m reasonably certain my real life circuit matches the layout I posted above. Would anyone with a fresh pair of eyes mind taking a peek to see if I am overlooking something silly?

Somehow this relatively simple step is the last bug to squash on a board with 12 DAC channels and 8 buffered gates - go figure. Thanks all.

Note that 6N138 is not a great choice for MIDI (though it’s commonly used anyway).

Verify you have the MIDI connector pinout right, it’s easy to get it mixed up and it’s described incorrectly in some places.



Thanks Analogoutput - I wasn’t aware of those IC options in DIY LC. I did try inverting the connections to no avail. I’ll certainly check out the 6N317 when I next go shopping.

It sounds like you didn’t spot any obvious errors in the layout, so it must be something physically incorrect with my build. I think at this point I’m just going to make a new midi input circuit on a separate daughter board and pipe the connections over.

1 Like

Have you put a scope across the 220R resistor, and from the 6N138 pin 6 to ground?

1 Like

Try using a 100 or 68 ohm resistor instead of the 220r. The LED inside the optocoupler might not be getting enough current to turn on.

1 Like

Thanks for the replies, guys. After literal hours of troubleshooting and ignoring my partner who would like to spend time with me, I finally stumbled across this forum thread recommending I add a 1K resistor from pin 7 of the optocoupler to ground:

This fixed the problem immediately, though not before I’d wasted my time adding a needless extra midi input daughter board thing to my project. With this final hurdle, I think I’ve completed the hardware aspect of this project, and will be moving on to software. I’ve used test code to confirm all my DACs, gates, oled screen, rotary encoder, button, 10 position rotary selector switch, and various midi and USB IO all works, so now comes the simple task of wading through integration hell for a month while ignoring my other life responsibilities. Progress photos coming soon.


This project is in a satisfactory state hardware wise, though I think I may need to come up with a better solution for the reference voltage. Here is a brief photo-journal of the process for anyone interested:


Here is the current hardware feature list. Each element has been tested with a few lines of test code, but much of it is not yet truly implemented in the software:

Midi USB in/out (also used for re-programming)
5 pin midi in (second input available, but not connected to front panel)
5 pin midi thru x 2
64x128 oled screen
rotary encoder with push button for menu
10 position rotary switch (preset selection)
12 buffered DAC outputs (12 bit)
8 gate outputs (5 volt, buffered)

I would like to implement a menu system that allows the function and midi channel for each output to be selected and saved to one of ten preset slots, eventually with assignable paraphony/polyphony groups for the oscillator CVs. Some of this is a ways down the road.


Holy cow, it’s been a long …checks OP date … 6+ weeks of working on this project, and I am super stoked to say that it’s done enough for now.

There are 10 presets that can be copied/saved to EEPROM, and all 12 CV outputs can be mapped to Note (first/last/high note priority available, tuning offset definable), CC (specific cc no. is user definable), or velocity, all of which can be set to a specific midi channel. All gates can also be set to a specific midi channel.

This is a little difficult to describe, so I plan to post a video soon-ish, and clean up my code to go on GitHub. This project saves a ton of space in my rack and has really allowed my synth to come alive in a way it never has before. I am so stoked on this project. If anyone else is interested in building one, I will try to get a guide worked up in the coming weeks. I need to refocus on some other life stuff at the moment, but man does this feel good.


Hi all, this project is really coming together except for one major problem. I think I have set up my voltage reference wrong, because is shifts periodically, throwing off the tuning. I can’t seem to find much literature on designing reference voltages, so I tried to follow LMNC’s example for the reference voltage in the tuner vco, however my adaptation does not seem to be working. Here’s what I did:

edit: the potentiometer there is a 100k trim pot. the desired voltage is right around 2.06 or 2.07 volts

Does anyone know a better way to get a super stable reference voltage, either from the 12v rail or the 5v regulator? thanks a million,

I’d think that’d be fine. What exactly are the symptoms? How much is it varying? Is it unstable at the LM4040 cathode?

The datasheet has what you need to design it:

(There’s more details below that.)

Assuming high impedance on your VREF load (is it?), current through the fixed resistor, I_Q+I_L, is (12-4.1)/4.7k = 1.7 mA and through the pot, I_L, is 4.1/100k = 41 µA. So I_Q = 1.7 mA, which is well within the acceptable range, and power on the resistor is 1.7 mA x 7.9 V = 13 mW, which is no problem.

You’ve tried replacing the LM4040?

1 Like

Thanks for the analysis, analogoutput. I found I had connected the shunt incorrectly and had to kludge it, I suppose I can replace it to determine if my earlier error damaged it. I find the vref will vary from about 1.8 to about 2.3 volts. The impedance should be high, since my code activates the input buffers on the DAC vref inputs. I’ll try replacing the shunt. would this circuit in any way benefit from being supplied by the 5v regulator rather than the 12v rail? I’ll do some experimenting tomorrow.

This thing will play beautiful music for hours at a time and then suddenly go out of tune - sometimes between power cycles, other times mid arpeggio. Strangely, the voltage swings all at once, rather than drifting slowly. I’m kinda wishing I’d gone with the DACs that have their own internal voltage ref.

1 Like

I soldered down a new LM4040Aiz-4.1 (my third one at this point) making positive that the orientation was correct. Had a great jam for about half an hour and then boom - VREF swung to about 1.89 and everything went flat. What a head scratcher. I don’t know whether to keep investing time in this or just learn to make custom PCBs and have a proper one made using the DACs that don’t need an external ref. Sad time, I was looking forward to being done with this!