First time using MOSFETs project

Thread Starter

exomic

Joined Mar 20, 2019
11
Hello,

First I wish to all of you a great year for 2021 (it can only gets better... right?... right???).

I trying to build a simple circuit wish involve a arduino mega to control LEDs using MOSFET and a 12v power supply (to avoid drawing current from the limited arduino's pins). I want to be able to switch the LEDs on and off using only the 5V from the Arduino IO pin without drawing the current from the arduino. To accomplish that I used N-Mosfets and it seems to work fine the simulation (I never used Mosfets before so maybe you will find something wrong in my circuit). I also wanted to use one arduino pin to DIM all the LEDs. That's where I know I messed up but I can't figure out a cleaner way to do it while keeping the circuit clean and simple.

IO1-2-3 represents the Arduino pins.

The project can be tested here
circuit-20210114-1634.png


The issue with the dimming is that the resistance is fixed at 2k in series with all the LED box so depending on how many led are turned on it will change the dimming.

Also I'm scared about the 12V going into the Arduino IO Pins in this circuit (blowing the Arduino with the 12v power supply). Could I use diodes after the 10k pulldown resistor to avoid flow towards the Arduino? What about the MOSFET could it flows there too and blow the Arduino?

Thanks guys!
 

Attachments

Last edited:

dl324

Joined Mar 30, 2015
12,871
Your schematic drawing method is poor. You've drawn the MOSFETs rotated 90 degrees from how they'd normally be drawn.

The 300 ohm resistors on the gates aren't required.

Dimming by switching the 2K resistor won't let you dim the pairs individually and doesn't give you much control. A better method would be use PWM on the gates of the MOSFETs being used as switches.

Using PWM lets you smoothly vary the brightness from on to off.

Ignore the 2 LEDs in the corner; that was a different experiment.

EDIT: Most discrete MOSFETs don't have any ESD protection, so handle them appropriately.
 
Last edited:

jpanhalt

Joined Jan 18, 2008
11,088
If you use PWM, the dimming will be a function of duty cycle. So you can run all LED's at full brightness, Then adjust the PWM, and they all dim equally regardless of how many re lit (assuming your supply is adequate).

Although not required, it would be easier to use a P-channel mosfet on the high (supply) side.
 

Thread Starter

exomic

Joined Mar 20, 2019
11
The 300 ohm resistors on the gates aren't required.
I used the 300ohm resistor to make sure the draw current from the Arduino's pin was not going to go above the 20mA limit (I read that MOSFET when turning ON can draw a large amount of current similar to a capacitor). Am I wrong?

Your schematic drawing method is poor. You've drawn the MOSFETs rotated 90 degrees from how they'd normally be drawn.
My drawing is poor I agree but I'm still proud of it considering that's my second time drawing any circuit. (we are not all at the same level). I will next time put the MOSFET the right way thanks for the tip.

Dimming by switching the 2K resistor won't let you dim the pairs individually and doesn't give you much control. A better method would be use PWM on the gates of the MOSFETs being used as switches.
I'm not looking to dim them individually. The dimming function would be used to dim all the LED to a Dimmed state all equally. PWM is not a bad idea I will try to think on a way to implement that.
 

Thread Starter

exomic

Joined Mar 20, 2019
11
Although not required, it would be easier to use a P-channel mosfet on the high (supply) side.
I can do the change to P-MOSFET but what would be the benefit/easier?

For the PWM can I do it without drawing the current from the Arduino?
 

jpanhalt

Joined Jan 18, 2008
11,088
I can do the change to P-MOSFET but what would be the benefit/easier?

For the PWM can I do it without drawing the current from the Arduino?
Far easier gate drive. P-mosfets SOURCE rather than sink current and don't require the gate to be well above supply voltage to turn on. That's why they are often use in a high-side configuration for motor drives.
 

dl324

Joined Mar 30, 2015
12,871
I used the 300ohm resistor to make sure the draw current from the Arduino's pin was not going to go above the 20mA limit (I read that MOSFET when turning ON can draw a large amount of current similar to a capacitor). Am I wrong?
The current spike is short and CMOS outputs were designed to drive capacitive loads. If the load is too high, you'd use a gate driver.
I will next time put the MOSFET the right way thanks for the tip.
I'd draw it like this.
clipimage.jpg
I'm not looking to dim them individually. The dimming function would be used to dim all the LED to a Dimmed state all equally. PWM is not a bad idea I will try to think on a way to implement that.
If you want them to all DIM at the same time, you can apply a PWM signal to the gate of Q4.
 

dl324

Joined Mar 30, 2015
12,871
I can do the change to P-MOSFET but what would be the benefit/easier?
You can't drive the gates on P channel MOSFETs with their sources at 12V directly from the Arduino outputs operating at 5V.

It'll be simpler if you stick with your original idea.
 

Thread Starter

exomic

Joined Mar 20, 2019
11
I just designed the PWM Dimming function out of the Arduino PWM Pin. I added some diodes not sure if it's needed but I wanted to be safer. I will redraw the circuit following your advices. I used a N-MOSFET for the PWM Dimming as the P-MOSFET was causing strange behaviors with voltage being reduce and passing through the 10k resistor.

Here's the simulation link

circuit-20210114-1921.png
 

dl324

Joined Mar 30, 2015
12,871
I just designed the PWM Dimming function out of the Arduino PWM Pin.
Your new circuit has no hope of working. When the Arduino outputs are HIGH, the P channel MOSFETs will still be on. To overcome this issue, you need to add an inverter between the Arduino output and the gate. As I said, you'd be better off staying with your original idea.

You don't need the diodes or 300 ohm gate resistors. The diodes will never be forward biased. What function do you think they provide?
 

Sensacell

Joined Jun 19, 2012
2,820
P-FETS are a bad idea here, you are better off with N-FETs.

With the N-FET you can drive the gates directly from an IO pin, even if the FET drain is switching a load connected to 12V, with a P-FET, you need to level-shift the gate drive - needless complexity.

If you are switching MOSFETs relatively slowly (Freq < 1khz) you can stick with the 10K and 300 ohm resistors as you show. Higher speeds can require a gate driver to supply more current than an IO pin can deliver. Ditch the diodes, they are not a good idea.
 

Thread Starter

exomic

Joined Mar 20, 2019
11
You don't need the diodes or 300 ohm gate resistors. The diodes will never be forward biased. What function do you think they provide?
For the diodes I wanted to make sure that no current would go toward the Arduino. As for the 300ohm resistor it's to limit any current surge from going above 16.67mA when the MOSFET initially charges (the Arduino's pin is limited to 20mA).

If you are switching MOSFETs relatively slowly (Freq < 1khz) you can stick with the 10K and 300 ohm resistors as you show. Higher speeds can require a gate driver to supply more current than an IO pin can deliver.
Honestly I don't know what frequency will be used for the PWM pin to give a proper dimmed light from the leds. I will go buy some mosfet to try it on a breadboard what kind of spec should I be looking when I buy my N-Mosfets? In the simulator the threshold voltage was set to 2V and it worked fine but as newbie I'd like your opinion for that.

Here's my updated circuit
circuit-20210115-0106.png

Thanks
 

dl324

Joined Mar 30, 2015
12,871
For the diodes I wanted to make sure that no current would go toward the Arduino.
The diodes aren't needed. The only current that can flow is gate leakage current and Arduino outputs will tolerate that current easily.
As for the 300ohm resistor it's to limit any current surge from going above 16.67mA when the MOSFET initially charges (the Arduino's pin is limited to 20mA).
You don't need them. CMOS outputs can tolerate brief shorts between VDD and VSS which happens every time they switch logic states.
Honestly I don't know what frequency will be used for the PWM pin to give a proper dimmed light from the leds.
With 4 pairs of LEDs, a frequency of a few hundred Hz will avoid flicker.
I will go buy some mosfet to try it on a breadboard what kind of spec should I be looking when I buy my N-Mosfets?
You want Vgs(th) low enough that the MOSFETs have low RDS(on) at a gate voltage of 5V. Vgs(max) needs to be higher than 12V. The PWM MOSFET needs to be able to sink the current for all 8 LEDs.

EDIT: 2N7000 should suffice. About a dime each in quantity 100.
 
Last edited:

Thread Starter

exomic

Joined Mar 20, 2019
11
Would it be a good idea for the dimming part to use a bipolar totem-pole driver to increase the speed of turning ON-OFF the MOSFET? The circuit will be used for around 100leds if that's might cause any issues for flickering.

I updated my circuit and would like your thoughts on it.

Thanks!

Link to the simulation here
circuit-20210115-1552.png
 

djsfantasi

Joined Apr 11, 2010
7,689
Why are you using one pin to dim all the LEDs? The Arduino has sufficient pins that can provide built-in PWM. On Arduino Uno, the PWM pins are 3, 5, 6, 9, 10 and 11. Then you can dim all in code
 

Thread Starter

exomic

Joined Mar 20, 2019
11
Why are you using one pin to dim all the LEDs? The Arduino has sufficient pins that can provide built-in PWM. On Arduino Uno, the PWM pins are 3, 5, 6, 9, 10 and 11. Then you can dim all in code
The circuit is showing only 2 led box individually controlled but my project have 200+ i/o with 5 arduino mega and around 200leds to power. So using less pin is important.
 

Thread Starter

exomic

Joined Mar 20, 2019
11
Why are you using one pin to dim all the LEDs? The Arduino has sufficient pins that can provide built-in PWM. On Arduino Uno, the PWM pins are 3, 5, 6, 9, 10 and 11. Then you can dim all in code
I have a control panel with:

132x Switches
100x LED Status Annunciators (200leds, 2 LED per Annunciator in parallel for redundancy but could always be installed in series if necessary for current saving)
8x Servo Motor (Model not chosen yet but I'm looking at those cheap SG90 RC Servos)
5x Potentiometers
2x Rotary Encoder
2x 5Bit 7 Segment LED Display

For the features I need each Status Annunciators to be able to turn ON via the Arduino. One pin will be used to DIM all the Annunciators using PWM with a AND GATE (see last circuit) seems a good idea.

Each switch's state (ON-OFF) must be updated into the Arduino in a fast and reliable way (for example, using matrix to save Arduino pins wouldn't work reliably as switching on 2 switch at the same time could cause one of the switch to be in the wrong state).
 

ElectricSpidey

Joined Dec 2, 2017
1,653
" 100x LED Status Annunciators (200leds, 2 LED per Annunciator in parallel for redundancy but could always be installed in series if necessary for current saving) "

If you place the LEDs in series you lose redundancy.

I haven't read this entire thread so forgive me if this is out of line, but I think you should dim the LEDs with a single P-Channel MOSFET driven by a MOSFET driver such as the TC4420/29, place the MOSFET between the anodes of the LEDs and the positive supply.
 
Top