Electronics > Projects, Designs, and Technical Stuff

PWM drive LED strip, weird waveform

(1/2) > >>


Im building a simple PWM 12V LED strip controller using N-MOSFET as downside switch (mosfet.png). The actual MOSFET I'm using is IRF640 but this part is not available in LPSpice so I use IRF530 instead. Parameter-wise they should be similar. PWM source is from a Arduino (500Hz).

I use a scope to check the waveform across LED. Am expected to see a clear square wave but to my surprise I see this (waveform.png, I had inverted the probe so please read inverted). I double confirmed similar results after change the circuit to a P-MOSFET upside switch with a NPN driver.

I've tried to replace the LED with resistor and the result waveform is clear square down to 0V.

I'm not sure what's wrong but it seems the LED is not as simple as I thought?

Can anyone enlight me what's the reason?



Try and change R1 to 100R and see what that produces.
The gate capacitance maybe causing your issue.
The IRF640 has a gate-source voltage of up to 20V so a current limit isn't needed, unlike a transistor.
The mosfet gate pin can draw up to 2A for a very short time (to charge/discharge its internal capacitance).
If you don't supply it with enough current (ie, limit current with a resistor) then it will be slow to respond to changes. This can be a big issue with high speed switching. 500Hz isn't high speed though, so it may not be your issue but is worth at try.

Also, when you say you're "checking the voltage across the LED with the scope". How are you doing this?
I ask because the led is in the middle of the circuit with no ground connection, so a scope isn't able to view the voltage across the led directly unless it's an isolated scope or your powersupply+arduino are floating.
If you connect the scope ground clip to either side of the led and your circuit has a connection to mains ground somewhere then you will be shorting one side to ground.

I assume your getting a square wave in your LTspice simulation and the waveform you have posted is the real circuit?

Thanks Psi.

The circuit is powered by battery so I'm able to connect the scope to both leads of the LED.
The circuit I posted is drawn in LTspice. I have done simulator and the outcome is nice square waves.

Will try the R1 adjustment when I reach home. Will post more scope results for investigating.

I just saw your comment about the waveform being inverted.  That shows your fet is slow to switch off rather than on.
You should change R2 as well.   
Try  R1=100R     R2 = 1K

100K is probably taking some time to discharge the gate, especially as the gate voltage starts to get low.

The total gate charge of IRF640 is 70 nC. From the scope picture it looks like your cycle period is 2 us, which implies an average gate current of some 70 mA. This won't happen thru 1k/100k charge/discharge resistors. Even if your gate driver is a totem pole going rail to rail with 0 internal resistance, it would take a 70 volt supply to properly drive the gate.
So please take the advice of Psi and reduce the gate circuit impedance by at least 10, maybe even more, it would not hurt.


[0] Message Index

[#] Next page

There was an error while thanking
Go to full version