Testing the Arduino ADC and DAC

I am presently living away from home as my cottage is being renovated. This makes experimentation difficult as most of my belongings are in storage. I decided to try to instrument what I was doing using my laptop.

I can use my laptop to generate and/or record audio signals and also use it to process and plot data received from the serial port. For my initial experiments I am using a tone generator program to provide sine wave inputs (ToneGen) and Matlab for recording audio and also receiving and processing data from the serial port. The speed of the serial port limits the amount of data that can be sent and therefore the frequencies that can be processed in this way.

The AC coupling used in the original the input circuit attenuates the low frequencies. A better, DC coupled, circuit uses an op-amp as a level shifter and can be used at the same time to adjust the input level to suit the ADC. The circuit that I used is


The idea for the circuit was suggested here. Assuming an ideal op-amp gives, for the {+} input

\displaystyle \frac{V_s-V_+}{R_2}+\frac{V_{in}-V_+}{R_1}=0

and, for the {-} input

\displaystyle \frac{V_-}{R_3}=\frac{V_{out}-V_-}{R_4}.

Rearranging gives

\displaystyle R_1 V_s+R_2 V_{in}=(R_1+R_2)V_+


\displaystyle R_3 V_{out}=(R_3+R_4)V_-.

Ideally {V_+=V_-} and choosing {R_1+R_2=R_3+R_4} gives

\displaystyle R_3 V_{out}=R_1 V_s+R_2 V_{in}.

Adjusting levels so that when {V_{in}=0, V_{out}=V_s/2} gives {R_3=2R_1} and

\displaystyle V_{out}=\frac{V_s}{2}+\left(\frac{R_2}{2R_1}\right)V_{in}.

The voltage gain {g=R_2/2R_1}. Choosing, for the moment, {g=1} gives

\displaystyle R_4=R_1\mbox{\quad and\quad}R_3=R_2=2R_1.

The recommendations here say that the resistors should all be at least {10k} and so I have taken

\displaystyle R_4=R_1=10k\mbox{\quad and\quad}R_3=R_2=20k.

For my circuit I used a TI OPA2340 low voltage rail-to-rail op-amp which comes in an 8 pin DIP package making it easy to use on a breadboard.


This entry was posted in Arduino. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s