Puzzled by voltage on UNO pin

The output from a motion sensor (MS) to my UNO D6 pin is normally high via 1k to the MS 5V supply and goes low when triggered by movement.

But when the UNO’s 5V supply is removed (not the MS supply, which is permanent), D6 drops to about 2V instead of staying at 5V as I’d expected. Same with alternative pins. I thought that these were high impedance so this puzzles me.

It matters because I’m working on another almost identical circuit using the same sensor input, and that obviously fails. I’m guessing the reason will prove embarrassingly obvious, but…

Terry

Never do this.

You may be back feeding thru the pin protection diodes.

1 Like

Show us a good schematic of your circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.

Thanks, that could explain it if I’ve understood you correctly. But does that mean you should never turn off an Arduino circuit if any of its inputs are connected to an external sensor that may have a voltage? If so isn’t that a serious restriction on practical usage?

You can design interface circuits to allow your I/O devices to remain powered when the Arduino is powered off.

Yes, but it's wider than that. Generally, you should never allow any pin of any chip to be exposed to a higher voltage than that chip's own Vcc pin*.

The reason is: those diodes @LarryD mentioned are called ESD protection diodes. Without them, most chips would be damaged between the factory and the circuit they are intended/purchased for. So that's great, but there is a side effect. If any pin is at a higher voltage than the Vcc pin, those diodes will allow the chip to be "phantom powered", because current can flow from the pin to the Vcc pin. This isn't how the chip is designed to work, and it can easily be damaged by that.

*: There are exceptions, chips that are designed especially to deal with that situation. For example tpic6b595. But not most MCU chips and other logic chips.

Please explain further. Are you thinking diodes and pull-up resistors?

Would have to see what the OP's equivalent external circuit is to say for sure.

An Arduino output could drive an NPN, PNP or MOSFET transistor that then drives the I/O device.
Could also drive a: transistor relay pair, opto-isolator, in some cases isolation diodes and/or open collector/drain arrays.

The OP's external devices can drive similar that then go to an Arduino's input which isolates the external I/O from the unpowered Arduino.

Certainly not! Why should it be? You always have just one 5 V power supply for all 5 V devices. :roll_eyes:

Otherwise you have to provide isolation.

Larry:

Here's what I think my circuit looks like. I don't have the motion sensor's internal circuit but as you see I think the output is taken low by an NPN/MOSFET or similar. The ebay supplier's description actually assumes a strip of LEDs as output. I've used a 1K resistor to 5V to get my low-going UNO signal.

It's inconvenient but I'll probably simply remove the sensor input as well as the 328 power, while I'm testing the second similar circuit, to avoid the issue.

Terry

Remove the 1K. The Arduino can probably use it's internal pull-up, when it is powered. Or connect the 1K to the Arduino's 5V pin rather than the sensor's 5V supply.

Doesn’t work without the 1k.

Did you turn on the internal pull-up resistor ?

Not using PC now so will check in the morning. But why would it matter? The 1k in parallel with built-in 20-30k will be around 900 ohms, closer to what the device expects from an LED strip?

Less components.

No, I use a separate 5V supply for servos, as widely recommended. And I also use a separate 5V supply for my motion sensor at a remote location.

Depends on where you understand "widely recommended". This actually refers to operation from batteries which are not capable of adequately powering the servos where a dip in the supply will clearly cause the Arduino to fail. And yes, the same requirement would apply to the use of a mains supply.

If the said supply is capable of powering the servos and the servos actually operate at 5 V, then you certainly should power both from the same supply - but you still need to connect the power for the servos (5 V and ground) directly to the power supply output terminals and do the same for the Arduino. This then means the servo control lines must travel along with the power lines to the power supply where they then travel back to the Arduino together with its power lines.

As to the motion sensor, if it is as you suggest here, an open-collector pull-down, then it should be isolated from the Arduino by a diode, cathode to motion sensor and anode to Arduino, with the 1k pull-up resistor on the Arduino side, to the Arduino 5 V. This of course means the motion sensor can pull the Arduino input LOW, but never supply any current to it. Same for any open-collector input device.

The 1K may be more appropriate than using only INPUT_PULLUP if the sensor is at some distance with cabling in between.

Re the power supply discussion. Thanks for the follow up, but can I check I’ve properly understood.

Take first the common situation of developing a circuit via the PC USB cable. I assume you now agree that it’s recommended that should not also power the servo(s) ? So then obviously a separate supply is needed, contradicting your original strong assertion that “You always have just one 5 V power supply for all 5 V devices”.

When a single (usually regulated) supply is capable of reliably supplying both the Arduino and servo(s) can you please expand on why you then recommend it’s essential to use only that? I don’t see why it would matter if a ‘larger’ supply powered the remote servo(s), while still using a local or PC USB supply for the Arduino? Obviously a lengthy control wire to the servo(s) is undesirable because it picks up noise, but that’s unavoidable in either case.

Terry

Basically yes - this is phantom powering and to be avoided (or limited to very small currents only). Just power all the sensors from the same power as the microcontroller and you don't have to worry about it.

No, not really. If you have separately powered devices that need to talk to each other you normally use an open-collector bus or opto couplers or something so they aren't at risk of phantom powering. For instance the original MIDI used opto-couplers for precisely this reason.

1 Like

Not a matter of "should not". :roll_eyes: The USB can not, does not power servos.

With a UNO, you do have to be careful about powering the controller board itself from 5 V when connected to a PC via USB, the concern is about "back-feeding" the USB interface of the PC with excess 5 V. The danger is to the PC, not at all the UNO. So you either disconnect the "5V" pin while the PC is connected, or if that is not practical, use a USB cable with the 5 V disconnected.

A minor inconvenience.

Thanks Mark. I’d certainly do that after completing a project, but it does handicap development somewhat while using the IDE.

Terry