Using an external 5V source as AREF for Arduino Micro

Background

On the one hand, I have an Arduino Micro powered over USB.

On the other hand, I have an analog circuit with a dedicated voltage regulator, powered by a "wall-wart." This regulator supplies 5V to a number of ratiometric sensors (i.e. output depends on supply voltage). Maximum sensor output will be around 4.8V. The total current drawn by this circuit is too high for the arduino's onboard 5V source to handle, hence the dedicated power supply.

To start with, the only connection between the arduino and the externally powered circuit is the ground.

Goal

My goal is to measure the output of the ratiometric sensors using the arduino.
Accuracy and stability/reproducibility are important.

Questions

I am not sure what the best approach would be, in terms, of reference voltage:

  1. Should I connect the arduino's AREF pin to the external 5V supply (and set analogReference to EXTERNAL), or should I just stick to the default reference voltage (which is the approx. 5V from USB)?

The first option would make most sense to me, because the sensors are supplied by that same external 5V supply. However, after reading the arduino docs, and quite a number of posts on this forum warning against using the AREF pin, I got all scared and confused (e.g. 1, 2, 3).

  1. If I would use AREF, I guess it would be safest to use a resistor in between AREF and the external 5V, as suggested in the analogReference docs. I read somewhere that the suggested 5k represents a lower limit for the resistance. Is that true, or could I also use e.g. 1k and still have good accuracy?

Thanks for your help.

I would just power the Arduino using the external power supply, connected to the 5V Arduino output.

AREF must not exceed the Arduino power supply voltage, which easily possible if, for example, the Arduino is powered by the USB bus.

jremington:
I would just power the Arduino using the external power supply, connected to the 5V Arduino output.

AREF must not exceed the Arduino power supply voltage, which easily possible if, for example, the Arduino is powered by the USB bus.

Thanks jremington, that sounds like a good solution, but I do need the USB connection for serial communication.

If I understand correctly, this post suggests we cannot supply 5V to the arduino's 5V output and have the USB connected at the same time...

Is that correct?

If so, do you think I could connect the external supply through a 1k resistor to protect the AREF? Or would that have other side-effects?

What is the total current drawn by your analog circuit? If your computer USB socket can provide that current you can power everything from USB. Just don't use Vin pin for powering both (arduino and analog circuit)

Is that correct?

It depends on your Arduino. Some designs have a diode to switch between USB and external power, but unless you know for sure, attempting to supply power from two sources is a situation to be avoided.

I recently ran across an eBay Arduino clone that had such a diode, but installed incorrectly. I had to remove the diode and modify the PCB in order to get it to work at all.

It is best not to apply a voltage to AREF unless you really, thoroughly, understand all the circuitry.

Ratiometric sensors are generally best measured by not using AREF, but just using Vcc as reference. Especially if that's the same voltage that powers the sensor itself (you're not clear about that part, or what the sensor even is).

alesam:
Just don't use Vin pin for powering both (arduino and analog circuit)

Actually, if you are using other subsystems - even minor ones - connected to the Arduino, don't use "Vin" for anything!

wvmarle:
Ratiometric sensors are generally best measured by not using AREF, but just using Vcc as reference. Especially if that's the same voltage that powers the sensor itself (you're not clear about that part, or what the sensor even is).

Thanks wvmarle,

As mentioned in my original post, the Arduino Micro is powered over usb, and the sensors are all powered by a dedicated external 5V voltage regulator (powered by a separate power supply). The arduino ground and external circuit ground are tied together.

I left out the sensor specs to keep things focused, sorry about that:
The external circuit has three Honeywell SS495A hall sensors, four Osram SFH 9206 "reflective interrupters," and some LEDs. The SFH 9206 draws most of the current.

What I am seeing, using the default 5v arduino reference, NOT AREF, is that any shifts in the USB voltage, due to e.g. a crappy usb hub, end up in my measurement.

I assume this is because the arduino reference voltage, i.e. the 5V from USB, is influenced, but the sensor input voltage, i.e. the 5V from external regulator, is not.

Please correct me if I'm wrong, but I was hoping that, by tying AREF to the same source that powers the sensors, I could get rid of this issue (because the reference and sensor output would then both be influenced by any shifts in supply voltage).

Thanks again for your help.

I was hoping that, by tying AREF to the same source that powers the sensors, I could get rid of this issue (because the reference and sensor output would then both be influenced by any shifts in supply voltage).

Correct, but this introduces new problems.

The USB Vcc voltage is typically less than 5V, and you MAY NOT use AREF > Vcc.

I remember the data sheet says Aref should be <Vcc + 0.5V. That should be safe in normal operations.

Nonetheless, you will have a serious problem if for whatever reason the external 5V is powered up, but the USB not. That will blow the Aref pin. The same accounts for the sensor outputs which may destroy your analog inputs. To mitigate that problem, add a 10k current limiting resistor in the Aref line. That way you limit current to <0.5mA through the clamping diodes which is safe.

Now the final remaining problem: it's indeed likely that Aref is slightly higher than Vcc in your situation. I have no idea how the ADC reacts to that situation, I can imagine the readings to be off because of that.

Probably the best course of action: cut all voltages in half. So a 1:1 voltage divider on the Aref (the 5V supply) and on all the analog outputs. That will keep it safely well below Vcc - unless the Arduino is powered off, in which case the resistors of the voltage dividers act as current limiting resistors keeping the clamping diodes and the rest from burning. Use 10k resistors for those dividers: high enough to sufficiently limit the current; low enough to have the analog inputs still work properly.

According to the processor data sheet, the analog input voltage should not exceed Vcc.

adc.png

adc.png

deey:
The SFH 9206 draws most of the current.

And that would be four times 20mA?

I think you're creating more problems than you have.
You should be able to draw several hundred milliamps from the Micro when on USB supply.
Leo..

jremington:
According to the processor data sheet, the analog input voltage should not exceed Vcc.

I was looking at the absolute maximum ratings - any pin except RESET is Vcc+0.5V. So you won'tbreak anything by having Aref higher than Vcc by <0.5V. That notwithstanding I'm sure it's not a good idea.

Wawa:
And that would be four times 20mA?

I think you're creating more problems than you have.
You should be able to draw several hundred milliamps from the Micro when on USB supply.
Leo..

Thanks Wawa, using only the USB power would indeed be a lot easier.

This does raise another issue/question, because as far as I know, there were two other reasons for using a separate, dedicated power supply for this analog sensor circuit, viz.:

  • The sensor system is calibrated and this calibration should remain valid, independent of the usb-device the arduino is connected to. I guess this implies the sensor supply and reference should be the same.
  • Minimize noise from the power supply.

Any toughts on that?

In response to your question: The SFH 9206's in this sensor circuit have 0.1k resistors, so at 5V, with a 1.5V forward drop (based on diagram in spec sheet), I would expect around 35mA each (although I did not measure this yet). I did find some current measurements in an old report for the total sensor system of 250mA to 300mA (so that's drawn from the dedicated power supply).

Maybe an alternative could be to keep the dedicated supply for the sensors, but connect this sensor supply voltage to another analog input on the arduino (instead of connecting it to AREF)? This way we would measure both the sensor supply voltage and the sensor outputs, relative to the default arduino reference.

wvmarle:
... The same accounts for the sensor outputs which may destroy your analog inputs. ...

Does this also hold when using the default internal reference with AREF unconnected?

So, for example, if the hall sensor output is 4.8V (typ. source output current 1.5mA according to spec), connected to an analog input pin on the arduino, while the arduino itself is not powered at all, will that blow the analog input?

The phototransistor from the SFH 9206 is used in a basic common-emitter configuration, with only a 4.7k resistor on the collector side.

deey:
So, for example, if the hall sensor output is 4.8V (typ. source output current 1.5mA according to spec), connected to an analog input pin on the arduino, while the arduino itself is not powered at all, will that blow the analog input?

That may happen - depending on the amount of current the output can deliver.

The SFH 9206`s each have a 4.7k resistor, in a basic common-emitter configuration.

OK, you got me to look up the data sheet and that confirms the feeling I had already.

You're doing it wrong. In several ways.

  1. the IR diode can handle up to 50 mA, I can't find a "typical" value - 20 mA or so should be enough in most applications. You can have the USB supply deliver enough current for several of those. That 35 mA of yours is very generous. Still, the USB supply should be able to handle that 300 mA.
  2. if you MUST power them from an external supply, you only use that for the emitter side (the diode). Keep the detector on the Arduino's supply.
  3. it's a digital output: beam is made or broken. You shouldn't be bothering taking analog readings of it, or mess around with Aref, in the first place.
  4. the SS495A is ratiometric, and is best powered from the Arduino and read through the default reference (Vcc). This way changes in voltage of the Arduino don't matter. This will give better stability than an external power supply, which of course is also not perfectly stable.

wvmarle:
OK, you got me to look up the data sheet and that confirms the feeling I had already.

You're doing it wrong. In several ways.

Thanks again for your time, wvmarle. Your help is very much appreciated. :slight_smile:

Unfortunately, I was not involved in the development of this sensor circuit, and there is hardly any documentation, so I can only guess at the reasons for the design choices. But let me try:

  1. the IR diode can handle up to 50 mA, I can't find a "typical" value - 20 mA or so should be enough in most applications. You can have the USB supply deliver enough current for several of those. That 35 mA of yours is very generous. Still, the USB supply should be able to handle that 300 mA.

The SFH 9206 is used here to measure the distance (order of magnitude 1 mm) to a reflective surface (in an enclosed space). This may not be the intended use for the "interrupter" (although "position reporting," from the spec sheet, can be interpreted several ways), but, nevertheless, it works remarkably well. My guess is that the relatively high current of 35mA is necessary to get sufficient signal strength on the detector side.

  1. if you MUST power them from an external supply, you only use that for the emitter side (the diode). Keep the detector on the Arduino's supply.

Sounds good, but, wouldn't I still get issues due to different supply voltages? If the IR diode supply voltage changes, the light intensity changes, so the phototransistor output changes. But the supply voltage for the phototransistor would remain "fixed" at the Arduino/USB level.

  1. it's a digital output: beam is made or broken. You shouldn't be bothering taking analog readings of it, or mess around with Aref, in the first place.

Please excuse my stubbornness, I'm just trying to understand: The detector in the SFH 9206 is an NPN phototransistor. Based on the name "interrupter" (for the IR-diode/phototransistor combination), I guess it would indeed typically be used in a "digital" sense, where the beam is either made or broken. But the actual output is analog, right? Could you tell me what precludes its use as an analog measurement device?

  1. the SS495A is ratiometric, and is best powered from the Arduino and read through the default reference (Vcc). This way changes in voltage of the Arduino don't matter. This will give better stability than an external power supply, which of course is also not perfectly stable.

Would that not increase "noise" considerably? At least when arduino is powered from USB? Currently the external power supply for the sensors uses an ADP3338 high-accuracy, low-noise, voltage regulator, which provides a pretty clean signal.

Sorry for keeping on going with the questions. :wink:

deey:
Thanks again for your time, wvmarle. Your help is very much appreciated. :slight_smile:
Sounds good, but, wouldn't I still get issues due to different supply voltages? If the IR diode supply voltage changes, the light intensity changes, so the phototransistor output changes. But the supply voltage for the phototransistor would remain "fixed" at the Arduino/USB level.

Sure - but the two will react differently, and the detector side will probably react MUCH stronger - there's not that much brightness difference between 30 and 35 mA - which would require about 0.5V change, a change that sees a 10% change in the detector.

"digital" sense, where the beam is either made or broken. But the actual output is analog, right? Could you tell me what precludes its use as an analog measurement device?

The whole digital world is, in the end, implemented in an analog one. So sure the change in resistance of the phototransistor may be used to measure the actual brightness of the beam, even if it's not the intended use.

Thanks again, everyone.

I'll look into a redesign using only USB power.