How does an electronic safe use a 9v battery to power a solenoid? - Page 1
Forum section: electronics / beginners

author: flyingblindonarocketcycle
author_rank: Newbie
timestamp: December 13, 2019, 09:53:06 pm
content: I have a gun safe with an electronic lock. I guess its a piece of junk as the electronics failed with in days of getting it. I thought it would be a good beginner micro controller project to replace the electronics. I have an adafruit ItsyBitsy 32u4 chip and I wired up the 4x3 keypad. The short version of this story is success...almost. The safe locking solenoid does not need to capable of much force at all but how do I control it with a 9v battery and not drain the battery very rapidly?The solenoid at rest has a very weak spring that keeps the pin out and blocks a mechanism keeping the safe locked. When the solenoid is activated it pulls the pin out of the way and the safe handle is allowed to be turned and open the door.The MCU circuit to control the solenoid was taken fromhttps://www.bc-robotics.com/tutorials/controlling-a-solenoid-valve-with-arduino/The code puts the ship to sleep. Wakes on a button press. Stays awake if a button is pressed within a short period. watches for the combination to entered. triggers the solenoid for a short period when the combination is entered. It appears that the solenoid is drawing over 400ma when activated.How can a 9V survive long like that? How is it that a 9V operated electronic safe is common place when they use a solenoid?ThanksFBOARC

author: Rerouter
author_rank: Super Contributor
timestamp: December 13, 2019, 10:03:37 pm
content: 400mA x 2 seconds = 0.22mAhThey would be using some capacitance to get around the batteries ESR, but the total amount of energy used is rather small per actuation.

author: flyingblindonarocketcycle
author_rank: Newbie
timestamp: December 13, 2019, 10:55:26 pm
content: Are you saying that activating a solenoid with a 9V batter powered circuit is not insane? I have been searching the internet and even on the adafruit forum I have been told that you can't use a solenoid with a battery. Obviously someone figured it out as safes do exactly that. But are you saying its no big deal? This is very encouraging!Do you mind expounding on what you mean by the batteries ESR?I should also mention that I did build this circuit and try it and sadly it only worked for a couple days. I have not yet pulled the micro out to see if it is damaged.

author: rstofer
author_rank: Super Contributor
timestamp: December 13, 2019, 11:09:34 pm
content: ESR => Equivalent Series Resistance. This internal resistance limits how much current the battery can deliver and, more important, how the output voltage is related to the output current (Ohm's Law works here). An ideal battery has 0 Ohms of ESR, a real battery will have some.So, by putting a capacitor in parallel with the battery, it will charge to the same voltage but when it comes time to activate the solenoid, the capacitor probably provides most of the energy because it will have lower ESR. It's not free energy, the capacitor has to recharge from the battery.For a gun safe used a couple of times per day, a pair of 9V batteries will last more than a year. Based on Sargent & Greenleaf A Series lock.https://www.sargentandgreenleaf.com/products/electronic-locks/aseries/

author: Rerouter
author_rank: Super Contributor
timestamp: December 13, 2019, 11:24:48 pm
content: It is not wise to operate a solenoid for a long period of time off a battery, small pulses are OK if you mitigate the other issuesBatteries have an internal resistance, for short duration pulse loads you can treat them like a power supply with a resistor between the supply and your load, this means drawing a large amount of current will make the voltage on your load decrease, and generate some heat in the ESR / resistor,The value of this ESR tends to get worse as the battery depletes, and changes with temperature,This is making some assumptions, but lets say your solenoid resistance is about 22 ohm (9V / 0.4A), a 9V battery is normally 1.5-5 ohm ESR for the first 50% of its capacityFor your solenoid, you could on a proper supply work out what its "Actuation Voltage" is, e.g. what voltage is the minimum to make it unlock, this tells you how low the voltage can droop before it stops workingAs for why your circuit stopped working, that is harder to say, its possible the nductive spikes carried into the rest of the circuit, (This is why circuits have decoupling capacitors and reverse polarity diodes across inductive loads)

author: james_s
author_rank: Super Contributor
timestamp: December 14, 2019, 04:39:56 am
content: Quote from: flyingblindonarocketcycle on December 13, 2019, 10:55:26 pm"A solenoid" describes a very, very broad range of things. Technically the motor in the typical quartz analog clocks that will run for years on a single AA battery is a solenoid. Solenoids can be tiny and consume a tiny amount of current or they can be huge and draw kilowatts. It's all a matter of current draw and duty cycle. You mentioned the solenoid draws 400mA, that's a very large load if you wanted to run it continuously from such a small battery but for 2 second pulses every now and then the amount of power consumed is very small. The data I found suggests a typical 9V alkaline battery is 500mAh, so that's more than 2200 2 second pulses consuming 0.22mAh each. That's completely ignoring the idle and active consumption of the microcontroller, loss due to the ESR of the battery and other factors but the point is it's perfectly acceptable to do what they're doing.

author: not1xor1
author_rank: Frequent Contributor
timestamp: December 14, 2019, 05:32:13 am
content: I think James is right.There are plenty of garden watering timers using a 9V battery to open/close a valve by short pulses to a solenoid.I have a couple of them exposed to all the weather stresses and after about 6-7 months of switching on/off a couple of times a day the batteries still have some charge. A few times I've even used rechargeable 9V NiMH batteries.

author: Brumby
author_rank: Unknown
timestamp: December 14, 2019, 07:01:31 am
content: As mentioned above -* A capacitor can store energy from the battery which is then available for the high current required to pull the solenoid in.* By this process, a number of short activations is quite possible on a 9V battery, so long as you manage this power usage properly.* A reverse protection diode across the solenoid is essential to safeguard any circuitry driving it. Without one, the back EMF from the coil when power is removed can run into hundreds of volts, which is a major risk to the driving circuitry. For example:Also - not mentioned is the fact that the initial current drawn to get the solenoid armature to move is much more than is required to hold it into position once it has moved to the "unlock" position. This provides you with the opportunity to experiment to find out:1. What current is required to move the armature to the unlock position and how long that current needs to be supplied in order to reliably achieve that - and -2. What current is required to hold it in that position.Finding these figures will help you derive much more efficient power management - giving longer battery life.(Solenoids operate on the magnetic field created, which is a function of the current flowing - but since they have a DC resistance, Ohm's law will apply during steady state, which will be a few milliseconds after power is applied or removed.)

author: flyingblindonarocketcycle
author_rank: Newbie
timestamp: December 14, 2019, 03:14:20 pm
content: Thanks a lot! This is all very good information.

author: Kleinstein
author_rank: Super Contributor
timestamp: December 14, 2019, 04:16:30 pm
content: Like with normal relays the current to hold the plunger in open state can be quite a bit lower. So it only take the full current for a short time (e.g. 0.5 s) and can than reduce the current to something like 1/2 or 1/3 the value.Reducing the current can be done quite effective with PWM modulation in the 10 kHz range if the diode is sufficiently fast. This way 1/3 the current only needs something like 1/6 the current.

author: IDEngineer
author_rank: Super Contributor
timestamp: December 15, 2019, 12:23:48 am
content: I've also seen battery powered applications like this use a motor or other rotary element to move the physical piece. Movement is slower but still well within human satisfaction. The benefits include lower current to actuate and potentially zero current when not changing.

author: james_s
author_rank: Super Contributor
timestamp: December 15, 2019, 01:24:11 am
content: Yes that works too, although I suspect a motor would not consume less power in this case, by design it's only going to give you a few seconds to open the thing after entering a valid combination. A motor would just have to crank it one way, stop, then crank it the other way a few seconds later. I doubt that would consume less power than holding in a small solenoid for the same period. It's also likely to be more mechanically complex and failure prone.

author: IDEngineer
author_rank: Super Contributor
timestamp: December 15, 2019, 01:39:45 am
content: I was thinking of rotating the motor ~180 degrees, to swing an arm that selectively locks the mechanism. That would take very little power and only during transitions.

author: Brumby
author_rank: Unknown
timestamp: December 15, 2019, 02:48:49 am
content: That would depend on the motor, the arm and the lock structure. A single 180º movement would require a certain amount of current, whereas a much less powerful motor running through a reduction gear set could achieve the objective with a significantly lower peak current requirement. Yes, it would need to run for longer, but it's the total energy use that is important here.I think I'd prefer to stick to the solenoid - especially since that mechanical structure is already in place and functional.

author: IDEngineer
author_rank: Super Contributor
timestamp: December 15, 2019, 03:16:05 am
content: I was just brainstorming... since you're retrofitting I agree, stick with what you've got.Another option for the motor approach would be a small stepper. Could be very low power, has some position retention with zero power.Lots of options, especially with a blank slate.

author: austfox
author_rank: Regular Contributor
timestamp: December 15, 2019, 05:21:42 am
content: I’ve used quite a number of these safes (shop safes, smaller ATMs etc) and the 9V battery easily lasts a year or two. Therefore I assume they work via a combination of electrical (solenoid latching a pin out of the way to allow the handle to turn and move the locking bolt to the unlock position), and mechanical (once the handle is turned back to normal position it mechanically disengages the latch of the pin and the lock bolt returns to the locked position).If you briefly apply power to the solenoid does it allow you to open the safe after the power has been removed?

author: flyingblindonarocketcycle
author_rank: Newbie
timestamp: December 30, 2019, 12:36:43 pm
content: Thanks for all the knowledge. My safe is now operational with its new brain and a 9V bat. The mechanics work exactly as austfox described.CheersFBOARC

author: eugenenine
author_rank: Frequent Contributor
timestamp: December 30, 2019, 02:22:44 pm
content: Something that tutorial misses is solenoids have a pull in current and a hold in current. If your going to hold the solenoid energized for more than a half of a second you can reduce the power to it to save more battery life.

author: james_s
author_rank: Super Contributor
timestamp: December 30, 2019, 05:46:00 pm
content: Quote from: flyingblindonarocketcycle on December 30, 2019, 12:36:43 pmNice job. I always like getting a followup on threads like this so we know what happened.

author: tebbybabes
author_rank: Contributor
timestamp: December 31, 2019, 12:55:10 am
content: Really interesting read! Thanks!