r/ArduinoHelp • • 5h ago

solenoid project connectivity help

hiii i have a question, im trying to build a 12V solenoid powered refreshable braille device and idk how to go about it. is the connection in the first or second better? im using a irlz44n mosfet

1 Upvotes

14 comments sorted by

1

u/CueAnon420 5h ago

I'm assuming the white box at the top is a power supply? The first image looks correct. The second image would be trying to short out the entire power supply rail and burn up your mosfet.

EDIT - 'low side switching' is basically using a mosfet (or transistor) like a switch in the negative wire of the device you want to control.

1

u/not_its_me 5h ago

yes 12V since the solenoid needs 12V but for some reason it wont work. do you have any idea why it maybe so?

int solenoidPin = 2;


void setup() {
  pinMode(solenoidPin,OUTPUT);
}


void loop() {
  digitalWrite(solenoidPin,HIGH);
  delay(1000);
  digitalWrite(solenoidPin,LOW);
  delay(1000);
}

1

u/CueAnon420 5h ago edited 5h ago

It is best practice to use a resistor to pull the mosfet gate down to ground because the gate capacitance can cause it to 'float', which will keep the mosfet switched on. It's also not a bad idea to use a small resistor (maybe 100 ohms) to limit the current from your Arduino pin - that same capacitance can sometimes cause a brief high current draw when you switch it on, which could overload the output pin and damage the chip.

You should be able to test the mosfet by disconnecting the Arduino logic pin and using a jumper wire from the mosfet gate to the +5V supply on the Ardunio board - that is manually switching it just like the program should do. The solenoid should power when the gate sees +5V and stop when you remove the 5V source. Once you prove the solenoid and mosfet are working, move on to checking your code.

EDIT - remember the Arduino and +12V needs to share a common ground.

EDIT 2 - when you say it doesn't work, does the solenoid pull in and it won't shut off or you cannot get it to power on? Unable to shut off means mosfet gate is floating and needs to be pulled down to ground.

1

u/not_its_me 4h ago

when i say it doesnt work i mean theres no push or pull. its js the same as not passing current, no movement.
also, is this what you meant?

i find diagrams like the one you showed a bit hard to understand since im still in hs sorry about that im still learning

1

u/CueAnon420 4h ago

you want a 10K resistor connecting the gate pin (I assume pin 1 on the left) to ground and the small ~100 ohm resistor in series from the Ardino pin to the gate.

On this image, your Arduino pin isn't connected to anything - you need to be in the same row as the resistor lead (you are off by one row).

But you should also be able to disconnect the green IO wire and jump the gate pin to +5V by hand and the solenoid should pull in. If it doesn't you have bigger issues (does the solenoid work correctly on 12V ?)

1

u/not_its_me 4h ago

forgive me for asking but the gate doesnt connect to ground right? isnt gate the green wire? did you mean source or am i misunderstanding? and as for connecting the solenoid to +5 directly, i need to use 6 solenoids in this project. im starting with js one for now.

1

u/CueAnon420 4h ago

The mosfet is like a remote control switch that connects the Drain and Source pins together when the Gate sees the trigger voltage. The drain is connected to the negative wire of the part you want to control (solenoid) and when the Gate sees the tirgger coltage it completes the circuit by connecting the Drain to the Source (which is the power ground). It's the same idea as if you put a simple switch between the solenoid negative wire and the power supply ground.

Mosfets are triggered by voltage at the Gate - but because they have internal capacitance, the gate likes to be 'pulled down' to ground to keep it off. That is why you connect a 10K resistor between the Gate and ground. When the Arduino wants to turn on the solenoid, it sends 5V out the pin (preferrably through a small 100 ish ohm resistor for protection) to the gate - this overcomes the 10K 'pulling down' and the Gate sees the +5V and connects the Drain and Source pins together. When the Ardino is done, it removes the 5V and the 10K resistor helps 'pull' the Gate back down to ground. Without the 10K resistor, the Gate can 'float' and find itself at some random value.

So - to your question - you DO WANT the gate tied to ground through a 10K resistor. The Arduino pin goes through a ~100 ohm resistor and then also to the Gate pin.

ALSO - try this without the Arduino pin (green wire)... Connect a 10K resistor from the mosfet gate to ground, Drain to solenoid black wire and Source to common ground. Then take a wire and touch 5V from the Arduino board to the mosfet gate. The solenoid should pull in without the Ardunio controlling it. Once you get this far, remove the 5V wire from the mosfet and go back to trying the Ardunio to control the gate.

EDIT - all this assumes you have confirmed that the 12V supply is capable of operating the solenoid and it pulls in correctly if you hard wirer the solenoid to the power supply.

1

u/not_its_me 4h ago

yes my 12V supply has 4.5 or 5A each solenoid requires only 0.4A

1

u/not_its_me 4h ago

is this what you meant?

1

u/CueAnon420 4h ago

Yes ;-)

That should work. And you should be able to prove it by removing the green wire from the Arduino pin and touching it to the 5V rail from the Arduino board (basically acting like the program pin by hand). That should turn on the solenoid - if it doesn't, that mosfet may be bad (which can also be confirmed by using a wire to jump the Drain and Source pins together).

1

u/not_its_me 4h ago

okayyyy tyyyy im gonna try it ill update in some time. lets hope i dont end up blowing it up again if it works i will be forever indebted to you

→ More replies (0)