Does my input circuit look OK?

I have an Arduino Uno R3. I have a device connected to it that is powered from the Arduino's GND and 5V pins. I have four -5V to 0V outputs on the device that I am reading with the Arduino's analog inputs. High resolution and accuracy are not critical.

I know very little about electronics. I came up with the following circuit to connect the device's analog outputs to the Arduino's inputs:

The +5V is the Arduino's 5V pin. The pins labelled "in" come from the device's outputs. A0-A3 are the Arduino's analog inputs. Additionally, I am planning on connecting the Arduino's 3.3V pin directly to AREF to lower the reference voltage to 3.3V.

That circuit should give me a 1V to 3V analog input from the -5V to 0V device output. It should also protect the Arduino from negative voltage spikes down to about -7.5V from the device (which should not happen). The resistor values are far enough apart that worst case for 10% tolerance resistors will still not give negative voltage to the Arduino's inputs. The ADC should have roughly 620 steps in the device's -5V to 0V output range, giving me a resolution of about 8mV, which more than satisfies my requirements.

Questions:

  1. Is this circuit OK? Will I safely be able to read the device output voltages with it and are my calculations correct?
  2. Can I connect the Arduino's 3.3V pin to AREF? Do I need a resistor or anything?
  3. Will powering the device with the 5V pin affect the analog input readings?

Thanks!
J

  1. Is this circuit OK? Will I safely be able to read the device output voltages with it and are my calculations correct?

Looks OK to me. Of course I'm not an electrical engineer. :slight_smile:

  1. Can I connect the Arduino's 3.3V pin to AREF? Do I need a resistor or anything?

One risk is that the Aref pin, when EXTERNAL is not selected, connects to the internal voltage reference. By default it is connected to +5V when the system powers up. Might be good to put a resistor in to limit the current coming from Vcc out the Aref pin to the 3.3V line.

  1. Will powering the device with the 5V pin affect the analog input readings?

No, as long as you have some decoupling capacitors to keep noise out of the 5V line or use the 3.3V reference.

Thanks!
J
[/quote]

Thank you!! Quick question before I revisit my circuit:

johnwasser:
One risk is that the Aref pin, when EXTERNAL is not selected, connects to the internal voltage reference. By default it is connected to +5V when the system powers up.

Are you sure that +5V is the initial state? I am looking at the atmega328p datasheet (http://atmega32-avr.com/Download/atmega328_datasheet.pdf), page 262. There it says the initial value for REFS0 and REFS1 is 0, which selects an external voltage reference source. Does the Arduino system change this when it powers on?

Edit: I answered my own question with the Arduino documentation, which reads:

Don't use anything less than 0V or more than 5V for external reference voltage on the AREF pin! If you're using an external reference on the AREF pin, you must set the analog reference to EXTERNAL before calling analogRead(). Otherwise, you will short together the active reference voltage (internally generated) and the AREF pin, possibly damaging the microcontroller on your Arduino board.

To me this implies that the initial state on power up is the external reference, but software sets it to the +5V reference the first time analogRead() is called unless analogReference() is called first. So it seems I should be fine with no resistor as long as I never call analogRead() before analogReference(). The Atmega datasheet says the reference voltage can be measured via the AREF pin, even if the internal references are selected, so when I get home I will verify this behavior with my meter.

J

My measurement shows only about 4.5 mV on AREF on power-up.


This sketch causes 1.096 V to appear on AREF:

void setup()
  {
  analogReference (INTERNAL);
  analogRead (A0);
  }

void loop()  {  }

(The switching of the reference is triggered by the analogRead).


This sketch causes 5V to appear on AREF:

void setup()
  {
  analogReference (DEFAULT);
  analogRead (A0);
  }

void loop()  {  }

This sketch causes 0.004 V to appear on AREF (so effectively it's an input):

void setup()
  {
  analogReference (EXTERNAL);
  analogRead (A0);
  }

void loop()  {  }