Driving many small mosfets and LEDs with microcontroller - Page 1
Forum section: electronics / beginners

author: mribble
author_rank: Regular Contributor
timestamp: October 27, 2017, 09:17:18 pm
content: I attached a quick sketch of how I have things hooked up today.I have a project driving sixteen BSS138 mosfets with a sam3x microcontroller. I've been doing this without any adverse effects, but I have often seen people add a resistor on the gate. I know this will slow down the switching time for the mosfet, but it is supposed to protect the microcontroller from current spikes. The input capacitance of this mosfet is 50pF (small), but has a rise time of 3 ns (fast). In theory this means the peak current can be way too high, but I wonder in practice things like wire capacitance and the internal capacitance of the sam3x IO pins might mean for such a small mosfet everything will be fine. I won't be switching any faster than 10Khz with a 50% duty cycle so average current usage of the IO line is tiny.On these same IO lines I'm also driving LEDs (again 16 of them). Even if I drive them with 5mA it becomes too much current on the micro since it's also using other IO pins for other things. I was thinking about using a ULN2003 to drive the LEDs. I know how to do a circuit using the ULN2003 for LEDs, but I don't see how it could also drive the mosfets since it would waste significant amounts of extra power when on. Though maybe I'm not seeing how to efficiently drive a mosfet with the ULN2003...I also thought of using something like a 74LV07 buffer chip to drive both the mosfet and LED on each IO line, but the current from that buffer is low, and I'm not sure if these buffers would also be damaged by the current spikes from the mosfet switching. If there is some inexpensive buffer chip that can drive 10 mA an is safe against the current spikes from the mosfet then that would be good.Do people have suggestions on how I should drive this? If it's safe I'd be happy driving the mosfet directly from the micro IO line and using the ULN2003 to drive the LEDs. However, if people think that's not safe or have a better suggestion let me know.Thanks in advance!

author: danadak
author_rank: Super Contributor
timestamp: October 27, 2017, 09:50:46 pm
content: You are challenged to turn on MOSFETs because LED load on outputpin will drop Voh levels. That then would cause MOSFETs to dissipatemore power because they are not "hard" on.I would buffer out the drive to LEDs by using 2003, so pin connects bothto MOSFET and to 2003 input. The 2003 though is darlington so its outputVcesat is high for use in a 3.6V environment. A better driver might be somelow voltage MOSFETs as well for that. If you use 2003 it needs a series Rto the input pin to limit amount of base drive, therefore maximize Voh on pinfor power mosfet.This might be a suitable LED driver -http://www.ti.com/lit/ds/symlink/sn74lvc244a-q1.pdfRegards, Dana.

author: mribble
author_rank: Regular Contributor
timestamp: October 27, 2017, 11:18:31 pm
content: Thanks for the reply Dana.I'm not actually having problems with the circuit. The mosfet turns on just fine. I'm more worried about long term reliability and getting rid of current load on the sam3x pins that I'm currently driving. I don't think the LED drops the pin output voltage. I would expect the voltage drop to happen after the LED. If this is really causing a voltage drop could you explain why?The buffer chip you linked to is interesting. I don't see why it can only drive the LEDs though. It seems I could drive both the LED and mosfet with it since it can source or sink 24 mA. Attached an image of how I think that would work. As long as I pick R1 and R2 to stay under 20 mA I can't see where there would be an issue. What happens if I try to draw more current from these buffers than is allowed? For example is it safe to drop R2?I also realized I should probably put a 10K pulldown resistor before the buffer while the micro is booting I don't accidently trigger the load while the pin is set to high impedance.

author: frog
author_rank: Contributor
timestamp: October 28, 2017, 02:15:12 am
content: Is there any reason why you don't put the LED downstream of the FET (i.e. switched by the FET). That way the IO pin only needs to drive the FET gate. You may find that 1mA or so is enough to drive the LEDs, in which case the micro should be able to provide the required current.It is typical to put a series resistor in the drive to a FET gate, but not essential. It slows the switching a little which is good for EMC. The IO pins generally won't supply enough current to do themselves any harm (even into a dead short) but a 1k (say) series resistor would be polite.Check the datasheet for the internal pull-up, off the top of my head it's nominally 100k for SAM3X but I know it's around 20k for some other Atmel micros. If I'm right then a 10k pull-down is fine, but if the pull-up is 20k then the FET gate might see a volt or so until the pin is set to be an output; that would be a bit marginal for starting to switch on the BSS138s. The good news is that they will be fully switched on at not much over 2v. Given that the forward drop of the LEDs will be around the same, it's unlikely that the load from the LED would stop the FET from switching on properly.

author: mribble
author_rank: Regular Contributor
timestamp: October 28, 2017, 10:33:32 am
content: Hi Frog,Yes, there is a reason I don't trigger the led with the mosfet. The reason is because the mosfet is acting as a switch for external photography flashes and cameras. These devices supply their own voltage and current. It is not enough current to power the LED.Thanks for the info about the FET gate. You have a good memory because the sam3x does have a 100K pullup. So I think the 10K value is good. I could even go higher since during startup the pins are in high impedance mode and I won't configure the software to ever use the pullup on these pins. That said, I'll probably just use 10K since I already have a bunch of those in the design and there's no reason to put another resistor on in the feeders for this case where a 10K is fine.

author: danadak
author_rank: Super Contributor
timestamp: October 28, 2017, 11:51:59 am
content: Bassic cmos output drive characteristics -As you can see the more current you source out of the SAM3x the higher the voltage drop acxrossthe output P channel device.Same is true for sink current, but it generally is lower drop for same current. Has to do with sourcebulk effect on PMOS side.Generally it is best to drive the LED to ground rather than thru its supply rail, eg.Vdd > LED Rlimit > LED > Pin rather than Pin > LED Rlimit > LED > VssThe problem with dropping R2 is that if you draw too much current from buffer, internallyits supply rail droops in V and can introduce logic errors because you violate noise marginfor CMOS logic. Simple buffers not a problem, ones with more complex logic suffer the effect.Processor I/O pins are complex logic architectures.Most modern processors specify the max current on all pins in a port or I/O ring that is allowed becauseof this issue.Regards, Dana.