I am currently working on a quantizer based on Arduino using the MCP4822 which I happen to have stocked. It is a 12bit DAC with an internal voltage reference, in contrast to the MCP49xx family which support external voltage references.
It’s currently work in progress and I have not fully defined what kind of features I’d like to implement but for sure, I want to provide an interface which allows me to select between scales or maybe even select individual semitones.
To understand the capabilities, I did some measurements and now working on a calibration procedure for the MCP4822, which you might be interested in, so I thought I share my findings. I also consider integrating the calibration process into the module, but let’s see When it’s finished, I’ll polish it up and put it on my website.
I measured the output voltage for a whole bunch of digitally set input voltages from 0 mV
to 4000 mV
in 50 mV
steps. The library I used to talk to the MCP4822 is the one written by Steve Gkountouvas MCP48xx DAC Library.
Here is the result:
The differences are quite subtle and more visible in the plot below where I subtracted the measured from the expected voltage. There is a clear correlation of the error with respect to the target voltage so I did a simple linear fit and also a polynomial fit:
The fit parameters can then be used to calculate the offset voltages which are then taken into account when setting the output voltage on the MCP4822. The calibrated voltages are now looking like this when applying the simple linear fit regression:
and the differences are now nicely centred around 0mV:
The MCP4822 I am using here can only output around 4030 mV
. I am using 4000 mV
to avoid some edge effects. If these 4 V
are used for 4 or 5 octaves, we of course have different errors in the notes. In case of 5 octaves squeezed into 4 V
, the semi-tone step is 66.67 mV
. For 4 octaves we have the usual 83.33 mV
.
In terms of “cents”, this means that after the calibration using the linear regression, I get around 1.87 cents
mean error (standard deviation) for 4 octaves and 2.34 cents
for 5 octaves. I think this should be more or less fine, but I have to hear it myself.
Here is the final calibration results showing the errors in cents using the 4 and 5 octave configuration:
Overall I think that’s fine, but I’d love to hear your comments. It’s possible to improve the results even more using the polynomial model but for now I just stick to the simple linear model since that one can also be tuned via two trim-pots, so that there isn’t even a need to modify the firmware (updating the coefficients) for a proper calibration.
Btw. the input ADC of the Arduino has 10bit, so that’s more than enough to catch the note with an error of 4.88 mV
which is roughly 6 cents
of an error.
I will now sketch the schematics.
Any kind of feedback is very welcome!