Relay help

Hey everyone I have a project that requires a relay. What I am trying to accomplish is if I punch in the right keycode the arduino will send a pulse to the relay. The problem is the relay will be hooked up to my ignition switch to my truck. I am pretty sure that runs at 9-12 volts. The arduino operates at 5v. So how would I connect a relay? Would I need a latching or non latching. I bought a spdt relay with a 12vdc coil. Rated 10A at 120VAC/24VDC. So matrix keypad to arduino. Arduino to relay/ignition switch. Correct keycode on the keypad arduino sends pulse to relay enabling ignition.

arduino sends pulse to relay enabling ignition.

If the arduino pulses the relay the contacts will pulse. If you have a holding relay you will have to figure out how to turn it off.

This link shows you how to connect a relay:-
http://www.thebox.myzen.co.uk/Workshop/Motors_1.html

Trucks tend to be 24V rather than 12V, you need to find out the voltage and current ratings for definite...

The problem is the relay will be hooked up to my ignition switch to my truck. I am pretty sure that runs at 9-12 volts.

Most likely +12vdc that can range from 9vdc while cranking the motor to +14 or so when being charged. Get a multimeter and measure to be sure and you need to own a meter if you are going to build something with a arduino, that's not optional in my book.

The arduino operates at 5v. So how would I connect a relay?

You need to add a transistor switch and resistor so that the arduino can control a 12vdc relay. Here is an example circuit: http://arduino.cc/playground/uploads/Learning/solenoid_driver.pdf It shows a solenoid being controlled but that is the same as a relay coil.

Would I need a latching or non latching.
Depends on what the arduino code is trying to do and control. In most cases you don't require a latching relay, just proper program commands in the arduino code.

I bought a spdt relay with a 12vdc coil. Rated 10A at 120VAC/24VDC. So matrix keypad to arduino. Arduino to relay/ignition switch. Correct keycode on the keypad arduino sends pulse to relay enabling ignition.

From a safety point of view do you trust an arduino you programmed and wired into your truck not to turn off the ignition while driving high speed on the hiway. Think about that carefully before proceeding. Just because an arduino can be made to perform a specific task doesn't mean it should be used for that task.

Lefty

Lefty, I do have a multimeter. I went and bought one the otherday. I understand your concern about the ignition being involved. See I thought the car runs off the alternator after it is started. That would mean the ignition has nothing to do with driving, while in the process. But I could be wrong and I guess to be on the safe side I will go with hooking the relay up to the selanoid.

I guess the relay being latched or non latched wouldn't make a difference with the proper programming.

annonymous:
Lefty, I do have a multimeter. I went and bought one the otherday. I understand your concern about the ignition being involved. See I thought the car runs off the alternator after it is started.

I don't think that is correct. The ignition circuit is it's own circuit, how else would you be able to stop the engine running by just turning the keyswitch off?

That would mean the ignition has nothing to do with driving, while in the process. But I could be wrong and I guess to be on the safe side I will go with hooking the relay up to the selanoid.

Well that is possible but be sure you have a relay that has contact current ratings able to handle what the starting solenoid requires.

I guess the relay being latched or non latched wouldn't make a difference with the proper programming.

Correct. And latch relays are more complex in that there is additional wiring to allow both setting and resetting for it.

Lefty

retrolefty:
Well that is possible but be sure you have a relay that has contact current ratings able to handle what the starting solenoid requires.

A typical small/medium car starter motor solenoid draws about 30 Amps initially, dropping to about 10 Amps once it has engaged the main contacts. If this is for a heavy vehicle it would likely need correspondingly more current.

PeterH, I just went outside and tested the starting selanoid with my multimeter and while the car is off the DCV is 12.5 to 13. When I turn the key back, the DCV drops to 12.10 to 12.53. While the car is on it jumps to 15-15.11 DCV.

So would the SPDT 12V relay at 120VAC/24VDC rated 10A work for my project?
What kind of diode and transistor would I need? Am I missing anything?

So would the SPDT 12V relay at 120VAC/24VDC rated 10A work for my project?

The voltage variation is fine for the 12volt relay coil, however the 10A contact ratings is probably much too low for handling the starting solenoid circuit, and you would end up with the contacts welded closed, which in not a good thing and would most likely end up destroying the starter motor or it's turning gear or both.

Lefty

So what contact rating is suitable for the starting selanoid, 30? Could I even find a spdt 12V relay that has a contact rating of 30?

annonymous:
So what contact rating is suitable for the starting selanoid, 30?
I have no idea what a suitable rating for your truck would be and don't know where to find such information.
Could I even find a spdt 12V relay that has a contact rating of 30?

30amps, maybe, higher then 30, not sure. Controlling the starter current path is not method I would attempt. I really don't have a solution for you other then to say using a arduino to control the starting or the ignition circuits is a pretty risky application. However cars and truck do come with such keyless entry systems and security systems and there my be 3rd party options that can be fitted to your truck. I'm just not sure it's a good arduino beginners project to take on.

Lefty

On my ranger there is a solenoid that looks like this:

By applying 12V to the silver terminal, it will close the copper terminals. I don't know how much amperage the coil will use, but for sure it will be under 10A. I would use the relay you have to control the solenoid.

edited to add: Applying 12V to the silver terminal will only cause the engine to crank. It will not energize the ignition, or turn on the fuel pump, or run the fuel control unit. All those are necessary to start the engine.

edit #2: Also, cranking the engine that way will also override any neutral safety switch. The truck will drive if it is in gear. Be very, very careful. If you go ahead with this, you should consider a reliable fail-safe method for this reason.

Perhaps a better approach would be as follows:

Connect a relay in series with the solenoid I linked to above. (i.e. the solenoid will only work if the relay is closed)
When you get in your truck, you enter the code, which closes the relay for a few seconds.
In that time, you start your truck with the key as normal.
This would be the safest and easiest approach to a key-code ignition lock.

John_s, I just returned the 10A relay and went to a car parts store and bought a 30A relay. But I am going to hook it up to the selanoid. I went over it with the master mechanic and he broke it down. It is actually really simple. But I am going to take the ignition wire that goes to the selanoid and connect that to the com terminal on the relay and the normally open to the selanoid positive. The arduino to the coil. Now I need to figure out how to make the arduino send 12 volts. And what line I have to hook up the diode to.

And what line I have to hook up the diode to.

Hook the diode across the coil with the cathode (the strip end) pointing towards the positive.

Now I need to figure out how to make the arduino send 12 volts.

I gave you a link to that in my first reply.

Yeah I know grumpy Mike. I took a look at your link and Google's a lot of things. I need a transistor which I have. I study them for a few hours. What I don't understand is, is the emittor what goes to the relay on the transistor? Since applied voltage to the base will draw current through the collector and send it out the emittor. Or do I have it backwards.

Sorry but I do not understand your answer as to which line the diode goes on. I know the flow of electricity flow to the cathode and never against it. But when you say on the coil, do you mean, the cathode on the positive side of the coil and the anode to the transistor?

is the emittor what goes to the relay on the transistor?

No it is the collector the emitter goes to ground.

Since applied voltage to the base will draw current through the collector and send it out the emittor.

Yes an applied voltage to the base (through a resistor) will put a current through the base to the emitter and this will cause a current to flow from the collector to the emitter.

Sorry but I do not understand your answer as to which line the diode goes on.

It is shown in the link you said you looked at. The anode goes to the collector (just like one end of the coil) and the cathode goes to the + supply driving the relay (just like the other end of the coil).

where am i placing the transistor? I attached the circuit schematic.

I assume it should look like this --->

Will you PLEASE look at the link I sent.
R2 should be direct to the arduino pin. The diode should be on the collector and other end of the coil. The other end of the coil, the one not connected to the collector should go with the diode to the relay power source.