I am trying to control my N channel mosfets (fqP30N06L) with a 75hc595 shift register.
I can get the shift register to work with 3v LED's on the outputs with 220ohm resistor just fine.
However I can't get the outputs of the shift register to turn on or off the mosfets.
I tried a 10K ohm resistor tied from the gate to ground and I also tried a 100ohm resistor from the output line of the shift register to the mosfet.
My actual circuit consists of 12V LEDs which I have 12V+ running to and then the negative side of the LEDS connects to the drain of the mosfets. Im powering the arduino separately but have tied all grounds together.
Can anyone offer any guidance on how I can use these shift registers to drive these mosfets? Or do I need different mosfets or something in addition?
Thanks for any help, I'm still just getting into shift registers and controlling high power devices from low power on Arduino.
Attached is my current circuit. I removed everything else so I could simply test one of the LED's in a simple circuit first.
I utilised the code below to change the shift register values.
B00000000 to turn off leds or B11111111 to turn on leds.
Would love to know where I'm going wrong, it's all part of the experience.
// Define Connections to 74HC595
// ST_CP pin 12
const int latchPin = 5;
// SH_CP pin 11
const int clockPin = 4;
// DS pin 14
const int dataPin = 6;
void setup ()
{
// Setup pins as Outputs
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop() {
// Count from 0 to 255 and display in binary
// ST_CP LOW to keep LEDs from changing while reading serial data
digitalWrite(latchPin, LOW);
// Shift out the bits
shiftOut(dataPin, clockPin, MSBFIRST, B00000000); // or B11111111 to turn on leds
// ST_CP HIGH change LEDs
digitalWrite(latchPin, HIGH);
}
Go back to using your normal led, the "3V" led as you called it. (Use a series resistor!) Try connecting it from the '595 pin to ground and confirm the led lights when you sent a "1" and goes off when you send "0". Then connect the led+resistor between 5V and the '595 pin (anode to 5V of course). Does the led light when you send "0" and off when you send "1"?
You do realise that is totally overkill for the led inside that switch? An ordinary npn like bc337 or n-channel fet like 2n7000 would be fine. Or replace the 74hc595 with a tpic6b595, which can handle 12V directly.
PaulRB:
Did you change the wrong "can" to "can't" ? Please confirm what is and what isn't working.
Yes, I made a spelling error and corrected it.
PaulRB:
Go back to using your normal led, the "3V" led as you called it. (Use a series resistor!) Try connecting it from the '595 pin to ground and confirm the led lights when you sent a "1" and goes off when you send "0". Then connect the led+resistor between 5V and the '595 pin (anode to 5V of course). Does the led light when you send "0" and off when you send "1"?
Yes, a simple LED powered from the shift register works fine. Turns on when there's a 1, turns off when there's a 0 in the shift register for that output. Just doesn't work for my mosfets.
PaulRB:
You do realise that is totally overkill for the led inside that switch? An ordinary npn like bc337 or n-channel fet like 2n7000 would be fine. Or replace the 74hc595 with a tpic6b595, which can handle 12V directly.
Yes I do realise. It's what I have on hand and what I would like to use as I will not only be wanting to control these 12V LEDs. Might look into the tpic6b595 but still I should be able to use these mosfets with the 74hc595 shouldn't I?
Railroader:
The MOSFET needs to be a logic one. Usual FETs will not eork well. The 5, or 3.3 volt output frim the IC is not enough for a regular MOSFET gate.
PaulRB:
Then connect the led+resistor between 5V and the '595 pin (anode to 5V of course). Does the led light when you send "0" and off when you send "1"?
I did more testing with just the arduino, mosfet, shift register and a regular LED with resistor. Powered via arduino 5V to the shift register, and shift register powering the led with 5v. Everything works perfectly fine, turns on and turns off.
Although the reason I wish to use this mosfet is obviously to ground side switch a 12V LED.
The shift register outputs around 5v when on, and 0 when off as it should.
So just something with the mostfet. It stays on for some reason.
Anyone have any ideas why this might be happening? Something occurs when the 12V circuit is introduced.
I would post pictures of the project but it's a bit of a mess to understand.
Hi,
Double check your gnd circuittry, make sure the gnd of the Nano, 595 and the source of the MOSFET are connected together.
Place a 10k resistor between the gate and source of the MOSFET.
TomGeorge:
Hi,
Double check your gnd circuittry, make sure the gnd of the Nano, 595 and the source of the MOSFET are connected together.
Place a 10k resistor between the gate and source of the MOSFET.
Tom...
I'll clean everything up and wire up a simple circuit consisting of everything and just one 12V LED and post back with pictures and maybe even a video of the results. I'm sure my connections seem fine so it should work (if my schematic is valid) but it can't hurt to try one more time!
TomGeorge:
Hi,
Double check your gnd circuittry, make sure the gnd of the Nano, 595 and the source of the MOSFET are connected together.
Place a 10k resistor between the gate and source of the MOSFET.
Tom...
I wired everything up in a simple circuit and it sort of worked.
When the shift register is told to turn the output off, the led becomes dimmer but doesn't turn off completely. When you turn the shift register output on, the led lights up full brightness.
I measured the output of the shift register when it's told to be OFF and there's still 0.40v coming out of it which means the mosfet is still somewhat on I think. When I unplug the arduino from the PC, the mosfet turns off completely as expected and the LED is completely off. Even if I disconnect the 12V and just check the shift register output as I just mentioned, it's still 0.40v on the shift register output/mosfet gate.
So somewhere the mosfet is still getting a small amount of voltage on the gate.
I have already tied a 10K resistor from the gate to the source.