AO MCVI MIDI to CV

This is a simple MIDI to CV synth module in Kosmo format. Of course there is already the LMNC Midimuso module, but I decided it does more than I need. Mainly I’m using MIDI to plug in a keyboard to a monosynth, so I don’t need six MIDI channels and 18 outputs, and devoting 10 cm of my case to a module I’d only use less than a third of the capability of didn’t seem to make much sense.

Hence MCVI (MIDI to CV mark I). It provides pitch and velocity CV, gate, and trigger for Note On events as well as pitch bend and modulation CV for one MIDI channel, and 1- and 4- pulse per quarter note clock outputs.

This project is adapted from https://github.com/elkayem/midi2cv.

It handles a range of 88 MIDI notes, corresponding to a standard piano keyboard, using a 12 bit DAC. CV output is 0 V (for MIDI note 21, A0) to +7.25 V (MIDI note 88, C8). Note selection in case of multple keys pressed is governed by a switch selecting lowest note, highest note, or most recent note priority.

Pitch bend CV range is 0 to +1.0 V (0.5 V when centered). Velocity and modulation CV range is 0 to +4 V. Gate, trigger, and clock outputs are +5 V; trigger and clock pulse width is 20 ms.

The module is built around an Arduino Nano. The sketch uses the standard MIDI and SPI libraries.

While the LMNC module is more than I need, this is just about sufficient for now. But sooner or later I’ll probably want another MIDI channel or three and some more configuration flexibility. So I’m already thinking about MCVII. But I decided to get this quick and easy module done for now, and then I can come up with something better at my leisure.

Schematics, Gerbers, and documentation are here:

I have a few board and panel sets up on Tindie.

10 Likes

Looks awesome! If I didn’t just start putting together my LMNC, I would have snagged one of yours!

Are you entirely “DAWless”?

very nice and tidy I love it and really like it alot. Very great documentation

1 Like

Bookmarking this shit for later. Looks great, perfect for my needs since im just mono voice anyways with my modular.

1 Like

I calibrated the pitch CV today.

McGovern’s software takes notes in the range A1 to C8, the range of a standard 88 note keyboard, and maps them to 0 to 4095 mV output from the MCP4822 12-bit DAC. Then this voltage is amplified by 1.77 to go from 0 to 7.25 V, which is 1 V/oct.

In principle, anyway; but if the actual gain of the output stage is different from 1.77, then the output will not be an accurate 1 V/oct.

I took some measurements, starting with looking at A in various octaves and finding I was getting, for example, 5.965 V instead of 6 V for A7. I measured more voltages, converted them to cents (1 V = 1 octave = 1200 cents) and made a plot:

The horizontal axis is MIDI note number (21 = A1, 108 = C8) and the vertical axis is the difference in cents between the measured value and the correct one. Clearly my output stage gain was a little low, I thought, by about half a percent.

So I went into the code and changed the constant of 47.069 (= 4095/87) used to calculate the output voltage to 47.069 × 1.005 = 47.304. This at first had the unfortunate effect of making C8 produce about 0 V, because the code was taking only the lowest 12 bits of a number larger than 4095, so I changed it to truncate to 4095 instead. With those changes in place, the new measurements looked like this:

That looks a lot better. C8 is still quite bad, more than a quarter tone off, because it’s been truncated to the maximum voltage the DAC can produce, but that’s just one little-used note. In the middle range the errors are mostly below the 5 cent level, which should be fine for most purposes. But at the high end and to a lesser extent at the low it’s worse, and there’s also a bad spot near the middle, MIDI note 52 being still about 10 cents flat.

All of which I think can be blamed on only one thing, and that is DAC nonlinearity. The MCP4822 has a typical integral nonlinearity of ±2 LSB, per the datasheet, with minimum and maximum ±12 LSB. Differential nonlinearity is ±0.2 LSB typical, ±0.75 LSB maximum. Here 1 LSB is 1 mV from the DAC or 1.77 mV at the output, which is 2 cents.

Then it occurred to me to try swapping the two DACs on the board and seeing how the other one behaved. That turned out to be a bit of a mess because I bent a pin on the other DAC in the process, and trying to straighten it out and re-insert it only caused it to bend again. Finally I gave up and swapped in a new chip.

And surprise!

Now the scale is off by about 0.5% in the other direction! But all I changed was the DAC. So it must be the voltage scale of the DAC itself that’s the problem, or part of the problem. (I shouldn’t have been surprised. The datasheet says the internal reference voltage tolerance is about ±2%.)

I ended up changing the scale factor to 47.022, just 0.1% less than the nominal value, and got this:

Decidedly better than with the other DAC. Still a little ugly at the bottom and uglier at the top, but the mid range looks great.

But compare with what I think you’d see from a perfectly linear 12 bit DAC:

That’d be quite an improvement! In the real world maybe there’s a DAC with better specs I could use for MCVII, or maybe just selecting the best of several MCP4822s is good enough.

4 Likes

Nice! What a project!! At the point where you select the DAC, wouldn’t it make sense to implement non-linear corrections? Like tuning each note according to measurement? I think the bastl midi2cv does something like this, even looking at osc frequency. So also the osc nonlinearity is corrected for. Almost cheating :wink: their stuff is mostly open source.

edit: Bastl 1983 Eurorack Module – Polyphonic MIDI to CV Interface this is the module I meant. I could not find this on their github, so maybe it’s not open source, but I found these two, which look like they might have been used there:
eurorack/calibrationDAC at master · bastl-instruments/eurorack · GitHub
eurorack/calibrationADC at master · bastl-instruments/eurorack · GitHub

2 Likes

That thought did cross my mind. Might be a good idea.

Great work! thanks for posting the charts!

Here’s something cute but probably pointless. The module is intended to cover a range of 88 notes, which is 7.25 octaves, so it maps 0 to 4095 counts to 0 to 7.25 V. But suppose you decided a few of those notes at the top and bottom are useless, and you only care about 6.825 octaves, so you modify it to map 0 to 4095 counts to 0 to 6.825 V. Then for a perfect DAC (no nonlinearities, no gain errors) the differences between actual and correct output voltages looks like this:

chartx

Yes, that’s the correct plot. The arithmetic happens to work out that the resolution error is zero for every MIDI note! The reason has to do with the fact that 4095/12 is an exact multiple of 6.825 (in fact it’s 50 x 6.825), which turns out to mean 1 LSB corresponds to exactly 2 cents frequency change.

The resolution error is already small enough that it’s not really worth throwing away 0.425 octaves to reduce it to zero, but I thought it was amusing.

1 Like