# Using capacitor to power a solenoid

I am working on a smart rat trap project with my students. We followed some instructions from make magazine. We have not received any response from those makers so I thought I’d ask here…

The cage is supposed to be released by 2 solenoids creating a reverse polarity magnetic field. They are powered by a 4700microfarad capacitor and triggered by a relay. We measured a 3.5 V discharge across the solenoids over about 20 ms. But the cage won’t drop. If we apply a constant 1.4 V with a power supply, the cage drops.

We have tried various capacitor banks in series, parallel, and up to 10000 microfarads.

Any ideas of what to try next? We hypothesize that the discharge time of 20 ms is too short.

Are the solenoids counteracting a permanent magnet? So a pulse is needed that is long enough for the cage to fall far enough that the magnet cannot immediately pull it back.

In 20ms a free-falling object in earth's gravity only falls 2mm, so its not surprising. In 100ms it could fall 50mm.

You may also be wasting your stored charge if its creating too high a current in the solenoid, adding some resistance in series would stretch the pulse out. However if the current is insufficient you'll both need to stretch the pulse and increase its magnitude.

Without a diagram of the release mechanism I am guessing though - can you provide one?

When I read the subject, I thought: wow, you need a big capacitor for that. The charge in a 4700uF capacitor is not that big for a strong solenoid.

Can you tell more about the solenoids ? Can you give a link to them ? Do you know all its specifications ?

20ms for a large solenoid is very short. My feeling tells me that 100ms is better, and probably more is needed.

What about the schematic ? How is the capacitor charged ? Why do you need a capacitor ? is the battery too weak ? A weak battery that charges a capacitor requires more power (due to losses) than a strong battery without capacitor.

(While I was writing this, MarkT wrote almost the same)

One of your problems is that the inductance of the solenoid will oppose the build-up of current and hence sufficient time is needed to build up the required field to operate the trap. Extra capacitance and a few extra volts required I think. Over-voltage on a solenoid from a discharging capacitor won't do the solenoid any harm

Are you using the recommended 12volt/1A supply.
Not just a 9volt battery.
These solenoids are supplied straight from the Vin connector.
A drooping supply could reset the Arduino and turn the relay off before the solenoids have done what they are supposed to do.
The 4700uF cap is not used here as a timing capacitor. Relay timing is done with the Arduino.
The cap is just there the help the supply a bit in case of a bad lineair supply, and to take some of the back EMF.
Did you measure the resistance of the solenoids.
The article just mentiones 35’ of magnet wire (no wire size).
Calculate current draw with these resistor values.
You could also try wiring the solenoids in series (watch polarity) if combined resistance is too low.
Leo…

Hi, Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png? So we can see how you are charging and then discharging the capacitor through the solenoid please? Any spec on the solenoid would be helpful.

Tom.... :)

http://makezine.com/projects/make-43/smart-rat-trap/

That makezine project makes my hair curl. In the photos there is never a battery or power supply visible. The self-winded solenoid could result in a solenoid that needs many amps. In the sketch the use of millis() has a rollover problem. The schematic is one of the most confusing I have ever seen. The power supply should be 12V 3A or so, a 9V battery will certainly not work.

MarkT: Without a diagram of the release mechanism I am guessing though - can you provide one?

It is the make magazine mechanism. http://makezine.com/projects/make-43/smart-rat-trap/

Peter_n: When I read the subject, I thought: wow, you need a big capacitor for that. The charge in a 4700uF capacitor is not that big for a strong solenoid.

Can you tell more about the solenoids ? Can you give a link to them ? Do you know all its specifications ?

What about the schematic ? How is the capacitor charged ? Why do you need a capacitor ? is the battery too weak ? A weak battery that charges a capacitor requires more power (due to losses) than a strong battery without capacitor.

(While I was writing this, MarkT wrote almost the same)

We tried 14, 18, 24 and 30 gauge wire solenoids about 35 feet in length since the article did not specify gauge. I was actually wondering about the resistance so the students are set to measure each. I don't have the values yet.

I was also wondering why we needed a capacitor so we have tried a circuit without. We can only get about 1 V across the solenoids using the arduino uno at the moment. We have been using just the 5 V from the arduino for power (I think??) Perhaps we should just use a 12 V supply separate from the arduino through the relay?

I'm a bit of an arduino newbie so forgive my lack of knowledge here... And thank you for your responses.

jackrae: One of your problems is that the inductance of the solenoid will oppose the build-up of current and hence sufficient time is needed to build up the required field to operate the trap. Extra capacitance and a few extra volts required I think. Over-voltage on a solenoid from a discharging capacitor won't do the solenoid any harm

I think you are right. We will try a higher voltage.

Peter_n: That makezine project makes my hair curl. In the photos there is never a battery or power supply visible. The self-winded solenoid could result in a solenoid that needs many amps. In the sketch the use of millis() has a rollover problem. The schematic is one of the most confusing I have ever seen. The power supply should be 12V 3A or so, a 9V battery will certainly not work.

We will try a 12 V 3A suppy.

Wawa:
Are you using the recommended 12volt/1A supply.
Not just a 9volt battery.
These solenoids are supplied straight from the Vin connector.
A drooping supply could reset the Arduino and turn the relay off before the solenoids have done what they are supposed to do.
The 4700uF cap is not used here as a timing capacitor. Relay timing is done with the Arduino.
The cap is just there the help the supply a bit in case of a bad lineair supply, and to take some of the back EMF.
Did you measure the resistance of the solenoids.
The article just mentiones 35’ of magnet wire (no wire size).
Calculate current draw with these resistor values.
You could also try wiring the solenoids in series (watch polarity) if combined resistance is too low.
Leo…

The drooping supply must be what is happening because the voltage is only 3.5 V. We think that the time constant should be more like 200 ms. We have also noticed that we have to reset the IR sensor everytime the relay trips which is more evidence for the arduino re-setting.

Isn’t the back EMF taken care of by the diode?

I know, right, the article mentions 35’ magnetic wire with no gauge. We tried 14, 18, 24, and 30 gauge wire. I don’t have resistance values at the moment. We will calculate the current with this.

We will try your series suggestion. Thanks again! You all have been helpful.

Hi, You may have the magnets the wrong way round' You could be increasing rather than decreasing the magnetic field with the pulse. Are both magnets the same way and are you feeding current in the same direction around the coils? Check you have wound the magnets in the same direction. Have you looked at the testing section of the article and used tape to space the magnets from the solenoids to weaken the attraction field? Or added weight to the cage? You cannot measure the pulse voltage with a DMM it is too short. Using a 12V supply, what is the voltage across the capacitor before you trip the trap??

What I am worried about is that the instananeous recharge current to the capacitor after firing will be huge and the UNO pcb tracks may fail.

DO NOT ADD extra capacitors, you may damage to PCB.

Tom.... :)

I think the solenoid part of the design is bad.
Just had a look at the wire resistance of 35’ of avarage size wire. Just a few ohms at best.

Fixing things with a bigger supply (Amps) can be dangerous for the Arduino. Everything runs over the 1A polarity protection diode and the Vin pin.

I would use a beefy capacitor on the solenoid (not relay) supply circuit, and connect that capacitor to Vin with a normal 220ohm resistor.
And increase the relay “on” time (line 124 of the code) to 500-1000msec or so.
Then the coil current is only drawn from the bulk capacitor.
You can use a smaller 12volt supply (maybe even a 9volt battery).
The Arduino won’t reset anymore.
And you can safely increase cap value untill it all works reliably.
Leo…

Hi, The relay should be a SPDT, in one position its charging the cap. In the other position its disconnecting the cap from the charging supply and connecting to the solenoids. This will prevent the UNO Vin from being loaded by the solenoid.

Tom.... :)

Hi, What is the part number of the relay you are using, driving relays directly from a UNO output is usually not good, due to a 40mA limit on the output current.

Tom.... :)

Using one relay contact to charge the cap, and the other to operate the solenoid is possible. But you still need a charge resistor. You don't want a discharged 4700uF cap suddenly appear at the Vin pin. That could dip the supply and reset the Arduino.

I don't think a high value charge resistor, like the 220ohm I suggested, will be a problem. Cap charging time will be a little longer. If that's a problem during testing, temporary replace it with a 10ohm/10watt resistor.

If you look at the article, you will find that the relay is properly driven by a small transistor. Leo..

TomGeorge: Hi, What is the part number of the relay you are using, driving relays directly from a UNO output is usually not good, due to a 40mA limit on the output current.

Tom.... :)

The relay is a SPDT HRs4

Thanks your help, everyone. We have a working trap. We ended up redesigning the relay circuit and taking out the capacitors all together.