Go Down

Topic: Analog Output Solutions for Arduino Uno R3 (Read 6054 times) previous topic - next topic


Hello everyone,

I am new to the Arduino forums, and I was looking for expertise in generating an analog output for the Arduino. I am given to understand that true analog output without PWM is impossible without a downstream digital to analog converter. What I am trying to do is to have the board output this signal:

The Y axis is Voltage in volts, and the X axis is time in seconds. FFT shows it's a 166Hz signal. The Arduino will most likely output this signal to a DB9 breakout, which will interface with downstream electronics that display a filtered version. What I care most about is getting the Arduino to store and reproduce this signal indefinitely (pictured is only about 50ms, but I want it to output continuously). I am wondering what kind of DAC should I get, considering that I wish to preserve the frequency elements in this signal (166Hz is the native frequency, but there are elements around 5 - 10 kHz I would also like to preserve). I'm not too sure about appropriate output impedance requirements. SNR does not have to be perfect either.

Any help would be greatly greatly appreciated! Thank you very much!


You signal seems to be a low pass filtered sum of two phase shifted different amplitude square waves. You do not need a DAC to generate a good imitation of such a signal.


I see what you mean. I've also zoomed in on the signal to show that better:

However, on a larger time scale, there is about a 0.75 - 1Hz slow frequency sinusoidal drift of the amplitude that I would also like to preserve.

This signal is actually the output from a standard pulse oximeter, and I am fairly certain there no filtering performed on it before it enters a patient monitor. The two overlapping square wave portions of the signal is from a phototransistor, receiving light signals from a red and IR LED that is switching on and off at 166Hz. The slow frequency drift actually contains information about the heart rate and needs to be sent to the monitor as well.

Because the monitor is super sensitive, I want to emulate this signal as close as I can with the Arduino. Therefore, if I would prefer to go the route of having a downstream DAC, where would I begin and how do I choose an appropriate component for this application?

Thanks again for any assistance!


problem isn't while looking straight at it, but if you move your eyes quickly it tracks across your vision,

That is just mains pickup beating and the instrument will filter it out.
There is a whole host of D/A converters avaliable, first choose the interface method, probbly SPI, then how many bits, what sort of resolution do you want?
Then go on a distribuitors web site and there is normally a filter to extract the right converter from the many hundreds avaliable.


MCP4821 from microchip.com with SPI interface will handle this nicely for you
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


Two approaches, both are fairly simple to implement:

1) You can digitize the data over 1 period, including drift. You can then use a phase accumulator to output the data to a dac to produce the desired output. This approach is simple, but requires considerable amount of (flash) space. If you want to reproduce 10khz signals over  a 1 second period, you need 40k+ data points (at 4x oversampling). At 8-bit per data point, you are talking about 40Kb of space; or double that for 16-bit resolution.

2) You can separate the data into two signals, a 166hz signal on top of a 1hz drift. You can keep two phase accumulators and combine them to form the output signal. More involved programming wise but will cut down your rom requirement considerably.

Either way, it is totally doable.


The fastest I tried, using the approach I outlined earlier, is to output to a parallel 8-bit dac at 10us per data point.

So you can conceivably make this work with a highspeed spi dac as well, using hardware spi.

With more programming tricks (naked isr + inline coding + optimization), you make be able to get it even faster.


Thank you very much everyone for the extremely helpful responses.

I am particularly interested in what was proposed by dhenry, but I am unsure as to the hardware implementation of a phase accumulator. It seems I'll have to use a chip or architecture designed for a direct digital synthesizer, which not only includes the NCO, but also the DAC as well. If there is a need for a DDS chip, how will my signal and my desired application select the supply current and voltage, the optimal SFDR, and clock speed?

I found a rough example of a DDS chip here: http://www.analog.com/en/rfif-components/direct-digital-synthesis-dds/ad9830/products/product.html

You also mentioned a concern with flash space. If I were to digitize one period and rely on a phase accumulator to periodically output my desired signal, there shouldn't be a reason that the arduino's memory couldn't handle such an application should there?

Thanks again for all the help!


A phase accumulator is really a counter, or an index. It increments with time, and is used to pick up an output from an array that contains your desired waveform.

Go Up