Pages: [1]   Go Down
Author Topic: simple MOSFET circuit to drive solenoid  (Read 1925 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, I'd really appreciate some advice on this circuit I'm trying to make.



The Ruggeduino is meant to be controlling the MOSFET through pin 8 (blue wire). I have 12V on the rail of the breadboard (black/yellow, bottom right) to drive the solenoid (left, fed by yellow/blue, datasheet attached). The MOSFET datasheet is here. A 47K resistor pulls down the MOSFET's gate pin.

My code is just a proof-of-concept to test the MOSFET and valve but the valve does nothing. It works fine if I connect it straight to 12V.

Code:
// set the pin that will control the valve
int ValvePin = 8;

void setup() {
    // set the digital pin as output:
  pinMode(ValvePin, OUTPUT);    
  
  // start the pin on LOW
  digitalWrite(ValvePin, LOW);  
}

void loop(){

digitalWrite(ValvePin, LOW);

delay(5000);

digitalWrite(ValvePin, HIGH);


delay(5000);
}

I can measure voltage switching from the I/O pin but it only gets up to 2.4V at high and won't drop below 0.17V on low. In response the voltage between drain and source pins of the MOSFET switches between 10.4V and 12.1V which is odd as I thought it would be off by default. Also, despite this voltage, the valve still doesn't switch. Its not a particularly heavy current drain so I am broadly stumped for answers here. I have duplicated this problem with a Duemilanove too.

I presume I am doing something stupidly wrong. Can someone throw me a bone?

Thanks,
Scary

* 225T031 3-way solenoid valve NResearch.pdf (105.53 KB - downloaded 25 times.)
« Last Edit: March 22, 2012, 01:57:09 am by scary » Logged

fear my badger

Offline Offline
Jr. Member
**
Karma: 4
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I see that your load (the solenoid) is connected between MOSFET source and ground. Usually the N-MOSFET configuration as a switch is done with the load between +12V and the MOSFET drain, with the source pin connected to ground.
Moreover when switching on/off an inductive load you should place a diode in parallel with the load (inverse polarity) to protect the MOSFET from voltage spikes.
« Last Edit: March 22, 2012, 08:50:54 am by ea123 » Logged

Offline Offline
Edison Member
*
Karma: 4
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You should also havr a ~480 ohm resistor to the gate, you can fry the pin from continously driving the very capacitave gate of the mosfet without the limit resistorresistor, idk if the ruggedduino has it built in or not, i think it has poly fuses which wont protect from that
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16548
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You should also havr a ~480 ohm resistor to the gate, you can fry the pin from continously driving the very capacitave gate of the mosfet without the limit resistorresistor, idk if the ruggedduino has it built in or not, i think it has poly fuses which wont protect from that

Every I/O pin on a ruggeduino is 'protected' with a series 220 ohm resistor. This will be fine for directly interfacing a N-channel mosfet wired as a low side switch.

Lefty
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, thanks for all the replies. I have switched the valve for an LED and the 12V supply for 5V from the Ruggeduino to simplify things. Nothing changed. There is still conductivity between the drain and source pins when there is no voltage to the gate pin. I have now switched the MOSFET for a transistor and it seems to work as intended so I will press on with the transistor. I think the loads should be okay.

I won't forget to add the diode either. Thanks ea123.
« Last Edit: March 22, 2012, 05:52:20 pm by scary » Logged

fear my badger

0
Offline Offline
Shannon Member
****
Karma: 162
Posts: 10496
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And you have a flyback diode across the solenoid to prevent it frying everything else in the circuit?
Logged

[ I won't respond to messages, use the forum please ]

Radelaide!
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If it helps I've been messing around with mosfets and solenoids as well, although in a more limited manner.

If it helps the thread is here
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And you have a flyback diode across the solenoid to prevent it frying everything else in the circuit?

Hee hee, I do now. I suspect that was my major fail with the MOSFET circuit. Ho hum, application solved for now though. Many thanks to all contributors, you guys saved my bacon once again!  smiley-mr-green smiley-lol smiley-mr-green smiley-lol
Logged

fear my badger

Pages: [1]   Go Up
Jump to: