Arduino Forum

Using Arduino => General Electronics => Topic started by: MrGarak on Feb 25, 2013, 04:55 pm

Title: Best setup for 12v solenoid
Post by: MrGarak on Feb 25, 2013, 04:55 pm
I am trying to figure the safest way to have the arduino activate a 12v solenoid. I've done a lot of reading up before posting, just had a few questions.

1) Two separate power supplies are needed, a 12v one for the solenoid, and the arduino one. I don't want to use the 12v for the arduino because the vreg will get very hot.

2) I will need to tie the grounds together. I heard this can lead to issues like backfeeding through the mcu pins and possibly damaging it. I tested with my multimeter and the potential across the two - for both supplies was around 48v AC. Apparently this kind of measurement is normal from what I read, it's just a matter of bringing grounds to the same potential.

3) It seems a mosfet is the best way of switching the 12v side. I don't know if this would protect the mcu pins well though. Using a relay instead of a mosfet still gives problems with current usage of the coil along with needing another diode, (The other one being across the solenoid) so it makes sense to go with a mosfet instead.

4) Optoisolating the 5v and 12v sides might be a solution, but is it necessary? Is there a decent optoislation chip anywhere? There was one on sparkfun but it was limited to 50ma, not sure if that would be enough for switching the mosfet? I saw this solution here: http://playground.arduino.cc/Learning/SolenoidTutorial
Title: Re: Best setup for 12v solenoid
Post by: retrolefty on Feb 25, 2013, 05:06 pm
I think using a 'logic level' N-channel power MOSFET as a low side switch is the best solution overall. As long as you have a diode across the solenoid coil terminals you shouldn't risk any damage to the arduino just because you have the 12vdc negative terminal wired to a arduino ground pin.

Lefty

Title: Re: Best setup for 12v solenoid
Post by: MrGarak on Feb 25, 2013, 05:11 pm
Got it, so optoisolation isn't really necessary then. Is it that hard to set it up so a HIGH output on the pin correlates to the solenoid being activated? Seems a lot of setups have it so you need to set output on the pin to LOW to switch the solenoid on.
Title: Re: Best setup for 12v solenoid
Post by: retrolefty on Feb 25, 2013, 05:13 pm

Got it, so optoisolation isn't really necessary then. Is it that hard to set it up so a HIGH output on the pin correlates to the solenoid being activated? Seems a lot of setups have it so you need to set output on the pin to LOW to switch the solenoid on.


If the mosfet is wired as a low side switch, then a HIGH from an arduino output pin wired to the gate of the mosfet will turn on the mosfet and allow 12vdc current to flow through the solenoid, through the mosfet drain/source terminals to ground, thus activating the solenoid.

Lefty
Title: Re: Best setup for 12v solenoid
Post by: MrGarak on Feb 25, 2013, 07:05 pm
I thought so, but wanted to make sure. Thanks
Title: Re: Best setup for 12v solenoid
Post by: dc42 on Feb 25, 2013, 08:11 pm

1) Two separate power supplies are needed, a 12v one for the solenoid, and the arduino one. I don't want to use the 12v for the arduino because the vreg will get very hot.


No, you can use a single power supply. The regulator will not get hot unless you draw a lot of current from the +5V pin of the Arduino - in which case, either use 2 supplies or use a 5V switching regulator to derive 5V from the 12V supply.
Title: Re: Best setup for 12v solenoid
Post by: MrGarak on Feb 25, 2013, 08:46 pm
Hmm, my previous experiences with running 12v to the barrel connection was the vreg got really hot, even when only powering a couple LEDs limited to ~5ma each. I will attempt it again though to see if I have better luck this time. If not, I'll use two supplies. I don't have a 5v switching regulator around, that would be the ideal solution to bypass the vreg entirely, though I'm not sure if that would introduce em noise problems.
Title: Re: Best setup for 12v solenoid
Post by: dc42 on Feb 26, 2013, 01:04 am
If it was a 12V unregulated power supply, then it may have been supplying much more than 12V when lightly loaded, and that would increase the power dissipation in the regulator.
Title: Re: Best setup for 12v solenoid
Post by: MrGarak on Feb 26, 2013, 04:12 am
Yea, I will have to test it again once I get the fet and solenoid. If it gets too hot I'll just use two supplies, or maybe find a way to heatsink the vreg.
Title: Re: Best setup for 12v solenoid
Post by: dc42 on Feb 26, 2013, 09:44 am

Yea, I will have to test it again once I get the fet and solenoid. If it gets too hot I'll just use two supplies, or maybe find a way to heatsink the vreg.


or you could use an external 7805 regulator with a small heatsink.
Title: Re: Best setup for 12v solenoid
Post by: MrGarak on Mar 04, 2013, 05:00 am
My tests so far with a 12v supply have led to no problems with the vreg even getting warm. It must have been the LCD screen's current draw causing the heatup on a previous project where I attempted to use a 12V supply.

Anyway, I noticed when the power supply is disconnected and the board is only powered through usb, there is still ~50mv backfed through the barrel jack. I'm afraid if the pin switches the fet in this state, the solenoid will attempt to draw a lot of current from the 5v usb supply back through the barrel jack, which might burn something out in the board. Do I need to take this into account, or is there some kind of limiting in the arduino board which will prevent this?
Title: Re: Best setup for 12v solenoid
Post by: dc42 on Mar 04, 2013, 09:27 am

My tests so far with a 12v supply have led to no problems with the vreg even getting warm. It must have been the LCD screen's current draw causing the heatup on a previous project where I attempted to use a 12V supply.


Some LCD backlights need as much as 100mA, and drawing that amount of current from the 5V pin would certainly make the regulator hot.


Anyway, I noticed when the power supply is disconnected and the board is only powered through usb, there is still ~50mv backfed through the barrel jack. I'm afraid if the pin switches the fet in this state, the solenoid will attempt to draw a lot of current from the 5v usb supply back through the barrel jack, which might burn something out in the board. Do I need to take this into account, or is there some kind of limiting in the arduino board which will prevent this?


Don'r worry about it. There is a diode in series with the barrel jack, and your high-resistance meter is registering the leakage current through the diode, which is probably well under a microamp.