MIDIXCV - MIDI to Multiple Control Voltages Converter
by baritonomarchetto in Circuits > Electronics
2984 Views, 18 Favorites, 0 Comments
MIDIXCV - MIDI to Multiple Control Voltages Converter
In 2021 I published a project about a MIDI to CV converter capable of generating up to four control voltages and four digital signals from MIDI messages. It was built around an Arduino nano and a MCP4728 DAC and has been the brain of my DIY paraphonic modular synthesizer for all these years.
Recently I added some functionality to the firmware and soon I found myself with new ideas and enough motivation to take the project back from the drawer and start something new.
I ended up developing a multi control voltage module with eight analog outputs, each having enought resolution to handle notes pitches.
But it's not only this.
The hardware I layed down can be extended to up to 32 (thirty two!) analog voltages and four more digital outs.
The octaves range, limited to four in the previous MIDI to CV converter, has now been extended to eight.
Being the firmware open source, the code can be modified to handle any sort of incoming MIDI message (note on/off, note number, velocity, pitchbend, aftertouch, control change, program change and so on) and convert it to a convenient voltage via user definable functions. Is it flexible enought? :)
In this instructable:
- I will show the 8 outs module and how it is layed down
- I will show how easy it is to add additional analog outs
- I will give details about the circuits that make all this possible
- I will share with you all the files needed to have the three (plus one) boards that constitute the module manufactured, thus speeding up the whole build process
- I will share all the necessary files to program it at home with no special devices (thanks Arduino!)
- I will give you hints to realize your module.
Let's go!
Supplies
Main Board
4x PJ324M (stereo or mono) female jack socket
1x MIDI DIN 5 (DS-5-01 for PCB mount or DS-5-07A for panel mount)
1x MCP4728 12-bit DAC
1x 6N138 opto coupler
1x TL074 operational amplifier
1x CONN 08x2 IDC connector
1x DIP-4 switch
1x 1N4004 diode
1x 1N4148 diode
5x 1000 ohm resistors
1x 220 ohm resistor
1x 330 ohm resistor
2x 4.7 K ohm resistors
8x 10K ohm resistors
4x 100 nF capacitors
2x 10 uF electrolitic capacitors
1x 8-pin female header
1x 11-pin female header
Analog Board
4x PJ324M (stereo or mono) female jack socket
1x MCP4728 12-bit DAC
1x TL074 operational amplifier
4x 1000 ohm resistors
8x 10K ohm resistors
1x 100 nF capacitor
1x 8-pin female header
1x 11-pin female header
1x 8-pin male header
1x 11-pin male header
1x 3-pin male header
Digital Board
4x PJ324M (stereo or mono) female jack socket
1x TL074 operational amplifier
4x 1000 ohm resistors
8x 10K ohm resistors
1x 8-pin female header
1x 11-pin female header
1x 8-pin male header
1x 11-pin male header
Calibration Pad
4x tact switches
1x 8-pin male header
1x 11-pin male header
You are also in the need for a soldering station, some solder wire, a magnifiying glass and some spare time (well spent, if you ask me ;) )
Hardware Configurations
As anticipated, the project is made up of three (plus one) boards:
- Main board
- Analog board
- Digital board
- (Calibration pad)
A modular module is not such without a front panel, so I also layed down a dedicated one :)
Main Board
Main board is the hearth of the project. It hosts the microcontroller board (Arduino NANO 328p), the MIDI input circuitry, a power supply filter section, a digital to analog convertion stage and a final amplification and protection stage.
The main board is stand alone, which means that if your project calls for 4 analog voltages, you need no more than that.
A DIN-5 MIDI connector can be directly soldered to the main board PCB, but this will make the module front panel not compatible with the PCB's stack. I use MIDIXCV this way, securely anchored to the bottom of my DIY case (there's some free space in the bottom). Alternatively you can adopt the Eurorack compliant front panel I layed down, but please notice that a different MIDI connector must be used (see attached pictures).
Analog Board
An analog voltage is a voltage that can assume any value in a given voltage range (e.g. 0 to 5V). Analog boards (please notice the plural) are intended to increase the number of analog output stages.
Every analog board adds "four" control voltages to the total outputs count.
Analog boards cannot work by themselves but are intended to be stacked over the main board. The more analog outputs the user needs, the more analog boards will stack.
In example, if 8 analog voltages are what you need, main board and a single analog board will be assembled and stacked toghether. For 12 outs you want to stack two analog boards over the main board.
In principle, one could stack up to 7 additional analog boards over the main board, thus gathering a total of thitry two analog voltages (*).
(*) The use of more than 12 outs is untested. Eight outs (main board + one analog board) is actually the configuration I tested the most.
Digital board
Digital signals are used to transfer binary messages. The two voltage values commonly representing the two states are 0V and 5V, but in modular synths world this can extend up to 12v.
This being said, a digital board was not really necessary being that analog voltages can be used (up to some extent) to control digital signals. Being that a digital board could be easily layed down and that analog board is more difficult to assemble (MCP4728 is a very small SMD device) and expensive (again, because of the DAC), I ended spending a due amount of time on this too.
Digital board delivers a maximum of four indipendent digital outputs. Stacking more than one digital board to the main board will lead to an active multiple, but you will still have access to no more than four indipendent outs.
Front Panel
This very specific front panel has been layed down to handle main board and a single additional board for a total of eight individual outputs.
Stacks of more than one additional boards are not compatible with the current front panel, but it would be possible to design new panels.
The panel exposes eight outputs and the MIDI IN connector to the user.
Disclaimer: MIDIXCV hardware can output voltages up to 10V. Feeding a voltage higher than the maximum rating of the destination hardware can damage it. I cannot be held responsible for any use, proper or improper, of MIDIXCV or any information reported.
Hardware Description
Most of the circuits I adopted for this project are well known and similar to those used in my previous MIDI4CV project.
Hardwarewise, main implementations are the stackable nature of boards (which makes the whole device way more flexible), the output voltage extention to the 0 - 8V range and the adoption of a different final protection stage.
The use of Arduino's PWM outs in conjunction with (cheap and easy to assemble) RC filters I adopted in some previous projects of mine has been completely discarded because highly unstable (you would need at least a PWM frequency of 1KHz for decent results and Arduino NANO has less than half that frequency).
MIDI IN Circuit
The MIDI input circuit is the most basic design built arount a 6N138 optocoupler. I have adopted this a ton of times in my projects and works great.
The circuit is compliant with MIDI Association specifications.
Microcontroller Board
Incoming digital messages from MIDI IN circuit must be converted into analog voltages in order to speak the same language of your synths modules.
MIDIXCV brain is an Arduino NANO328 microcontroller board. It receives MIDI messages and converts them to (still digital) user definable informations. These are then sent to DACs through I2C comunication protocol.
Digital to Analog Convertion
The digital to analog circuitry is a MCP4728 12-bit QUAD DAC and it's slave components. DAC's resolution is approximately 1mV (with internal voltage reference), reduced to 2mV at the final amplification stage.
This is a very good hardware choice for this application, but also the existence of a whole lot of different libraries for it is very important and drammatically increase the chances of success of a hobbyist (do not forget) project like this.
Amplification and Protection Stage
Every single DAC output (main board, analog board and digital board) is buffered and over/inverse voltage protected by op-amps (TL074), followed by series resistors.
There are debates on which is the best solution for this task, but honestly I find the aforementioned one's simplicity a winner with respect to the (small) voltage loss it cause (*). A good calibration (see dedicated Step) takes care of the voltage loss anyway.
Op-amps amplification is hardware set to 2X. User can limit the output voltage by software. In example, if a CV is intended to drive pitch, the full voltage range should be used. On the other side, if control voltages for modulation sources or gates are going to be outputted, they should be limited to 5V. It is very important to collect informations about the modules you are going to control with MIDIXCV output voltages in order to understand the limits.
(*) Well designed modules have high impedence at their CV inputs. Assuming 5uA of current absorbed during normal operation, a 1K ohm series resitor will cause a 5mV voltage drop.
Others
Main board and slave boards are put into electrical contact by means of pinheaders. Pinheaders have the additional benefit of giveing some structural "stability" to the whole module.
There are four DIP switches on the main board. One is hard wired to arduino's Rx line and must be used to upload a new firmware (more on this later). The other three are directly connected to three arduino's digital pins and can be used for general tasks like activating functions and modes coded into the sketch.
Female jacks are PJ324M stereo. The stereo feature is not used, but these are easier to source and anyway compatible with the mono version, then a good choice for me.
The PCB mount MIDI DIN (5-DIN) used is very common too. The one selected for face panel mount makes no exception.
Main Firmware
Every single Instructable of mine comes from a personal need. In this case, I wanted to extend the functionalities of my DIY modular synthesizer MIDI converter.
In my synth I adopted the most basic paraphonic configuration I could think of, with four oscillators directly connected to the MIDI converter CV outputs. The "uniqueness" of my configuration reside in how voices are handled:
- if only one key is triggered, all the voices are set to the same pitch (unison-like)
- if an additional key is pressed, two of the four voices are assigned to the new key
- if a third key adds, two of the voices are stolen and assigned to the new key
- if four keys are pressed, all oscillators are independently set to individual pitches.
The synth works in a sort of "depleted unison" mode, with all oscillators always active in the audio path.
Every time a new key is pressed, the gate (and then the envelope) is retriggered.
This paraphonic approach has two advantages over the conventional:
- it allows to avoid a multi switch/VCA stage to mute unused voices
- it allows to use a single gate out instead of separate gates, one for each switch/VCA
- your sound will be fatter in sub-max paraphony conditions.
The firmware handles 8 individual analog outputs. Outputs are sorted this way:
- the four main-board outputs are used to generate control voltages as a function of the MIDI note's pitch received (V/octave format)
- analog-board output #1 sends a gate signal (single gate - "depleted unison" parafonic setup)
- analog-board out #2 sends a voltage proportional to the latest note velocity
- analog-board out #3 sends a voltage proportional to the note position on the keybed (keyboard tracking)
- analog-board out #4 sends a voltage proprotional to aftertouch
The current firmware also supports pitchbend.
Here we are adopting the V/oct standard, which means that every semitone is 83mV from the next.
MCP4728 can be software set to use an internal voltage reference (a straight 2.048V reference) or external (Vcc). Using the internal voltage reference has the advantage of a rock solid voltage tracking, but limited to a 0 - 4.095 V range. This means that by using the internal reference (and no amplification stage) we have a span of four octaves instead of five. Voltage is more repeatable and reproducible by using internal reference.
In this sketch, analog voltages for pitch control use the DAC internal voltage reference. Output voltages are then doubled by the final amplification and protection stage for a full 8 octaves range span.
All "pitch" outputs (main-board outs) have their own CV table. This means that the calibration procedure (see calibration dedicated Step) must be repeated four times, one for each output.
Analog voltages for auxiliary CVs are software limited to approximately 5V, but you can increase the range to 8V commenting the line
#define LIMIT_CV
("commenting the line" means writing // before the line, or deleting it completely).
DIP switches are left unused here, with the exception of DIP1. DIP1 is hard wired to the arduino's Rx line and must be used to upload a new firmware (I prefer to use hardware serial when possible). To upload a sketch switch DIP1 to "OFF" position. After the upload, re-set it to "ON" to receive incoming MIDI messages.
Libraries
Main sketch calls for the following libraries to be pre installed in arduino IDE:
Please notice that this is only a (100% working!) demo sketch, just to show you some possibility (well, it's the one I use on my synth anyway). MIDIXCV is obviously not limited to features here described thanks to it's software and hardware flexibility.
Disclaimer: MIDIXCV hardware can output voltages close to 10V. Feeding a voltage higher than the maximum rating of the destination hardware can damage it. I cannot be held responsible for any use, proper or improper, of MIDIXCV or any information reported.
Analog Out Calibration Sketch
Even if ideal voltages for pitch control are simple to derive, real world physics makes things more complicated.
In addition to this, being that there are no two electronic components acting exactly the same, a calibration process is mandatory.
Calibration here reside in the fine tuning of all single output voltages. In the main sketch these are associated to numbers from zero to 4095 (the 12-bit thing, remember?). The goal of this procedure is to find the number giving the best real vs ideal voltage match possible for every single semitone in the whole octaves range supported (eight).
Calibration calls for a good, calibrated, voltmeter and a PC with Arduino IDE installed. Results are real-time displayed on the serial monitor.
The sketch handles 4 indipendend outputs with a CV table each: this means that you are going to set 96 x 4 values (yes, it's a whole lot of work).
Calibration procedure
Upload the calibration sketch (MIDIXCV_outs_calibration.ino) to MIDIXCV and open arduino IDE's serial monitor. Place your voltmeter leads to ground and to the analog output you want to calibrate, then:
1 - short to ground "N+" (note# +) or "N-" (note# -) pad on the main board to increase or decrease the MIDI note# you want to tune
2 - short to ground "V+" (voltage +) or "V-" (voltage -) pad on the main board to increase or decrease one step (*) the voltage of the current MIDI note#
3 - when all notes have been calibrated, press "N-" (note# -) while keeping "N+" (note# +) pressed: a full log will be displayed.
4 - Copy and paste the log in MIDIXCV.ino sketch replacing values in cv#ExtRef[MAX_EXT_V] array.
5 - repeat for all four outputs
6 - Upload MIDIXCV.ino sketch with the four updated arrays: MIDIXCV is now calibrated!
(*) Steps are approximately 2mV steps.
Calibration should be done with a load applied: your VCO's "V/oct" input is a very good choice or, eventually, a 100K ohm resistor to ground will do (e.g. the load value on my AS3340 VCO module is 90K ohms).
Being the calibration procedure a tedious one, I layed down a simple calibration pad PCB (*) to make things simpler. It is not mandatory to use it, but helps A LOT.
(*) Please notice that the shared calibration pad has "reversed" layout and silk-screened prints with respect to the one pictured in this instructable. I think it is more practical now ;)
By default the calibration sketch is set to tune outputs of the device with ID#0, but it can be easily modified for any of the other possible devices (ID# 1 to 7). See next step on how to set up analog boards and their IDs.
Analog Boards - How to Set Up
In order to give DACs their own identity thus simplifying the MPU communication task, it is necessary to reprogram them with a unique address each.
As always, the Arduino Community comes to the rescue and makes operations like this possible also for non professionals like me and you.
I slightly modified a reprogramming sketch from Jan Knipper in order to simplify things a bit. Follow thse steps:
1) Install SoftI2CMaster library in our arduino IDE
2) Open the reprogramming sketch (MIDIXCV_DAC_address_prog.ino)
3) Change #NEW_ADDRESS global constant to your desire (if you have a single analog board, set it to "1", otherwise use individual values for each analog board)
4) stack the analog board you are going to re-address over the main board
5) short pin "LX" and "L1" together with a removable jumper
6) Upload the sketch
7) put the jumper back to short "LX" and "L0".
You can now test how many unique-address chips are installed by running I2C_Scanner. Open the IDE's serial monitor: If everything went well unique DAC's addresses will be displayed for each DAC.
Soldering Hints
Being the DAC a 0.65 mm pitch integrated circuit, you have to adopt some strategy to succesfully solder it in place with a common stilus soldering station. Some suggestion follow.
General Procedure:
- solder the DAC first. You want space around your solder tip and you don't want to waste other components in the case of problems.
- use a thin iron to solder the chip
- use a magnifing glass to zoom the soldering area (even better would be one of those "cheap" microscopes they sell nowadays, but it's not everybody priority I know)
- use soldering flux. I had the best results with those siringes containing dense flux, lately.
Soldering Method:
- melt a little amount of solder on PCB's IC pads. You want to see a certain amount of solder over the pads, but no shorts between pads
- place the DAC over it and apply soldering flux. Be 100% sure the IC has the right orientation!!
- remelt the pad-solder with a clean iron tip while applying a very small pressure on top of the IC.
Re-apply the flux everytime you feel it's needed.
The iron temperature is very important: it should be high enought to fast melt the solder, but not too high or it will kill the IC. I had success with a temperature of 350-370°C.
When the DAC is soldered, check for continuity between IC's legs and the corresponding test point, marked TPA, TPB, TPC and TPD.
Alternatively...
If you don't feel confident in soldering such a small SMD component, be aware that most PCBs manufacturing Companies offer an SMD assembly service you can take advantage from. I had the opportunity to test JLCPCB SMD assembly service more than once now, and I have always being very happy with the result. This project made no exception.
In MIDIXCV Github repository you will find Gerber files but also BOMs and CPLs for main board and analog boards (those with the DAC microbe) in order to take advantage of the SMD assembly service.
Please notice that the DAC is the only SMD component in this project, so it's the only element you will find assembled.
Where Are All Those Files!
You can download all the necessary files to do it yourself a copy of MIDIXCV at >>THIS<< Github repository.
In that repo you will always find the most updated versions of boards and sketches, all for free! :)
You are anyway welcome if you want to donate some change to help me cover components costs and encourage the development of new projects.
>>HERE<< is my paypal donation page, just in case... :)
Acknowledgments
Many thanks to those nice girls and guys at JLCPCB for sponsoring the manufacturing of FR-4 PCBs, aluminum face-plate and SMD assembly for this project.
JLCPCB is a high-tech manufacturer specialized in the production of high-reliable and cost-effective PCBs. They offer a flexible PCB assembly service with a huge library of more than 350.000 components in stock (included the MCP4728 needed for this project).
3D printing has been added to their portfolio of services so one can create a full finished product, all in one place!
As almost always happens lately (I am going old...), I had some PCB design rethinking after the order was placed, but guys at the customer service were fast and helpful (even during night time), so many thanks (and sorry for that night-time thing...). Remember: as far as the PCB is not already put into production, you can ask to replace a file. Very reassuring (is it only me or errors are more easily spotted after the payment has done?) :D
By registering at JLCPCB site via THIS LINK (affiliated link) you will receive a series of coupons for your orders. Registering costs nothing, so it could be the right opportunity to give their service a due try ;)