Go Down

Topic: Controlling a 5V Solenoid with a Mosfet irf540 (Read 15244 times) previous topic - next topic

electroturk

I am trying to control a 5V (240-1000 mA) solenoid from my Arduino using a irf 540 Mosfet. 

I wrote a simple code that turns on the output pin HIGH for 10 secs, and LOW for 2 sec. The output pin of the arduino is connected to the Gate, the solenoid to the drain, the source to the ground. An external 5V power source is connected to the solenoid.

The mosfet seems to work well as a switch, since I can measure a voltage over the solenoid of 5V for 2 secs, and 0,7V for 10 secs.

However, this 0.7V keeps the solenoid in an "active" state, so the solenoid is constantly switched on.  (I do feel a difference in force of the solenoid however)

How do i get the drain voltage to drop to 0 (instead of 0.7) when the arduino output is turned HIGH?

Datasheet of the mosfet irf 540: http://www.futurlec.com/Transistors/IRF540.shtml
(The datasheet says the  max gate voltage is 4V, while the arduino output is 5V. Might this be the problem? Tried lowering the gate voltage to 2.5V (with two equal resistors), but this resulted in a constant drain voltage of 5V)





retrolefty

1. IRF540 is not a 'logic level' mosfet, and requires +10vdc gate voltage to reach minimum Ron value.
2. Post a drawing to see if you have the external power sharing a ground with the arduino.

Lefty

Grumpy_Mike

Quote
The datasheet says the  max gate voltage is 4V

No it doesn't. It says the maximum gate voltage is +/- 20V

It says the maximum gate threshold voltage is 4V, the is the point where the FET just begins to turn on and can be as low as 2V. This is not an absolute limit it is a parametric limit. In other words they guarantee the gate threshold will not be greater than 4V. 

MarkT

Often the gate threshold is quoted for 0.25mA source-drain current - nowhere near
what you need for your solenoid.

To drive a MOSFET from 5V you must have a logic-level MOSFET (most MOSFETs
in TO220 package are not logic-level).

There are three voltages normally given in the datasheet, the threshold voltage
(which you might as well ignore, it won't tell you anything useful), the plateau
voltage (usually given in a graph of gate-charge v. voltage - which displays a
plateau.   This is the gate-source voltage at which the device is really turning on,
the source-drain current rises a lot as the gate voltage rises a little.

The third voltage is the gate-source voltage quoted for the value(s) of Rds(on).

For instance "Rds(on) = 0.02ohm for Vgs=4.5V" would indicate a logic level
MOSFET with an on-resistance of 20 milliohms.  "Rds(on) = 5.5 mOhm at Vgs=10V"
only implies the device works with 10V (unless there is another value
quoted for Vgs=4.5V or 5V).

The plateau voltage is a useful guide to the best gate voltage for fast switching, you want
the plateau to be about 1/2 the gate drive voltage for symmetrical turn-on/turn-off.
The IRF540 has a plateau of around 4.5V, so 10V is a good choice for gate drive.

You'll find logic-level devices tend to have a threshold from 0.5 to 1.0V, and a plateau
around 2 to 3V.

The plateau and thresholds will vary by a volt or two for a particular part, due to manufacturing spread and also aging effects.  The only guaranteed value you typically
get is the Rds(on) value.
[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]

electroturk

Wow, Thnxs for your quick responses and detailed explanations!

Seems that i have to dive into this is a little further before i fully understand whats going on. But your explanations already helped a lot and I now understand the irf540 mosfet is not suitable for controlling with the (5V output of the) Arduino (weird that I got it from an "Arduino" basic components kit bought on the internet). 

anyway, thnxs again!

pwillard

#5
Oct 14, 2013, 02:17 pm Last Edit: Oct 14, 2013, 02:19 pm by pwillard Reason: 1
Controlling a 12V motor (Like a PC fan)  with an IRF540 is more likely the intended reason you have one in your kit... but, the fact  remains that to use it properly, you really need to get the gate voltage closer to 10V. The 5V from the arduino pin will seriously under drive the part.  

How to solve?

Personally, I do it with a 74HCT06 (since I have a  lot of 7400 IC's handy for glue logic).  The 7406 is an open collector part which means that the output can be tied to circuits where voltages above 5V exist.  (the part can only SINK, not SOURCE).  NOTE: SINK means "provide a circuit path to ground".  

The input of the 7406 goes to an Arduino pin... the output goes to the MOSFET GATE and that connection ALSO is "pulled up" to 12V using a 10K resistor.  

So, you need 2 extra parts... but you can make your IRF540 useful IF you are working with a 10V or higher load voltage.

oztmert

http://arduino-info.wikispaces.com/Brick-4ChannelPowerFetSwitch

Hey I just checked some topic that is related to that issue. Elecktroturk  at link that I shared you can see that those shields are activated irf540 with Vpp voltage , not with 5 V auruino output.

You can check out with some of the simulation program.

DrAzzy

#7
Mar 23, 2015, 05:45 pm Last Edit: Mar 23, 2015, 05:45 pm by DrAzzy
oztmerk - that module would work for switching voltages of 10v+ - but OP is asking (as far as he's said) about just the mosfet directly, which won't work so well, and he's switching a 5v device.


There is a depressing, and rather inexplicable, shortage of basic mosfet driver boards (from the usual channels) that actually have proper logic level mosfets on them. You can buy mosfets in SOT23 that'll switch 3A, with 1.8v on the gate, and they're *cheap* too, and tiny so they won't take up much board space. But for some reason, they instead insist on using obsolete, non-logic-level IRF540's.
ATTinyCore and megaTinyCore for all ATtiny, DxCore for DA/DB-series! github.com/SpenceKonde
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Go Up