Introduction: Arduino 16-bit 500SPS Dual Channel DAQ

Long story short: I needed to sample an analog signal with as many bits and samples per second as possible but without breaking the bank. I also needed the sampled data to be stored on my PC.

In this instructable I will show you how to do just that for less than $10 per one DAQ unit.

If you want to know more WHY I built this, check out my GitHub page about the Meteor Radiometer project.

Step 1: Parts & Equipment

These are the parts we'll need. I have provided the links for the cheapest ones I could find (which I bought and they work!).

Parts (from ebay):

  • Arduino UNO clone: LINK
  • Arduino UNO ProtoShield: LINK (note: if you buy one from another retailer, be sure it looks exactly like the one on the image!)
  • AD7705 analog-to-digital converter board: LINK
  • Screw terminals: LINK
  • A few pieces of wire (I sacrificed one Dupont wire, its nice and thin)

Equipment:

  • Multimeter
  • Soldering iron
  • Solder
  • Pliers, a small screwdriver

Step 2: Soldering the ADC Board to the ProtoShield

This ADC board is great because you can sample an analog signal with 16 bits at 500 samples per second! It also has a built-in gain control, filters, etc. But first we need to properly connect it.

The ADC board comes with yellow piece of 4 pin headers which needs to be soldered to the ADC board as well as the ProtoShield.

  1. Take the ProtoShield and put it's top side up (the side with female pin headers).
  2. Place the yellow pin header as indicated on the first image. It is important to position it in the right spot - one row below the top row of ProtoShield pin holes, and such that the columns it is covering are without any markings.
  3. The pins on the yellow piece are of 2 different lengths with respect to the yellow plastic. Make sure that the shorter pins are on top.
  4. Put the ADC board on the ProtoShield - align holes on the ADC board with pins from the yellow pin header.
  5. Solder the pins
  6. Turn the ProtoShield upside down and solder the ADC board to the ProtoShield

Step 3: Soldering Screw Terminals

To somehow connect your source of signal to the DAQ board, you need a few screw terminals.

  1. Use a marker to draw the path were we will run our signal lines from the board to the screw terminals. Draw the lines as they are shown on the first image. This will help us during soldering. Notice that there are also 2 lines connecting the VCC and GND from the ProtoShield to the ADC board!
  2. Turn the ProtoShield to its top side and place the screw terminals as it is shown on the second image. Be sure that the inputs of the terminal (big holes) are facing outward. The third image shows the bottom side of the ProtoShield with screw terminals in place.
  3. Solder the terminals.

Step 4: Soldering Signal Lines 1

Now the hard... ahem... "fun" part. We need to connect the pins of the ADC to the pins of the screw terminals. We can do this using some wires, but I have chosen to do this with solder. So take some solder (in form of a thin wire), solder one end to the ADC pin (hold the solder wire on the little ball of solder until it cools), then align the wire with the black marker line we drew. Cut the solder with the soldering iron and solder the free end to the screw terminal pin.

You will notice that you'll have to make a 90 deg angle turn on the second pin. I recommend you first make a small ball of solder on every 90 degree turn point and solder it from one point to the other. Once you finish soldering the second pin, you should have it looking like mine (second image).

Testing time! Now to see if we did a proper job soldering. Use your multimeter in the ‘Continuity’ mode (it should produce a sound when you touch the two probes together).

  1. Check if there is a connection between the AIN2+ pin and the left input of the screw terminal unit at the right.
  2. Now check if there is a connection between the AIN2- pin and the right input of the screw terminal unit at the right.

Finally, make sure there is NO connection between those two pins. If there IS a connection, you must find where the two solders are touching and remove that piece of solder.

If you did things right, I recommend you use your marker to write on the screw terminal which input is which (fourth image).

Step 5: Soldering Signal Lines 2

Do the same thing for the AIN1 terminal. This one can be a bit tricky as it has more 90 degree turns.

Take a look at the first image how I put little drops of solder on the 90 degree turn points. This will help you align the wires.

When you are done, test the pins as you did in the previous step. NOTE: Do not be alarmed if the AIN1- and AIN2- are connected, it's fine. They are all connected to the GND.

Finally, write the AIN1+ and AIN1- in the screw terminal and you are good to go!

Step 6: Soldering GND and VCC

Before we set out soldering with real wires, we need to connect the ADC board to power lines. There are two: GND and VCC (i.e. +5V). The good thing about this ProtoShield is that it has them available quite close to our ADC power pins.

See the first image and solder the power pins.

Finally, test if they are properly connected.

Step 7: Soldering ADC Communication Lines

ADC needs to talk with Arduino somehow. I won't get into details how they actually talk (you can read about it on Wikipedia), I'll just show you what you need to solder.

We'll need to solder 4 ADC pins to 4 ProtoShield pins:

  • Pin 10 to CS
  • Pin 11 to DIN
  • Pin 12 to DOUT
  • Pin 13 to SCK

There is a little legend on the ADC board to show you which ADC pin is which. When you turn the board on the other side it's a bit difficult to know. I have attached images to help you with soldering.

Notice when I'm soldering CS and DIN: I have first soldered a wire to CS and a wire to Pin 11, and then soldered them to their respective pins. This is useful as it allows you to solder with one side free, instead of soldering between 2 pins.

Finally, test that you have correctly soldered everything.

Step 8: Hardware Done!

If you did everything right, you should have your DAQ shield ready for a real test.

Connect the shield with the Arduino.

Step 9: Preparing the Test

To test the DAQ shield, I have decided to use a simple potentiometer.

A potentiometer has 3 pins - connect the leftmost to +5V, the rightmost to GND and the middle to the AIN1+ on the DAQ shield.

Connect the Arduino to your PC with an USB cable.

OPTIONAL: If you still don't have the Arduino drivers installed and can't find them for your Arduino 340P clone (i.e. the one I recommended), see this LINK.

Several things can happen when you connect the Arduino to your PC:

  • a) absolutely nothing
  • b) Arduino and/or DAQ shield release a puff of blue smoke
  • c) Arduino and/or DAQ shield catches fire

If nothing happens, you may be on the road to success. This would mean the drivers are properly installed and you have soldered everything right. There is an off chance something is not properly connected - but you should have caught that if you did the testing as you were supposed to.

Now, regarding b) and c): depending on the severity of your situation, you should probably buy new parts and start from scratch. Or in extreme cases, contact your local fire department.

Step 10: Installing Arduino Software and AD770X Library

I will presume a basic knowledge of using the Arduino platform. If this is the first time you are working with Arduino, you will surely find this instructable very helpful.

To use the DAQ shield with my software, you will need to install a few software packages.

For using the Arduino:

  • Arduino IDE - most likely you are running Windows, so download the Windows Installer and install it
  • modified AD770X library

Thanks to Kerry D. Wong, we have a functional library for using the AD7705 ADC board with Arduino. I have slightly modified this library to use 500 samples per second and you have it attached to this post.

  1. Download the AD770X.zip and unpack it
  2. Copy the unpacked folder to My Documents/Arduino/Libraries
  3. Download this file: LINK
  4. Unpack it and open the file: MeteorRadiometer-master\Arduino\MeteorRadiometerArduino\MeteorRadiometerArduino.ino
  5. Upload this Arduino sketch to your Arduino device.
  6. Make note on which COM port your Arduino is connected on (e.g. COM4).

You are just one step away from sampling the potentiometer signal!

Extra:

If you take a look at the Arduino sketch you uploaded, you will notice that when it starts sending the data to PC via serial, it also turns the digital pin 8 on. I used this to control a relay. Currently it has no purpose, but maybe you have some idea what to use it for. Pin 8 is turned off when the DAQ stops recording.

Step 11: Installing Python and Additional Libraries

To use the DAQ shield you will need to have Python installed (+ a few Python libraries).

Here is the complete list:

  • Python 2.7
  • Python libraries:
    • Matplotlib
    • Numpy
    • Scipy
    • PySerial

Installing Python + libraries:

To easily install everything you need, download and install Anaconda Python 2.7. That's it, you're done.

If you already have Python installed, but not the Anaconda version, I would recommend you google how to install any libraries you may be missing.

Extra:

I don't like Python's original IDLE. Some people prefer to code in Eclipse, but I find it too cumbersome. So I use Sublime. It's lightweight and has everything I need.

Step 12: Start Sampling!

It's time for a final test.

Here's what to do:

  1. Download the ZIP file in the attachment.
  2. Unpack it and open the readArduino.py file for editing.
  3. Locate this line of code:
    ser = serial.Serial('COM4', 115200) 
  4. Remember the COM port of your Arduino? My COM port is COM4. Modify the previous line accordingly if yours is different.

  5. Run the script! (F5 is using Python IDLE of Ctrl+B if you are using Sublime)

  6. Start turning the potentiometer randomly.

  7. It will run for 10 seconds and at the end it will show you how the input signal changed on a graph!

Bravo, you did it, it works!

Step 13: Recording and Plotting

OK, let's say you got the DAQ working and you hooked it up to a signal source of your preference.

It fun to see the signal you just captured, but what if you want to record for a longer period of time and leave the DAQ unattended?

Recording:

Take a look at the ZIP file from the previous step. There is a file called radiometerRecord.py. In that file there are several important lines of code to modify:

# Record duration in hours 
record_duration = 8 #hrs 

# Duration of a single time block in seconds 
data_block_time = 10.24 #s

With record_duration you define how many hours you want the DAQ to record. It will store the data to a CSV file, and every data point will be time stamped.

With data_block_time you define how many samples will be in one CSV file. E.g. you want one file per minute then you define data_block_time to be 60.

Run the script and start recording!

Plotting the data:

So you got yourself some CSV files that were recorded by the radiometerRecord.py script and you want to see what was actually recorded. This is where the radiometerPlot.py script comes in. It plots the data from the CSV files and stores the results as PNG images.

It has several important lines of code that will have to be modified:

# Where are the CSV files relative to the script
csv_directory = '2015082223 Pula' # Directory where to output the plots plot_dir = 'plots'

So after the recording you transferred the CSV files to some folder (e.g. 'test1'). You must tell the plotting script where to look for those CSV files by using the csv_directory variable (e.g. csv_directory = 'test1').

In what folder do you want the script to plot the results in? Use the plot_dir variable to tell it, although you can just leave the default value 'plots'.

Run the script and you should have your data plotted!

Step 14: Modifying Sampling Rate and Gain

Maybe you won't need such big sampling rate or your signal is very weak and you need to amplify it. In those cases, you will have to modify the AD770X library and re-upload that Arduino sketch.

Open the AD770x.cpp in My Documents/Arduino/Libraries/AD770X. There is a piece of code at the bottom of the file:

void AD770X::init(byte channel) {<br>    init(channel, CLK_DIV_1, BIPOLAR, GAIN_1, UPDATE_RATE_500);
}

To modify the number of samples per second, you have to change the UPDATE_RATE_500 constant. Here's what options are available:

  • UPDATE_RATE_20
  • UPDATE_RATE_25
  • UPDATE_RATE_50
  • UPDATE_RATE_60
  • UPDATE_RATE_100
  • UPDATE_RATE_200
  • UPDATE_RATE_250
  • UPDATE_RATE_500

If you need to modify the gain, here are the options:

  • GAIN_1
  • GAIN_2
  • GAIN_4
  • GAIN_8
  • GAIN_16
  • GAIN_32
  • GAIN_64
  • GAIN_128

When you are done modifying, save the AD770x.cpp file and re-upload that Arduino sketch.

IMPORTANT:

The DAQ is currently only using the AIN1 input. If you want to use the AIN2, you will have to modify both the Arduino sketch and the Python scripts!

Step 15: Final Thoughts

That's it, thank you for reading my instructable! I have been following this site for more than 9 years now (I remember the good ol' Weekend Builder newsletter) and have finally decided to make one instructable.

There are perhaps some details I have unintentionally left out, so feel free to ask questions in the comments!

Comments

author
AlisdairH (author)2016-03-19

Hey thanks for making this, I am trying to measure temperature using an RTD 3wire pt100. Two questions: I had an error when running the readArduino script, which immediately closed the script. It said no module called serial. I downloaded pyserial but it wont install so I'm kind of lost there.

Second question, I'm a bit confused as to how to wire the rtd with the ADC board... is it the same as the pot (5v,Gnd, ain1)? Or do I need put the Gnd on both ain- and Gnd? any help would be swell.

author
delorayn (author)AlisdairH2016-03-19

Thank you for asking!

So regarding the script, if you installed Anaconda Python, you should be good to go. If you only installed Python separately, then I recommend opening a Command Prompt window (search on google how to do that if you have no clue what I'm talking about) and write:

pip install pyserial

Hit Enter and PySerial should be installed. But you will need other libraries as well: numpy and matplotlib. You could google how to install each one, but why not remove your current python installation and install Anaconda Python 2.7? That should take care of any library issues.

I recommend that you open the Python script with a text editor and check that you have the proper COM port set (see Step 12).

Regarding the RTD, I have no experience with it nor have any idea how to wire it. Try to dig some more on the interwebs. But to answer (a part) your question: The AIN- ports are already connected to the GND (if you did your soldering right) internally in the ADC. That's why in Step 9 I only connected the middle potentiometer pin to the AIN1+. But you should certainly connect the GND from the RTD to the Arduino GND.

author
AlisdairH (author)delorayn2016-03-20

Thanks for getting back to me. I was so thrilled to see somebody using an identical adc!
I got the python script working, did the pip thing dunno why it wasn't working though, I installed anaconda as instructed.

Now my issue is that I get odd readings with the pot, it gives off either 0.0, 1023, 14336 and sometimes 65535. and the readings don't seem to have any relationship at all to the turn of the pot. I have checked all the wiring swapped out the board for and adc for identical ones. not sure what is going on, I have tried using the example Arduino code from the kwong website with no more success.

author
AlisdairH (author)AlisdairH2016-03-20

I Got it to work! I changed it from ad7706 to 7705 in the example code, have not had a go of your code yet.

author
GrandDiego (author)2015-10-31

What is a DAQ ?

author
tomatoskins (author)2015-10-16

WOW! Over 9 years! And such a great instructable! I'm excited to see what else you share!