5
\$\begingroup\$

I need to perform a A/D conversion for a differential signal using Arduino Uno. I have tried a software method where I connect one input to A0 and another to A1, read ADC for both channels and then subtract it in the code. But the 100 us time to convert the analog signals is causing some errors as it is not perfectly a differential signal conversion (i.e. there is some delay between the two samples taken and hence it is not exactly differential signal).

Now I am not sure about this, but can I connect one of the analog inputs to the Arduino Uno GND pin and then perform a conversion for the other signal i.e. one input to ground of Arduino another to A0 of Arduino and then perform A/D conversion for A0. Would this be correct? Would it cause damage from a circuit perspective?

\$\endgroup\$
2
  • \$\begingroup\$ Connecting signal source to GND is bad idea. What is your signal source you want to measure? Can you add schematic? I feel you are trying measure differential signal incorrectly. \$\endgroup\$
    – Kamil
    Commented Jun 14, 2014 at 20:49
  • 2
    \$\begingroup\$ How negotiable is your choice of Arduino? If you were to use e.g., a Leonardo or Micro instead of an Uno, you'd have a differential A/D converter built in. \$\endgroup\$ Commented Sep 13, 2014 at 0:29

4 Answers 4

3
\$\begingroup\$

Given your requirement to measure a 20mV signal on top of 2.5V, one solution to this is to use an instrumentation amplifier. To get 10-bit-ish accuracy out of a 20mV signal you need 20uV-ish stability. One choice, only available in a rather tiny MSOP8 package, would be the AD8237. Use the maximum gain possible that will not result in any possible saturation (of the amplifier or overrange of the ADC). That way you can get about 10 bits resolution rather than just a few bits- maybe 200-250 times better.

You could use a lower performance difference amplifier, but it would greatly compromise the measurement.

\$\endgroup\$
1
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

If you look at the ATMega328p datasheet you'll see that the ADC only supports single ended voltage measurements. For some other Atmel chips (e.g. the ATTiny45) you can change the negative pin used by the ADC by setting the ADMUX register. For instance

ADMUX |= _BV(MUX0);

should set ADC1 as the negative input.

If you look at the Arduino source for analogRead (wiring_analog.c) you'll see that this method resets the ADMUX register so you'd have to write your own function if you wanted to use a differential measurement using a chip that supported it.

\$\endgroup\$
5
  • \$\begingroup\$ How does this relate to the original question? Can you be more specific? \$\endgroup\$ Commented Dec 22, 2015 at 8:22
  • 1
    \$\begingroup\$ If you connect one input to ADC0 and the other to ADC1 then set ADC1 as the negative input to the ATMega's ADC you will perform a differential measurement in a single conversion. I haven't tried this using the Arduino analogRead yet but it works using the ADCSR. I use this all the time when building transimpedance amplifiers using op amps. You need to measure the differential voltage across the feedback resistor to get the full resolution of this circuit so I hook the op amp output to ADC0 and the other side of the feedback resistor to ADC1. \$\endgroup\$
    – 32bits
    Commented Dec 22, 2015 at 17:36
  • 2
    \$\begingroup\$ I just got ahold of an ATMega and realized I'm wrong. This chip does not support differential A to D conversion. The section I was reading is the mega's Analog Comparator which does allow a differential comparison. My comments stands for ATTiny chips though which is what I've been using to measure my TIA circuit. \$\endgroup\$
    – 32bits
    Commented Dec 23, 2015 at 4:18
  • \$\begingroup\$ Please, update your answer accordingly. It is a great answer, even if it does not proves useful for the MCU used by the OP. You can edit and comment that you cannot use an ATMega328p for the purpose but that you can use some other Atmel MCUs (with very similar microarchitecture). Thank you! \$\endgroup\$ Commented Dec 23, 2015 at 8:33
  • \$\begingroup\$ This should be possible on the Atmega328. Look at how it was implemented here: softservice.com.pl/corolla/avc/ipod.php \$\endgroup\$
    – Greg Nutt
    Commented Feb 10, 2023 at 15:30
1
\$\begingroup\$

You can use Arduino Leonardo, which is based on AtMega32U4, which supports differential ADC input. However, the Arduino library doesn't seem to support this mode, so you may need to manipulate registers directly.

There is a small example here: https://forum.arduino.cc/index.php?topic=276903.0

\$\endgroup\$
0
\$\begingroup\$

You should use one of these (hardware) solutions

  • op-amp in differential circuit (LM358 - cheap and popular rail-to-rail op-amp)
  • external differential ADC (MCP3421 - i2c, differential, slow, accurrate, easy to use but slow)

to measure differential signal with ATmega328, because this microcontroller ADC has no differential feature.

Trying to connect your signal source may be very bad idea (depending on your signal source).

If your signal can be sampled slower - you can add some RC filters to make voltage changes slow enough to get difference by measuring 2 channels one after another.

\$\endgroup\$
2
  • \$\begingroup\$ Hi the two differntial input specifications are as follows. The two inputs have a 20mV signal riding on +2.5V DC. I was wondering if i could connect one of these two the GND pins and another to one of the analog input pins. So that when i do an ADC conversion, I get the differential voltage converted. \$\endgroup\$
    – dpk
    Commented Jun 15, 2014 at 17:20
  • 1
    \$\begingroup\$ IF AND ONLY IF the two systems have different grounds and the signal is always positive can you connect one of them to the ground. This is usually not the case. \$\endgroup\$
    – pjc50
    Commented Jun 14, 2015 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.