0
\$\begingroup\$

I am trying to control an RGB LED (with common cathode configuration) with a BC327 PNP transistor. The LED is powered by a 5V line. The base of the transistor is controlled by a BC548 NPN transistor connected to the GPIO of an ESP-01 module (ESP8266). I attach the circuit diagram below.

The values of the resistors connected to the GPIO are selected in such way so that the GPIO is pulled up during boot in order to boot properly.

I can control the brightness of each LED from the ESP-01 but, the problem here is that the LED is flickering when the PWM is supposed to be off.

Do you have any insights on why this might be happening?

Thanks!!

RGB PWM control circuit

\$\endgroup\$
2

2 Answers 2

0
\$\begingroup\$

When the GPIO is low the the NPN transistor is OFF (open). Thus, the PNP transistor base is floating (not terminated). Provide a valid weak termination. Place a high value resistor between base of the PNP and the 5V line. This should keep the PNP transistor always in a valid state.

\$\endgroup\$
2
  • \$\begingroup\$ This is that whole collector current injection into the base-emitter junction junction right? \$\endgroup\$
    – DKNguyen
    Commented Feb 24, 2020 at 2:35
  • \$\begingroup\$ Two purposes. One to provide a valid reference to the base of the PNP when the BJT is OFF. Secondly, the BJT is not a ideal switch,with parasitics there can be charge movement still from collector to base of PNP Pulling up also reduces the effect of radiated noise on the PNP circuit. \$\endgroup\$
    – User323693
    Commented Feb 24, 2020 at 3:06
0
\$\begingroup\$

In addition to the other comments/answers, when the GPIO pin is not actively driving a logic HIGH output signal or a logic LOW output signal, the 10 kΩ pull-up resistor on the GPIO pin will likely turn ON the NPN transistor by default, which turns on the PNP transistor, which turns on the LED. (Imagine disconnecting the GPIO pin from the rest of the circuit.) This situation can occur when

  • the GPIO pin is configured as an INPUT pin (e.g., during system boot-up), OR

  • the GPIO pin is configured as an OUTPUT pin, AND the pin is configured for "high Z" output mode, in which case the output pin is effectively turned OFF—i.e., it is not actively driving a logic HIGH signal nor a logic LOW signal.

If you want the LED to be OFF when the GPIO pin is not actively driving a logic HIGH or logic LOW output signal, the 10 kΩ resistor should be reconnected between the GPIO pin and ground (pull-down configuration) rather than between the GPIO pin and the +3.3 V power rail (pull-up configuration). In pull-down configuration, the NPN transistor is OFF by default, which shuts off the PNP transistor, which shuts off the LED.

Also, depending on the LED's power requirements, it may be possible to turn the LED ON|OFF using only one NPN transistor configured as a low-side switch.

\$\endgroup\$

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.