Simple DIY MIDI-to-CV Translator Box
for use with monophonic analog modular sound synthesizers

Another DIY project blog by M.J. Bauer


[ A photo of the finished device will appear here when it's done! ]

Thanks for taking an interest in this project. I hope the design suits your requirements. Otherwise, perhaps you will get some ideas for your own design. Feel free to send comments and queries, either post on the Synth-DIY Facebook group (search for my posts), or email direct to me.

There are other DIY MIDI-CV designs to be found and many commercial products available at reasonable prices, so why would I design and build my own? The primary reason is that I want a device which is compatible with my EWI MIDI controller (REMI 2) which plugs into a MIDI IN socket (DIN-5) modified to supply 5V DC power to the EWI controller. This arrangement is called "Power-over-MIDI". There are other features I want in the device as well, not all of which are provided in other designs.

But most of all, I like tinkering and making things. I don't care if I'm "reinventing the wheel".

Here is my list of requirements (preliminary specification) for the device:

  • Powered by 5V via USB receptacle (micro-B)
  • Classic MIDI IN connector (DIN-5) with "Power-over-MIDI" (5V output)
  • USB-MIDI connectivity - responds to USB-MIDI messages
  • MIDI THRU/OUT connector (jumper-selectable THRU or OUT function)
  • Four (4) CV outputs, 0 to 5V range;  Pitch CV OUT has 12-bit resolution
  • GATE output (5V logic), responds to Note-On and Note-Off messages
  • Self-test/calibrate function initiated by button on front panel
  • Toggle switches (at least 3) to select various modes of operation
  • LED status enunciators (Power, Gate, Fault, etc)
  • Very low cost

Provision of USB-MIDI comm's capability will allow the device to connect directly to a computer, enabling software app's (e.g. DAW or MIDI sequencer) to control modular analog synth's. Provision of a classic MIDI IN (DIN-5) connector allows any old MIDI keyboard or EWI MIDI controller to be plugged in.

Pro Micro clone

A low-end 8-bit micro-controller with at least one high-resolution PWM output pin will suffice. Using PWM for D/A conversion saves the cost and complexity of an external SPI DAC and S&H circuits. However, the PWM signals will need to be filtered.

I chose a Sparkfun "Pro Micro" module based on the ATmega32U4 MCU.  Real cheap Pro Micro clones are readily available on AliExpress. The Pro Micro module has 3 PWM pins capable of 12-bit resolution and another PWM pin giving 10-bit resolution. Plus, the ATmega32U4 MCU has on-chip USB to provide the USB-MIDI capability.

Initially, I plan to develop the firmware with "Microchip/Atmel Studio for AVR and SAM devices" because it is a more professional IDE than Arduino and I am familiar with it.
Further down the track, I will attempt to migrate the program to Arduino because it is very popular among hobbyists. There is an Arduino MIDI code library available for the Pro Micro module, which could save me the effort of coding the low-level USB-MIDI peripheral driver functions.

These sketches show what I have in mind for the front and rear panels...

MIDI-CV front panel sketch

The front panel (above) has 3 mini toggle switches to select modes of operation. The firmware can be customized to suit any particular requirements, of course, but this arrangement functions as follows:

Switch #1 selects the "base note", i.e. the MIDI note number corresponding to 0.0V on the Pitch CV output. The 2 options are note 36 (C2) or note 48 (C3) to suit instruments covering the Tenor, Alto (Treble) and Soprano ranges.

Switch #2 selects either 1 volt/octave or 0.5 volt/octave for the Pitch CV output. When 0.5 V/octave is selected, switch #1 setting is ignored and the "base note" is set to 12 (C0) or whatever else may be hard-coded in the firmware. The maximum CV output level is 5 volts, so the range is limited to 5 octaves when 1V/oct is selected.

Switch #3 selects the MIDI message type associated with CV output #4 to suit the type of MIDI controller plugged in. An EWI controller (e.g. Akai 4000s, REMI 2, etc) sends Breath Pressure messages (CC2), whereas a MIDI keyboard may send Expression (CC11) or Channel Volume (CC07) messages. In any case, output CV4 would most likely be patched to a VCA control input on the synth to control the audio amplitude.

Also on the front panel is a push-button switch. Its main function is to initiate a self-test/calibrate routine to check and adjust the CV outputs' volts-per-octave transfer characteristic. Another button function sets the MIDI channel number and Omni On/Off mode.  If the button is pressed within 3 seconds following power-on, the toggle switches select 1 of 8 options encoded as a 3-bit binary number;  i.e. 000 = Omni On,  001 = channel 1 (Omni Off), 010 = channel 2 (Omni Off), 011 = channel 3, ... 111 = channel 7 (Omni Off).

The 2 LEDs indicate the device status in the current mode of operation.  (Details TBA.)

MIDI-CV rear panel sketch

The rear panel has a 5-pin DIN socket which can function either as 'MIDI THRU' or 'MIDI OUT', selected by a hardware jumper. In 'MIDI OUT' mode, the transmitter is driven from the MCU (UART TX pin), so the firmware gets to decide what messages are sent, on what channel and when.  (Details TBA.)

A 'Gate' output (5V logic) and four CV outputs are provided on the rear panel using 3.5mm TS (mono) phone sockets. If you're patching into a Moog 'System 55' modular synth (for example), you'll need adapter cables with a 3.5mm plug at one end and a 1/4 inch phone plug at the other end.

The four CV outputs are nominally 'Pitch', 'Velocity', 'Modulation' and 'Expression' to suit MIDI messages commonly implemented by MIDI controllers, including EWI's of course. You might want to substitute Expression with After-Touch on CV4, if you are using a keyboard which supports After-Touch.

The yellow 'GATE' LED illuminates while the Gate output is asserted (High).

I'm not sure yet how to handle Pitch Bend messages.  What do commercial MIDI-to-CV devices do with Pitch Bend data?  Do they provide a separate CV output, or is the Pitch CV output level adjusted according to the amount of bend (data in the Pitch Bend message)?  For my purposes, I would choose the latter.

In this instalment, I'll begin with a look at MCU I/O pin allocation. Does the Pro Micro have enough I/O for the application? (Spoiler: Yes!) Then I'll explain the trade-off between PWM resolution and carrier frequency. Again, we'll see if the ATmega32U4 can meet the specified performance requirements.

This image shows the MCU pin allocation. All required signals are catered for, without a single spare I/O pin!

mcu pin alloc

What if there were not enough I/O pins?  An easy solution would be to use an I2C I/O port expander, assuming only digital I/O's were needed.  Adding analog inputs gets messy... that would involve a multiplexer. When a design crosses that line, it's often better to choose an MCU module with more I/O.

Four analog inputs (A0..A3) will be used to measure the voltages on the CV outputs, in the self-test and calibration routine. The ADC can be configured to use the MCU's internal precision reference (1.1V) to measure the supply voltage (Vcc) on ADC8 (pin 4) via a 5:1 divider.

PWM Resolution and Filter Response

The CV output used to control synth oscillator frequency (pitch) needs to have high resolution. 16 bits would be ideal, but using a modest 8-bit MCU with a CPU clock frequency of 16MHz, a PWM resolution of 16 bits (1/64K) would allow a maximum PWM frequency of (16MHz / 64K) = 250Hz. This is way too low because the response time would be too long.

Using PWM to make a D/A converter (DAC) requires the PWM "carrier" frequency to be eliminated. Practical (i.e. simple) low-pass filter circuits using a single op-amp are limited to 3rd-order designs, giving a roll-off slope of -60 decibels per decade. The attenuated PWM signal amplitude should be no greater than 1 LSb (least significant bit) of the DAC output at full scale.

The PWM filter time-constant, i.e. reciprocal of the cut-off frequency, is a fair measure of the response time, i.e. the time it takes for the CV output voltage to respond to changes in the DAC digital value (PWM duty).
In reality, the "settling time" or time it takes for the output voltage to settle within an acceptable tolerance, is much longer than the filter time-constant... maybe 5 to 10 times longer. 
For the Pitch CV output, a response time up to about 2.5ms could be tolerated (with some compromise which I will explain later). The corresponding filter cut-off frequency is therefore 1000/2.5 = 400Hz.

So let's try for 12-bit resolution, which would be quite acceptable for the intended end-user application. The DAC LSb is about 1/4000th of full-scale, corresponding to a filter attenuation of 52dB. This is achievable with a 3rd-order filter, but what about the response time?  With MCU timer clock freq = 16MHz, the PWM frequency is (16MHz / 4000) = 4kHz. For a third-order low-pass filter, 60dB attenuation occurs about one decade higher than the cut-off frequency, so Fc = (4kHz / 10) = 400Hz. This corresponds to a time-constant of 2.5ms which is in the right ball park.

It's time to design a filter. 

From the foregoing theory, we know that the filter should have a cut-off frequency of 400Hz or higher and an attenuation of at least 52 decibels at the PWM frequency, 4kHz. I chose a 3rd-order filter comprising a 1st-order stage cascaded with a 2nd-order Sallen-Key configuration. You can find more theory here:

Second-order low-pass filters

To verify the filter design, I ran a simulation in LT-spice. The circuit is shown below. Normally the first stage would consist of only a resistor (R1) and capacitor (C3). However, to obtain the desired Butterworth filter characteristic, the pass-band gain, Av = 1.6. At high values of PWM duty, the op-amp output would clip at the +5V supply. To allow the full 5V output range, the PWM signal input to the filter must be scaled by a factor of 1/1.6. This is achieved by adding a resistor (R7) to form a voltage divider. But placing a resistor in parallel with capacitor C3 alters the filter frequency response, reducing the roll-off slope from -60dB per decade to -52dB/decade. Fortunately, this still meets the design criteria, as can be seen from the Bode plot.

LPF circuit

The composite 3rd-order filter frequency response is the solid magenta (pink) trace. The output amplitude at 4kHz is almost exactly -52dB, as required. The dotted trace is the phase shift curve which is of no great significance in this application. The green traces are for the first stage of the filter, taken from the high side of capacitor C3. Note that the pass-band amplitude is lower than that of the composite output due to the action of the voltage divider, R1 & R7 at the input. 

LPF plot

Apart from verifying that it works as expected, another benefit of simulating a circuit before you build it is  you can fiddle with component values to see how critical they are to the circuit's operation. For example, the filter pass-band gain is set by resistors R5 and R6. To obtain the optimal (flat) response, the gain (Av) should be 1.6 which means R6 should be 20k. I found that using the more common value of 22k made negligible difference to the filter response. Likewise, using 100nF for C3 made only a small change to the attenuation at 4kHz, i.e. 49dB instead of 52dB.

The Pro Micro module provides 3 PWM pins capable of 12-bit resolution at 4kHz and another PWM pin giving 10-bit resolution at 16kHz. It would be possible to implement two more CV outputs with 12-bit resolution, but the other 3 CV outputs are not as critical as the Pitch output, CV1.  Hence, in the interests of simplicity, I decided to make CV2, CV3 and CV4 all 10-bit resolution at 16kHz. Also, the response time of these 3 CV outputs is not as critical as CV1, so their filters can be a simple 1st-order RC circuit. 

Let's do the math again. A 10-bit DAC has LS bit = 1/1000th of full-scale.  As noted earlier, the PWM filter attenuation should be a similar value.  If we choose a CV response time of 5ms, the filter cut-off frequency is 200Hz. A 1st-order filter has a roll-off slope of -20dB per decade.  Between 200Hz and 16kHz is roughly 2 decades, so we can expect an attenuation of about 40dB at 16kHz. 40dB represents 1/1000th of the pass-band output amplitude, so once again, conveniently, the design criteria have been met.


... to be continued ...

(Next instalment:  Complete circuit, MIDI TX/RX options)

Other projects by MJB that you might be interested in:

'REMI 2' - EWI MIDI Controller

'REMI  Synth' - Monophonic digital synth  (based on PIC32 MCU)

Send email enquiries, comments, suggestions, etc, to...

link to email address

Last update: 13-MAY-2024

MJB's Home Page