How to control 24v signals with an Arduino Uno

Hello everyone,

I am a first year mechanical engeneering student at the Technical University Delft.
This will be the first time that i am working with an Arduino board.
For a project we would like to control 12 solenoid valves (to control 12 pneumatic cylinders) with an Arduino Uno.
These valves have a working voltage of 24v (DC), so we need to convert the 5v signals of the arduino to the required 24v signals.

I have already searched for some possible solutions and one of them is to use an optocoupler.
Can anyone here tell me how to use these or how to wire them properly.
What is important that we need to have 12 outputs.

Also we would like to use a wireless (playstation)controller. This should be a fairly simple process according to some tutorials I have found. Thats why I would like to know if it is possible to combine these 2 systems.

Thanks in advance! :slight_smile:

The Arduino UNO has 20 I/O pins (0-13 and A0-A5) so it shouldn't be a problem picking 12 for outputs. You should not use Pin 0 or Pin 1 since those are the Serial pins. Depending on how the PlayStation controller connects you may have other dedicated pins that you can't use for I/O so get that working first.

The easiest way to control a 24V solenoid is with an NPN transistor or N-Channel logic-level MOSFET. Google for Arduino Transistor to get the details.

Follow the tutorials for connecting your wireless PlayStation controller to the Arduino.

If these valves do not need to be cycled quickly then you may also consider using relay modules.

Thanks for the replys!
Sorry for my late answer, i have been very busy last week.
I have looked into the N-Channel MOSFETS and I think this could be a good solution.
I made a little test circuit with some simulation software, could you tell me if this would work?
The LED's represent the valves and the 18v powersupply should be 24v ofcourse, but they were not so easy to find in the program.
For the playstation controller I would like to use the PSX library, so I might have to use different pins for the valves.
The transistors are added to make sure that the MOSFETS won't get any signal when they should be off.
I was also wondering if there should be any protection against the higher voltage for the Arduino board.

Looks like the +24V supply isn't connected to anything, which is fine as long as the load connects between +24V and the Drain of the MOSFET. You don't specify what MOSFET you are going to use. They are not all the same.

I don't see any current-liniting resistors for the LEDs.

I don't see any current limiting resistors between the Arduino pin and the Gate of the MOSFET. My limited understanding is that the MOSFET Gate acts as a capacitor and draws a lot of current when you switch from OFF to ON.

I don't think the pull-down resistors are wired correctly. I would expect them to be connected between the Gate and Ground. This should keep the MOSFET off until a solid HIGH is output on the pin.

Perhaps you should just show one circuit (since they are all the same) so you can spread the parts out a little more to make is more clear how things are connected. Or you could generate a schematic and mistakes in wiring will be more obvious.

I still have to figure out what kind of MOSFET I am going to use.
I am a complete noob when it comes to building circuits like this so what i made was based of things I found/read on the internet.
Here is only one circuit, which I revised a bit.
You were right about the powersupply being connected to nothing.
The LED's in this circuit aren't actual LED's, but the valves which work at 24V, so they don't need current limiting resistors.
I also added a diode (1N4001) between the + and - of the valve to protect the MOSFET for voltage spikes from the solenoid

That looks pretty good to me and will probably work.

In theory you should put a current limiting resistor between the Arduino pin and MOSFET Gate like I mentioned above.

Be sure to use a Logic Level (5V Gate) MOSFET. Common MOSFETS expect 10V at the Gate to switch fully on. Look at the datasheet and if the On Resistance (Ron) is specified only at Vg=10V then you don't have a Logic Level MOSFET.

siroy the first diagram is correct the last one is faulty.
use a ULN2003 cheap and easy solution.
on each output a coil and that should do the trick.

Alright, so now i am confused...
I would like to just use the solution with the MOSFETS because I finally get to understand it a bit.
The MOSFET I would like to use is an IRFZ44Z, I saw this being used numerous times and I think it will suit my project, I only have to check the input (gate) voltage.

John, by the current limiting resistor, do you mean i have to basically replace the wire with a resistor? And what kind of capacity should it have then?

Thanks for answering, you are really helping out here. :slight_smile:

That MOSFET appears not to be a logic-level MOSFET.

Parameter: RDS(on) Static Drain-to-Source On-Resistance
Min: ---
Typical: 11.1 m?
Max: 13.9 m?
Conditions: VGS = 10V, ID = 31A

See that RDS(on) is only specified at 10V VGS. You want one with a low RDS(on) at 5V VGS.

Perhaps the IRLB8743PbF is available:

RDS(on)
Static Drain-to-Source On-Resistance
Min: –––
Typical: 2.5 m?
Max: 3.2 m?
Conditions: VGS =10V, ID =40A
Min: –––
Typical: 3.5
Max: 4.2
Conditions: VGS = 4.5V, ID = 32A

See how they show RDS(on) at 4.5V VGS? That is how you know the MOSFET is intended for logic-level switching.

How much difference do MOSFETs make when driving low current leds?
Why not just use shift registers and save a lot of pins and wire?

For LED's the MOSFETs aren't really necessary, but we would like to switch some 24v solenoid valves.
I couldn't find those in the program I was using, so I put some LEDs in it (to simulate the valves)...

Those MOSFETs should work indeed, it is really hard to make a choice, because there are so many of them.
The ones you chose are also available at my supplier so I geuss I am going with those.

To clear things up I made another Diagram.
What kind of resistors should I use, the ones I used in the diagram are 10 kilo Ohms would this be sufficient?
Also, I put a resistor (220 Ohm) between the pinof the Arduino and the gate of the MOSFET, is this correct?

Thanks again for helping!

1 Like

The 220 Ohm resistor for the Gate will limit the current to about 23 mA which is plenty safe for the Arduino.

Alright, then I will try to build the circuit and test it.
Thanks for al the help!
If everything works right I will post it here and if there are more questions I will probably do the same :stuck_out_tongue:

Here's a better idea. Buy yourself one of these:

I have no affiliation with SainSmart. But I control pneumatics with Arduinos for the haunted rides and attractions industry all the time with these babies as a side-business. ( See http://www.hauntsoft.com ) These relay modules have all the protection circuitry built-in and will handle 24V solenoids no problem, and they have LED indicators on each relay. They can also handle 110V AC no problem, which makes them perfect for adding fog machines and AC lights to the mix.