Author Topic: Arduino - Control fqP30N06L N-channel mosfet with 74hc595 shift register?  (Read 1273 times)

0 Members and 1 Guest are viewing this topic.

Offline kylegpTopic starter

  • Newbie
  • Posts: 6
  • Country: au
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: [Select]

// 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);


 
}
 

Offline Dabbot

  • Regular Contributor
  • *
  • Posts: 192
  • Country: au
Can you light the LED via the MOSFET when you manually connect the gate to +5 or +12?
 

Offline kylegpTopic starter

  • Newbie
  • Posts: 6
  • Country: au
Can you light the LED via the MOSFET when you manually connect the gate to +5 or +12?


I 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.
« Last Edit: August 25, 2020, 01:42:55 pm by kylegp »
 

Offline Dabbot

  • Regular Contributor
  • *
  • Posts: 192
  • Country: au
Although the reason I wish to use this mosfet is obviously to ground side switch a 12V LED.

So, 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?
 

Offline kylegpTopic starter

  • Newbie
  • Posts: 6
  • Country: au
Although the reason I wish to use this mosfet is obviously to ground side switch a 12V LED.

So, 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?

Yes, 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?
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3109
  • Country: us
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:

1054172-0

- 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.
 

Offline kylegpTopic starter

  • Newbie
  • Posts: 6
  • Country: au
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:

(Attachment Link)

- 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.

Works 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?
 

Offline Dabbot

  • Regular Contributor
  • *
  • Posts: 192
  • Country: au
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.

Looks like you have found the problem. I just checked a couple of HC595 chips I have and their outputs measure 0V when low.
 

Offline kylegpTopic starter

  • Newbie
  • Posts: 6
  • Country: au
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.

Looks like you have found the problem. I just checked a couple of HC595 chips I have and their outputs measure 0V when low.

Yes 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?
 

Offline Dabbot

  • Regular Contributor
  • *
  • Posts: 192
  • Country: au
Yes 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?

Is there any current flowing out of the MOSFET gate? That would raise the voltage of the HC595 low driven outputs, as per the datasheet.
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3109
  • Country: us
Yes 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?

Just to be sure... are all of the GNDs tied together?
 

Offline kylegpTopic starter

  • Newbie
  • Posts: 6
  • Country: au
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.
« Last Edit: August 28, 2020, 01:16:21 pm by kylegp »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf