Arduino - Control fqP30N06L N-channel mosfet with 74hc595 shift register? - Page 1
Forum section: electronics / projects

author: kylegp
author_rank: Newbie
timestamp: August 25, 2020, 09:56:48 am
content: Hi there,I am trying to control my N channel mosfets (fqP30N06L) with a 75hc595 shift register.I can get the shift register to work with regular small 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.I attached my circuit diagram.Here's my arduino code:Code:// Define Connections to 74HC595// ST_CP pin 12const int latchPin = 5;// SH_CP pin 11const int clockPin = 4;// DS pin 14const int dataPin = 6;void setup (){// Setup pins as OutputspinMode(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 datadigitalWrite(latchPin, LOW);// Shift out the bitsshiftOut(dataPin, clockPin, MSBFIRST, B00000000); // or B11111111 to turn on leds// ST_CP HIGH change LEDsdigitalWrite(latchPin, HIGH);}

author: Dabbot
author_rank: Regular Contributor
timestamp: August 25, 2020, 11:15:01 am
content: Can you light the LED via the MOSFET when you manually connect the gate to +5 or +12?

author: kylegp
author_rank: Newbie
timestamp: August 25, 2020, 01:27:32 pm
content: Quote from: Dabbot on August 25, 2020, 11:15:01 amI did more testing with just the arduino, mosfet, shift register and a regular 5V LED with resistor. Everything works perfectly fine, turns on and turns off. In other words, if you replace the 12V LED in the diagram with a standard 5v LED and dont use any 12V in the circuit, it works as expected.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.

author: Dabbot
author_rank: Regular Contributor
timestamp: August 25, 2020, 02:21:34 pm
content: Quote from: kylegp on August 25, 2020, 01:27:32 pmSo, taking everything out of the picture except for the MOSFET, an LED and a resistor as required with the +12V supply, can you manually control the MOSFET by alternately connecting the gate to +12V and 0V?

author: kylegp
author_rank: Newbie
timestamp: August 26, 2020, 03:50:26 am
content: Quote from: Dabbot on August 25, 2020, 02:21:34 pmYes, and 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.Any ideas?

author: ledtester
author_rank: Super Contributor
timestamp: August 26, 2020, 04:41:20 am
content: Ideas:- Disconnect the shift register output pin from everything. Does it still output 0.4V when in a low state? If not, make sure /OE is low; try the same experiment with the other output pins; try a different 595 chip.- Try placing a 0.1uF capacitor across the power pins of the 595 (i.e. between pins 16 and 8 on a PDIP package). Place the capacitor close in proximity to the chip. This is closer than you need, but it gives you an idea of what "close" means:- Make sure you don't have the gate and source pins mixed up on the MOSFET.- Try driving the MOSFET directly from your microcontroller.- Try replacing the MOSFET.

author: kylegp
author_rank: Newbie
timestamp: August 26, 2020, 05:05:33 am
content: Quote from: ledtester on August 26, 2020, 04:41:20 amWorks perfectly fine if I use an arduino pin and control the mosfet with HIGH or LOW.Gate is definitely correct and the testing from the microcontroller should confirm that./OE is always grounded low as per my schematic so I think that's already taken care of?The only thing I don't have is any caps at the moment to test with. Would that really make or break basic turning on and off in this circuit? From what I've read, it helps to smooth out the signal (remove flicker) but I wonder if it's vital when using mosfets and shift registers.I'll have to get some caps...Maybe I need to pull the mosfet to ground more?

author: Dabbot
author_rank: Regular Contributor
timestamp: August 26, 2020, 05:26:03 am
content: Quote from: kylegp on August 26, 2020, 03:50:26 amLooks like you have found the problem. I just checked a couple of HC595 chips I have and their outputs measure 0V when low.

author: kylegp
author_rank: Newbie
timestamp: August 26, 2020, 05:44:13 am
content: Quote from: Dabbot on August 26, 2020, 05:26:03 amYes however if I take everything else off the circuit and measure the HC595 outputs, they're 0V when low. So something happens where the gate is energised still when the mosfet, LED and 12V power are introduced?

author: Dabbot
author_rank: Regular Contributor
timestamp: August 26, 2020, 05:49:53 am
content: Quote from: kylegp on August 26, 2020, 05:44:13 amIs there any current flowing out of the MOSFET gate? That would raise the voltage of the HC595 low driven outputs, as per the datasheet.

author: ledtester
author_rank: Super Contributor
timestamp: August 26, 2020, 05:52:08 am
content: Quote from: kylegp on August 26, 2020, 05:44:13 amJust to be sure... are all of the GNDs tied together?

author: kylegp
author_rank: Newbie
timestamp: August 26, 2020, 06:15:19 am
content: EDIT: Turns out I had several faulty mosfets. Either a bad batch or something was shorting them out. Most of them failed manual operation and in my tester. This was the whole reason for pulling my hair out, faulty mosfets.Thanks all for the replies. I think it was a bung HC595.I just soldered up a fresh HC595 with this known good mosfet and my circuit is now working normally. The 12V LED can be turned on and off with the shift register. I can only assume the shift register was bad and accidentally shorted, or there was a poor solder joint on one of the wires which was corrected when I soldered a new HC595. It was working with normal LEDS which is why this whole thing is confusing.Either way, it seems to work now.