I am attempting to modify the suggested solenoid interface, and I'm a complete electrical idiot, so I wanted to put this out there and see if people think this will work or if there's a better way to do it.
Essentially, I want to take the standard Arduino - transistor - solenoid circuit and add a manual switch plus a means for the Arduino to detect when the manual switch has been activated.
I'm thinking I can just add a switch S1 in parallel to the transistor to enable manual activation. So far, so good?
Then I want to detect when S1 has been closed. V+ for the solenoid is 12V, and the Arduino analog inputs handle up to 5V, so I think I need a voltage divider between the positive terminal of S1 and GND. Still on target?
If so, I figure that I need a "top" resistor R2 (connected to the positive terminal of S1) and a "bottom" resistor R3 (connected to GND), and a wire connecting the middle of the divider to an analog input on the Arduino. If my algebra is correct, these values come out to:
R2 = 7/5 * R3
I assume it would be a bad thing to use low resistances because I'm putting this between 12V and GND, so I pulled these values out of my butt:
R2 = 14K Ohm
R3 = 10K Ohm
Then I should be able to sample the analog input pin and get 0 when S1 is open, and close to max when S1 is closed.
So, does this make any sense at all?
Will it work?
Is there a better or easier way to do this?
Thanks for any help!!
-s
PS: I'll try to post links to circuit diagrams in a follow-up. YaBB won't let me post them here..
The voltage across the divider will be higher than 12V when the solenoid is shut off due to back EMF. It will rise until the diode conducts so if it were my circuit, I'd go with a lower ratio than your 5/12.
If you made R2=33k and R3=10k then you'll be reading 10/43 of the collector voltage, or just under 3 volts when it's off.
When the switch is open and the transistor is off you'll see a high voltage and when either of them is conducting you'll see zero (for the switch) or a very low voltage (for the transistor.) So if you tested for the pin voltage to be >= 2V for "OFF" and < 2V for "ON" you'd get what you want.
I like Richard's idea for elegance and efficiency, but I'm going to try my original design with Mike's suggested corrections.
The reason is that the switch and the solenoid already exist, and I'm just adding on the Arduino. I want it to be removable and fail-safe so that the switch will always continue to work even if the transistor or Arduino fails, and I believe the parallel design accomplishes that.
This forum is a great resource and a service to the community. Keep up the good work!
Just be aware that reading a 0vdc on the Arduino analog input pin CAN mean TWO different things. 1. The switch is turned on, activating the solenoid or 2. The 12vdc power is off and the solenoid is not really activated.
no idea, need suggestions: Q1: needs to pass 3A at 12V without frying, prob needs a heatsink, needs to be logic level..? D1: needs to pass 3A at back EMF voltage (hundreds of volts..?)
The back EMF on L1 is very high. When I manually connect it to VCC1, it activates with a solid clunk. When I disconnect, it arcs visibly and emits a strong ozone smell.
Is the recommended 1N4004 capable of handling these specs, or do I need something else?
What MOSFET would folks use here? How about something like IRFU3711Z?