[Solved!] Power two things from one Pin

Perhaps showing my true analog electronics n00b colors:

I have several devices power pins wired to A0 to allow me to turn them off when my arduino goes into a power-saving mode. One device is a generic 16-pin single color LCD screen with backlight. The backlight is on a separate pin, and I have no trouble controling it. The other device is a pair of digital temperature sensors, Maxim DS18B20 OneWire devices, FWIW. The datasheet for the LCD says it draws 1-4mA and the temperature sensors draw 1-1.5 mA max (each). I actually measured the current at one point, but don't recall the precise values.

The problem is, when I digitalWrite(A0, HIGH); only the LCD works, I am unable to talk to either of the temperature sensors. However, if I disconnect the LCD from A0, the temperature sensors work fine.

What basic electroniics concept have I not learned?

One wire is a combination of power and signal.
Do you try to communicate via A0?
If you connect the LCD you short the signal with the bypasscapacior in the LCD.

If you can post a schematic it's easy to say what's wrong

Pelle

r4z0r7o3:
The datasheet for the LCD says it draws 1-4mA

With backlight?

r4z0r7o3:
What basic electroniics concept have I not learned?

"Measure, measure, measure!"

r4z0r7o3:
I actually measured the current at one point, but don't recall the precise values.

Time to get your multimeter out again...

You need to use a switching device with a low on-resistance to switch
supply to a sensor. The Arduino pin output transistors have an on-resistance
of around 30 ohms which is far too high to regulate a supply effectively,
and you may be overloading the pin drastically.

You also need decoupling on the supply to your devices and Arduino pins
cannot safely drive 100nF load of a typical decoupling capacitor.

Use a PNP transistor or logic-level p-channel FET to switch the supply,
and ensure the load has some decoupling.

Pelleplutt:
One wire is a combination of power and signal.
Do you try to communicate via A0?
If you connect the LCD you short the signal with the bypasscapacior in the LCD.

Naa, just using A0 for Vcc to the LCD and Max18B's. OneWire goes to separate Arduino pins. The OneWire pins go through 4.7k pull-ups to the A0 pin (i.e. not using parasite mode).

With backlight?

I'm running the backlight with PWM from another pin, datasheet says 120-140ma, but what I get out of analogWrite(LEDPIN, 255) is plenty bright enough.

"Measure, measure, measure!"

I did measure, both voltage and current, at many points, and even made sure I wasn't exceeding the current limits for pin-groups on the 328p (it's close, but not going over). Everything else 'works', except the temp-sensors :S They draw current, but don't respond on one-wire bus. You'll have to believe me, I tried my best to troubleshoot first before posting :smiley: There's gotta be something I'm not seeing in my multimeter readings, or something wrong with the design, or something I'm just not measuring correctly :S

datasheet says 120-140ma, but what I get out of analogWrite(LEDPIN, 255) is plenty bright enough.

Sounds like you are overloading that pin then, it will give way more than 40mA if you put the wrong load on it like this.

MarkT told you what to do. I would advise you to do the same. The voltage output from logic pins drops as the current increases so they are not very regulated and **** useless for powering sensors.

MarkT:
You need to use a switching device with a low on-resistance to switch

Thanks, totally unknown concept, but I'll read up on it!

You also need decoupling on the supply to your devices and Arduino pins
cannot safely drive 100nF load of a typical decoupling capacitor.

I have a vague notion of what decoupling is, but no practical experience other than toss small value ceramic caps everywhere with one pin on ground. The ones that don't blow up, are the ones you need :smiley:

Use a PNP transistor or logic-level p-channel FET to switch the supply,
and ensure the load has some decoupling.

I tried this with a NPN (N3904 IIRC) since I want my A0 going low, to turn things off). Stuck a 10k ohm on the base-to-A0 since that's what google said I should do. Worked like a champ! Trouble is, I don't understand why, so I'll read up on "on resistance" as suggested above. Thanks!

I have a vague notion of what decoupling is, but no practical experience other than toss small value ceramic caps everywhere with one pin on ground.

Read.
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

The ones that don't blow up, are the ones you need

Wrong way round. The one that do blow up are the ones you need more than ever only this time get the voltage rating of them correct.

Grumpy_Mike:
Sounds like you are overloading that pin then, it will give way more than 40mA if you put the wrong load on it like this.

Tried disconnecting that LED pin to no avail, problem persists. I selected the LED pin carefully so it's on a different group than A0. However, your advice seems sound, so I'll stick some more protection on it too. Just as easy to drive another transistor that PWMs the backlight. Thanks for the suggestion.

MarkT told you what to do. I would advise you to do the same. The voltage output from logic pins drops as the current increases so they are not very regulated and **** useless for powering sensors.

Told != understanding :smiley:

I'm guessing you must be speaking of this "on resistance" thing? Hmmmm interesting. So the current draw is causing a kind of brown-out for everything on that pin (two sensors + LCD). Perhaps the LCD is able to tolerate the drop but the sensors are not? I still don't totally understand why, but I'll read up on this "on resistance" thing. Interesting concept.

Thanks!

Wrong way round. The one that do blow up are the ones you need more than ever only this time get the voltage rating of them correct.

Awwwwww man! Ruin all the fun. Blowing stuff up and learning is the best! Especially when the combustibles are cheaper than candy :smiley:

I'm only joking of course. I'll go read that link, thanks again!

Grumpy_Mike:
Read.
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

Interesting, Hmmm, okay, that made me totally paranoid about noise, I think I understood about half of it. I'll read it a few more times, but it seems a 'rule of thumb' (not ideal, nor for all situations, but a starting place) is:

  1. 47uF on close to the power-supply/regulator/battery.
  2. 0.1uF close to Vcc pins of most ICs on the board.
  3. For really really really sensitive bits (like 328p's A/D VCC) stick in a series resistor (value?) then 0.1uF as close to the pin as possible. Is that kind of like a low-pass filter? Low-pass filter - Wikipedia

Interesting. Thanks again for the link. The parts of inductance, reactance, and impedance I didn't follow, so I'll read it a few more times :smiley:

So, for those not paying attention: Use one arduino pin per device, respect current limitations of the 328p chip. To power more than one thing, with heavier current needs, use a transistor/mosfet. Additionally, de-couple all Vcc pins, as described in the link above.

r4z0r7o3:
So, for those not paying attention: Use one arduino pin per device, respect current limitations of the 328p chip. To power more than one thing, with heavier current needs, use a transistor/mosfet. Additionally, de-couple all Vcc pins, as described in the link above.

NO! Don't directly power anything which uses a decoupling capacitor with a pin, it cannot
drive 100nF load without exceeding the 40mA absolute max rating.

So you can power, for instance, a thermistor resistor-divider circuit, since that doesn't use
a decoupling capacitor (and the 30 ohm approx output resistance of the pin adds to the
fixed resistor value).

But any chip with decoupling, you need a proper high-side switch. You also need to
make sure any other connections to that chip are brought LOW before powering down
the chip, otherwise you risk back-driving it through a protection diode.

MarkT:
NO! Don't directly power anything which uses a decoupling capacitor with a pin, it cannot
drive 100nF load without exceeding the 40mA absolute max rating.

So you can power, for instance, a thermistor resistor-divider circuit, since that doesn't use
a decoupling capacitor (and the 30 ohm approx output resistance of the pin adds to the
fixed resistor value).

100nf/40mA load...don't understand...need more reading...

Let me try again: Simple things, like LEDs, POTs, data-bus's and simple buttons are okay on arduino pin, and don't need decoupling. However, don't power anything with "smarts" from one, use the power-rail, and decouple near the device. It's okay to tickle a gate/base though, as long as you use a series resistor and don't ask too much current of the arduino pin. Also, assume there's a built-in 30ohm resister on each pin (on-resistance?)

MarkT:
But any chip with decoupling, you need a proper high-side switch. You also need to
make sure any other connections to that chip are brought LOW before powering down
the chip, otherwise you risk back-driving it through a protection diode.

Right, I've seen that happen before, where my "FTDI-friend" back-powers through the reset pin. That was a bit scarry the first time it happened...something I powered-off was still blinking at me :astonished:

Anyway, in my specific case here, you're saying bring my OneWire bus pins, and the parallel data lines to the LCD, down LOW before sleeping. That's done by pinMode(FOO, OUTPUT); digitalWrite(FOO, LOW); or you mean something else? Fortunately (I think) I'm already doing this, though only by accident (didn't occur why it was needed) so thanks for connecting the dots :smiley:

Thanks man, I really appreciate the help and advice! Electronics are sooooo much more interesting when things don't work and you gotta find out why :grin:

I'm definitely an electronics n00b, and I think I might possibly be facing a similar issue..

Essentially, I'm tring to run fade and ON/OFF switch for LEDs off an Arduino Uno with a 328 microprocessor. Here's a link to my thread with a picture of my set-up and my code:

http://forum.arduino.cc/index.php?topic=248183.0

I'm not sure if cross posting like this violates any forum etiquette, my apologies if it does.

MarkT:
But any chip with decoupling, you need a proper high-side switch. You also need to
make sure any other connections to that chip are brought LOW before powering down
the chip, otherwise you risk back-driving it through a protection diode.

What if I used something like three of these NPN BRT (datasheet) on the ground pins of the LCD, Backlight, and two OneWire Max18B20 pins? Would I put a decoupling cap. on the collector and another on each device's Vcc, or just each Vcc only?

I think I'm reading the datasheet correctly...looks like I should be able to comfortably pass ~30ma through each BRT from a 5v / 5uA arduino pin (w/o getting anything too hot), ya?

plausiblephysicist:
I'm definitely an electronics n00b, and I think I might possibly be facing a similar issue..

We all start somewhere.

I looked, don't think it's same problem, though you could easily be exceeding current limits.

Read (or at least browse) the 328p datasheet. It lists the current limits for which groups of pins.

Measure how much current each of your LEDs is drawing (don't trust you got the right resistor).

Also make sure you're fade on/off LEDs are on PWM-pins, and not just regular digital pins (they're marked).

I'm not sure if cross posting like this violates any forum etiquette, my apologies if it does.

It does. Sometimes u just gotta wait for an answer.

100nf/40mA load...don't understand...need more reading...

A discharged capacitor looks to an output like a short circuit for a fraction of a second. Then it charges up and looks like an open circuit. In that fraction of a second it is looking like a short circuit the limit of 40mA WILL be exceeded and damage will be done to your chip. It might not cause smoke or sparks but it will be damaged. It might fail earlier than it otherwise would do.

It is like you getting 800 times the "safe" radiation dose, you will not even feel it at the time but years down the line you could get cancer.

Grumpy_Mike:
A discharged capacitor looks to an output like a short circuit for a fraction of a second. Then it charges up and looks like an open circuit. In that fraction of a second it is looking like a short circuit the limit of 40mA WILL be exceeded and damage will be done to your

Oh wow...that actually makes perfect sense! Now I see the n00bs trap I fell in: Assuming the caps are always charged up and DC is perfectly flat all the time :~ Thanks for connecting the dots!

I remember reading that AC has no problem going right "through" a cap. So basically the ramp-up time from 0-to-whatever volts DC, behaves more like AC for part of that duration. Would I be correct to assert the duration is inversly related to the voltage change and capacitance (assuming perfect wires)?

This must also be part of the reason people suggest giving yourself double-or-wider headroom on your caps voltage rating. Well, fantastic!

I'm seeing my circuit in a totally new perspective now, thanks! :grin: