1
\$\begingroup\$

I have 22 lights that I am trying to control. Each light consists of a resistor and LED, and the manufacurer recommends running the lights at 12V. I want to be able to switch these lights on and off indivdually from a Raspberry Pi. I am aware that there are LED driver ICs, but I am trying to make a circuit out of components that I have access to.

Below is the circuit I have designed and following that is a description.

enter image description here

I have a 12V power supply that I will convert to 3.3V using a ld1117v33 regulator. The shift registers will run on 3.3V as the Raspberry Pi GPIOs opperate on 3.3V, and this voltage is within the tollereance of the 74hc595 shift register. The Raspberry Pi's ground pin will be tied to the ground of the 12V power supply, and the Pi will be powered by its own power supply. To control the light, there is a transistor operating as a switch. \$A_{R1}=\frac{3.3V}{1000}=3.3mA\$, which is within the tollerance per pin of the shift register.

I intend daisy chaining 3 shift registers together, and will have a transistor and resistor pair per light.

Will this circuit work as I intend? I am worried about damaging my expensive Raspberry Pi.

\$\endgroup\$
5
  • \$\begingroup\$ Add also a buffer as the gpio used are only outputs ... Something as this compatible 3.3V ti.com/lit/ds/symlink/uln2803a.pdf in place of all the BJTs ... \$\endgroup\$
    – Antonio51
    Commented Jan 9, 2022 at 10:10
  • \$\begingroup\$ raspberry pi might need 5V for some features to opperate correctly - possibly for ethernet, and USB. 74HCT595 can operate from 5V and accept 3.3V logic signals \$\endgroup\$ Commented Jan 9, 2022 at 11:17
  • \$\begingroup\$ @Jasen I am not planning to power the Raspberry Pi from the 3.3V. I will power the Raspberry Pi from the official USB power supply. \$\endgroup\$
    – Morgoth
    Commented Jan 10, 2022 at 12:11
  • 1
    \$\begingroup\$ then the 3.3 is only to power the 74HC595? the official usb supply has excess capacity you can use some of the current to run your circuit. hence my suggestion of 74HCT595 which you can run from a 5V power pin without a regulator. \$\endgroup\$ Commented Jan 10, 2022 at 12:18
  • \$\begingroup\$ That is a good point. I see the Raspberry Pi has both 5V ad 3.3V power pins, so I could choose either. \$\endgroup\$
    – Morgoth
    Commented Jan 11, 2022 at 7:05

2 Answers 2

1
\$\begingroup\$

What you have should work, but could be improved:

  • R.pi GPIO is 3.3V, so the HC595 also has to be powered 3.3V to have compatible levels (so, ok.)
  • Don't draw power from the Pi. Instead, make local 3.3V for the HC595's using an LDO from 12V (so, also ok.)
  • You have the option of running the HCT595s on 5V, which is compatible with 3.3V logic so you could use USB power and save the regulator. That's kind of messy, wiring-wise assuming you want to tap from the same USB as the Pi, so I don't recommend it.
  • Add series damping resistors to the shift register controls. Make sure there's a good ground return for them.
  • Add bypass caps to the HC595s
  • Use n-FETs instead of NPNs to drive the LEDs. This will reduce Idd to the HC595's.

The latter point is important. Worst-case, you have 3.3mA * 22 NPN bases = 72mA. This base drive comes from the 3.3V linear regulator, which will dissipate up to 631mW when all 22 lamps are on. That's kind of wasteful.

With FETs instead of NPNs there will be only the HC595 static draw, so the regulator dissipation is far less: just 80uA (696uW) per shift register shed in the regulator.

What kind of FETs? Any common n-FET like 2N2002A or BSS138 can work.

\$\endgroup\$
4
  • \$\begingroup\$ They can tap from the 5v pin header, so no messy wiring really. \$\endgroup\$
    – Passerby
    Commented Jan 13, 2022 at 8:00
  • \$\begingroup\$ If there’s an inadvertent short, or worse, connection to 12V… could let the magic smoke out. It’s not goof-proof, and I infer that OP wants to avoid frying the Pi. \$\endgroup\$ Commented Jan 13, 2022 at 8:09
  • \$\begingroup\$ Under that same logic, if they short the 5v or 12v to the 3.3v the same thing happens. \$\endgroup\$
    – Passerby
    Commented Jan 13, 2022 at 8:13
  • \$\begingroup\$ It's always possible for Something Bad to happen on the LED board. But the fewer and better-contained the connections, the less likely there is for a mishap. Also, a 5V fly-wire makes a separate ground loop rather than containing SPI to the board-to-board ground that's part of the bundle, so it's poor EMI design. \$\endgroup\$ Commented Jan 13, 2022 at 8:27
1
\$\begingroup\$

The schematic as shown will work fine.

You could replace the transistors with ULN2003. It is easier to solder 3x SOIC chips than 22 transistors and resistors.

You could also replace the whole thing with TPIC6C595, also exists as NPIC6C595 and 596. The 596 version is preferable as it shifts data out on the negative clock edge. It's basically a 74HC595 with integrated open drain power MOSFETs that can drive your 12V LEDs directly. It runs on 5V so you can power it from the Pi's 5V supply or replace the 3V3 regulator with a 5V one and add a 74HCT chip powered from 5V to do voltage translation between 3V3 and 5V.

If you're feeling extra paranoid and want to protect the Pi's outputs from anything that can happen on the 12V board:

enter image description here

Use a MOSFET that is fully on with 2.5V Vgs. This will also handle voltage translation between 3V3 and 5V. MOSFET source is on the bottom. If something goes wrong and the output goes to 12V, the MOSFET will limit voltage at the Pi to a bit less than 3V3.

\$\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.