Generate Control Voltage for a modular synth

hi

can someone from the music side explain how this CV thing is used what its electrical characteristics are? Then us hardware types can figure out how to do it. Not that the two sides are mutually exclusive. I'd like to build a synth too. :slight_smile:

D

Daniel: CV/gate - Wikipedia
Essentially, a constant voltage corresponds to a constant frequency.

The trick I think we're looking for is how to turn the analogWrite PWM into a constant voltage.
If I call analogWrite( 128 ), I want a steady 2.5V out. Not a 5V peak square wave with a 50% duty cycle. Makes sense?

yes that totally makes sense now.

the simple way to do that is with an Resistor and Capacitor (RC) filter. You could get what, 6 CV's form An Arduino, as it has 6 PWM pins?

It would be good to have an op-amp in there too, to prevent loading effects and to promote stability.

This Microch*p application note describes how to do it, and gives formulas for calculating the RC values. Try the values they give (4K and .01uF) and see what happens!

D

Thanks for your help, Daniel. Could you explain this further for me?
My limited understanding of analog circuits was that a low pass filter, by removing the higher order harmonics, would turn the square wave into a sine wave. How does the op-amp circuit put out a constant V?

I also don't understand why that data sheet refers to turning the PWM signal into an "analog output." To me, PWM is an analog signal - no digits involved. So what do they mean then by analog?

I'm curious about the limitations of having the Arduino carry out the process - would using the PWM pins limit us in terms of resolution or have problems with extreme changes in voltage relatively quickly? Anyone know how to calculate how many bits would be needed for relatively precise control over 1V/oct oscillators?

Also - some synth users may require a 0-10V range - the PWM only provide a max of 5V, correct?

There's another solution that occurred to me - what about using a digital potentiometer to attenuate a reference voltage, rather than generating the voltage out of the arduino pins. That would allow your 0-10V interface.
I'm curious what those knowledgeable about hardware think of that.

As for precision, let's say you made only a 1 octave synth. With only 256 possible voltage levels from an analog write, that gives you about 23 steps per note, or a worst possible error of 5 cents -- kinda funky. Trying to control a wider voltage range would get worse, obviously.

However, if you used 14 digital pins to control a DAC, 2^14 == 16384 voltage levels, which seems pretty reasonable.

I'm no expert - but from what I know the nature of digital pots is incremental (256 tap points along a particular resistance, etc) so once again we're into stepped adjustments unless an integrator or similar is used to smooth things out...

I was looking at the data sheet for a 1024 tap digipot (MAX5481) which would probably be somewhat reasonable even across 10V. Although you're right, it would be steppy. The tradeoff is you get 14 CV outs, rather than 1 out from a 14 bit DAC.

@relaxing:

the RC filter is very simple, just like a power supply filter. When the putput pin is at +5, the cpacitor charges slower than normally through thee resistor, and the voltage across the cap rises. When the output goes low, the cap discharges into the output in through the resistor. Sort of like a shock absorber. If the values are right, the hard variations ( 90[ch730] rising and falling edge of PWM signal) will get flattened out. With just one RC, it won't be a totally smooth voltage, but it will be pretty good.

D

I built the circuit, no luck. All I get is the 485hz PWM tone modulated by my desired frequency.
The RC filter just sounds like a lowpass filter -- is there some "magic" value of cap and/or resistor where the square wave will suddenly go flat?
When I tried the formula on that datasheet I ended up with a miniscule value for R... but they were dealing with a PWM frequency in the MHz range.

hey

what did you feed the circuit into? you need to give it a high-impedance load, so if it was something like a 1K line input, that would defeat the circuit entirely... when I get a chance I'll build it myself and see what's up.

D

I'm feeding them into a modular synth -- Signal Input Impedance: 100K ( according to Technical Information | Synthesizers.com )

Actually, I think it's working now. What I neglected to mention was that I was trying to output in the audio domain -- I was hoping I could digitalWrite out a sawtooth wave at audio frequencies, and the arduino just isn't fast enough to do it. (There go my dreams of making a wavetable synth.)

When I gave that up and tried generating control voltages, it seems to work ok.

By turning a pot I was able control the pitch of a VCO with the CV the arduino generated.

void loop() {
  k = analogRead( 0 )/4;
  for( i = 0; i < 1000; i++ ) {
    analogWrite( 3, k );  
  }
}

Now I'm not sure that it's giving me the full 0-5V range, but I'll have to play with that more tomorrow.

Has anyone made further progress with this? I'm interested in the same thing- outputting a 0-10v CV control for my modular synth. I see that relaxing was successful at filtering the 5v pwm output, but how does one go about scaling that to the 0-10v range? Any chance someone could post photos or schematics for this?

I have been thinking about something similar.

My inspiration is Kymatica's parallelport CV / gate interface :

http://www.bitminds.net/kymatica/uploads/Hardware/pc-interface.pdf

He uses a serially controlled MAX536 quad DAC to generate the CV with very high precision.
It should be easy to use Arduino in stead of the parallel port.

The MAX536 is VERY expensive and need quite a lot of external components to work in this scenario, but it can generate 4 CV's at the same time and with the high precision a musical application requires.

Cheaper single channel DAC's could surely be found, but as soon as you require the handeling of 10V with a decent "bit depth" the pricetag just goes up.

MikMo
http://ww.mikmo.dk

What features should I be looking for in a DAC to provide sufficient resolution?

I just realized that the AnalogWrite function only provides 256 values, which, as already noted, is not nearly enough precision for 0-10v @ 12 steps per volt. I suppose a workaround would be to allocate one pin for the frequency within a single octave, and a second pin for the octave offset. This would yield 21.3 values per semitone, which seems like plenty of resolution.

The 256 value limitation for the analog out is the reason to choose a DAC that kan be serially controlled. That way you are only limited by the capability of the DAC.

The MAx536 has 12 bit precision. That will give you 4096 discreete values. If your synth use the standard 1V/octave over a 0 -10 volt range you will have a little more tha 409 "steps"/ octave or 34 "steps" for each key in the octave. This should be enough even to make pitch bends with out anoying stepping of the pitch.

I guess this is my newbie ignorance showing, but what do you mean by "serially" controlled? Does it use several digital out pins in conjunction to communicate a single value to the DAC?

Yes exactly.

There are a few different "protocols" twi and i2c and SPIare a couple of them. They use a few digital lines to implement serial communication to devices that support the protocol.