0
\$\begingroup\$

I have a lighting project that I want to control the light on it's own but I also want it to be controlled by external PWM source. There are numourous LED drivers that can do pulse application with EN tied to Vin make it suitable for higher voltage PWM as control and power source at the same time. With that solved, the next problem would be how to switch between external and internal PWM control.

Since the power input (12 VDC) also powers the MCU through an LDO, there are 2 options:

  1. PFET

schematic

simulate this circuit – Schematic created using CircuitLab

If I understand it correctly, in this PFET configuration, when the MCU signal is not present (meaning it's being pulled low) then the FET is switched on. Hence when the external input is constant 12 V or PWM 12 V the light will adjust accordingly. The downside is when using MCU's PWM signal to control I need to control it reversely (higher the duty cycle the dimmer the lights.)

  1. NFET

schematic

simulate this circuit

NFET is the general approach when it comes to PWM control (such as controlling fan speed,) but I am not feeling comfortable when thevinput is 12 V PWM. My thought is changing the MCU output to constant pull-up when using 12 V PWM input, but doing so means the MCU is also turning on and off with the 12 V PWM. I know it's the same with the PFET but it won't depend on the MCU's signal to switch the FET in order to make the 12 V PWM work. At least with the PFET I could insert a PD resistor so it can stay logic low.

Which solution is better? Will PWM as power source to MCU will cause any problem to the MCU for being powered on and off?

\$\endgroup\$
11
  • \$\begingroup\$ A PFET there will straight up just not work, if you can only drive the gate to 3.3 V above ground. It'll always be on. PWM as a power source for a microcontroller will not work, but filtered PWM will (this is called a buck converter). \$\endgroup\$
    – Hearth
    Sep 24, 2022 at 16:33
  • \$\begingroup\$ @Hearth I’m a bit lost on “ if you can only drive the gate to 3.3 V above ground. It'll always be on. ” are you referring to NFET or PFET \$\endgroup\$
    – Travis Su
    Sep 24, 2022 at 17:12
  • \$\begingroup\$ I explicitly said the PFET; I'm not sure what's unclear. An NFET, if you pick one designed for 3.3 V logic drive, will work fine. \$\endgroup\$
    – Hearth
    Sep 24, 2022 at 17:13
  • \$\begingroup\$ @Hearth so no such thing as logic PFET for that matter? It required larger voltage to drive the gate? \$\endgroup\$
    – Travis Su
    Sep 24, 2022 at 17:18
  • \$\begingroup\$ There is such a thing as a logic level PFET. But the voltage that matters is not the voltage with respect to ground, it's the voltage with respect to the source. If the PFET was turned off, the source would be at 12 V, so applying 3.3 V to the gate would give you a gate-source voltage of 12-3.3=8.7 V, still plenty to turn it on. So it can't be off. \$\endgroup\$
    – Hearth
    Sep 24, 2022 at 17:20

3 Answers 3

2
\$\begingroup\$

A PFET there will straight up just not work, if you can only drive the gate to 3.3 V above ground. It'll always be on. The voltage that matters for a PFET is not the voltage with respect to ground, it's the voltage with respect to the source. If the PFET was turned off, the source would be at 12 V, so applying 3.3 V to the gate would give you a gate-source voltage of 3.3-12=-8.7 V, still plenty to turn it on. So it can't be off.

If you apply 12 V to the gate, then the gate-source voltage will be 12-12=0 V, and it will turn off. But your microcontroller can't output 12 V to control it, so you'd need a level shifter.


To answer the other question, PWM alone can't be used to power a normal MCU. But if you take a PWM circuit and add an LC low-pass filter to filter out the AC component, then use feedback control to make sure you can keep the voltage right under varying load, then you have what's called a buck converter, and that is one of the most common power supplies in existence due to its simplicity and high efficiency. I say simplicity, but you're not going to be driving one with just an MCU before several years of classes in circuits and control systems--but there are dedicated chips for doing all that for you, so it's not hard to use.

\$\endgroup\$
13
  • \$\begingroup\$ So if using NFET I need to figure out the power source for Microcontroller and if using PFET will need level shifter to make it work. Both needs extra circuitry and higher BOM cost. \$\endgroup\$
    – Travis Su
    Sep 24, 2022 at 17:45
  • \$\begingroup\$ What's the problem with using an NFET? \$\endgroup\$
    – Hearth
    Sep 24, 2022 at 17:46
  • \$\begingroup\$ as you can see on the schematics the LED circuit and Microcontroller shares the same and only available 12VDC power source. If using NFET the microcontroller has to keep applying 3.3V to the gate to keep it on right? But the 12VDC power source could be 12VDC PWM. And you said PWM won’t power the microcontroller without extra circuitry. \$\endgroup\$
    – Travis Su
    Sep 24, 2022 at 18:00
  • \$\begingroup\$ If I use LC filter to convert it into usable supply at some point on low duty cycle it will gets lower than 3.3V and the microcontroller will shut off so I will lost some dimming range? \$\endgroup\$
    – Travis Su
    Sep 24, 2022 at 18:11
  • \$\begingroup\$ @TravisSu What do you mean "the 12VDC power source could be 12VDC PWM"? \$\endgroup\$
    – Hearth
    Sep 24, 2022 at 18:25
0
\$\begingroup\$

You did not say but I am assuming the PWM source is a microprocessor. The most common is to use your "NFET" circuit. You will also need to add a pull down resistor (10K range OK) to the microprocessor pin to keep the MOSFET off during reset etc. Generally when the processor is in reset mode the port pin is in its high impedance state until the code defines it. Pick a MOSFET that compatible with your driving source, possibly a microprocessor pin. Common output voltages from the microprocessor port pins are 3V3 and 5V. The parameter you need to look at is Vgs threshold, you want something in the 2V range it will work with both the 3V3 and 5V processors. Another parameter to look at is is it avalanche rated, if so you will not need a diode from the output of the MOSFET to +12 to protect it from flyback voltages if the load is inductive.

When working with MOSFETs the reference point is the Source regardless of how it is configured. For a N-Channel the gate has to be + and for a P-Channel it has to be - in relation to the source as specified by there Vgs rating. So without a level translator that will take the gate of the P-Channel device to about 15V it will not turn off properly as you will have (source = 12V - 3V3) as the Vgs.

\$\endgroup\$
1
  • \$\begingroup\$ The PMOS won't require 15 V, 12 V is plenty. \$\endgroup\$
    – Hearth
    Sep 24, 2022 at 17:04
0
\$\begingroup\$

In the schematics, you are doing low side switching, because the FET switches to ground and load is connected to supply voltage.

Typically, in most low side switching cases, PFET is simply wrong and you use NFET.

PFET might be correct for high side switching, but you need additional circuitry as then the PFET can't be driven with a 3.3V/0V signal.

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