Jump to content
  • 0

Analog shield A/D counts to voltage


jfsaraceno

Question

Hello Digilent community,

I'm running an analog shield on an arduino uno (well, actually an Ruggeduino SE, but I understand they would operate the same here). Arduino 1.8.2

I'm reading from two sensors and reporting data to the terminal.The board is attached to and powered by usb (which reads ~4.75 V):

The sensors are powered form the Analog shields +5/-5 V rails.  

1) A thermistor that is dropping over a 10K resistor on analog channel 0. The analog shield reports the thermistor reading ~48150 A/D counts when it reads ~2380 mV with the multi meter. 

2) an ion selective electrode another sensor that outputs -150 to +150 mV on analog channel 1. The sensor reads ~33070 counts and 55 mV with the multimeter

I would like to know the transfer equation to convert the A/D count so that I can compare the analog shield reading to my multimeter. The sensors have been characterized in the voltage domain so I would like to convert the A/D counts to volts so that I can convert the sensor readings to engineering units (celsius, etc).This is a newb question, yes - I don't have any experience with bipolar sensors and A/D converters.

Typically the transfer function for A/D to volts is something like this:

Equation 1 (from googling around): Volts = ((A/D reading / (Nbits-1))* Vfullscale) - Vfullscale/2

For this system I've gathered the following info from the datasheets and docs:

Nbits -1= 2^16 -1 = 65535, 

Vfullscale = 10V (5V to -5V),

Are these values correct? Should I change them to the bus voltage that is measured (for example, change 5V to 4.75V when plugged into USB)?

Plugging these values in for the thermistor reading I get: 2347 mV, an error of ~1.5%, not bad.

Plugging these values in for the ion selective electrode reading I get: 46.2 mV, an error of ~16%.

Do these error magnitudes seem acceptable to you? I'll likely re-characterize sensors with this platform as it will deployed rather than relying on the previous sensor characterizations done with a multimeter.

I'd like to know if this is this the correct approach to convert A/D counts, and if so, suggest it be added to the example code or documentation to help others. If not, please let me know how and where I'm in error.

Here is the code:

//include libraries
#include <analogShield.h>   //Include to use analog shield.
#include <SPI.h>  //required for ChipKIT but does not affect Arduino\

//Defines
// which analog pin to connect
#define THERMISTORPIN 0
#define ISEPIN 3
// full scale voltage (5V- -5V)
#define VFS 10.0
//loop delay time in ms
#define DELAYTIME 1000
//16 bits (0 to 65535)
#define NBITS 65535.0

void setup() {
  Serial.begin(9600);
}

void loop() {
  // read data from A/D
  double ISE_counts = analog.read(ISEPIN);
  double  therm_counts = analog.read(THERMISTORPIN);
  //Convert A/D counts to volts
  double ISE_volts = ((ISE_counts / NBITS) * VFS) - VFS / 2;
  double therm_volts = ((therm_counts / NBITS) * VFS) - VFS / 2;
  //print data to the terminal
  Serial.print("Average temperature voltage: ");
  Serial.println(therm_volts);
  Serial.print("Average ISE voltage: ");
  Serial.println(ISE_volts);
  delay(DELAYTIME);
}

Thanks in advance,

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Hi @jfsaraceno,

I would suggest to run the passthrough demo and see the results that you get there for the different voltages.  Here is the datasheet for the ADC and here is the datasheet for the DAC. I do not see an issue with you code to convert to an analog value. With that being said on page 27 of the DAC datasheet it has the formula of how the DAC converts the digital data to an analog voltage that might be helpful. Unfortunately, We do not have a demo that converts the digital to analog in software.  You could look at the analogShield::read and the analogShield::write in the analogShield,cpp to see how we handle the the digital data from the ADC and what we do to the digital data when we send it to the DAC.

thank you,

Jon 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...