Arduino CV output: R2R, RC or DAC?

Hi all, Ive been breadboarding a CEM 3340 VCO and want to make a 1v/oct IR thermin type thingy to control the VCO pitch via an arduino. As far as I can fathom there are 3 methods to get a stable CV output from an arduino, an R2R resistor ladder, a simple DAC (such as a MPC4725) and a RC low pass filter applied directly to the arduino PWM output. I have limited electronics knowledge (and monies) so thought I would ask on this awesome forum if anyone has any opinion on which of these methods will work best to control the pitch of a VCO?

1 Like

I’ve used a DAC — specifically I’ve used the MCP4922, which is a dual channel, 12-bit DAC with an external voltage reference and SPI interface. MCP4822 is similar but with an internal voltage reference, and MCP4921 and MCP4821 are single channel versions. If you want continuous pitch with good precision over a large range on your CV, you want the high resolution. For example if you use 0 to 5V to cover 5 octaves, then 12 bits gives you (5*1200)/4096 = 1.5 cents resolution, which is a little better than what a good ear can hear. With PWM/RC done the easy way you get about 10 bits resolution. (I’ve read that you can do better, but I’ve never found a clear explanation of how.) That would be 6 cents resolution, maybe acceptable but starting to get large enough to hear. R2R would need, what, 12 data pins to get 12 bits?

Of course if you only want equally tempered semitones over one octave (to take the other extreme) you only need 12 distinct voltages and you can do that with 4 bit resolution, easily done with R2R.

A DAC solution isn’t much harder to build or to use than the others. It’s another chip but you don’t have to design and build just the right filter, and software libraries exist to make it painless to program.

You can look at https://github.com/holmesrichards/dac_ino which is a general purpose Arduino/DAC design, probably overkill for your purposes but it’ll show you how the DAC connects and how the software works. That one has an op amp gain stage after the DAC but if you just want 0 to 5V on the output you can go directly from the DAC.

3 Likes

@analogoutput Thanks for the hints, super helpful, I see that those 12 bit MCP ICs are only a couple of quid and fairly easy to implement so this is likely an ideal solution for me.

Also thanks for the link to the general purpose DAC design thats some v.impressive work Im envious of your skills!

Id be super interested in any experiences people have of using the PWM/RC method I found this link for calculating the R and C values but I cant get my head round the implications in terms of transient response times etc!

http://sim.okawa-denshi.jp/en/CRlowkeisan.htm

2 Likes

For an ideal DAC, that is. You may want to check the DNL and INL parameters as well (the former is how off a single step may be from the expected value, the latter how off the full range can be, both measured in LSBs).

4 Likes

That method is used by the LMNC midi2cv interface based on the midimuso implementation. As far as I know quite a few people have bought the LMNC version. Maybe someone of those can comment on its stability and accuracy/resolution?

There is some more explanation about using PWM from Kassutronics (on page 15).
To summarize the advantages of PWM:

  • low nonlinearity <0.01% (MCP4822 has 0.1%)
  • easy to handle in software (only write to register)
  • you can get down to an error of 2mV, which is 2.4cents (if you match resistors closely)
  • AS3340 only has tracking accuracy of ~5mV
  • if you are fine with only semitones, you only need 7 bits of resolution to get a range of 10 octaves

But with this you need a well regulated power regulator (LP2951N is used by Kassutronics) and I would say then you could as well get a DAC, like @analogoutput described, if you want something simple :wink:

2 Likes

to beat a resistor and a capacitor ? Obviously it ultimately depends on the stability of the components you control with the CV voltage and the quality of your hearing.

Not so simple if you’re Kassutronics:

3 Likes

Wow thanks everyone, I was really attracted to the simplicity of an RC filter however for now it appears that the novice friendly approach is to use the DAC method. I will order a couple and let you know how I get on.

Thanks again for all the help and info :smiley:

1 Like

Probably not exactly what you meant, but I found this very interesting article where they use two PWM channels together to get higher resolution! If I understand it correctly, they “scale down” (using different resistors) the second channel so it will act as the lower bits. :slight_smile:

3 Likes

Also see:

http://wiki.openmusiclabs.com/wiki/PWMDAC

Dual PWMs just mix an upper and lower value together, to make one analog value. This mixing occurs through 2 resistors, one of which is 2^n times the other, where n is the bit depth.

3 Likes

That’s a great resource… assuming it’s correct of course! I note they show a simple first order passive filter, as opposed to the much more complex filter from the Kassutronics module. Is someone either overdesigning or underdesigning?

Maybe this is relevant, from the page they link to here:

If your PWM frequency is out of the audible range, you won’t need to spend much effort filtering it, unless the amplifier you are putting it into doesn’t have a good low-pass filter at 20kHz. It is quite common on sound cards and mixing boards to use 30kHz or 40kHz as the low-pass frequency, so be wary. Your signal could easily distort the input amplifier stages, even though your signals are outside of the audible range. In these cases, a 3rd order active filter with a single opamp will solve the problem.