Is MCP4728 able to generate different waves with different voltage and frequency simultaneously?

Post here to discuss thoughts on DAC's.

Moderators: Chuckt, Garth, bitfogav

Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
lulala
newbie
newbie
Posts: 4
Joined: Sat Aug 20, 2016 3:47 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Is MCP4728 able to generate different waves with different voltage and frequency simultaneously?

Post by lulala » Mon Oct 18, 2021 1:22 pm

I’m using the MCP4728 DAC with Arduino. I have a question. Is MCP4728 able to generate different waves with different voltage and frequency simultaneously?
Thanks in advance!

Garth
I practically live here!
I practically live here!
Posts: 232
Joined: Wed Jan 16, 2013 1:17 pm
Contact:

Re: Is MCP4728 able to generate different waves with different voltage and frequency simultaneously?

Post by Garth » Mon Oct 18, 2021 3:03 pm

It's not a signal generator. I only converts numbers to DC voltages. It has four digital-to-analog converters (DACs), so it can output four different ones at once; but each voltage will remain stable until you write a new number to the particular DAC. For example, you might write to channel A the number that makes it output 1.06V. It will continue at 1.06V, ie, a DC voltage, until you write a new number to it. You can keep writing the individual sample numbers to generate a wave, and in fact you could write to one DAC and then another and then another and then come back to the first one to write the next sample for that channel. You do have to keep writing on a regular schedule though if you want AC signals. It won't generate them by itself.

So for example, if you wanted to sample at 24kHz, you would have to write to each channel every 41.67µs. To write to all four that often, you would have to do one every 10.42µs. At 18 bits each (ie, two bytes plus acknowledge bits), that's a bit every 578.7ns, ie, a bit rate of 1.728Mbps, slightly over half of what it can handle in its high-speed mode of 3.4Mbps. Its other I²C speeds will not be fast enough. If you want a faster converter, you need to go to SPI or parallel, not I²C. I²C's speed is pretty limited. I'm looking at page 38 of the data sheet for this, where you select the device once, keep it selected and in high-speed mode, and just keep writing samples, as it cycles through the channels.

The common question then is, "Do I need a smoothing filter, to smooth-out the steps?" The answer is probably not. Take a look at this analysis I did 30 years ago of a sine wave sampled in only 16 steps per cycle. (The graphs on the right tell the phase that the various harmonics are at, with the vertical scale being 40° per division, such that you could wrap the paper around like a toilet-paper tube, so the +180° would meet the -180°.)
SineStepDistortion.jpg
SineStepDistortion.jpg (124.33 KiB) Viewed 7644 times
With 16 steps, the first two distortion products are at the 15th and 17th harmonics, and they are about 24dB down from the fundamental. If the fundamental were at 1kHz, those harmonics, that far down, are nearly inaudible. (At 100Hz instead of 1kHz, then yes, 16 samples per cycle would produce very audible distortion products; but what will remain the same is the number of samples per second, not the number of samples per cycle, so at the same sampling rate, 100Hz would get 160 samples per cycle, not 16. (You may need anti-alias filtering though.)

The number of samples per cycle does not need to be an integer. Look up, if you're not already familiar with it, direct digital synthesis (DDS), or numerically controlled oscillator. You can of course produce arbitrary waveforms. The signal does not need to be sine waves, nor do it need to repeat over some interval. It will require constant attention from the processor though, as the DACs will not produce signals on their own.
http://WilsonMinesCo.com/ lots of 6502 resources

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 1 guest