Go Down

Topic: Using OUTPUT pin instead of 3.3v pin (Read 406 times) previous topic - next topic

majinjoko

Dear all,

my circuit is complet yet simple. I connect 3 digital pin of my arduino to three optoisolators to detect some signals from my alarm system.
The pins are in a pull-up configuration, connected to the 3.3 pin and to a 1 k resistor.
When on of the optoisolator close, the corresponding "circuit" is closed and 1.6 mA are used.
This is perfectly fine!

The point is that I'm trying to minimize the power consumption. Since I read the pins status every 15 seconds, in the worst case scenario I'm going to waste 1.6*3 mA for ~15 seconds.
I would like to be able to consume power only when necessary.

What if I change the +3.3 reference in the pull-up configuration, using another pin to act as the 3.3v ref?
My idea is to set HIGH this special pin, read all three digital pins, then set DOWN again.
This way I will draw 1.6mA of current for a very short amount of time.

Is this a reasonable approach? Any drawback?

To give you more details, I'm using a ESP8266 12e, programming it with the Arduino EIDE. I hope they're are so similar to let me ask for your help.

Thank you in advance!
M

ReverseEMF

#1
May 19, 2018, 07:25 pm Last Edit: May 19, 2018, 07:44 pm by ReverseEMF
I'm too lazy, right now, to attempt to find a datasheet for your "ESP8266 12e", but I suggest you give that a try and see if you can find out how much current each Digital Pin can source.  More than likely it's more than 1.6mA [my guess is around 12mA].  So, if it's clear that at least 1.6mA can be sourced, and if the total current the device can allow is at least 3 * 1.6mA [or 4.8mA] (and I'll be surprised if it isn't), then, yes, that will work.  In fact, I've used that technique, in various designs, for the same reason.

Now, to be clear, "can be sourced", includes the ability to source the required current, and still supply the requisite voltage required by what you are powering.  When an output goes HIGH, and when the thing it is connected to draws current from that output, there is, typically, a voltage drop.  So, you need to determine what that voltage drop will be, for the 1.6mA that will be drawn (from that output), and if that will be a show stopper.

I also suggest you consider that there might be a "power up timing" -- in other words, when the Digital Output [that is powering the Optos] goes HIGH, their may need to be a slight delay included, in your sketch, between this Power Up point, and the point where you actually read the Opto states.  Probably not more than a microsecond or two.  If you have an oscilloscope, you can measure the rise time on this output, and determine if it's fast enough to not be an issue, or if a delay needs to be added to your code.

"It's a big galaxy, Mr. Scott"

| Please DON'T Private Message to me, what should be part of the Public Conversation -- especially if it's to correct a mistake, or contradict a statement!  Let it ALL hang out!! |

outsider

I've done something similar to keep from heating a thermistor by applying voltage from an output pin for a few mS while reading it, so your scheme will probably work, but, without seeing your wiring, I can't say for sure. Can you post a wiring diagram?

majinjoko

Dear all,
thank you for your interesting replies.

As per the circuit schematic, this is it:


(The left part of the project is some wiring coming from my alarm system connected to the optoisolators.)

Now, to be clear, "can be sourced", includes the ability to source the required current, and still supply the requisite voltage required by what you are powering.
I suppose I would not have such a problem in the current scenario, am I right?

I also suggest you consider that there might be a "power up timing"
Yeah, I was already thinking to test some short delay (say <5 ms) and check whether it would be enough.


I've done something similar to keep from heating a thermistor by applying voltage from an output pin for a few mS while reading it, so your scheme will probably work, but, without seeing your wiring, I can't say for sure. Can you post a wiring diagram?
The diagram is above (not very formal, excuse my lack of skills!).
Should I use a digital or an analog pin set as output?


Thanks!!

Jobi-Wan

When all 3 optocouplers are on, you have your 3.3v (minus the voltage drop of the transistors) connected to GND through 3x 1kΩ in parallel. That draws 8 ... 10 mA. If your I/O pin can't source that, you could use a PNP transistor or P-mosfet on the high side.
This is essentially a 3x1 input-matrix that you're scanning with a lot of dead time.

ReverseEMF

When all 3 optocouplers are on, you have your 3.3v (minus the voltage drop of the transistors) connected to GND through 3x 1kΩ in parallel. That draws 8 ... 10 mA. If your I/O pin can't source that, you could use a PNP transistor or P-mosfet on the high side.
This is essentially a 3x1 input-matrix that you're scanning with a lot of dead time.
I think you are forgetting that there will be an LED in series with each of those 1k resistors.  The OP says the individual currents are 1.6mA, and that will be true if the Opto's internal LED has a forward drop of 1.7V [thus the total current would be 3 * 1.6mA = 4.8mA.  
But, I've know that voltage to be as low as 1.1V, which would result in a current of (3.3V - 1.1V)/1k = 2.2mA -- for a total current of 3*2.2mA = 6.6mA.
"It's a big galaxy, Mr. Scott"

| Please DON'T Private Message to me, what should be part of the Public Conversation -- especially if it's to correct a mistake, or contradict a statement!  Let it ALL hang out!! |

ReverseEMF

#6
May 19, 2018, 10:33 pm Last Edit: May 19, 2018, 10:34 pm by ReverseEMF
I suppose I would not have such a problem in the current scenario, am I right?
Can't be sure without consulting the datasheet.

Should I use a digital or an analog pin set as output?
Definitely Digital [though, it might be possible to configure an Analog pin as a Digital Output -- but, again, would need to see datasheet].
"It's a big galaxy, Mr. Scott"

| Please DON'T Private Message to me, what should be part of the Public Conversation -- especially if it's to correct a mistake, or contradict a statement!  Let it ALL hang out!! |

outsider

Why such low (1k) pullups? I would think 10k would work OK, if all 3 optos were pulling low, current would only be 1 mA.

outsider

Are you talking about switching off the optos led current when you are not taking a reading? Your schematic does not show that part of your circuit.

Wawa

I connect 3 digital pin of my arduino to three optoisolators to detect some signals from my alarm system.

The pins are in a pull-up configuration, connected to the 3.3 pin and to a 1 k resistor.
Why don't you use the internal pull up of the chip.
No external resistor. Just the opto transistor between pin and ground.

pinMode(opto1, INPUT_PULLUP);

That will draw less than 100uA on the opto transistor side.

Opto LED current can be reduced to a few hundred uA.
Leo..

outsider

@Wawa,
  Leo, for a "generic" opto, how much LED current is required to cause the phototransistor collector to pull down to, say, 0.5V with a 10k pullup?

Wawa

Look at the CTR (current transfer rating) in the datasheet.
It can be anything form 50% to 500%.

If worst case is 50%, then you need at least twice the transistor current through the LED.
More LED current if fine, but wasted.
Leo..

majinjoko

Thanks to all for your interesting replies!

Actually I was using 1k ohm resistors since I designed the circuit with a Raspberry PI Zero, which seemed unable to sense HIGH/LOW states when using resistors >1 k.
In the current circuit I can use 10k Ohm resistors. And I will!

I also try using a digital pin as 3.3v output, and it works great.

This way, I have improved the power saving of this system, while keeping it very similar to yesterday.

Thank you so much,
MJ

westfw

Quote
What if I change the +3.3 reference in the pull-up configuration, using another pin to act as the 3.3v ref?
Allowing the input pins to "float" when not being used can lead to HIGHER current consumption, if they happen to float somewhere in the middle and bias parts of the digital IC into linear regions.
https://www.avrfreaks.net/forum/current-atmega640-figured-it-out-interesting

Go Up