Go Down

Topic: Switching 18V (Read 2176 times) previous topic - next topic



Sorry for the total noob question.

I have an electric door release I want to change from its current mechanical switch to something controlled by an Arduino. The switch has 18V8 DC and 0.27A running through it.

How should I control this via the IO port on the Arduino? I'm guessing a relay switch is overkill? Should I be looking at some kind of transistor? pointing me in the right direction would be appreciated :)



You need to drive the relay with a transistor.  You can find the driver circuit herehttp://arduino.cc/playground/uploads/Main/relays.pdf


If it is acceptable to common the grounds of the Arduino and the door release power supply, then you don't need a relay, you can use a BJT such as BC327 to switch the current to the door release directly. See http://www.arduino.cc/playground/uploads/Learning/solenoid_driver.pdf.

If you can't common the grounds, then I would still switch the door lock with a BJT instead of a relay, but I would use an opto isolator to drive the BJT.
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.


Before you try any of the suggestions here except a relay you should post a drawing of what you are controlling exactly as it is. Suggestions for a transistor are based on assumptions that might prove to be unworkable. A single relay board can be purchased in many places on the Internet that cater to Arduino. I bought a nice one from Terry Kings store Sunshine for a few dollars.

--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard


The door release is likely to be a very inductive load (electromagnet) - you want to rate the relay contacts significatly higher than 0.27A and/or consider adding a free-wheel diode across the door-release coil to prevent inductive spikes.

Photos of the set-up might provide useful information (how is it powered with 18V for instance?)

If you want to power the Arduino from this same supply that's another thing to consider.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


Hi Thanks for the suggestions.

I'm not totally sure on the existing circuit as it includes various wires going all over the place. I believe though that the switch I want to replace could be directly connected to the door magnetic lock, so I'm guessing with my very little knowledge that it could kick back a spike of voltage when switching on/off which I would need to protect against.

I'm thinking a relay would probably be a good option for safety (for my micro controller) with transistor and diode as per the above link to protect then against the relays spike. Should that then make the circuit safe?

Is this the kind of relay that I need: http://uk.farnell.com/omron-electronic-components/g5la-1-5dc/relay-pcb-spdt-5vdc/dp/1455502

I would like to simulate this so I can see it "working" and make a diagram. I have been using http://www.falstad.com/circuit/ for simulations. I'm having trouble though understanding what all of the parameters are that I need to enter to simulate it. Its asking me for:

Inductance (H):
On resistance (ohms):
Off resistance (ohms):
On Current (A): 72mA?
Number of Poles: 1
Coil Resistance (ohms): 69.4?

Could someone please tell me what the missing values are and if I put the correct values down for ones I believe are correct (data sheet: http://www.farnell.com/datasheets/96357.pdf)

Thanks. I have so much to learn!


The relay will work however you can buy pre-made relay boards for the arduino in many places for about the same money as the individual relay would cost.
You will need a PCB of some kind whether it's Veroboard or a proto shield or what ever and an NPN transistor 2N3904 - 2N2222  a 1K resistor and a 1N4001 diode  as a minimum parts count you should add an optional but useful 100 nF capacitor from 5V source to ground.
Unless you have a supply of commonly used parts these will be needed to construct a relay interface board. I wouldn't worry about simulating the relay as it is really sort of optional now.
Until you have a larger understanding of electronics most of what the simulation will return to you will be pretty arcane any way.
  A description follows:
Mount the relay on your selected board connect a 100 nF capacitor from your selected ground trace on the PCB to the PCB trace you have selected to be your 5V source trace.
Connect a diode across the relay coil and connect the cathode end (the end with the stripe) to the 5V trace. mount or solder the NPN transistor to the board and connect the collector lead to the remaining relay coil terminal and the anode end of the diode (the end W/O the stripe).
You can connect an optional LED across the coil, connect a 220R resistor in series with the LED and connect the cathode to the collector of the transistor and the anode to the resistor to the 5V source. The LED will light when the relay is activated
Ground the emitter of the transistor.
Connect one end of the 1K resistor to the base lead of the transistor and connect the other end of the 1K resistor to the trace you will be connecting to the Arduino control pin (relay control pin). Recheck ALL Parts for correct connections, for good soldering and insure that there are no accidental short circuits to other parts or unused traces on the Protoboard. If you are happy with your work and inspection then test it.
When the control pin is high the relay will pull in when the control pin is low the relay will drop out... Simple.
Remember to connect the contacts of the relay to places where you can connect to the circuit being controlled and DO NOT connect any of the relay contacts to ANYTHING that connects to the Arduino.
Test your relay board as follows: Connect the ground lead to the ground of a 5V source, connect the 5V source to the 5V source lead on the relay board and note that the relay doesn't operate. Connect the 'open' end of the 1K resistor to the 5V source used for testing and note that the relay operates and If you have added the LED that the LED lights.
If the relay board passes the tests you can connect the relay to the Arduino. Ground to the Arduino ground, 5V to the Arduino ground and control to the pin you've designated as the control pin
The reason why the simulation is less than useful is because it is designed for an unknown relay and the relay you've selected was designed to be controlled in this manner to simulation isn't needed as the relay coil's properties are well known and well in the range of the transistors specifications.
Simulations are great tools for predicting circuit behavior or just for education and the information you require for the simulation can be found on a comprehensive data sheet for the part.
Simulating this circuit however is not really very interesting. Your simulation tool has a fault in it common to many relay simulations and that is that the relay's inductance will change when the relay is activated as the armature is now pulled to the coil and this changes the coil inductance.. so the real data will not match the data returned by the simulation.
Unless the device controlling the relay has some current dependence use the pulled in value for the coil inductance as it is worst case (Highest).
Basically choose a transistor with at least twice the required collector current requirements of the relay coil and at least 10 times the source voltage (Vceo).
The 2N3904 (data sheet attached) will fill the specifications nicely and is frequently used as a transistor to control relays of the type you've chosen.
The 2N2222 is also a good choice and frequently used to do the same task. Have Fun...

--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard


Thanks Doc for the very informative reply :)

I'm going to try to take it all in and get this working.

I see very cheap relay boards on ebay but I would kind of like to build the circuit my self for a couple of reasons

1) to learn and understand it more.
2) to be neater. I would ideally like to keep everything to one or as few PCBs as possible.

I really appreciate all your help


Tim, If there is ANYTHING I can help you with just ask. If possible I would prefer to keep all in the forum because it just might be educational for someone else...
((that's where I get a lot of Arduino specific and C++ questions answered))
If not PM me... I'll be happy to help.

--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Go Up