MUFF WIGGLER Forum Index
 FAQ & Terms of UseFAQ & Terms Of Use   Wiggler RadioMW Radio   Muff Wiggler TwitterTwitter   Support the site @ PatreonPatreon 
 SearchSearch   RegisterSign up   Log inLog in 
WIGGLING 'LITE' IN GUEST MODE

Generating CV/Gate with Arduino
MUFF WIGGLER Forum Index -> Music Tech DIY Goto page 1, 2, 3  Next [all]
Author Generating CV/Gate with Arduino
stk
I'm sure this has been discussed before, but my quick search found naught.

Anyway, finally got around to playing with my Mega I bought over a year ago. Programming's going all well and good, just wanted to check something:

For steady variable DC output (not wobbly PWM) I'm going to need some kind of DAC solution, right?

Thanks.
widdly
If you filter the PWM you can get a steady DC. The electricdruid site has some good filter circuits....

http://www.electricdruid.net/index.php?page=projects.lfo9

You will need a dual rail supply for these. You can see from his scope shots that it is a smooth output.

Resistor Ladders are cheap and easy. They can run off a single supply. This page has some good tips..

http://ikalogic.com/dac08.php
stk
Awesome, thanks. I've just been reading up on R-2R resistor ladders smile
stk
IIRC somebody posted here a while ago regarding offering Arduino shields for modular synth integration (providing the necessary dac/smoothing and voltage multiplying business), anybody remember that thread?
ringroad1
Never tried the PWM thing myself, but I've had very acceptable results building a little sequencer with a Microchip MCP4922 DAC - I based what I was doing off http://mrbook.org/blog/2008/11/22/controlling-a-gakken-sx-150-synth-wi th-arduino/ - there's a good code example there as well.

MCP4922 is less than 2 quid from Mouser and they're available in DIP. Plus it's a dual DAC, so one output could be note CV and another could be filter cutoff - is lots of fun.
stk
Okay, decent results with a quickly thrown together LFP (2k2 resistor & 2.2uf cap). CV is a little shaky on higher values, and there's an obvious slew, but I call that vintage character This is fun!

I will look into DACs when I have a moment, atm enjoying playing with code.
lazerkind
You mean Neutron7's neutron shield modulator?
https://www.muffwiggler.com/forum/viewtopic.php?t=23785
stk
lazerkind wrote:
You mean Neutron7's neutron shield modulator?
https://www.muffwiggler.com/forum/viewtopic.php?t=23785


That's the one, thanks smile
deastman
I've been endlessly frustrated in my attempts to find a suitable but affordable DAC. Correct me if I'm wrong, but it seems that cheap 8-bit DACs aren't going to provide enough resolution for volt/oct use.
jupiter8
deastman wrote:
I've been endlessly frustrated in my attempts to find a suitable but affordable DAC. Correct me if I'm wrong, but it seems that cheap 8-bit DACs aren't going to provide enough resolution for volt/oct use.

Due to the way digital works an 8 bit DAC will only have 256 possible values.
If you do 0-10 volt each step will be 4 cents (0.04 volt).
Yeuky
deastman wrote:
I've been endlessly frustrated in my attempts to find a suitable but affordable DAC. Correct me if I'm wrong, but it seems that cheap 8-bit DACs aren't going to provide enough resolution for volt/oct use.


The MCP4922 previously mentioned is a great product. Less than 3 bucks gets you two 0-5v 12-bit dac's. No supporting circuitry required, easy to daisy chain, cheap as chips. If you need bipolar values or of a higher range, its a doddle to do. I'm using these in a few products soon to ship. Highly recommended. thumbs up
jbartee
It depends what you're doing with it, but PWM can be completely useable. It definitely shouldn't be wobbly, just run it through a simple RC circuit. The issue is more precision (as in 10 vs 12 vs 16 bit) and speed; if it's not holding a steady voltage though something is screwy. You should even be able to feed a 1v/Oct input from PWM and get rock solid, steady pitches.
stk
jbartee wrote:
It depends what you're doing with it, but PWM can be completely useable. It definitely shouldn't be wobbly, just run it through a simple RC circuit. The issue is more precision (as in 10 vs 12 vs 16 bit) and speed; if it's not holding a steady voltage though something is screwy. You should even be able to feed a 1v/Oct input from PWM and get rock solid, steady pitches.


I'm feeding RC filtered PWM into Hertz Donut 1v/Oct input.
It works great, but seems to drift and wobble a little, particularly on the higher frequencies. I'm using 2k2 resistor and 2.2uf cap, mainly because they were the first things of suitable value to fall out of my bits box.


Yeuky wrote:
The MCP4922 previously mentioned is a great product.

I will be having a play with some of these when I have a chance, figure it will get me steadier voltages than just filtered PWM.
Do they work off multiple digital outputs like a R2R DAC? OR via serial?
daverj
A filtered PWM signal can give you an extremely stable and extremely accurate DC voltage. But, like anything else, it doesn't come without issues and tradeoffs.

A simple RC filter has an extremely gentle slope. So to effectively filter out the PWM cycle frequency the filter must be set many, many octaves below the PWM cycle frequency. At the same time, the lower the frequency of the filter, the longer the settling time of the DC output.

If the RC filter frequency is too high, then you end up with a sort of variable duty cycle non-linear triangle wave, because a lot of the frequencies of the PWM waveform get through. On the other hand if the filter frequency is too low then every time you change the PWM setting the DC voltage has to slowly ramp to the new value. Once there it will hold that value. But getting there is the "settling time".

You need an op amp after the RC filter to drive other modules. Otherwise you no longer have a simple RC filter. You have a complex circuit with whatever parts are in the module you connect to becoming part of the filter circuit.

If you have a low pass filter in your system that is DC coupled from input to output, then feeding the PWM through that can work better than a simple RC filter since it's slope is typically much steeper than an RC filter. That allows you to filter out the PWM cycle frequency better without creating such long settling times.
jbartee
stk wrote:

I'm feeding RC filtered PWM into Hertz Donut 1v/Oct input.
It works great, but seems to drift and wobble a little, particularly on the higher frequencies. I'm using 2k2 resistor and 2.2uf cap, mainly because they were the first things of suitable value to fall out of my bits box.


Are you going through an op amp? As daverj pointed out, a buffer is essential. Even just simple unity gain.

The precise values used in the RC circuit have a huge impact on the response -you don't necessarily have to do the math on it (calculator!), but definitely do a little trial and error to find the sweetspot.

On the PIC24 series of micros, I like to use a 25k resistor and a .01uF cap -which I arrived at by ear after the values I calculated didn't quite feel right. Basically you want to find a combination that introduces a little bit of portamento, and then back off until the response is acceptable for your needs.
stk
Ahah, thanks for the replies.
I have not been buffering it (although I was planning to, eventually - I'm still in the breadboard stage) so that may well be the cause of my wobbliness.

I will also be playing about a bit more with exact values for the RC filter.
Neutron7
I have some arduino shields which convert the output to +-5v. and gates/triggers.



also it can level shift and filter 2 CV inputs.

you can use a dual 12 bit DAC or the PWM for the output.
the output can have 2 or 3 pole filter by adding optional capacitors, with different values depending on your output method, and PWM prescaler
(you can use a header if you want to experiment with different capacitors)

MIDI in/out

MOTM,.COM or EURO power footprints, with diode reverse polarity protection.

onboard 5v regulator so the arduino will not pollute your power lines. (usb can be plugged in for programming while it is powered)

optional extra input over and undervoltage protection on all analog and digital i/o

it has an amplifier, in case you want to add a gameduino.(tested compatible)
http://www.youtube.com/watch?v=V-itMy7BMs8
Gameduino is supposed to be for making games, but it has 64 sine oscillators!

you can attach up to 4 analog pots for controls, and all the other digital pins not used by the PWM or SPI can be trigger in or out, or LEDs etc.

for more controls
the daughter board can have 16 pots/switches and 8 LEDs

the main boards are tested and good, but i havent finished testing the daughterboards.

the main thing holding me back from releasing it to sale, is that i hate doing technical writing, and there is little documentation.
stk
Neutron7 wrote:
I have some arduino shields which convert the output to +-5v. and gates/triggers.


That looks pretty cool!
For my projects however I need (different combinations of) 4 cv ins, 4 cv outs, 4 trig/gate ins and 4 trig/gate outs.

The trig/gate i/o are fine as is (I think), and the analog ins can handle 0-5v.
If a shield was available that just took care of converting Arduino outs to +/-5v (and buffering them) I'd be happy.
wwall
Neutron7 wrote:
I have some arduino shields which convert the output to +-5v. and gates/triggers.


This looks great! I would definitely be interested in one (or several) if you decide to offer them.
deastman
Yeuky wrote:
deastman wrote:
I've been endlessly frustrated in my attempts to find a suitable but affordable DAC. Correct me if I'm wrong, but it seems that cheap 8-bit DACs aren't going to provide enough resolution for volt/oct use.


The MCP4922 previously mentioned is a great product. Less than 3 bucks gets you two 0-5v 12-bit dac's. No supporting circuitry required, easy to daisy chain, cheap as chips. If you need bipolar values or of a higher range, its a doddle to do. I'm using these in a few products soon to ship. Highly recommended. thumbs up
Okay, thanks for the tip! I'll pick up a few these to play around with.
Yeuky
stk wrote:

I will be having a play with some of these when I have a chance, figure it will get me steadier voltages than just filtered PWM.
Do they work off multiple digital outputs like a R2R DAC? OR via serial?


They work via serial (SPI), so two pins for data/clk, and a chip select. Data and clock are busses, so for every additional daisy chained chip, you only need one extra digital output (Chip select) ontop of the original three.
Yeuky
Oops, double post. Sorry.
Neutron7
stk wrote:
Neutron7 wrote:
I have some arduino shields which convert the output to +-5v. and gates/triggers.


That looks pretty cool!
For my projects however I need (different combinations of) 4 cv ins, 4 cv outs, 4 trig/gate ins and 4 trig/gate outs.

The trig/gate i/o are fine as is (I think), and the analog ins can handle 0-5v.
If a shield was available that just took care of converting Arduino outs to +/-5v (and buffering them) I'd be happy.


the reason i only used 2 CV outs, is because only one of the timers (associated with pins 9 and 10) can be made to do 10 bit PWM, all the rest are only 8 bit.

If you want a lot of good quality CV outs, you could use a MIDIbox AOUT NG
which i have built got to work with an arduino.

then you just have shift and attenuate the inputs which is easy.
stk
I see, thanks.

I've just noticed ADDAC's VCC which looks pretty interesting - https://www.muffwiggler.com/forum/viewtopic.php?t=35651#511130

8 outs @ apparently 16bit..
ringroad1
stk wrote:
I see, thanks.

I've just noticed ADDAC's VCC which looks pretty interesting - https://www.muffwiggler.com/forum/viewtopic.php?t=35651#511130

8 outs @ apparently 16bit..


ADDAC's VCC uses the Analog Devices AD5668, 8 outs at 16 bit:

http://www.analog.com/en/digital-to-analog-converters/da-converters/ad 5668/products/product.html

Shame it's only surface mount, but you could use an adapter.

It's rather more expensive than the MCP4922, if you can find anywhere that sells it. Having said that Analog Devices will send you samples - they sent me some a few weeks back, only took a couple of days to arrive.

Robin Price built a midi-cv converter using an AD5668 and posted some code samples too:

http://registeringdomainnamesismorefunthandoingrealwork.com/blogs/?p=5 1
MUFF WIGGLER Forum Index -> Music Tech DIY Goto page 1, 2, 3  Next [all]
Page 1 of 3
Powered by phpBB © phpBB Group