Werking Solenoid Slot

An Introduction to Solenoids

Page last updated 11 Dec 2019, by . 0 replies MOSFET, solenoid


A Small 5VDC Solenoid from Sparkfun

Guardian 'pulling type' solenoid. 115v DC intermittent duty. 0.435' outside diameter piston with 0.184' x 0.617' fork slot with pin. Mounts via side bracket. 1' c-c mounting holes. Mounts via side bracket. 1' c-c mounting holes. A rotary solenoid is a unique type of solenoid which is used for various applications where there is a need for easy automatic control process. It works on the same principle as the other solenoids and has the same elements, a coil and a core, but they have a different operation.

Unlike motors, solenoids directly provide linear (and not rotational) movement. Solenoids are found in many devices such as door locks and valves. If you have a car or have a washing machine, they are using solenoids. Note the spring on the sliding cylindrical bar or armature in the image above. The spring holds the bar out to the left, but when the coil is energized the magnetic force pulls it to the right. Whenever the coil is turned off, the spring pulls the bar out to the left again. André-Marie Amphere invented the solenoid in the late 1820s.

Applications of Solenoids

Solenoids are around everywhere in your home and car. Cars use then in starters, fuel injectors, some electric door locks, and shifting gears in automatic transmissions. Most older electric doorbells use a solenoid to strike the metal chime. In the home, solenoid controlled water valves can be found in washing machines, dishwashers, icemakers, central humidifiers, and automatic sprinkler systems for yards. Pinball machines use solenoids for flippers and bumpers.
Fuel injectors in car engines contain a solenoid
A solenoid water valve from Sparkfun


Solenoids shift gears in a car's automatic transmission


Home Doorbells hit the metal chimes using solenoids
A solenoid door lock from Adafruit
This model train track switch has a twin coil solenoid.
Pinball flipper image from: http://findinglincolnillinois.com/gambling/flippermechanism.jpg

A recent CBS Network news story on the comeback of pinball machines

A Solenoid Hello World

If you want to try using a solenoid with mbed, Sparkfun has a small solenoid that uses 5VDC at 1.1A max. It is somewhat small, most solenoids are larger and need higher voltages and more current. The tricky bits are that it will require a driver circuit (i.e., needs more current than an mbed output pin provides) , an external 5V power supply must be used (i.e., it requires more current than the mbed's power supply provides), and it can only be left on for short periods of time (i.e, it can overheat and burn out).


Sparkfun Power MOSFET driver board

For this example, a small MOSFET driver board was used from Sparkfun. This MOSFET has a maximum rating of 60V 30A, so it can also handle larger solenoids that may need a higher voltage and more current. It also has the internal snubber or suppression diode that should always be used on inductive loads. The board's PCB traces and terminal blocks would likely fail well below 30A. Larger gauge wires may also be needed for higher current solenoids. Breadboard jumper wires are only good for a bit more than one amp, but the MOSFET PCB's terminal blocks allow the use of larger wires on high current devices. For higher voltage or AC solenoids, a relay or solid state relay can be used instead for the driver circuit. Sparkfun also has a 5VDC 2A low cost AC wall adapter power supply that was used for this test. Breadboard jumper wires can be attached to the MOSFET driver board screw terminals and they can also be pushed into the connector on the solenoid, so everything will hookup on a breadboard.

Information

When using multiple DC power supplies, don't forget to connect power supply grounds together, but not the V+ outputs!

Wiring

mbedMOSFET PCBExternal DeviceExternal 5 V supply
gndJP2-2 gndgnd
JP2-1 RAW5V
P8JP2-3 Control
JP1-1Device(neg)
JP1-2Device(pos)


Demo Code

A basic code demo using the mbed DigitalOut API and the MOSFET driver circuit is shown below. Time delays are needed to ensure that the solenoid is turned on long enough to close, but this solenoid also needs waits for the time delay to cool down to avoid overheating. The on and off cool down times will vary quite a bit depending on the application and solenoid used.

Werking Solenoid Slot Cars



The code is simple enough, but it must always be turned off to avoid overheating. It might make sense in many applications to use a timer to automatically turn it off later in a timer interrupt routine, so that a program can do other things while the solenoid is on. Assuming the RTOS is not used, the TimeOut API can be used. With the RTOS, multiple threads could be used to avoid the issue of blocking while the solenoid is on.
Here is an example with a 'Solenoid' class that sets up a timer to automatically turn off the solenoid. The solenoid works exactly the same as the first example, but the program does not need to stop for the solenoid on-time delay and it turns off automatically later with a timer interrupt.

Solenoid


Warning

This solenoid is rated only for intermittent duty. It may overheat and fail, if left on for longer than a few seconds. The data sheet suggests a 25% duty cycle with a max on-time of 1 sec followed by 3 seconds off. Even running the example code (20% duty cycle), it gets a bit hot after several minutes. Only a larger and more expensive continuous duty rated solenoid can be left on, but most are rated for intermittent duty only.


If an external event triggers the solenoid, it might also make sense to ensure in software that it stays off long enough to cool down. For example, consider a system where a user presses a button to activate the solenoid. If the user kept the button pushed down forever or the button fails in a short condition, the solenoid would burn out. A wait or timer could be used to ensure that the solenoid would remain off long enough to avoid overheating. If needed, this feature could also be added to the solenoid class. This can also be handled by a hardware pulse (one shot) circuit. Once a system has a microprocessor, the software solution is likely to be more economical.
Here is the new class setup that enforces a minimum off time delay with a timer and also still turns off automatically using a timer interrupt. Even through the code turns on the solenoid in an infinite loop without any waits as fast as possible, it functions in a identical way to the two earlier examples as far as the solenoid is concerned. It turns on for 0.5 seconds and then off for 2.0 seconds. So it is not possible to overheat it and burn it out.


It is probably advisable to back off the maximum rated duty cycle a bit. It is likely that this value assumes the solenoid is mounted on a piece of metal that provides a heatsink effect and is also probably for room temperature conditions with some airflow. Mine seems a bit too hot even at 20% after several minutes of operation on the breadboard. Some newer devices with solid state drivers (i.e., not relays) even use a PWM output control bit to vary the power of the solenoid's stroke.
One could still envision a possible scenario where the processor crashes while the solenoid is on and it somehow disables the timer interrupt and the solenoid burns out (possible, but with extremely low probability of ever occurring over the life of a device). The watch dog timer and/or the brown out detection interrupts could also be used to make such a burnout event so unlikely that numerous other failure modes including hardware failures become more likely to occur first.

A solenoid RTOS timer setup

If an application is using the RTOS, a thread can be used to time the solenoid on/off cycles. Since the solenoid timing is 10-100ms or more, the RTOS scheduler with a thread::wait() can do the timing delays and other threads can all run during the delays. Keep in mind that RAM size limits the total number of threads possible with the RTOS to just a few (each thread needs it's own stack and some other RAM). Here is a simple example with a class that sets up the solenoid thread and delays. Main sets a flag, turnon, that the solenoid thread checks. This could also be done with a signal, but it is a little messy doing it in a class for more than one solenoid since the thread object name must be used to get the signal to the correct thread. Once again, it operates the same as the earlier examples as far as the solenoid is concerned (i.e., 0.5s on and 2.0s off).


Some larger and higher voltage solenoids can be found in stock at Sparkfun, Adafruit, and Digikey. The MOSFET will handle almost all of them, but you are going to need a higher voltage DC power supply.

Werking Solenoid Slot Car

Other Types of Solenoids

There are a couple of additional types of DC solenoids although they are not as common this basic type with one coil and a spring. The other two types do not use a spring to return to the other position. Although they require a bit more complex driver circuit and two control bits, they offer an advantage in that power is only consumed briefly when changing positions.
A twin coil solenoid has two coils with one wound clockwise and another counter clockwise. A coil must be activated to move it to either end. Often these have three wires with one wire being common on the two coils. This type of solenoid will require two output bits and two driver circuits (one for each coil). It is pulsed briefly on one of the coils to move it one way or the other and when the coil is turned off, it stays in the last position.
Another type of DC solenoid is sometimes called a latching solenoid. It requires the current to be reversed though the coil to move it the other direction. An H-bridge driver is needed for this type of solenoid with two output bits (i.e., forward and reverse) to control it. Sometimes a latching solenoid still has a small return spring and a permanent magnet that holds it at the other end in addition to the single coil.

Interesting Solenoid Videos

A Solenoid Rhythm Section

Eight Solenoids used to power a strange V8 style engine for those that hate normal boring DC motors. Note the relays under the solenoids on the right side and crankshaft contacts on the left.

Another V8, but with state-of-the-art mbed-based electronic ignition. Note the mbed and eight power transistors with LEDs near end of video. It uses a shaft encoder, PWM for solenoid control, and a PID control loop for timing.

Brain control for Solenoid Flippers on a Pinball Machine

A Player Pipe Organ using Solenoid Air Flow Valves

Smart yard sprinkler systems are basically IoT controlled solenoid valves

Many hotel room locks with swipe card keys use a solenoid. A hacker with an Arduino and a cable plug can unlock over 4 million of the older ones. A tragic security design flaw for a lock!

An electronic design error is believed to have overheated an intermittent duty solenoid that blew up one of the world’s first military drones in WWII killing Joseph Kennedy, the older brother of U.S. President John Kennedy. In addition to RF remote control, it also had live video feeds. The drone’s mission was to destroy Hitler’s Supergun bunkers in France that were designed to destroy London.

Please log in to post comments.