Pages: [1]   Go Down
Author Topic: Analog Output Solutions for Arduino Uno R3  (Read 2493 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34143
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27088
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

MCP4821 from microchip.com with SPI interface will handle this nicely for you
http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en024015
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34143
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have a look here:-
http://uk.farnell.com/jsp/search/browse.jsp?N=2031+203666&Ntk=gensearch&Ntt=D%2FA&Ntx=mode+matchallpartial
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: