[sdiy] Quantizer with Arduino, ADS1115 and MCP4725
mskala at northcoastsynthesis.com
mskala at northcoastsynthesis.com
Thu Jun 20 04:20:32 CEST 2024
On Wed, 19 Jun 2024, Scott Bernardi via Synth-diy wrote:
> number of semitones. For example, a major scale would be
> 0 2 4 5 7 9 11 semitones.
> Minor would be
> 0 2 3 5 7 9 10
> The necessary binary counts would then be 512 times these.
> Using the number of semitones for the scales is convenient, because then for
> the 12 bit MCP4725 output, I would multiply by the bits per semitone value
> of 32. Or another way to think of it is to throw away the 3 least
> significant bits and the sign bit to go from 15 bits plus sign bit to 12
> bits for the output.
The MCP4725's output may be up to 14.5 counts off of a theoretical linear
input-to-output function. If full scale is 5.333V, that translates to
0.02V or about 23 cents of pitch. And that is how closely it approaches
*some* linear function, not necessarily *the* linear function you want it
to be. Gain error 2% and offset 0.75% are possible according to the data
sheet. If I'm correctly understanding how those are applied, it seems
like in the worst case gain and offset could add error of up to 0.14V, 165
cents (!), on a reference voltage of about 5V.
If you want your pitch accuracy to be better than that, a simple "multiply
semitones by X" calculation is not going to be good enough. You have a
bigger problem than just trying to make X be equal to 32.
I think to get good results you're going to need to do some calibration:
send different codes to the specific individual DAC chip you're using,
measure the output, find the code you need to send for each desired
output voltage, and then store those in a table and look them up when you
want to get different voltages. This needs to be done individually for
every chip because the point is to compensate for the manufacturing
variation among the chips.
Similar issues may apply to the ADC, so you risk a garbage-in, garbage-out
situation.
And then if you're doing the work to calibrate individual steps, there's
not much to be gained by pushing the power supply voltage, and I wouldn't.
The 5.5V maximum spec really means "it's 5.0V with a safety margin," not
"5.3V is perfectly okay and normal" and if you cut into that safety margin
you may end up regretting doing so.
--
Matthew Skala
North Coast Synthesis Ltd.
More information about the Synth-diy
mailing list