Go Down

Topic: Using two oscillators dual DAC (Read 969 times) previous topic - next topic


Looking for recommendations for using a simple sketch to utilize two DACs on DUE or comparable unit to generate a low freq wave (.1 Hz to 30 Hz) as one component with the other oscillator riding on the same wave form with an adjustable frequency of 1 Hz to 100 Hz.

I'd use two analog inputs to set the frequency pots.

Would I have to take one DAC output and use as analog reference to achieve this as a mixer?

Ideally would like to be able to control this from an iPhone.



Mixing is done by summation so it's easy to do it in software.   For example, add sample-1 from the 1st waveform to sample 1 of the 2nd waveform, add sample-2 to sample-2, etc.*

But there are a couple of "extra things".    ...If the sum exceeds the voltage limits (typically 5V peak-to-peak) you'll get clipping so you'll need to scale-down** before or after summing.

...Analog mixers are built around summing amplifiers and that's pretty easy too.   

Most mixers have level controls for the channels (before mixing) plus a master level control (after mixing) so in practice it's a weighted average instead of a simple sum.

Most mixing software works in floating-point so the software itself won't clip, but you can still clip the DAC (which is integer based) so the level has to be reduced before sending the data to the DAC.   

Floating point in the Arduino is probably too slow, but you can use type-longs, etc., but you'll still need to scale-down to 16 or 24 bits to match the DAC.

Or you can make a passive mixer with resistors, and again it works out more like averaging than summing.

* If you're new to digital audio and you don't understand sampling, the Audacity website has a nice tutorial.    i.e.  CD audio is sampled 44,100 times per second with each sample representing the amplitude/height at one instant in time.    The DAC "connects the dots" and smooths/filters to re-create the continuous waveform.

** Volume changes (scaling) is done by multiplication...  Multiply all of the samples by 2 for a +6dB boost, and Multiply by 0.5 for a 6dB cut, etc.



Other copy DELETED.


It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google (who would have thunk it ! ) or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.


Aug 06, 2019, 07:42 am Last Edit: Aug 06, 2019, 07:46 am by Grumpy_Mike
Floating point in the Arduino is probably too slow
He is using a 48MHz Due so for the very low frequency wave he is using then it will be fine.

However a word of caution about those D/A outputs on the Due.
1) They don't operate over the full range of 0 to 3V3 but over a smaller section. Can't remember of hand what so look it up if it is a worry.

2) Those pins are extremely delicate and are only rated for 3mA. It is very easy to burn them out as I, and many others, have discovered. Ideally they should be buffers by an op-amp wired as a voltage follower.

Would I have to take one DAC output and use as analog reference to achieve this as a mixer?
No that would not mix the signals but would amplitude modulate them. Unless you are using the word mix in RF terminology and not audio terminology.


Aug 11, 2019, 10:29 pm Last Edit: Aug 11, 2019, 10:30 pm by MarkT
The DACs go from 1/6th of the supply voltage to 5/6th of the supply voltage (its stated in the
datasheet in a very non-obvious place).  Despite being 12 bit you get far less accuracy than you'd
expect as they have very poor performance (speckle patterns of many LSBs).  They are also very
delicate output pins and many people have fried them.

I strongly recommend using an external SPI (or I2S) DAC using a clean supply voltage from a linear regulator. 
The analog side of the SAM3X8 chip is not upto par, and the Due board 3.3V analog rail is noisy.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up