How is it (mis)behaving?
Just some ideas:
1. In general, don't hook up your actual output device until you're sure the circuits controlling it work with a voltmeter. Put a resistor in place of the LED strip to see if the transistors are switching properly.
2. Are the transistors switching properly? What voltages are you seeing at the transistor drains for each control input voltage?
3. I saw from the 2N7000 spec sheet that it has a typical gate threshold voltage of 2.1 V, though it could go as high as 3V. You might have trouble controlling it from a 3.3V Arduino. You might want to replace it with an NFET with a lower gate threshold or use a good old 2N2222 bipolar NPN transistor.
4. You haven't biased the first transistor's gate, so when you first turn on power the transistor may or may not switch on, depending on what's driving it and whether that driver is floating. You may want to have a pull-down resistor so it's guaranteed off when you first power up.
I will take everything above into consideration.
I'm having feeling of dejavue with a similar circuit some time back to do a similar task.
The first FET is right on the limit for conducting, so you could reduce the resistor to 1k or similar.
You should be able to prove it works with a voltage (12 or 5v) on the control side of R1.
Personally to get what you want you might consider swapping both fets and using an Optocoupler.
You can drive the LED (pin and ground) or have it connected between the 3v3 and Arduino pin, and simply connect the output in place of the second 2n7000 (ie between the IRF540 Gate/R3 and ground)
This is the part of the 2N7000 datasheet that shows you what current you can expect with what voltage applied at the different Gate to Source voltages (ie 3v3, 5v and 12v)
At the best you're probably only going to get 30-50mA on your first 2N7000, so you could try swapping the 2k2 with the 10k.
I agree with John about ensuring the pin is in a known state, so ensure the PinMode is at the start of setup.
edit I was right my memory isn't going after all ...
So you had this version working ......
Yes, that circuit works (from old thread) and I remember all of the content in the very very long and interesting discussion.
In this new version I am trying to correct two issues I had with the last:
1. Circuit logic -> The logic in the old circuit was backwards, which was annoying.
2. Current draw was too high by Bi-Polar.
A response by someone in the old long thread said that adding an extra FET would fix issue ( 1 ) above.
For issue 2 I was under the impression that MOSFETs didn't pull anywhere near as much current as the Bi-Polar (which was around 50-70mA on the old circuit). I was thought that for the first FET in the circuit the current in the Gate would be <10mA.
I accept that a pull-down resistor needs to be added to that diagram. I have corrected that. Thank you.
From a completely electrical theoretical point of view, will what I am trying here work? (yes / no)
You are correct on all counts - the gate current will by much less than 1 mA.
It looks to me like the circuit will work fine with no pull-down or pull-up on the first FET, Even R1 is not needed with this FET.
To ensure full switching operation R2 should be relatively high - between 30 K and 100 K should be safe, although it will likely work even with a 10 K resistor.
My previous comments only apply if the FET doesn't work quite as well as the datasheet indicates.
1 of 1 people found this helpful
What is the reason for such a high R2 (R3 in new diagram) resistance?
Do you recommend any values for the other resistors (new diagram: R2, R4)?
FET gates have very high impedance, so you can get by with high resistance on the pull-ups and pull-downs. If you use a low resistance on R3 (in the new diagram) you're wasting current when the left-most transistor is on.
I suggest 10K - 47K for R2-R4. I suggest zero Ohms (i.e., short circuit) for R1. Since a FET gate is high impedance, you can drive it directly from a microcontroller output as dougw suggests. I like R2 since it forces the LEDs off when you power up.
1 of 1 people found this helpful
If you want to save as much power and cost as possible then R1 = 0 (replaced with a wire), R2 is removed (infinite resistance), R3=100K, R4=100K.
If you want to modulate the control with PWM to achieve variable brightness then R1=1K, R2 is removed, R3=10K, R4=2.2K.
If you really need R2 to keep the LEDs off for the microsecond it takes to power up, it should be 100K, and R1 should be replaced with a wire.
Thanks Doug and John,
The circuit is working with the following configuration:
I have not tried to use PWM with the circuit yet, but if should be ok.
Thank you for all your help.
That explains it then.
As another question, why are you worried if the output is HIGH or LOW to control the LED's.?
Even if you used PWM, it would be similar that 0 is fully ON while 255 is OFF.
That is one of the nice things about micros and code.
Thank you everyone for your comments and recommendations. They are always much appreciated.
To answer your question Mark: I wanted to use the RGB LEDs with a DMX shield and link them into the DMX controller. Not sure how the DMX controller would cope with 'false' logic from a control point of view. I thought it would be better safe than sorry!
To test the circuit as drawn connect the free end of R1 alternately to Vcontrol and ground - the output should switch.
If it doesn't, check your wiring or swap components if the wiring is correct.
If it works, you could replace the first FET with a lower threshold FET such as a TN0702.
If you really need to use the FETs you have, you could put a pull-up resistor on the first gate and a pull down resistor on the arduino output such that the voltage at the arduino output is 3.3 V (without the arduino connected. This would allow the gate to be at a higher voltage, hopefully turning the FET on. When the arduino is connected it can pull the gate down, hopefully enough to turn the FET off. It may take some calculation or trial and error to get it set properly, but just be sure the control input voltage is 3.3 V before connecting the arduino.
You might want to have a little TV time , yes im in them but its better than coronation street (IMHO)
and for reading:-
I am having issues with this circuit:
Background: This circuit is to control an RGB LED strip (so three of the above would achieve this). The reason for this particular design is: IRF540 to drive load (large current) and the two 2N7000 drive the MOSFET, reducing current drain from Controller (possibly a 3v3 Arduino). The double 2N7000 allows the IRF540 to be active when logic high.
Can someone please tell me if there is a problem with the above schematic, otherwise I think it would be my breadboard layout is not correct. (too hard to post that right now).
Any comments would be much appreciated.