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

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.

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.

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.

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.

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

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.

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?

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.

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.