I want to do this right. I have a basic RGBWW LED strip that I will control via ESP32. I thought my IRL540N (x5) and a 220 ohm resistor at each GPIO was the answer, but it's not working quite right.
I realize now that the IRL540N is not a logic level MOSFET. So, I've ordered some RFP30N06LE and was about to move forward with these when they arrive. ...but then I saw this webpage where the maker uses optocouplers between the Arduino and the MOSFETs. I have a lot of PC817 laying around and if it would be advantageous to use them, I'd like to.
I might have enough unused IRL540N remaining, or I could use the RFP30N06LE when they arrive, and just provide the 5V (for IRL540N) or 3.3V (for RFP30N06LE) on the rail in place of the 12V described in the webpage ...and drive the MOSFETs with a PC817 at each GPIO (with a 390 ohm? or maybe I can use 220?).
Is there much of an advantage in using optocouplers in this way?
The Arduino Uno/Nano can output 20mA with a pin (up to 40mA). They can drive leds and optocouplers.
Most newer processors can output only a few milliamps. The ESP32 can output 12mA, stay below that for safety, say 10mA.
A optocoupler can be used as a level shifter or a inverter. For example to drive a P-Channel mosfet from a Arduino.
Does the PC817 work well with a 3.3V 10mA signal ? You have to check the datasheet for the voltage drop at 10mA and then calculate the resistor.
Can you tell more about the ledstrip ? How much current is needed at what voltage. Can you give a link to the ledstrip. How about the sketch ? Do you use PWM ? With what library ? and so on and so on.
Could you provide a schematic A drawing on a piece of paper is okay.
Why I ask so many questions: the required gate voltage depends on the current to drive. The PWM frequency should not be higher than what the circuit with the mosfet can do. The heating of the mosfet depends on the PWM and the circuit at the gate.
I see in Figure 5 of the PC817 datasheet that the voltage drop at 10mA is not much in comparison to 20mA. The Electro-Optical Characteristics chart reads a Forward Voltage of 1.2V at 20mA. So, perhaps about 1.5V at 10mA would work?
The LED strip is 24V and 1A. Here it is. I plan to use PWM for each color (and white) of the strip. If I were to try to draw a schematic I think it might actually be counterproductive. I'm capable of reading simple ones.
I do also have a few 74HC14 if those would be worth using instead of the optocouplers (assuming the IRL540N with 5V at the gate is indeed worth pursuing).
I see about 1.25V forward voltage at 20mA and 1.2V at 10mA.
(3.3V - 1.2) / 10mA = 220 Ω
You can use the opto-coupler to get 9V at the gate of the IRL540N. You also need a circuit to limit the 24V to maximum 16V, because that is the maximum the gate can have.
The IRL540N has a input capacitance of 1.8nF. The input resistance at the gate will create a low-pass filter. You have to check the output current of the optocoupler (13 mA) and adapt the resistor to GND, I would start with 2k2. It should be good up to a few kHz.
Are you use the ledc library ? I don't know what frequency it uses.
I don't like 5V at the gate of the IRL540N. I see different numbers and different graphs for different manufacturers.
When driving a "logic level" mosfet with a ESP32 pin, then only a current limiter resistor of 330Ω is needed (and perhaps 10k to keep the mosfet off during a reset and power-up). The low-pass filter is less a problem. If you can use the RFP30N06LE, that will be more straightforward and easier.
I understand. I know most here speak a very precise language that is best transcribed into a proper schematic. I'm confident that if I were to try to speak that language, the thread would turn into a language lesson, at best.
Sweet. I'll use the RFP30N06LE with a 330Ω at the GPIO and a 10kΩ between gate and GND(?)
Yes, I will use ledc along with ESPHome's RGBWW platform. From the ledc page on ESPHome.io: The frequency range of LEDC is from 10Hz to 40MHz...
I tried SmartDraw.com and it was a bit too much for me at this point in time. So, I just modified another schematic from the web with MS Paint. This is my plan, only I'll be using two additional channels for the warm white and cool white.
It's harder to quickly see what's wrong when you're not sticking to schematic conventions.
Signal goes from left to right, supply up, and ground down.
Leo..
@Koepel when you say that "some may frown about the 10k resistors going up to GND", do you mean that the flow of the schematic goes against conventions, or do you mean that the 10k resistors should in fact not be connected to GND at all?