0
\$\begingroup\$

My question is about how to turn on a led before the GPIO pin has been initiated. When the IC has just been powered on and has not yet been initiated the GPIO pins remains in state HI-Z.

In Circuit-1 GPIO-P1 is pulled via a pull up resistor R7 HIGH and the led turns on before initiating the IC. once the IC has been initiated, GPIO -P1 is set to LOW to turn off the led. The problem with this circuit is that if GPIO-P1 is accidentally set to HIGH, it will short the led. (not current limiting resistor)

I believe I can solve this problem via circuit 2 and 3.
In circuit 2 I limmit the current through R2 in case of P1 is accedentially set to HIGH.
In circuit 3 The P mosfet is driven on via R5, lighting up the led, only when GPIO-P1 is set to high does the led turn off.

Out of interest would there be ANY reason at all to choose for circuit 3 over circuit 2? I see none.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$

3 Answers 3

1
\$\begingroup\$

Out of interest would there be ANY reason at all to choose for circuit 3 over circuit 2? I see none.

I would also consider circuit 4: -

enter image description here

Circuit 4 allows P1 to clamp the LED anode to about 0.7 volts. This, in effect will turn the LED off; in other words, P1 cannot drive "extra" current into the LED because of the direction of the diode; it can only shunt current away from the LED. This means that R7 can be chosen the deliver the maximum design current into the LED and P1 can only shunt this away.

In circuit 2, for instance, you can't deliver full design current into the LED except when IC is driving it.

So, I would consider circuit 4 because with circuit 2 you can never get full brightness of the LED unless P1 is activated. Also circuit 3 is slightly more costly than circuit 4. However, circuit 3 is more energy efficient if wishing to turn the LED off because R5 can be much higher in value than either R1, R2 or R7.

A less obvious advantage for circuit 3 is that pin P1 of the IC that drives the LED doesn't have to handle currents that are used to activate the LED. The current may be as high as 20 mA (for a standard red LED or even higher in some cases) and that current has to flow into P1 when deactivating the LED; this eats into the maximum current budget that can be handled by the IC (normally specified in the data sheets as the current that can be passed through the ground pin of the device).

So, there are other considerations.

Fail safe led circuit

I don't think any of the above can be called Fail Safe.

\$\endgroup\$
4
  • \$\begingroup\$ Can you please elaborate how the diode acts here? \$\endgroup\$
    – Jr.Maxwell
    Commented Jan 14, 2020 at 5:09
  • \$\begingroup\$ Do you still need help given that you have accepted an answer. \$\endgroup\$
    – Andy aka
    Commented Jan 14, 2020 at 7:18
  • \$\begingroup\$ Yes please, If you would explain the behavior of the diode when the IC Pin1 is low that would informative. \$\endgroup\$
    – Jr.Maxwell
    Commented Jan 14, 2020 at 7:24
  • 1
    \$\begingroup\$ @Jr.Maxwell I've amended my answer to hopefully clarify \$\endgroup\$
    – Andy aka
    Commented Jan 14, 2020 at 10:52
2
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

User Choices

LED Off until initialized as output with value = "0" ,

May be inverted to 1 = ON with LED cathode to 0V an 1k to Anode.

LED reverse voltage <=5V is OK

\$\endgroup\$
0
1
\$\begingroup\$

If LED will be placed outside of your PCB, there is always risk of get any voltage spikes via LED wiring into the circuit - and this may damage the IC. In case that you use additional driver (circuit 3), the risk of damage of IC is much much lower - of course, transistor will be damaged probably. From service point of view it is easier (an cheaper) to replace transistor than IC. NOTE: I prefer to use here any PNP BJT transistor, not MOSFET - MOSFETs are too sensitive to expose them outside ;)

Of course, if LED is located on PCB (for example as any kind of internal module diagnostics), there is no risk for issues as above, so circuit 2 or circuit 4 will be enough.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks for the response! What do you mean by "there is always risk of get any voltage spikes via LED wiring into the circuit". \$\endgroup\$
    – Jr.Maxwell
    Commented Jan 13, 2020 at 14:25
  • 1
    \$\begingroup\$ 1. Short circuit with other wires; 2. Electrostatic discharges; 3. Intentional action of any people who want to damage this; :) The people's fantasy has no limits - my eperience shows, that all, what can be done, will be done - this is the question of time only ;) So, if you create any thing for any other people, you can't believe him on that he will use this as expected :) \$\endgroup\$ Commented Jan 13, 2020 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.