go away spammer

Author Topic: What's the best way to switch car headlights using an Arduino?  (Read 9482 times)

0 Members and 1 Guest are viewing this topic.

Offline DaaniiTopic starter

  • Robot Overlord
  • ****
  • Posts: 138
  • Helpful? 3
The electric car project I'm working on needs the headlights and other lights to be switched on and off. I want to control the lights with an Arduino Mega, using one output pin for each light or other device to be switched. That means I will have a 5 Volt, up to 40 milliamp output signal to switch the 12 Volt, up to 5 Amp power supply line to the device.

One way I have thought to switch the lights is using this solid state relay from Futurlec: http://www.futurlec.com/Relays/SSRDC100V40A.shtml I think it will work fine, but the relay is rated for 40 Amps (much bigger than I need), and costs $22 (much more than I want to spend).

Another idea was to use an automotive relay, like this one: http://www.parts-express.com/pe/showdetl.cfm?Partnumber=330-073 But while the price is right ($2), the control signal needs to be 12 Volt, and 150 milliamps, neither of which the Arduino can put out.

So I thought of using a transistor to switch the lights and other devices. But I guess I would need an optoisolator to protect the Arduino. And I cannot find any circuits to do quite what I need. That is, use a 5 Volt, 40 milliamp on/off signal to switch a 12 Volt, 5 Amp power supply line.

Any advice on how best to approach this? Particularly, any transistors you can recommend that will do the job?

Thanks.

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: What's the best way to switch car headlights using an Arduino?
« Reply #1 on: August 21, 2011, 02:08:08 AM »
Hi,

That means I will have a 5 Volt, up to 40 milliamp output signal to switch the 12 Volt, up to 5 Amp power supply line to the device.
[...]
Another idea was to use an automotive relay,  [...] the control signal needs to be 12 Volt, and 150 milliamps, neither of which the Arduino can put out.

So I thought of using a transistor to switch the lights and other devices. But I guess I would need an optoisolator to protect the Arduino. And I cannot find any circuits to do quite what I need. That is, use a 5 Volt, 40 milliamp on/off signal to switch a 12 Volt, 5 Amp power supply line.

Any advice on how best to approach this? Particularly, any transistors you can recommend that will do the job?
Use the automotive relay, While I cannot see the page with the SSR, they're usually for AC and even if you fin a DC version, it would be hopeless overkill anyway.

You don't need an optocoupler, but if you like to add parts, go ahead ;D just remember that the more parts you use, the greater potential for errors.
The transistor will be all the protection you need. It keeps the 12V side confined to collector-emitter. As long as the (NPN) emitter is grounded, you will have that isolation and to address any concerns over a faulty transistor - the typical failure mode for diodes and transistors is shorted.
Even if we imagine the unlikely (almost impossible) situation where there's +12V on the basis, there's a couple of resistors that keeps the board in the clear.

A BC337 (can possibly be substituted with 2N2222, if you check the h_FE ) with a 2k2 resistor from basis to I/O-pin plus a 1k0 pull down (I/O-pin to ground) to make sure the transistor stays shut when the controller is powered off. In case of 12V on the basis, the I/O-pin will see a maximum potential of 3.75V with an impedance of ~690 Ohm. This means a max. of 5.5mA hitting the I/O (and this doesn't even take the loading from the I/O itself into the equation - this will lower it further.

Emitter to ground, collector to relay and the other end of the relay to B+. A reverse biased 1N4148 (or 1N4448, NOT 1N914) as close to the relay coil terminals as possible (best way to mount them is directly at the terminals, but that will probably be impossible. Next best is to make sure that the diode is directly in the current path and not as a separate entity (I usually go for the diode to be placed in the direct path from B+ to the driving transistor and then make traces from the diode to the relay coil.
All in all: 2 resistors, 1 diode and 1 transistor.

Don't know if it helps (or the quality of them), but a couple of days ago, I spotted some sockets for automotive relay - a wire ended socket and one for PCB mounting.
As mentioned, I can't vouch for the quality, but with a series of relays to keep in order, it provides a tidy and easy solution (Oh, the times spent under the hood in heavy rain, just to persuade 4..5 spade connectors to give).
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline DaaniiTopic starter

  • Robot Overlord
  • ****
  • Posts: 138
  • Helpful? 3
Re: What's the best way to switch car headlights using an Arduino?
« Reply #2 on: August 21, 2011, 01:41:14 PM »
Thanks very much, Soeren. I'll give that circuit a try.

(By the way, the solid state relay I found is DC. But the price tag of $21 makes me agree with you that it is overkill for this.)
« Last Edit: August 22, 2011, 10:07:32 AM by Daanii »

Offline DaaniiTopic starter

  • Robot Overlord
  • ****
  • Posts: 138
  • Helpful? 3
Re: What's the best way to switch car headlights using an Arduino?
« Reply #3 on: August 22, 2011, 08:56:21 PM »
Is this schematic correct? (It's not very well done, I know. I used ExpressPCB to draw the schematic. First time for me to use one of these programs.)
« Last Edit: August 22, 2011, 09:04:52 PM by Daanii »

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: What's the best way to switch car headlights using an Arduino?
« Reply #4 on: August 24, 2011, 10:17:04 PM »
Hi,

Yes, it's correct.
I would have drawn it up for you, but I had a couple of days with shaky (on/off) server connection, so I figured text would do for such a small circuit... And your schematic is proof that it did  ;D
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline corrado33

  • Supreme Robot
  • *****
  • Posts: 611
  • Helpful? 11
Re: What's the best way to switch car headlights using an Arduino?
« Reply #5 on: August 25, 2011, 04:57:32 PM »

Don't know if it helps (or the quality of them), but a couple of days ago, I spotted some sockets for automotive relay - a wire ended socket and one for PCB mounting.


I've bought sockets for SPDT relays before, they worked very nicely.  IIRC I bought the socket and relay together for a couple of bucks.  You will have to keep them somewhere out of the weather though (but since this is for a car and what you are doing is replacing the headlight switch, I think it'll be fine). 

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: What's the best way to switch car headlights using an Arduino?
« Reply #6 on: August 25, 2011, 09:20:42 PM »
Hi,

You will have to keep them somewhere out of the weather though
Most cars use similar sockets on wire ends for single relays placed under the hood and they're very resilient, when you think of their environment, from perhaps -20°C (or lower) to around 80°C (or higher) - There's no rain, but oil mist and a wide range of temperatures is quite a challenge in itself.

The difference (when it comes to connecting/disconnecting) between "normal" relays and the automotive type is that the latter have spade terminal and it is faster and easier with a socket (which you can get a hold on) than with a series of loose spade terminals.

Where I really think they'd shine in Daaniis project is in presentation - with PCB's holding a row of relays it looks both neat and powerfull  :)

For most one off projects, where a relay is gonna last the lifetime of the rest of the circuit, soldering the terminals is a better choice, as sockets can develop a bad connection (especially if the contacts are made of a different material - never use a gold plated terminal in a tinned socket or v.v. that's a  problem waiting to happen).
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline DaaniiTopic starter

  • Robot Overlord
  • ****
  • Posts: 138
  • Helpful? 3
Re: What's the best way to switch car headlights using an Arduino?
« Reply #7 on: August 27, 2011, 04:03:28 PM »
I came across a circuit that uses a power MOSFET, the STP40NF10L. If I read the datasheet correctly, the FET can switch up to 100 Volts, up to 40 Amps, using logic level at the gate.

Would this work to switch my lights? Or am I missing something here?
« Last Edit: August 27, 2011, 04:22:26 PM by Daanii »

Offline DaaniiTopic starter

  • Robot Overlord
  • ****
  • Posts: 138
  • Helpful? 3
Re: What's the best way to switch car headlights using an Arduino?
« Reply #8 on: August 28, 2011, 03:15:03 PM »
Here's another alternative: http://iteadstudio.com/store/index.php?main_page=product_info&cPath=18&products_id=430

They have these boards in 2, 4 and 8-relay configurations. They can switch up to 10 Amps, and up to 30 Volts DC. You can hook them directly up to an Arduino output pin.

The coil in each relay uses about 380 milliwatts to keep the relay closed. I think that is pretty comparable to the power dissipated by a power MOSFET. But I am not sure.

Very clever product.

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: What's the best way to switch car headlights using an Arduino?
« Reply #9 on: August 28, 2011, 05:12:59 PM »
Hi,

Just when I had finished an answer for your previous post, my PC went down with a bang (cutting a 1.5 hour ongoing video conversion as well :(), so here's the short version:
The MOSFET may do fine (try it). If it gets hot, a driver made from an NPN, a PNP and a few resistors will make for a 12V drive.
I won't quite call it Logic Level, as the Miller plateau is at (or perhaps a little above) 5V, which will make it switch much slower and the R_ds_on will be higher than if properly driven.


Here's another alternative:
[...]
They have these boards in 2, 4 and 8-relay configurations. They can switch up to 10 Amps, and up to 30 Volts DC. You can hook them directly up to an Arduino output pin.
That should work, as long as you don't demand the full 10A - you might need a snubber on the contacts, depending on what kind of lamps you plan to switch


The coil in each relay uses about 380 milliwatts to keep the relay closed. I think that is pretty comparable to the power dissipated by a power MOSFET. But I am not sure.
Err?  5V@20mA = 100mW

What's dissipated in a well driven MOSFET, say the one you chose, which should be 33mOhm (worst case IIRC). At 10A that's 0.033*10^2 = 3.3W

There will be a small contact resistance in any relay (and this is usually inverse proportional with the price), so that loss should be considered as well in a comparison, but neither 0.1W or 3.3W matters much compared to 130..140W into the load.


Very clever product.
It's a relay board - technology that dates back more than 50 years... nothing too exciting about it, but if it gets the job done...  ;D
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline DaaniiTopic starter

  • Robot Overlord
  • ****
  • Posts: 138
  • Helpful? 3
Re: What's the best way to switch car headlights using an Arduino?
« Reply #10 on: August 29, 2011, 10:48:27 AM »
Thanks for the information, Soeren. I need to switch 16 lights or other devices, so I'm going to use 4 different approaches. Then I can compare them.
« Last Edit: August 29, 2011, 01:02:55 PM by Daanii »

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: What's the best way to switch car headlights using an Arduino?
« Reply #11 on: August 29, 2011, 10:20:56 PM »
Hi,

I need to switch 16 lights or other devices, so I'm going to use 4 different approaches. Then I can compare them.
If the devices have vastly different current demands, perhaps a mix of methods are in order.
Anyway, relays=safe bet, but they're large compared to transistors.
Testing's good... Builds experience  ;D
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

 


Get Your Ad Here