0
\$\begingroup\$

I've been trying to switch voltage rails (both Vcc and Gnd) of a device on and off from a digital pin on a Teensy 3.2. I have made a corresponding Low side switch using BC547 npn transistor and a High side switch using a BC557 pnp transistor with another BC547 to serve as a level shifter as it switches 5V from 3.3V and an inverter since I am using the same digital pin for both. The load is an tiny lcd display that draws no more than 100mA. I've tested the two circuits individually and they work flawlessly.

The reason I want to switch both Vcc and Gnd is because the Teensy goes through a sleep mode and even if I used only Low side switching, the display used to flicker and not turn off like I wanted it to. And I'm thinking that would lower my power consumption but that isn't really a matter to me although I'm not sure if that really does lower it.

The problem I am facing is when I switch both Vcc and Gnd off through the transistors and turn them on again, the lcd is misbehaving, i.e is not intialized properly, it does not behave the way it would when it is powered directly and completely fails its purpose by not displaying anything. I tried adding a delay between turning on the transistors and initialization but that doesn't seem to help. Am I doing something wrong here or should I connect the Gnd before Vcc? I'm pretty sure I'm missing something here but I can't seem to figure it out. Can someone help me out? Thanks in advance.

This is the npn Low side switch from this same website:enter image description here

And this is the pnp High side switch also from this website: enter image description here

\$\endgroup\$
4
  • 2
    \$\begingroup\$ You likely want FETs non BJT's, at the least, your 10K base resistor may be too large. But really this sounds like it is probably an XY problem related to I/O signals from the MCU injecting current past your power switch. To get a meaningful answer, you need to include the actual LCD specs and connection in your question. \$\endgroup\$ Oct 31, 2020 at 14:47
  • \$\begingroup\$ As the answers making opposite recommendations well demonstrate by their opposing assumptions, this is not meaningfully answerable without more information. Voting to close so this doesn't degenerate into a war of whose assumptions are more unfounded. \$\endgroup\$ Oct 31, 2020 at 15:21
  • 2
    \$\begingroup\$ How have you connected it to MCU? Please provide full information which LCD is it and what connections it has and where, including all connections to GND and VCC, even if they go via resistor etc. \$\endgroup\$
    – Justme
    Oct 31, 2020 at 15:46
  • \$\begingroup\$ @ChrisStratton Since this is a prototype, I have gone with BJTs as they were just lying around. Eventually I plan on using FETs. Also the lcd is a 2.4 inch tft lcd that uses the ILI9341 IC. \$\endgroup\$
    – Slug FPV
    Nov 1, 2020 at 6:12

3 Answers 3

1
\$\begingroup\$

You should not switch it from the low side.

The LCD is connected to the micro via data lines. If you put a transistor in the GND connection of the LCD, then it is no longer referenced to GND. If the micro's GPIO output signals, then the LCD won't be able to decode them. If the transistor is off and the micro outputs signals, then the LCD will be powered through the data lines and the ESD protection diodes at the input of its chip. That's not recommended.

You need a high side switch. The simplest is to use a PMOS.

LCD GND should always be connected to microcontroller GND.

Before turning off the LCD power, make sure all micro's pins that are connected to the LCD are configured either as inputs without pullup, or as outputs with logic level 0, because when the LCD is not powered it should not receive any voltage on its input pins.

\$\endgroup\$
5
  • \$\begingroup\$ Well just to be clear I'm using a 2.4 inch tft lcd with theILI9341 driver IC. So the chip uses SPI to talk to the microrcontroller. Would setting the DOUT, DIN and clock low do it and could I use a High side switch only? Also what do I do with the chip select pin, because I'm thinking that should be low also since that would not select the chip all together. \$\endgroup\$
    – Slug FPV
    Nov 1, 2020 at 3:21
  • \$\begingroup\$ Yes, correct. Well no need to make MISO pin a 0V output, it's an input so it won't send voltage into the unpowered LCD. But it shouldn't have a pullup. \$\endgroup\$
    – bobflux
    Nov 1, 2020 at 8:25
  • 1
    \$\begingroup\$ Okay yes, no pullup resistors because those might end up sourcing the current and in a way power the chip. A previous mistake from an older project. Important to keep in mind. \$\endgroup\$
    – Slug FPV
    Nov 2, 2020 at 9:23
  • \$\begingroup\$ Yes pullups will power the LCD through its input protection diodes. They will probably not allow enough current for it to get proper VCC so it'll be in a zombie undefined state. Some parts need VCC to ramp up reasonably quickly to reset properly. If VCC ramps up too slow like in this case, even if VCC is applied later via high side FET, the chip may stay in undefined state and not respond to commands unless kicked via hardware RESET signal... \$\endgroup\$
    – bobflux
    Nov 2, 2020 at 9:30
  • \$\begingroup\$ Okay, so that was why it worked fine the first time but once shut down and woken up later, it would enter a wierd state where the data doesn't get processed like the way it used to in the completely power on state. That is the exact problem I had and you really were able to pinpoint it to this precise issue. Well after I looked at this, I tried the hardware reset alone and leaving it in the zombie state(which was just for experimenting and unintended) I was able to wake it up, trigger the hardware rest pin and it worked perfectly. It all makes sense now. Thanks a lot \$\endgroup\$
    – Slug FPV
    Nov 3, 2020 at 10:11
0
\$\begingroup\$

What else is connected to the LCD?

If you use a low side switch, and switch it off, the other interface signals to it can partially power it via their protection diodes.

However, if you tristate all the other control signals, and enable the weak pullups on each Teensy I/O pin, then everything will be at the same potential (+V) THEN turn off the LCD with just a low side switch and it should shut down properly.

(I'm assuming the MCU and display use the same V+ here)

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

My final solution was just using High side switching using the pnp transistor with the only downside being inverted logic. And the transistor is switching 3.3 V as I found it out in the lcd spec sheet so I directly connected it to a digital pin and it was good. Eventually though as pointed out, I will switch it out for a p channel MOSFET and that will be better. Although I could'nt find many p channel logic level MOSFETs that is still the plan. When the Teensy enters the sleep state, I didn't care much about the state at which I left my communication pins but now I write all the communication pins LOW and that seemed to fix the problem I earlier had and it is working just like the way I intended it to be.

Thanks a lot for helping me out.

\$\endgroup\$

Your Answer

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

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