Author Topic: PWM a bunch of 1W 3.3V LED's from a 3.3V MCU  (Read 1068 times)

0 Members and 1 Guest are viewing this topic.

Offline smitthhyyTopic starter

  • Newbie
  • Posts: 1
  • Country: au
PWM a bunch of 1W 3.3V LED's from a 3.3V MCU
« on: April 08, 2020, 10:33:45 am »
See attached image for tried circuit.

I want to be able to dim my LED's using PWM from a 3.3V Microcontroller. These LED's are 1W LED's with 3.3V driving them.  I was trying to use a IRF520 Mosfet that I have a few of but 3.3V isn't enough to turn it on so I thought I'd try and use a transistor to switch 12V to the gate. When I test the idea on a breadboard without the Micro, just taking a jumper wire and applying 3.3V or 0V to it I get a strange result. I get just under 12V at the base of the transistor.

I'm worried that if I go to use a Microcontroller, it's going to be damaged with 12V on its GPIO.

How should I be doing it to use PWM to dim a high current load of LED's using the same 3.3V for the MCU and the LED's, but having 12V ~300mA available too?

Or won't I destroy the Microcontroller, that I'm just missing something?
 

Offline Whales

  • Super Contributor
  • ***
  • Posts: 2000
  • Country: au
    • Halestrom
Re: PWM a bunch of 1W 3.3V LED's from a 3.3V MCU
« Reply #1 on: April 08, 2020, 10:40:45 am »
Yes you will get about 12V - 0.7V ~= 11.3V at the base.  PNP and NPN transistors have two junctions diodes in them, for a PNP they are C->B and E->B.  The arrow on an NPN or a PNP indicates one of these diodes.

You are currently using this NPN in an "emitter follower" configuration.  You can't convert 0-3.3V to 0-12V using this type of amplifier layout.  Instead you might want to use a "common emitter" amplifier configuration.

EDIT: woops, this is a common emitter.  You could use an NPN (low-side) style common emitter one instead of this PNP style one.  That will let you shift 0-3V into 0.2-12V for driving the fet.
« Last Edit: April 08, 2020, 10:46:26 am by Whales »
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19773
  • Country: gb
  • 0999
Re: PWM a bunch of 1W 3.3V LED's from a 3.3V MCU
« Reply #2 on: April 08, 2020, 11:39:49 am »
No, that circuit won't work. The PNP transistor will just turn on, as soon as its base is taken around 0.6V below the 12V rail, so will turn on continuously, when connected to the 3.3V output of the MCU. Around 80mA will flow into the MCU's output, which might also damage it and increase the voltage on the 3.3V, frying other components. The LED is connected to the MOSFET, which is configured as a source follower, so will never turn on.

How many LEDs do you have?

Use a logic level MOSFET or a MOSFET driver to enable the MCU to drive the MOSFET to switch the LEDs.
 

Offline Chalcogenide

  • Regular Contributor
  • *
  • Posts: 165
  • Country: it
Re: PWM a bunch of 1W 3.3V LED's from a 3.3V MCU
« Reply #3 on: April 08, 2020, 12:22:39 pm »
If you don't have any logicc level MOSFET around (which would be BY FAR the best choice), you might be able to use a diode-based level translator such as the one attached. You should size the resistors so that the "idle" voltage on the MCU GPIO pin is lower than 3.3V, in order to be on the safe side. When the GPIO pin outputs 0V, the Vgs on the IRF520 is two diode drops (1.2 to 1.4V) which is lower than the specified minimum threshold voltage, so the transistor should stay OFF (at least as long as it stays cool, as the threshold drops with temperature), and when the GPIO outputs 3.3V the Vgs should be around 4.5 to 4.7 V, which is enough to turn it on, although just barely. As long as the current through the LED is low, you might be able to make it work.
The switching time of the FET will be quite slow, so don't push the PWM frequency.
Furthermore, if you sourced the FETs from eBay or Aliexpress the threshold voltage might be different and this circuit might not work or might need adjustments.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19773
  • Country: gb
  • 0999
Re: PWM a bunch of 1W 3.3V LED's from a 3.3V MCU
« Reply #4 on: April 08, 2020, 01:30:33 pm »
What colour are the LEDs? Assuming they're white, running them off 3.3V is marginal design, since it's close to their nominal forward voltage.

If you've got more than one LED anyway, then it makes more sense to connect them in series and use 12V.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf