Have any of you geniuses/lunatics built a VCO from an Arduino?
I’m currently working on an 8-bit wavetable VCO on an arduino and i’m curious how I should handle the CV input into the arduino. After some googling around i’ve seen some similar forum posts with quite a lot of variety in methods on how to deal with CV input and I’m unsure of the direction to take.
It seems a lot of problem focus around the fact that CV could be -5v to +10v, but at the same time I’m thinking, since I’m building my Kosmo system from my own modules, i could make sure that I keep CV within the 0v-5v range and not bother with this? For example, i’m planning on using the Korg SQ1 as a sequencer which I believe only does 0v-5v.
The other part I’m not sure about is how to properly scale the 0-5v input to the correct frequencies for the oscillator to produce the correct notes.
as you can see it’s pretty simple, I wanted to keep it as simple as possible so it’s easy to modify. Currently it’s only using one wavetable since I havent quite figured out how I want to control mixing between different wavetables.
You could, but be aware that’s a big self limitation: It prohibits you from ever using a design from someone else that goes outside that range, and it limits you to a 5 octave pitch range. Yeah, you can do a lot in 5 octaves. But with just an op amp you can rescale and offset (or with just a voltage divider you can rescale) a larger CV range to 0 to 5 V and not have that limitation.
Edit to add: There is a downside, which is that you have a 10 bit ADC and with a 0–5 V input an LSB is 4.88 mV corresponding to 5.85 cents pitch. If you rescale a ±5 V CV to 0–5 V and digitize that then an LSB is 11.7 cents, nearly an eighth of a semitone. That’s… not very good pitch resolution. Even 5.85 cents (and that’s in the ideal case, with no ADC nonlinearity) isn’t that great. An external 12 (or more) bit ADC would give better results.
For that you might look at this:
which is a DCO, not a wavetable, but maybe the CV scaling could be done similarly. Edit to add: You notice that uses a 16 bit ADC and takes 0–10 V input.
Exactly, thats sort of my thinking right now, I’ve built one Kosmo case, and i have a good about where I want to go with it, so I’m almost thinking that 0-5v may not be a big problem for me, especially since i’m definitely more of a software guy…
I wrote a simple thing that reads an analog pin on the arduino and converts it to a midi key number. Then pass it to the mozzi function mtof() to convert that into a frequency. Here is the code I wrote. updateControl() is a Mozzi thing.
But I think you could import the mozzi library, use its functions and this code and it will generally work for whatever you want without using the actual Mozzi sounds or control functions.
// define the CV input pin as A0, Tremelo as A1, Wave select as A2
const char CV_in_port = 0;
// read CV frequency
int CV_value = mozziAnalogRead(CV_in_port);
// .... other stuff to choose a waveform called current_waveform
// Convert CV to a midi note between 21 and 117 which is Moog 1V/Oct as per midimuso documentation
int low_to_high = (117 - 21);
float midival = (CV_value / 1023.f) * low_to_high;
midival = midival + 21;
// Convert midinote to a frequency using mtof function from mozzi
float midifreq = mtof(midival);
I can’t recall, there may be a negative voltage protection diode in my circuit; but nothing else to sheild the arduino voltage in. From this link the voltage in will handle decent over voltage up to 12V and nothing in my system can produce more than this: Arduino Leonardo with Headers | Arduino Official Store.
But tell me if you advise something better than that? But the circuit has worked great!