View Full Version : Arduino / LED / MOSFET question
Gary Rowan
16th Feb 2021, 11:48 PM
I've started working on a prototype Arduino based LED light controller for the PWRR.
I have the basic circuit on paper, but I keep getting lost when it comes to trying to choose the correct MOSFET for the application.
I keep getting lost in all the Vgs, Ids, Mic...Key on the data sheet.
I know I need a 'Logic Level' n-channel MOSFET that can handle 12 volt based (or less) LED lighting strips with a decent current rating (say 30 amps max).
So the question is: What specific MOSFET can I use, or is there a good general purpose MOSFET for use with Arduinos and LED strips?
Thanks in advance...
TwinDad
17th Feb 2021, 01:37 AM
Are you serious about the 30 amp load? That's 360W at 12V. That's going to require a pretty hefty MOSFET, probably with a good sized heatsink. There are entire computers that put out less power than that. You might want to calculate your loads in a little more detail, and maybe break the strips up into multiple separately driven strips to keep the load on any one MOSFET to something more reasonable.
I did a very similar project for my over-layout lighting... bunches of LED strips controlled by Arduinos connected into my LocoNet network. I looked for the bill of materials for my driver boards but couldn't put my finger on it right now. I'll look tomorrow.
I'd be happy to go into the calculations in more detail. For now, I'll say this.... most any reasonably sized MOSFET will probably be able to be directly driven from the Arduino. The key spec to look for is the Gate Threshold Voltage. You'll want this to be well below your Arduino's high logic voltage. it's not hard to find one in the 2V or less range. On the output side, you want to check the Drain-Source maximum voltage (Vds max). Anything higher than your load voltage will be fine. Then you have to check both the maximum current AND the maximum power dissipation... and the max power dissipation really should be calculated through the various package thermal values to make sure it won't overheat, and whether and how big a heat sink it might need. Under Thermal Characteristics, check for Total Power Dissipation. There should be values for both no heat sink and infinite heat sink, plus some information on the thermal resistance of the case.
If you want, shoot me some details on the application, and I'll help you work through the requirements and find a suitable MOSFET.
TwinDad
17th Feb 2021, 01:45 AM
Ah. Found it. Here's the MOSFET I used to drive my LED strips...
https://www.digikey.com/en/products/detail/infineon-technologies/IRLB8721PBF/2127670
Along with this heat sink
https://www.digikey.com/en/products/detail/aavid-thermal-division-of-boyd-corporation/507302B00000G/5849
Each one is driving approximately 6 feet of 5050 LEDs, either white (1 transistor) or RGB (1 transistor per color).
Gary Rowan
17th Feb 2021, 10:08 AM
Ah. Found it. Here's the MOSFET I used to drive my LED strips...
https://www.digikey.com/en/products/detail/infineon-technologies/IRLB8721PBF/2127670
Along with this heat sink
https://www.digikey.com/en/products/detail/aavid-thermal-division-of-boyd-corporation/507302B00000G/5849
Each one is driving approximately 6 feet of 5050 LEDs, either white (1 transistor) or RGB (1 transistor per color).
TwinDad
No, I don't plan on trying to control 30 amps worth of LEDS with a single MOSFET. I was trying to choose a rating that would
have a good safety margin.
My application is going to be similar to yours: 4-6 foot LED strips / multiple strips per layout section.
I can feel confident ordering some of these knowing that they've been used in a very similar application.
Thanks...
TwinDad
17th Feb 2021, 10:43 AM
@TwinDad (https://www.nscale.net/forums/member.php?u=5043)
No, I don't plan on trying to control 30 amps worth of LEDS with a single MOSFET. I was trying to choose a rating that would
have a good safety margin.
My application is going to be similar to yours: 4-6 foot LED strips / multiple strips per layout section.
I can feel confident ordering some of these knowing that they've been used in a very similar application.
Thanks...
Cool... let me know if I can be of any further assistance.
TwinDad
17th Feb 2021, 03:57 PM
I made a mistake... I forgot something rather important.
The power rating of the transistor relates to the power dissipated by the transistor itself, not necessarily by the whole circuit. If the circuit is set up in the usual way where the FET is a low-side switch, that is, source is ground, and drain connects the cathode end of the LED (chain) to ground through the FET, then the voltage across the FET will only be Vds(on), which can be inferred if necessary from Rds(on)... for my MOSFET, Rds(on) is .016Ω at Vgs=4.5V and Id=25A... which means if you're running 30A at 12V through the LEDs, that's 30A across 0.016Ω through the FET and its power dissipation is "only" 14.4W. This will lead to a 33.2˚C temperature rise, putting the junction at 58.2˚C. You could probably do without the heat sink entirely, though they are cheap insurance.
In my head I was including the power dissipation of the LEDs in the transistor calculation, which is wrong. The LEDs would have to dissipate 345W, but the transistor would not.
It gets a little more complicated, though, because the transistor has to be derated... working backward, with a max junction temp of 175 and an ambient of 25, there's 150˚C of rise to allow... the junction/case thermal resistance is 2.3˚C/W and the thermal resistance of the heat sink is 24 (in still air), for a total of 26.3˚C/W. Dividing it out gives only 5.7W max, which would be a current of 18.8A, or an LED wattage max of 226W. Without the heatsink, the thermal resistance from junction to air is 62, which would allow only 2.4W (12A).
Sorry. It's been a minute since I had to do these calculations...
conrailandrew
17th Feb 2021, 07:20 PM
I don't know any of the technical stuff like TD does, so I'd go with what he says, but here's what I did if it helps at all: https://www.nscale.net/forums/content.php?199-Using-LED-Strips-for-Day-Night-Cycle
TwinDad
18th Feb 2021, 09:13 AM
I don't know any of the technical stuff like TD does, so I'd go with what he says, but here's what I did if it helps at all: https://www.nscale.net/forums/content.php?199-Using-LED-Strips-for-Day-Night-Cycle
What I did isn't really any more sophisticated than yours, I just geeked out a little more on the hardware design. And I really like your Arduino code. Elegant. In fact, one of the problems I had was coming up with the LED color values for the various lighting conditions (I'm an engineer, not an artist). Would you mind if I steal yours?
Gary Rowan
19th Feb 2021, 11:26 PM
Okay....
Here's the basic schematic I've come up with.
118442
PWM 0-5 are the 6 PWM pins on from the Arduino UNO or NANO. I've included a single digital pin for a single on/off light strip (extra work lighting maybe?).
TwinDad - Is this similar to the circuit you used?
The Ol' Curmudgeon
20th Feb 2021, 01:20 AM
Okay....
Here's the basic schematic I've come up with.
118442
PWM 0-5 are the 6 PWM pins on from the Arduino UNO or NANO. I've included a single digital pin for a single on/off light strip (extra work lighting maybe?).
TwinDad - Is this similar to the circuit you used?
I'm diggin' what you're doing, Gary. Got me delving back into all the basic MOSFET stuff I've not touched in years.
Wondering about the voltage divider, though. R1's value strikes me as really too low compared to R2's. The resulting voltage at the gate wouldn't be that much different than Vs from PWM0 -- 4.91V assuming source is 5V. Should one or the other be a different value? But I could be missing something. In fact, I have a sneaking suspicion that I am. ...
I will eagerly await further enlightenment.:D
TwinDad
20th Feb 2021, 01:46 AM
Okay....
Here's the basic schematic I've come up with.
118442
PWM 0-5 are the 6 PWM pins on from the Arduino UNO or NANO. I've included a single digital pin for a single on/off light strip (extra work lighting maybe?).
@TwinDad (https://www.nscale.net/forums/member.php?u=5043) - Is this similar to the circuit you used?
Baslcally, yes. You don't need R2. These are FETs, not BJTs, and we're doing logic switching not AC waveforms, so there's no need to set a bias voltage. And since the Arduino's outputs are push-pull, there's no need for a pullup or pulldown. In fact, the voltage divider created by R1/R2 is probably just going to hurt. R1 is fine, and 1K is an OK value. It will help prevent short circuits from killing the Arduino IO pin. If the FET is permanently connected to the Arduino in such a way that the likelihood of a short is low you can dispense with it and drive the FET directly. But R1 is cheap insurance.
On mine, I left out R1 even though my driver board (with the FETs) is connected to the Arduino controller board by a cable with RJ-11 connectors. That was probably a mistake in retrospect due to the aforementioned potential for short circuits killing the Arduino IO. It's something I'd probably fix if I create a V2 of the controller board for some other reason, but not something I'd re-fab the board for if that's the only change.
Heiko
20th Feb 2021, 08:33 AM
I beg to differ: I'd keep R2. It makes sure the FET stays "entirely off" while the Arduino reboots or is flashed or if you accidently turn the pin to an input. If you leave it floating, it may load to about 2V, the FET may start conducting, but with a very high resistance. That will cause the FET to heat up with the LED strips just dimly lit.
Don't sweat the exact value, 10k sounds fine, 100k would be fine too. Just make sure it's much larger than R1.
R1 is not really necessary here. It sort of protects the Arduino pin, but mostly it limits how quickly the FET turns on and off. Not really important here, but you can play with its value when you have the PWM running. Too slow (too large R1) will cause heat buildup in the FET, too fast may cause EMI and overload the driver. Although the Arduino isn't easy to overload.
The FET type seems a good choice for 5V, low drain-source resistance (RDSOn) at 4.5V gate-source voltage (VGS).
Heiko
TwinDad
20th Feb 2021, 11:33 AM
That's a good point, Heiko. I stand corrected.
I'd say R1 would be somewhat important if there was a connector between the Arduino and the FET (as in my case, where they're separated by a cable), where there's a good chance of a short. On an integrated board, with just a trace between the two, the chances of a short are very low, and so R1 wouldn't be much help. In that instance, you'd be about as likely to get the short at the Arduino pin (where R1 would be useless) as at the FET gate (where it might help some).
Heiko
20th Feb 2021, 03:04 PM
I'd say R1 would be somewhat important if there was a connector between the Arduino and the FET (as in my case, where they're separated by a cable), where there's a good chance of a short. On an integrated board, with just a trace between the two, the chances of a short are very low, and so R1 wouldn't be much help. In that instance, you'd be about as likely to get the short at the Arduino pin (where R1 would be useless) as at the FET gate (where it might help some).
Yes, or if you were running a 500kHz PWM and needed to slow down the rise and fall times of the gate voltage on turning the FET on and off to avoid radio interference in a commercial product. Or if you had a much less robust output driver than the Arduino has (I've accidently short-circuited AVR outputs directly to GND and they still work - the inrush current of a 1nF gate capacitance certainly isn't going to kill it).
Bottom line: R1 not important here.
Heiko
The Ol' Curmudgeon
20th Feb 2021, 03:30 PM
Refresher course in session!
About all I do with MOSFETs anymore is replace them, and it's really easy to spot that they've failed: the scorch marks are dead giveaways. Most commonly found on circuit boards for relay drivers, signal lamp drivers, and US&S switch machine motor control units.
Gary Rowan
20th Feb 2021, 10:23 PM
Thanks for every one's input so far...
As I was building the complete schematic for the circuit board, I had the following thought...
I plan on using an RJ-45 jack for the control signals from the Arduino to the lighting board. Can I reduce my Arduino count by adding a second jack to pass the control signals through to another lighting board. How many, if more than 1, MOSFETS can I drive from a single Arduino output? What spec do I need to look at to determine the current draw by the gate of the MOSFET?
Thanks in advance...
TwinDad
21st Feb 2021, 12:54 AM
I'm not sure how to actually calculate this in detail... the Arduino pin will have to sink or source the charge on the Gate when switching... this will not be very much. The max gate charge for this MOSFET is only 13nC, which puts the gate capacitance at about 2.6nF. At 5V gate voltage, the charge is only about 8nC, which would be 1.6nF. I couldn't directly find the slew rate for the Arduino IO, but the rise/fall time for the SPI bus would be a good analog... it's 300nS, which would make a slew rate of 16.6V/mS.
Using i = C * dV/dT that works out to about 27mA maximum, instantaneous, but of course this would drop off rapidly to zero as the charge is depleted, so connected like I do with no R1, you could only drive one FET, maybe two if you wanted to push it.
I suppose another way to look at it is that with a 300mS rise/fall time, the charge 8nC will be depleted in 300nS, so the current would be i = dQ/dT or, you guessed it, 27mA.
But R1 changes the equation by slowing down the response. With a 500 ohm resistor, the gate will discharge in... 10uS, which makes the current 8mA, so you could drive like 4 or 5 FETs. (I'd stick with 4 max to give a little safety margin).
@Heiko (https://www.nscale.net/forums/member.php?u=8692) please check me on this. It's been quite a while since I got this down and dirty.
My solution was to use an i2C PWM driver chip and drive each of the eight FETs with a separate output. But then I was fabbing a board, so surface mount chips like that weren't too big of a problem. If you are perf-boarding or breadboarding this, you'd have to find a through-hole PWM driver chip.
EDIT: D'oh. I'm an idiot, somewhat. For a back-of-the envelope calculation, figure the Arduino switches instantly (it doesn't). The peak current will be at the instant the Arduino switches, at which time there will be 5V across R1. If R1 is 500 ohm, the peak current will be 10mA. So, 4 FETs max. The actual peak current will be less than 10mA because the Arduino won't switch instantly, so some of the charge on the FET gate will flow off during that switching time, and the voltage across R1 will never be 5V. It's too late and I'm too tired to do that calculus :)
Heiko
21st Feb 2021, 07:52 AM
What TwinDad said.
Heiko
conrailandrew
21st Feb 2021, 09:39 AM
And I really like your Arduino code. Elegant. In fact, one of the problems I had was coming up with the LED color values for the various lighting conditions (I'm an engineer, not an artist). Would you mind if I steal yours?
Steal away! Most of that is bits and ends I found and worked in myself, I'm by no means a professional coder, lol. And the colors aren't perfect, but they were good enough for my tastes. You can pretty easily tweak them as needed, as I remember.
techhobbies
5th Mar 2021, 10:27 AM
Hey TwinDad, I'm interested in knowing why you are choosing to do some of the heavy lifting for LED control when you might have chosen and RGB or RGBW strip and reduced some complexity. I've been doing a lot of LED work for my O layout, and am working on the N layout now, and personally prefer the APA102 and WS2812, even if they aren't as bright in many cases.
I'm considering a sun path overhead for my layout now, which would have to be brighter but controllable brightness given my space constraints overhead. So, I am thinking now about how I might handle that, and your post got me curious.
Thank you.
TwinDad
9th Mar 2021, 09:06 PM
Hey @TwinDad (https://www.nscale.net/forums/member.php?u=5043), I'm interested in knowing why you are choosing to do some of the heavy lifting for LED control when you might have chosen and RGB or RGBW strip and reduced some complexity. I've been doing a lot of LED work for my O layout, and am working on the N layout now, and personally prefer the APA102 and WS2812, even if they aren't as bright in many cases.
I'm considering a sun path overhead for my layout now, which would have to be brighter but controllable brightness given my space constraints overhead. So, I am thinking now about how I might handle that, and your post got me curious.
Thank you.
Why? Same reason George Mallory climbed (or tried to) Everest. Because it's there.
Or more directly, same reason one might scratchbuild a structure that is commercially available... or handlay track... for the challenge, mostly. I am in fact using commercial RGB and W strips for the actual lighting, it's just the control and drive circuitry and logic that I'm custom building. Brightness can be handled two ways... brighter LEDs, or MORE LEDs. Over each zone I run two strips of White (actually one long strip doubled back on itself) and one strip of RGB, and I chose 5000K whites to get a daylight approximation. At full power I can get a very bright daylight, and for dusk/dawn/night I can bring the whites way down (or off) and let the RGBs do the heavy lifting.
I should probably start (or resurrect if I already did one) a thread detailing my lighting system.
techhobbies
15th Mar 2021, 04:05 PM
I should probably start (or resurrect if I already did one) a thread detailing my lighting system.
That would be interesting. I do a lot of lighting work for a variety of projects around the house, and love the ESP32 and FastLED to make it fast and easy. I'm starting my first N scale layout this spring (need to finish a railing rebuild in the house first to get the garage back), and I am in the process of planning what I'm going to light and how I will do it. I've been going through this forum looking for ideas and am using my electronics experience to work on fun lighting and controls to add to make the layout more automated.
Powered by vBulletin® Version 4.2.5 Copyright © 2023 vBulletin Solutions Inc. All rights reserved.