Solenoid

A push-pull solenoid: a coil around a steel plunger that pulls in when current flows and springs back out when it stops.

Aliases: push-pull solenoid, JF-0530B, solenoid actuator, tapper. It is the simplest actuator there is, and the part that teaches the flyback diode, because it is nothing but an inductor with a moving core.

Pins

Pin What it does
1, 2 The two ends of the coil. It has no polarity.

Wiring it to an Arduino

The coil draws far more than a pin can give (300 mA for the default 12 V, 40 ohm coil), so a pin drives a logic-level MOSFET such as the IRLZ44N, or a TIP120, and the transistor switches the coil:

  • one coil lead to the supply, the other to the MOSFET's drain;
  • the source to ground, shared with the board;
  • a diode such as the 1N4007 across the coil, cathode to the supply.

Then digitalWrite(pin, HIGH) pulls the plunger in and LOW lets it go.

The kick, and the diode

A coil's current cannot stop at once. When the transistor turns off, the coil keeps pushing its current and the voltage at the switched end climbs until something conducts. With no diode that is the transistor itself, at hundreds of volts, which kills it. With the diode, the current goes around the diode and the coil, the drain sits one drop above the supply, and the current dies away over a few milliseconds. Put a meter on the drain and remove the diode to see it.

Properties

Property What it sets
voltage The rated coil voltage, 12 V by default.
resistance The winding's resistance in ohms, 40 by default.
inductance The coil's inductance in millihenries, 30 by default.
pull, release The currents, as fractions of the rated current, at which the plunger starts in (0.75) and starts back out (0.15).
pull_ms, release_ms How long the plunger takes to travel each way.

What the model gets right

The coil is an inductance in series with its winding resistance, solved in the circuit's matrix, so the current builds with the L/R time constant and the kick on switch-off comes out of the same equations. The plunger follows the "must operate" and release figures small solenoid datasheets give, with a travel time each way. A diode across the coil slows the release, as it does on the bench.

What it does not model

The inductance rising as the plunger closes the gap (the dip in the current that tells a driver the plunger moved), the force over the stroke, heat in an overdriven coil, and whatever the plunger hits.

See it in action

Solenoid tap taps it once a second from an Uno. Open it at /templates.