Introduction: Another MIDI to CV Box
Another MIDI to CV box is a project I developed when a Korg MS10 knocked my door and took place in my studio. Being that my setup heavily relates on MIDI to automate and syncronize all the instruments, when I bought the MS10 the first problem I had to face was how to implement such control.
Korg MS20/10 are not the easiest synths to implement MIDI to: first of all, they rely on Hz/V control (linear correlation between the control voltage and note frequency), instead of oct/V (1V per octave); second, to trig a note you must send a negative gate signal and short the input to ground (S-Trig), not a +5 V signal (V-trig).
There are various commercial solutions to control such instruments nowadays (i.e. Arturia Beatstep Pro, Korg SQ-1, Kenton Solo) but I am a cheap bastard and even 100 euros are too much for a "not sounding" device :).
Here we are then: let me show you how to build a low budget MIDI to CV box to control/automate a pre-MIDI synth's pitch, gate, velocity and cutoff frequency with an external MIDI controller (Keyboard, DAW, sequencer or whatever).
"What about the new MS20 mini?"
As almost anyone know, the new MS20 is actually MIDI ready :IN with a 5 poles MIDI connector and IN/OUT with USB connector.
"So, if I have a MS20 mini this thing is useless!"
Well, no. MS20 mini recognize only note on/off messages and keyboard is not velocity sensitive. There's no way to overcome this with the MS10/20 vintage or mini keyboard, but with midi box and a velocity sensitive keyboard you are golden. In addition, with the MIDI box you can automate filter cutoff (or any other voltage controllable parameter) or have it modulated by the incoming MIDI note on velocity. Again, the only MIDI channel MS20 mini responds to is channel 1. With this box you can overcome this limit too.
"What if I have a Oct/V synth?"
No problem! The code I wrote is compatble with Oct/V synthesizers (untested, but I am confident that will work out-of-the-box ;)).
Step 1: !! Note of Caution - Disclaimer !!
Your equipment is very valuable and should not be used to perform tests.
Toying with electricity can severely damage your equipment or harm yourself.
I cannot be held responsible for damages to your equipment/hardware or even yourself coming from any of the software or schemes or informations or links I reported in this instructable.
You have been warned!
Step 2: Engineering the Hardware
Arduino comes handy when dealing with projects like this. The existence of a big Community and very good libraries that span almost every common task make it the right choice. Here the board will be programmed such that it will read incoming MIDI data and then will send appropriate voltages to drive:
- Pitch, by converting a pwm output into an analog voltage to drive the VCO via a digital to analog converter (DAC)
- Velocity,by filtering a pwm output to drive the VCA with a simple RC filter
- Filter Cutoff Frequency,by filtering a pwm output to drive the VCF with a simple RC filter
- Gate, directly from a digital out in case of V-trig (put a 1Kohm in series with the output to reduce the current drain) or by a simple pnp transistor switch out of the digital out (see schematic attached to the schematics step).
Arduino is not capable of outputting directly steady voltages, but 0/+5 V pulses with various periods (PWM). We are in the need for digital to analog converters (DAC) for the pourpouse. RC filters are the easiest DAC I can think of. A RC filter is good enought for the voltage controlled amplifier and filter (VCA and VCF). The RC filters are tailored to result in a cutoff frequency < 20Hz (lowest audible frequency).
I made some test with low capacity non polarized capacitors and I ended with a capacity value of 0.1uF to be the best fit. Tested good on a MS20 MKII.
Unfortunately, we can't rely on a RC filter to drive the voltage controlled oscillator (VCO) since it would be not accurate enought (in Hz/V scale, on the lower end two adiacend semitones differ for less than 0.02V; in V/oct two adiacent semitones differ for 0.083 V); we are going to use an IC DAC (MCP4725) for this.
Known Limits
Limiting the drive voltage to 5V (the Arduino output voltage), the full 0 to 5V range is covered for velocity; the cutoff is half covered (-5V to +5V); the VCO range is partially covered being that in Hz/V a voltage of 8 V would be required to reach the 440 Hz A4. With a 5V output limit we can pitch the oscillator up to the D4 frequency in Hz/V.
Step 3: Components List
You are in the need for:
1X Arduino UNO (or nano)
1X MCP4725 DAC board
4X 1/8" or 1/4" mono connectors
1X MIDI connector
1X 6N138 optocoupler
1X 1N4148 diode
1X 220 ohm 1/4 W resistor
1X 470 ohm 1/4 W resistor
1X 10K ohm 1/4 W resistor
4X 1K ohm 1/4 W resistor
2X 0.1 uF capacitor
1X BC547 npn transistor (in case of S-trig)
1X ABS box (at least 55 x 70 x 100 mm)
... and obviously breadboard or perfboard, solder iron, solder wire and cables (2 meters of 28 AWG should be enought).
Notice that in the pictures above my prototype mounts 100 uF electrolitic caps, but they are too slow because of the capacity charge time. A capacitance of 0.1uF is the right choice.
I used a additional connector to supply power to my arduino; it's not necessary being possible to juice the microcontroller directly via the onboard mini USB connector.
Step 4: Connections/Schematics
MIDI IN
The MIDI IN circuit is simple and well described on the net. Take THIS excellent instructable on MIDI and Arduino by Amanda Gassaei, for instance. I made the nth schematic on the matter anyway.
Notice that i added a switch in the MIDI IN scheme (switch 1): this is necessary when uploading a new sketch to Arduino because the opto interfere with the RX line even without incoming midi messages. You must open the switch before uploading your sketch or the IDE will fail to upload the new sketch.
You can eventually modify the sketch to use a serial software communication.
DAC, RC Filter, Synthesizer
Connection for DAC, RC filters and Synth (pitch, gate and velocity) are shown in the diagram on top. I took for reference a Korg MS20 patch panel, but I tested everything on a MS10 too. The direct connection of the velocity CV to VCA "initial gain" patch point has no effect (I must dig this thing further) but if you connect it to the "Total" patch point and rise your total external pots (MG/T.EXT), you will hear nice tone variations as a function of the note velocity.
My schematics (and my prototype too) do not use a current limiting resistor at the DAC output, but it's always a good idea to place one to ensure long life to your circuits. A 220 ohm resistor will be enought.
Notice that in the schematics above 100 uF electrolitic caps are reported, but they are too slow because of the capacity charge time. Non polarized, 0.1uF caps are the right choice.
Gate Out
In case you are going to sequence a synth compatible with V-Trig (voltage trigger) signals, a 1k ohm series resistor to reduce the current drain will be sufficient; in case of a S-Trig (switch trigger) synth, you could use a simple npn switch circuit (see attached scheme).
Step 5: The Software
I tried to keep the sketch as clear and "readable" as possible.
I worked on a simple calc sheet i found HERE to derive a Voltage Vs Note# curve and use directly the equation in the microcontroller. The equation is shown in the graph on top. I used C2 as reference note to obtain a Arp/Korg compliant Voltage Vs note relation (C0 - 0.25V, C1 - 0.5V, C2 - 1V, C3 - 2V, C4 - 4V, C5 - 8V and so on).
I had to define some variable to toy with in order to get a good tuning... take your time to find the correct values. A tuner is necessary.
We are going to increase the pwm frequency of a Timer/Counter to reduce output voltages ripple (as easy as a line of code).
To keep the code responsive to incoming bytes, the code rely heavily on functions callbacks.
You are in the need for the Sparkfun's "Adafruit_MCP4725.h" and Forty Seven Effects/Francois Best's "MIDI.h" libraries to compile! (Many thanks to these persons: without their efforts this project would never be realized!).
I will assume you have Arduino IDE ready in your PC and you know how to load a sketch to your Arduino board.
I am not a coder in real life, so it is well likely that the sketch could be written in a better way. I am open to suggestions (I always learn something looking at coder's code ;))
Additional notes are written in the code below. Install the two libraries, open the attached code on your IDE, connect your board, select the type of board and upload.
Attachments
Step 6: Troubleshooting
Even if the project is low level, there are tons of things that could go wrong. If you are experiencing issues while attempting to create your own MIDI to CV box, follow these steps:
1. Be sure that Arduino is correctly receiving MIDI messages
Check the output channel your keyboard or DAW or Sequencer is outputting MIDI messages to. Arduino is listening to channel 1 by default. Upload "TEST_MIDI_IN.ino" to read a incoming noteON message.
2. Double check your wirings
... or even better: triple check them! Keep your time for this.
3. Check the DAC address and output
The DAC could be set to receive data on a different address than the one i set in the sketch. Check the address by running "I2C_scanner.ino". If a "no device found" error happens, check your DAC wiring (SDA and SCL inputs are different on different Arduino boards!). If you have an oscillocope (even those 15 euros digital oscilloscopes are good enought... and fun to toy with!) you can check the output of your DAC by uploading the trianglewave generator example included with the DAC library installation.
Remember that when a optocoupler is connected to the RX input of your arduino board, you will not be able to upload a new sketch!! Place a switch (it could be a simple jumper) before the RX pin.
Most of these test sketches are not mine or at least based on existing online material.
This thing sounds out of tune to me!?
This is not a real issue: the equation derived for Hz/V control is "ideal". Some drift from the ideal behaviour can rise from the +5V you are supplying being not 5.000V, from the DAC and from the instrument itself. To solve you must act on your synth tune/fine tune potentiometer and "voilà" a perfectly tuned MIDI control ;)
Step 7: Useful Links
https://en.wikipedia.org/wiki/CV/gate
https://www.instructables.com/id/Send-and-Receive-...
http://www.songstuff.com/recording/article/midi_me...
https://pages.mtu.edu/~suits/NoteFreqCalcs.html
https://espace-lab.org/activites/projets/en-arduin...
https://learn.sparkfun.com/tutorials/midi-shield-h...
https://provideyourown.com/2011/analogwrite-conver...
https://www.midi.org/specifications/item/table-3-c...