+86 400-003-5559 CN


Overthinking Solenoid Control | Hackaday

tags10uf capacitor

No circuit is so trivial that it is not worth thinking about. [Charles Wilkinson] Think

It will remain open for a long time. This means reducing the holding current to prevent wasting so much power. He stumbled across this article

Absurd depth.

[Charles] made two videos, one is where he debugs the circuit and learns life in the camera, and the other is where he summarizes all the videos. We will guide you through the long process, but you can skip it at any time.

The solenoid valve is initially more difficult to open than to keep it open. Therefore, [Charles] connected his solenoid to a variable power source and tested the activation voltage and release voltage-because nothing can beat empirical data. He slowly increased the voltage (about 6-7 minutes) and then tripped at 3.5 V. When the test solenoid closed again, he reduced the variable power supply to 1.25V. Lower holding voltage.

This is the point of view of Bob Pease in the linked article. The capacitor will initially pass current, but will then charge over time, thereby reducing the voltage drop across the solenoid, thereby reducing the holding voltage. Then, the trick is to choose resistors and capacitors to match the characteristics of the solenoid.

In the video, [Charles] built the circuit in about 30 minutes and found that it didn't work. He did not edit, but troubleshooted in real time. (Brave!) He failed and then went offline. The final question? He also supplies power to the circuit via USB while charging the phone. He just has insufficient power supply. Then, after ten minutes of intermittent debugging, he added a buffer capacitor to the power rail and the problem was eliminated.

To get rid of all this, there are two things. The first is a simple but delicate circuit that can be used to drive solenoids or relays or other circuits with strong initial current requirements. The second is the importance of stable power supply and buffering.

After the first opening, can you only PWM them?

Of course, if you want, you can even press them to increase their opening/closing force.

For example, you have 88 large solenoids that require high power for PWM, and you must ensure that the PWM frequency is within the audible range. Oh, and also, please make sure you have a fast switching flyback diode, the transistor switching time here is very important!

This is a cool technology to learn... Other technologies I have seen are usually more active, using two transistors and two power supplies.

Usually, it is only done in the frequency range of 50 to 200 Hz. No need for ultra-fast diodes or switching transistors. You will be a little buzzing, but this is acceptable.

Expert tips:

This is exactly how to reduce the power consumption of the relay coil. This is also an article in EDN.

You can actually run PRBS in the timer/background and let the output modify the PWM duration (keep the duty cycle constant), jumping between two "random" PWM frequencies will make the squeaky noise similar Low-level noise sounds. Can get rid of interference at a frequency of 10kHz or lower (but avoid the resonant frequency of the relay/electromagnetic coil). "Spread Spectrum Clock" in the audio range;)

The PRBS in a typical microcontroller counter/timer peripheral requires excessive CPU overhead. However, the PRBS solenoid drive can be done quite cheaply in the fudge CPLD. To my surprise, more microcontroller counters/timers these days do not have built-in PRBS register taps and XOR. The additional cost and space required to add functionality seems trivial.

Still not using the valve?

No need to shout! B ^)

(It took me a while to understand what you meant by "normally open", but you just reversed the problem to keep the valve closed, maybe a latch type actuator?)

"[Charles Wilkinson] wants to drive a solenoid valve that will stay open for a long time."

We don't know what the exact "long time" is, nor do we know the duty cycle requirements.

If it is 95% open and 5% close duty cycle, why use NC valve to start and need extra effort to slowly open it with limited input current, unless there are other design constraints (need to power off) to close, etc.) ?

Maybe he needs fail-safe conditions? If there is a power failure, he hopes to close the valve in a fault state.

I agree with the Flash. I designed an electromagnetic lock control circuit for the hospital, which is not feasible, and I must always turn off its power. Its fault protection function is to turn on the power when the power is off to prevent people from being locked in in the event of a fire.

I use PWM to turn off the solenoid at full load, and then hold the throttle back. What I added was the occasional full load pulse, lasting one second to make sure the solenoid was closed.

That is a sneaky method! Although "fixing with software" doesn't feel so good...

It is not "fixed in SW" but "made in SW". The advantage is that the PWM solution eliminates the power consumption in the resistor. If you really need it, you can design a solution with dual hardware timers (NE556 :-) to PWM the solenoid (one timer acts as an oscillation after the initial phase entry (the other timer is a monostable)器).

This is a very good point. thanks for your hints:-)

And, if you feel smarter, you can monitor the current through the solenoid. Since you are performing PWM modulation from a possibly fixed voltage source, this means that you can measure its inductance indirectly.

When the solenoid is inserted, the iron core entering the coil will increase the inductance of the coil, which you can detect. Some clever codes can be used to automatically analyze the solenoid to find and introduce current, and to detect the current position of the iron core.

This function is only valid when you have a spare resistor for current sensing (and ADC's spare IN). In the final analysis, if power consumption is an issue, the solution (as described in other posters) will simply be to obtain a self-locking solenoid. Does anyone know the specific reason for determining whether the solenoid remains engaged? A specific threshold in Joules/sec? In any case, what is the charging/discharging method of the solenoid (for example, can you get "peak efficiency" in a certain range, such as the motor power curve? That is, minimize the integral (t1, t2) I ^ 2 * V component ) Is the constraint "keep locked"?

Since the solenoid is driven by a transistor and an Arduino, I think using PWM to drive the transistor can be implemented with fewer components.


There are simpler relay control techniques:

Perhaps the use of a servo valve is a more ideal choice, although the conversion speed is slower, but the power is only used when changing the state.

If fast switching is not required, electric valves are a good way to reduce power consumption. You only need to connect the RC servo to the quarter turn valve. Technically speaking, if there is no feedback, it will not be a servo mechanism, but a feedback tank can be used to avoid the need for limit switches.

This may be the most correct solution to the problem encountered by the OP, because b/c he needs to turn it off at night and during the day-the cycle is very long.

This is a good idea, but if the power fails, I want the system to fail with the valve closed. Electric valves are a bit difficult.

I think backup batteries and even super capacitors can provide enough power to close the valve in the event of a power failure. But this might make the whole thing a little too much.

You will violate the USB specification if you add too much capacitance.

For those who do not want to download and read the full specification.

>Inrush current will increase the capacitance between VBUS and ground on the device. Therefore, the specification specifies that the maximum decoupling capacitance on the device is 10uF.

Yes, but it can be useful: Cheap hardware will only have a polysilicon fuse and will not trip due to a large number of capacitors. Good hardware will shut down.

I have one of those 10-port 2.4A USB power supplies. Pull the maximum current into direct current, no problem. Insert something 220uF into the input... No, it will close it.

Can the coil suppress the inrush?

You may need a lot of inductors.

Polyfuse works by limiting current, so eventually the capacitor will charge. Good USB host/hub implementations use USB power switches (electronic fuses), but these are rare today. I use these types of hubs to test prototypes.

Power supply overcurrent trip is actually a safety function. Some people use free-riding as a recovery mechanism, so a fee will eventually be charged. The safe start protection type is really bad for some devices, so there are some latches. For example, HDD, because the head may crash when the power is off/off in a short time.

I am not sure I will follow? The circuit is not USB powered-I used to convert an old ATX PSU to a desktop power supply.

Ah, I misunderstood. The HaD article said that I want to turn off the USB power supply while charging the phone with the same USB power supply (this is an easy mistake because I did not fully explain how I power the circuit in the video).

In fact, I was powered by an ATX PSU desktop power supply, to which I added a USB port powered by a 5v rail. This is how I charge my phone and power the circuit. Therefore, the supply should have been able to supply enough juice for both.

I think the problem is that supply cannot respond quickly enough to the sudden nature of current demand changes. Therefore, I must add a smooth cap.

Did not see the video, but if his "arduro" contains a microcontroller :) he can use pwm to save more power. This will make the solenoid coil become part of the smps, and he does not have to waste any power in the 80 ohm resistor. Use a higher pwm duty cycle to activate and lower pwm to keep it open. Using FETs instead of bipolar can also improve efficiency.

Oops, I'm probably the tenth suggestion. The option to delete my comment would be great...

No! We like to see people addicted in despair! B ^)

Think of it as a vote. Currently, although I personally use the electric on/off function, it looks good for PWM.

Yes, PWM seems to be the most popular choice. Not sure I like the "fix in software" method. For some reason, it doesn't feel elegant.

For this reason, there are also many application specific integrated circuits. Perhaps the easiest to find is LM1949. It does increase the number of components, but it can be used with almost any power supply voltage within a reasonable range, and the current can even be adjusted when the power supply voltage changes.

If the solenoid is still driven from the microcontroller, this is not needed. Almost every µC has a PWM timer.

Opening the valve without connecting it in series with the pressurizing circuit will provide you with other values ​​of voltage and current (this is the current that opens and maintains the selenide) and then pressurizes. Especially when the valve is working under vacuum, it may take more power to open the valve (pressure outside and inside the moving parts). Since the measured value is not very high, I will test these two cases before choosing other components.

As mentioned earlier, there are ICs for this purpose. These measures its current and rising or falling; characteristics of the spleen. This is the correct way. Over and over again under variable pressure.

However, his solution is good and can save energy, and most importantly, he learned something. We are just bystanders in the process and can debate this.

good idea! A load (vacuum or pressure) should be applied to the solenoid, or more tests should be performed with a heavy object suspended from an open solenoid.

Good point! Although the mechanical design of a particular solenoid means that the pressure in the system should not affect the power required to switch the solenoid.

It is difficult to explain in a quick comment, but the positive pressure input is pressed on the side of the sliding barrel of the solenoid, not on its plane of motion.

If the barrel is pushed in laterally, it will still increase friction

Yes, but the hole is small and the pressure is small, so I hope it can. At least I know to pay attention to this now.

Thank you:-)

A better solution is to use an electromagnetic latch solenoid, which only requires power to change state. The permanent magnet keeps the valve open/closed after moving. Yes, they are more expensive, but very suitable for low-power applications.

This is a video showing how they work:

If they are like latching relays, they usually don't know what state they are in when they are first energized.

Yes, this is the answer. Magnetic latching relays are used in various lawn watering timers and irrigation systems. In fact, I will use one on my custom lawn watering system.

I am not saying that it is not impressive, but there are other easier solutions.

Do you know where to find a small valve like this?

I want to build a DIY drip irrigation project, each factory or community has a solar sensor and valve to minimize garden water use in arid environments.

But usually, this kind of latching solenoid needs to use reverse voltage power supply to "unlock", so this means H-bridge, so the design is more complicated (4 transistors instead of 1). A simple energy storage capacitor plus a mosfet driven by PWM is sufficient to achieve this simple control.

I used to work in a company that performed PWM and hysteresis to reduce the relay conduction current consumption; the design must be a good way to save energy

If yes (NDA is allowed), can you provide the source code/part number?

I only use a driver chip like MCP1407 for the pinball solenoid, and the PWM stays on. It's very simple.

"The first is a simple but delicate circuit, you can use it to drive solenoids or relays or other things that have a strong initial current demand." I think that in this day and age, the elegant solution is to use bulkier capacitors Better IC:

Unless you build a trash bin... I will use this technique and it works well. I think sometimes we forget that just because there is an IC available does not mean we have to use it... Through this logic, we should use ic to drive every LED we use, because doing so is more than just a simple LED it is good. resistance. What happened? 8-bit and 32-bit microcontrollers can be said to be the same... (duck to avoid being hit by the flying stm32 development board in the entire room)

Yes, I am with you in this regard-it is difficult to know where to draw a line. I must admit that using PWM will be a more effective solution, but in a sense, it is not satisfactory. Without all the passive factors, the performance board might look boring :-)

If you think about it carefully, you can actually implement discrete functions: use 2 transistors, one with the resistor moved to the emitter, and one without. One resistor with emitter resistance maintains the base resistance, and the other with a C base drive, which is much smaller than the original resistance. At startup, the transistor without emitter resistance will be turned on briefly until the base capacitor is charged.

Or you can use 2 pins, 2 drivers.

There are many ways to do it... If you want to skip the large C.

A technique often used in diesel generators is to make the fuel solenoid valve have 2 coils and a switch. The first coil will activate it and turn on the low power holding coil. The problem is that if the solenoid is not fully pulled, the high-power coil is enough to ignite the cable, because the fuel solenoid remains conductive when the current surges and the starter rotates, blowing the fuse. Therefore, even if it cannot be pulled immediately, even if a brand-new fuel solenoid is used, the wiring will often catch fire. Simple design, but easy to catch fire! Since the cable becomes very hot before it catches fire, some kind of overheating trip is required.

I encountered the problem of overheating of the solenoid valve and solved it with PWM. Three years ago, I was building an RO water purifier for my house, and the water inlet solenoid needed to be turned on during the filtering period. In the initial test, I found that the solenoid valve overheated after a few minutes. I used a PIC controller in my design. The solution is to apply full power to make the solenoid work for a few seconds, and then switch to PWM to keep it constant. This is a simple solution because it is implemented in software without any modification to the designed hardware.

If you want to save power, use a self-locking relay. It only needs the power to change the state.

This is a good example of the top-down approach mentioned in the recent HaD article. He studied in depth and proposed a solution, but because he did not have the necessary background knowledge, his solution was not very good. Then, people on the Internet ended the cycle:) The comments of those with background/expertise revealed better solutions. win! great!

In industrial use, I usually see an easier way to do this, except that they pay too much for the current limiter.

The solenoid consumes the most power at startup, so the holding current is much lower. There is a kind of resistance device that first goes high, and then increases resistance over time...

Yes, we are just connecting the incandescent bulb with the solenoid in series. I have a pneumatic robotic arm that uses several welding bulbs connected in parallel to control solenoid current. Cheap, simple, and effective, even without considering the size of capacitors and resistors or PWM codes. Insert the bulb, use the solenoid as an on/off switch, and finish the job.

what! That's really a red neck. no offense:-)

Oh, it must be so. At the same time, this is a cheap independent variable current limiter that can be used almost anywhere.

Usually, the products sold by the company with various names and descriptions are a sealed box in the cable, which contains one or more bulbs, and more than one bulb can be made. The interesting side benefit is that if you haven't purchased the sealed version, they can also visually indicate whether the power is flowing.

This one keeps appearing recently. Interestingly, I don’t remember any discussion about using bulbs as two-terminal devices of resistors, capacitors and inductors, but it seems that their characteristics are very convenient in circuits.

I have conducted some experiments with 24VAC sprinkler valves:

And found that you can use an instantaneous high DC voltage (such as 24V) to power these valves, and then you can reduce to a lower DC voltage (such as 9V) to provide holding current. This is the principle behind the OpenSprinkler DC circuit:

The idea is to use a boost converter to provide an instantaneous high voltage, and then lower the voltage to a lower voltage to provide a holding current. It is suitable for 24V AC valves and DC valves.


Therefore, I am sitting in the current situation and hope someone can help answer me...this will be my best explanation!

I have a 12VDC power supply for connecting 2 12VDC latching solenoids (connected to the water valve)...

Positive polarity opens the valve and negative polarity closes the valve. Great

This is the problem

I now want to open one valve and close another valve on the same circuit. So switch at the same time...

It is a water pipe divided into two pipes. Due to the drop in water pressure, the two pipes cannot be opened at the same time. Therefore, one pipe needs to be closed while the other pipe is opened...so there must be a constant flow of water.

One solenoid valve is positive wiring, and the other solenoid valve is reverse wiring.

When I provide a 1 second power pulse, one solenoid will close, but the other solenoid will not open (assuming that the opened solenoid only turns on when I provide a 1 second power pulse, please remember These are self-locking solenoids)

If I power each solenoid separately, will it work 100%?

Just short it? How can I work?

Should I connect diodes in series?

Hope this makes sense and someone can help me!

The back EMF from one may lock the other.

Please be kind and respectful to help make the comment section great. (


The site uses Akismet to reduce spam.


By using our website and services, you expressly agree to our placement of performance, functionality and advertising cookies.