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.
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?
Is this what you're trying to do?
If so then it will work fine. To dim the LEDs you need to connect it to a pin that can do PWM. This will turn the LEDs on/off very fast and, depending on the value, make it brighter/dimmer.
You need to learn how to draw schematics so that people can follow them. Note in the above, positive voltages at the top, ground at the bottom and signal flow from left to right.
BTW, the MOSFET used needs to be a logic level MOSFET or you need a MOSFET driver chip.
If you want to use PWM to dim all the LEDs to the same level, you could add a 2 input NAND gate at each input, and drive the 2nd input of all channels with the PWM signal.
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.
Just make sure they are "Logic level" FETs with a current rating somewhat higher than the load you expect, voltage well above the supply and a low "on" resistance at the working gate drive voltage to minimise power loss (heating).
I'd probably go for something like an STP40NF03L; they seem reasonably rated and not particularly expensive.
Can you do the translation for me? I'm not sure to understand the 2/3 thing regarding the mosfet current. I do understand his 2 circuit using an optocoupler, 2 transistors and a N-mosfet but I'd love to understand why it's a better solution.
I tried using google translate but the result was not clear so I hoped you could help since you seems to have understood him perfectly... but whatever I hope you feel good now...
Mosfet devre de kullanımı, mosfet akımının 2/3 değerinde kullanılır ... Örneğin; 100mA olsun mosfet en az 300mA'lik akım olmak zorunda. İki led için fazla akıma gerek duyulmadığı için 360mA Drain akımına sahip düşük güçlü BSP89 mosfet kullanılabilir.
By looking at the circuit you provided, you suggest to use an opto-coupler to power 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. Also I see that you didn't put any resistors before the transistors and the mosfet gate is that normal?
I updated my circuit and would like your thoughts on it.
Borrowing Pommie's schematic, I would add dimming by inserting a NAND gate in each input (available in a quad package). The PWM inputs from all channels are tied together, to dim the LEDs. The other input of each NAND gate is the on/off control for that channel.
Borrowing Pommie's schematic, I would add dimming by inserting a NAND gate in each input (available in a quad package). The PWM inputs from all channels are tied together, to dim the LEDs. The other input of each NAND gate is the on/off control for that channel.
Wow at first it seems too beautiful to be true but omg it works haha. I changed the NAND for an AND to allow the switch to operate the right way (ON on High instead of OFF on High).
I think that could be the best way of doing it unless someone think otherwise?
The (N)AND gate will work well but I feel you are over complicating this. The Mega has 15 pins that can do PWM, the current through your LEDs is ~10mA which the pins can easily handle. Why not power the LEDs from 5V and have each LED powered from a MEGA pin via a 280Ω resistor? OR, parallel all the LEDs and use 1 MOSFET driven by a PWM pin to switch them all?
BTW, in your original diagram, the PWM MOSFET is a P type!
If you need each LED to be individually switched but universally dimmed then PWM the ground via a MOSFET and supply the 5V by an individual pin via a 280Ω resistor.
The (N)AND gate will work well but I feel you are over complicating this. The Mega has 15 pins that can do PWM, the current through your LEDs is ~10mA which the pins can easily handle. Why not power the LEDs from 5V and have each LED powered from a MEGA pin via a 280Ω resistor? OR, parallel all the LEDs and use 1 MOSFET driven by a PWM pin to switch them all?
BTW, in your original diagram, the PWM MOSFET is a P type!
The thing is I have a total of 100 led box (each has 2 leds) so for 200leds total. I need 100 switch to independently switch them (it’s a control panel indicator) so the current is a issue for any arduino so I’m using a 12v power supply.
This is one part of my big project that requires around 245 inputs so I have around 5 arduino mega.
If you tell us what you're trying to achieve, we may be able to suggest ways of doing it. For example, reading 256 switches can be done using 32 inputs, 100 LEDs can be controlled via one pin - google WS2812. BTW, the only difference between using a 5V supply and a 12V supply is the value of the resistors and the heat they produce.
The thing is I have a total of 100 led box (each has 2 leds) so for 200leds total. I need 100 switch to independently switch them (it’s a control panel indicator) so the current is a issue for any arduino so I’m using a 12v power supply.
This is one part of my big project that requires around 245 inputs so I have around 5 arduino mega.
If you're using 12 Volts for your LEDs, you can reduce your system current by putting your LEDs in series.
Instead of two LED/1K resistor groups in parallel, put your two LEDs in series with a lower value of resistor. The same current now does twice as much useful work, while wasting less power keeping your resistor warm.
You can daisy chain as many of those as you like (data out to data in) and feed them from an SPI port, which is far faster than I2C.
Just transmit as many bytes as needed for the number of ICs, then pulse the "latch" pin to transfer the new data to the outputs.
Or you can have several different chains fed from the same clock and data lines, with different pins feeding the load (latch) signals to you can update different parts of the output array separately.
You can also use parallel load shift registers in a similar way to add large numbers of inputs to a device via the same SPI port.
I don't use Arduinos, but if the SPI port can run at eg. 8MHz, you could update 16 ICs (128 output) in a 16uS burst.
The 74HC (or HCT) 595 can operate to 20MHz clock or more, at 5V, so extremely fast updates are possible.
If you tell us what you're trying to achieve, we may be able to suggest ways of doing it. For example, reading 256 switches can be done using 32 inputs, 100 LEDs can be controlled via one pin - google WS2812. BTW, the only difference between using a 5V supply and a 12V supply is the value of the resistors and the heat they produce.
You’ve piqued my curiosity now and I like it! Basically what I'm trying to achieve is simple:
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).
I will search regarding the WS2812 as it would be great to be able to control all the annunciators with 1 or 2 Arduino pin.