Go Down

Topic: Yet Another LED Strip with Current Draw PWM Module and MOSFET Post (Read 982 times) previous topic - next topic

wcndave

I have seen this asked, and sort of answered, a number of times, and yet never quite seen a complete answer.

I have LED strips that run off 5v USB and have the little remote to control them. 
They are common anode.
I assume since they are strips, that the current limiting is built into the strip, (as opposed to the controller), and is therefore not necessarily an issue.

The functions however are limited, and I want to create my own, from an Arduino Micro.

First up, I got three pwm of the arduino to control a normal RGB LED.
Then, as I need more power, I read up, and settled on IR520 MOSFET.
I got them on boards, with terminals for in and out power, and with various diodes and resistors built in, so some of those elements are taken care of, they are this model:  https://forum.hobbycomponents.com/viewtopic.php?t=1872

With these, I could put my 5v power supply to a rail, take power to Arduino from this, power the LED strips directly from the source, and not worry about current through the Arduino pins.
(It turns out that given I am using the same power source, and the ground is connected to V-, all I have to do is connect V- to the strip channel, and gnd/signal to Arduino, the other 3 terminal connections are not needed)

So I have this, click for full size.




Then I hit upon the typical problem of how to add more PWM, as I need more than Arduino has.
So I get led to the TLC5940
Then discover it's a current drain, so won't work as expected
Then read about some ways to use PNP transistors (I have lots of them)
and the trail goes cold.

There's lots of talk about pull up, pull down, etc, however nothing really "final".

I found some threads that were so close….

this one from 3 years ago, is what I want to do, however the thread stops before it's concluded

What I want to do, however ended up with shiftPWM solution

This from 6 years ago got close

This one looked super close, however I wasn't sure the issue of the current set had been resolved

Would anyone be able to help with the final steps to a completed circuit?

The PNP I have available are: 2N3906, 2N5401, A1015, S8550, S9012 and S9015.

Many thanks!

Dave


Paul__B

Right.

So, you have a common anode strip.

You cannot use PNP transistors or N-FETs to drive it.

Your IRF520 drivers will be just fine with a couple of quirks.  :smiley-eek: You will need pull-up resistors to the gates, preferably to a 10 V supply if your LED strip (each channel) requires more than half an Amp as the IRF520 is not a logic-level device and actually requires more than 5 V to properly turn on.

As the module also contains a 1k pull-down resistor (the one on the right), you would need either to remove it or use a 470 Ohm pull-up to 10 V.

So the TLC5940 outputs now pull down the FET gates and you need to program the PWM in reverse.  Set the current limit resistor to a sufficient current to drive the 470 Ohm resistors - 22 mA for the 10 V supply or 12 mA if you have removed the 1k resistor from the module and are using 5 V for pull-up but it would be better in this case to use IRL520s.

Grumpy_Mike

Quote
and yet never quite seen a complete answer.
Then you are going to have difficulty with electronics because the answers were quite complete. It would help if you explained what you consider missing for a complete answer.

That last link is probably the best. You should have a base resistor of 1K and set the output current for 10mA.

PaulRB

I have LED strips that run off 5v USB
They are common anode.
...
So I get led to the TLC5940
Then discover it's a current drain, so won't work as expected
Why not? Current drain/sink is exactly what you want with common anode.

Then read about some ways to use PNP transistors (I have lots of them)

The PNP I have available are: 2N3906, 2N5401, A1015, S8550, S9012 and S9015.
For common anode you need NPN. You have all those PNP and no NPN?

wcndave

Thanks for the responses, I will try to respond to each one as well as I can.


Why not? Current drain/sink is exactly what you want with common anode.
For common anode you need NPN. You have all those PNP and no NPN?
This is correct if the LED is connected directly.  However I have a strip of varying length, which could be pulling quite a bit of current.  Therefore I was using the Arduino PWM (high) to control a MOSFET, which drove the LED strip.  That requires a "high" output on my circuit, and the TLC5940 provides a sink.  I've got about 9 flavours of NPN, however that's besides the point I think.

Then you are going to have difficulty with electronics because the answers were quite complete. It would help if you explained what you consider missing for a complete answer.

That last link is probably the best. You should have a base resistor of 1K and set the output current for 10mA.
Hi Grumpy, hoped you were going to pitch in!  Did electrical and electronic engineering at Imperial, however it was so theoretical, and such a long time ago, I'm just tinkering these days, and don't visit it frequently enough to recall various elements.

The first link you indicated a pull up resistor and gate resistor, however poster had a resister across source and gate, which I wasn't sure about.  There was an implication that it should work, but the OP never indicated that it was working, and they never posted that they got it working, so I considered a "this should work but doesn't" thread as being incomplete.


The second thread you indicated that using a pull up and an inverted signal would never turn off the LED completely... and then they used shift registers anyway, which I don't have to hand.

Third thread also resulted in you stating that there was going to be an "always on" issue.

The last thread, which I did say I thought was the closest, had a schematic post, which was followed by "missing current set resister" (I guess now that's the IREF for the TLC5940, however wasn't sure), there was talk of 1mA, however I think the outputs should be a min of 5mA for reliability, then there was a concern about a non -logic level FET getting too hot, and the OP never indicated "it all works like this"...


So, you have a common anode strip.

You cannot use PNP transistors or N-FETs to drive it.
I was thinking to use the PNP as per thread 4 above, to drive the MOSFET, not the LEDs directly, am I misunderstanding something?

Your IRF520 drivers will be just fine with a couple of quirks.  :smiley-eek: You will need pull-up resistors to the gates, preferably to a 10 V supply if your LED strip (each channel) requires more than half an Amp as the IRF520 is not a logic-level device and actually requires more than 5 V to properly turn on.
The spec for the IRF520 says it is perfect for logic:
"Input Switching Voltage: Suitable for 5V microcontrollers."

As the module also contains a 1k pull-down resistor (the one on the right), you would need either to remove it or use a 470 Ohm pull-up to 10 V.

So the TLC5940 outputs now pull down the FET gates and you need to program the PWM in reverse.  Set the current limit resistor to a sufficient current to drive the 470 Ohm resistors - 22 mA for the 10 V supply or 12 mA if you have removed the 1k resistor from the module and are using 5 V for pull-up but it would be better in this case to use IRL520s.
So I am not sure if you meant to add two pull up resistors, one to set gate to high when no input, and other to somehow compensate for the pull down, if I don't remove it.

Also wasn't sure which 470res you were referring to, however I am guessing you're thinking that with 12mA based on the IREF resister of say 3.3k, that a 470 would drop about 5v, triggering the gate to low.

However from the other threads, I had understood that this solution is not great, as it leaves an always on "flicker".

Perhaps an illustration of how the right solution is not clear, is that one response to my thread is something that is sated as incorrect elsewhere, another response says I have what I need, and another one says to read other threads... :smiley-confuse:

Using PWM from Arduino to drive LED strips, and adding TLC5940s to extend the number of PWM outputs seems to be quite a common theme, and yet each thread appears to have differing an inconclusive answers (IMHO).

I'll try Paul__B solution first, and see if there's any flicker, I am planning to use the following values. (click for full size)





However I am wondering if the other LED/Resistor combo on the board also needs to be removed (R6 on the right side)

Also, just to test things on the TLC, I have got it all set up exactly like this:
https://howtomechatronics.com/tutorials/arduino/how-to-extend-arduino-pwm-outputs-tlc5940-tutorial/
bar the decoupling capacitors.

Nothing happens, does it seem likely that the lack of decoupling capacitors would cause the circuit to fail completely?

I have some capacitors, however they are different values (0.1nF and 100mF), so will need to get some on order...

Thanks again!

Grumpy_Mike

Quote
does it seem likely that the lack of decoupling capacitors would cause the circuit to fail completely?
Normally the lack of capacitors makes things work erratically.

Quote
I guess now that's the IREF for the TLC5940, however wasn't sure
It was.

Quote
however I think the outputs should be a min of 5mA for reliability,
Well you are trying to drive a FET which needs only voltage to keep it on, with a constant current supply. When a FET first switches on you need to charge up the small gate capacitance in order to get that voltage. The longer that takes the longer the FET will be in a partially conducting state and so the hotter it will get. The same goes for a non logic level FET. But as you can put the pull up voltage to 12V there is no need to worry about that because then the gate will go to 12V and turn on a normal FET.

Quote
Did electrical and electronic engineering at Imperial
True story.
I was 21, and working on active filters at the Admiralty Underwater Weapons establishment and my department was showing some work at Lab X 72 at Earls court. I was explaining to one punter how a filter sorted out sounds into different frequencies and when I was finished he said "What is frequency?". So determined not to make the same mistake again I started talking to the very next visitor to the stand and said, "Do you know what frequency means?" He looked down his nose at me and said "I am Professor of Electronics at Imperial Collage". doh!


Paul__B

I was thinking to use the PNP as per thread 4 above, to drive the MOSFET, not the LEDs directly, am I misunderstanding something?
Yes, you certainly can.  The choice of PNP is then less critical as it only has to switch the FET.  However using bipolar transistors as saturating switches is a problem with PWM as saturation results in delayed turn-off so you actually have to prevent them saturating.  In this case you also still have a problem with the necessary gate drive voltage.

The spec for the IRF520 says it is perfect for logic:
"Input Switching Voltage: Suitable for 5V microcontrollers."
And just from where did you pull out this "spec"?   :smiley-eek:  Because it clearly is not.

So I am not sure if you meant to add two pull up resistors, one to set gate to high when no input, and other to somehow compensate for the pull down, if I don't remove it.
Well, I meant two different values depending on whether you had removed the pull-down or not.

Also wasn't sure which 470res you were referring to, however I am guessing you're thinking that with 12mA based on the IREF resister of say 3.3k, that a 470 would drop about 5v, triggering the gate to low.
Sounds right.

However from the other threads, I had understood that this solution is not great, as it leaves an always on "flicker".
Don't know what you mean by that.

Using PWM from Arduino to drive LED strips, and adding TLC5940s to extend the number of PWM outputs seems to be quite a common theme, and yet each thread appears to have differing an inconclusive answers (IMHO).
What else would you expect?  :smiley-lol:

I'll try Paul__B solution first, and see if there's any flicker, I am planning to use the following values. (click for full size)
Sort of.  Except ...

However I am wondering if the other LED/Resistor combo on the board also needs to be removed (R6 on the right side)
Yes, I missed that!  Obviously it would also need to be removed.  Again, unless you drive the FET with 10 V.

Also, just to test things on the TLC, I have got it all set up exactly like this:
https://howtomechatronics.com/tutorials/arduino/how-to-extend-arduino-pwm-outputs-tlc5940-tutorial/
bar the decoupling capacitors.

Nothing happens, does it seem likely that the lack of decoupling capacitors would cause the circuit to fail completely?
What you you mean "Nothing happens"?  That circuit shows no outputs connected.

As per your diagram, (you didn't really mean to substitute an IRF521!  :smiley-roll: ) if you also remove the LED resistor (or change it to 10k) then the 470 at 5 V will ensure positive switching of the gate as per Mike's comments but will not be switching the non-logic-level FETs fully on at more than somewhere between half and one Amp.  We still don't know how much current your LED strips actually require.

If on the other hand, you had a 10V pull-up voltage, then the 470 ohm should be able to switch the FET fully on even with the 1k pull-down - but maybe not the LED as well.

Grumpy_Mike

Quote
Quote from: wcndave on 06-12-2019, 11:14:04

    However from the other threads, I had understood that this solution is not great, as it leaves an always on "flicker".
Quote
Don't know what you mean by that.
If you invert the switching of the LEDs, that is make them come on when the TLC5940 is not sinking current and off when it is, then you can never turn them off fully.

This is because the chip, when driving the chips at maximum brightness by sinking current into it, has a duty cycle of 4095 : 1. That is the maximum brightness is never a continuous on but always has one clock cycle when it is off. Normally this doesn't matter because you don't notice that it could be 1 smidgen brighter. When the chip is off it is producing a duty cycle of 0 : 4096 - that is off all the time.

However, if you invert the signal then the minimum brightness you can get is a duty cycle of 1: 4095 which you can see, as a flicker or very dim light. The dubious bonus is that full on is that 1 smidgen brighter.

So when designing an external current driver you have to make sure it is driving while the chip is sinking and not driving when it is not sinking.

Paul__B


Grumpy_Mike

Dim light I can follow, but why flicker?

Good point, but people often say flicker in these situations, not sure why.

wcndave

But as you can put the pull up voltage to 12V there is no need to worry about that because then the gate will go to 12V and turn on a normal FET.
Unfortunately I don't really have the option of 12v on this.  I am using standard USB power supplies to make this an easy project for people to adopt.


...so you actually have to prevent them saturating.
I don't recall how to do that... Will try to research

And just from where did you pull out this "spec"?   :smiley-eek:  Because it clearly is not.
https://forum.hobbycomponents.com/viewtopic.php?t=1872
Also, the data sheet puts Vgs(threshold) at between 2-4v.


What you you mean "Nothing happens"?  That circuit shows no outputs connected.
There is an LED connected.  It's a working LED, and connected the right way - just not getting any action when connected to 5940 connected to Arduino.

As per your diagram, (you didn't really mean to substitute an IRF521!  :smiley-roll: )
No, for some reason when copy/pasting in Fritzing it incremented the number by one...


if you also remove the LED resistor (or change it to 10k) then the 470 at 5 V will ensure positive switching of the gate as per Mike's comments but will not be switching the non-logic-level FETs fully on at more than somewhere between half and one Amp.  We still don't know how much current your LED strips actually require.
My current circuit is pulling max 1A per channel, however I want this to be a generic solution really.
I'd thought from the data sheet I was well within the range I'd need.


If on the other hand, you had a 10V pull-up voltage, then the 470 ohm should be able to switch the FET fully on even with the 1k pull-down - but maybe not the LED as well.
Here is the actual project.  Connected to power with USB charger, the idea is that this is an easy to adopt generic solution, so I don't know how many LEDs I might need in future.

https://youtu.be/BsekIxu7L0Y

Currently, that's running 2.5m at the back, and 1m in the middle section, both off standard USB controllers that came with the strips.

Only the front is using the FETs, as per the "what i have now" diagram on the left of the original post, which only drives a 50cm strip.

Given you can do this with tiny boards built in, and all I really want is full programming control over the colour patterns/speed/variations, I feel there has to be a better way.  All that's required is to extend the PWM outputs of the Arduino "as is", so they work the same.  However I have only found current drain chips.  Is there some easier way to just extend PWM?


Thanks for all your answers and advice so far.

BTW: I think i say flickering, as it's coming on once per 4096 cycles, so a very fast flicker right ;-)

Grumpy_Mike

Quote
Also, the data sheet puts Vgs(threshold) at between 2-4v.
That parameter is where the FET turns off if you go below it. It is not the voltage you have to apply to turn it on fully.

Quote
I think i say flickering, as it's coming on once per 4096 cycles, so a very fast flicker right
Well no because these things are very fast and you only have to have 30 flashes per second to see it as continuous, so there must be some other phenomena in play.  

Quote
Is there some easier way to just extend PWM?
Search for a soft PWM library, or use a Mega.

Quote
Quote from: Paul__B on 06-12-2019, 21:57:38
    ...so you actually have to prevent them saturating.
Saturation is only applicable to bipolar transistors not FETs, it is caused by putting more current into the base than it needs to turn it fully on.

wcndave

That parameter is where the FET turns off if you go below it. It is not the voltage you have to apply to turn it on fully.
Showing how much I forgot from Uni, recognise everything, remember almost nothing.  However, it does work with a logic level signal.
Well no because these things are very fast and you only have to have 30 flashes per second to see it as continuous, so there must be some other phenomena in play.  
Yer, I was being tongue in cheek there.  Technically it's flickering, however you see it as a steady state.  When talking about it from an electronics perspective, I can see why people say flicker though.
Search for a soft PWM library, or use a Mega.
At some point, any single board is going to run out, it it's generic, and I need between say 1 and 20 (each one requires 3 channels of pwm)

I'll have a look for any other pwm libraries.
Saturation is only applicable to bipolar transistors not FETs, it is caused by putting more current into the base than it needs to turn it fully on.
This came up, because the closest thread I found used a pnp to basically reverse the logic, which also would solve the "never off" problem.

Grumpy_Mike

Quote
However, it does work with a logic level signal.
Well it might function but the FET is not at its lowest resistance therefore it is burning more power than it needs to be. This could cause excessive heating. You are getting away with it because your current is small and maybe you don't notice the excess heat.

wcndave

Well it might function but the FET is not at its lowest resistance therefore it is burning more power than it needs to be. This could cause excessive heating. You are getting away with it because your current is small and maybe you don't notice the excess heat.
Is there a logic level FET that you'd recommend?

IRL540 showed surprisingly few results on sites like Amazon, compared to the IRF520, which appears everywhere as the "perfect Arduino board"...

I am still not 100% sure whether I ought to be pursuing:

1. The "Paul__B" circuit above

Which means basically destroying the IRF520 break out board
Given I am using only v- and then removing all the built in resistors - the board is not worth having.
AND, this issue of having enough voltage to turn it on with low power consumption
AND, that I will have a "never off" circuit.

So I think I will rule that one out.

2. Same circuit with a logic level FET, which will still have the "never off".
3. explore using pnp with #2 to reverse logic and allow it to be off.
4. go for some soft PWM / shiftPWM completely different solution...

I think I need to investigate #4 first to see what that means.

You recall I started with saying I had not found a "complete" solution to this, well, even after all your kind help I am still not at a good solution, nor being pointed at (what I would describe as), a complete answer.

I will solder on....

(see what I did there ;))

Go Up