1

Instead of doing PWM on each "return pin" as it can be seen in Schematic diagram A, my idea is to use only one PWM for powering the circuit from GPIO4 (PWM) as it is drawn in circuit B. Is it (diagram B) safe?

1) GPIO4 goes high (with whatever I set duty cycle) and return GPIOs are low. Safe?

I have read about limiting 15mA source and sink currents (at least 220 Ω resistance here), so Schematic diagram A seem to be valid with multiple PWMs. But I am not sure about the second one.

The reason is changing brightness for all LEDs (7 segment display) simultaneously and equally .

Schematic diagram A is safe as far as I know regarding to sink and source current idea behind the RPi. But how about Schematic diagram B? Is it safe to source current from GPIO14

0

Your idea in diagram B is NOT safe:

an individual GPIO pin can only safely draw 16mA

(source)

If all three LEDs are on, you draw more than 16mA from GPIO4 (pin 7 on your diagram).

But that's not the only problem. You connected GPIO18 directly to GPIO27 (which is probably GPIO2, actually). I don't understand the reason to connect two GPIO pins directly to each other. If you accidentally pull one of them low and the other high, while they are both in output mode, I think your Raspberry Pi will burn. I say "I think", because I never tested this - for the obvious reason.

Even if you are super careful what you set on those pins, a reboot after a certain update might still burn your GPIO.

if you're relying on the pins to be set to a particular state at boot time, then DON'T.

(source)

(Let me remind you, that a loose connection is enough for an involuntary reboot.)

I wouldn't drive LEDs directly from the GPIO. Especially so close to the maximum current values. A current spike might still destroy your device. If I had to drive an LED directly, I would connect the + side of the LED to the GPIO and the - side to the ground over a resistor. So for 3 LEDs, you need 3 GPIO pins.

You mentioned a 7 segment display. You cannot drive a 7 segment display with a Raspberry Pi, unless you change those 220 Ohm resistors with something that has more resistance. But then you wouldn't be utilizing the full range of brightness the display can offer.

... The GPIO pins can draw 50mA safely (note that that means 50mA distributed across all the pins...

(source)

But as I said, I would avoid direct drive. Instead I would use some sort of buffer between the Raspberry Pi and the LEDs. You might want to look into "using MOSFET as a switch", "using NPN transistors as a switch". If you want to control the LED brightness independently, you could also buy an external PWM module. I used this one. An IC like ULN2003 could do the trick as well - it has 7 channels like the 7 segment display you have at hand.

For a simultaneous change in all LEDs, I recommend you use a MOSFET connected to one of the PWM pins of the Rasbperry Pi.

  • Thank you for your answer. Let me clarify the schematics a bit - the pins GPIO18 and GPIO27 are not connected directly - it is not good circuit diagram (copied straight from a tutorial book and changed a bit in ms paint) – Didzis Lauva Oct 23 '18 at 11:13
  • The next thing you wrote is about driving LEDs directly or indirectly. Well, for my project (which merely is educational demo project) I still could limit current, let`s say, with 1kOhm resistors. Then GPIO would draw altogether... 3.3/1000 = 0.0033A = 3.3mA. Okk.. In the case of 3 LEDs it goes up to 10mA. Relatively safe. In case of using 7 segment LED, thats too much. Not safe, indeed. – Didzis Lauva Oct 23 '18 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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