Arduino and 12V car relay / 12V input switch

Hi everyone,

I am making an arduino device to control the windshield wiper motor in my truck. My truck is old and doesn’t have an intermittent setting, so I am going to make one. All the arduino has to do is read an input and open and close a relay (or two relays). I am going to use a NPN transistor and resistor to connect the relay to ground, basically exactly like this guy’s article:

http://henrysbench.capnfatz.com/henrys-bench/arduino-output-devices/tip122-arduino-relay-tutorial/

In addition to a 5V input to the arduino, I want to also be able to read a 12V input from the cars factory wiper motor switch. Of course I can’t connect 12V to the arduino, so I need to step it down / regulate it. So my questions are:

  1. Can/should I use a zener diode voltage regulator like I have shown on my attached schematic? Or just a regulator voltage divider or optocoupler? Not sure what the pros and cons are. The cars voltage is just about 14V when running.

  2. The 1N4002 diode in the schematic is a flyback diode to prevent voltage spikes when the relay closes. How do I size this diode? Also someone on youtube said the diode should be physically close to the relay, why is that? Can the diode not be inside the cab with the other components?

  3. If you seen anything wrong in my schematic or know of a better way do do this, please let me know!

Thank you in advance!

Drawing1 Model (1).pdf (16.3 KB)

  1. Can/should I use a zener diode voltage regulator like I have shown on my attached schematic?

That'll work. [u]Here[/u] are some over-voltage circuits (I'd increase the resistor to between 1K and 10K).

Or just a regulator voltage divider

The issue with a voltage divider is the unregulated input. You can use a voltage divider plus a "protection diode" but that's usually not necessary.

or optocoupler?

An opto-coupler is fine too. It's completely isolated so I suppose it's "safer" but you should have no problems with the diode methods.

  1. The 1N4002 diode in the schematic is a flyback diode to prevent voltage spikes when the relay closes. How do I size this diode? Also someone on youtube said the diode should be physically close to the relay, why is that? Can the diode not be inside the cab with the other components?

It just needs to handle the relay coil current. I don't know what the issue is with "long wires" I suppose you might get some electromagnetic radiation into the car radio or something. [/qutoe]

  1. If you seen anything wrong in my schematic or know of a better way do do this, please let me know!

It looks OK to me.

ok here's my post to explain the flyback diode:

Flyback Diode

the reason why you want it close is because the wires can add additional inductance which if it's high enough can cause emf and arcing.

Do your wipers self-park when the power goes off?

Paul

One here with a 555 timer.
Could be modified for Arduino.

Paul_KD7HB:
Do your wipers self-park when the power goes off?

Paul

The motor has a constant 12V source for the park with a mechanical internal switch. This guy explains is pretty well if you're interested, I have the same type of motor:

wolframore:
ok here's my post to explain the flyback diode:

Flyback Diode

the reason why you want it close is because the wires can add additional inductance which if it's high enough can cause emf and arcing.

3.6kV is really high. Does that mean the diode needs to be rated for 3.6kV?? I know it only spikes for a second. The diode in the article is rated for 100V, 1A

Also, I've never seen flyback diodes used in cars before. Is it only needed here to protect the sensitive electronics of the arduino?

That’s without the diode. If you look at what happens with the diode it steers the current around and brief jump in current but not a big deal.

wolframore:
the reason why you want it close is because the wires can add additional inductance which if it's high enough can cause emf and arcing.

Which happens to be complete nonsense! If by "close" you mean having the diode adjacent to the inductor. :astonished:

Just for the record:


I find it surprising that even educated engineers can resort to "magical thinking" about the situation, with assertions about "current surges" and putting the diode as close as possible to the inductor because the inductor "generates" the surge.

That turns out to be an absurdity. What generates the transient is not the inductor but the switching device, either a mechanical contact or a semiconductor. The inductor - as a response - acts to maintain the instantaneous current flow by generating the "back-EMF". So you provide an alternative path for it to do so through the diode. It is still the case that the current through the inductor and its connecting wires does not change rapidly.

What does change rapidly is the current through the switching element and the power supply which suddenly drops to zero, and the current through the diode which as a consequence suddenly rises from zero to maintain that same current.

The significance of this is that if interference is going to be caused by electromagnetic radiation from a suddenly changing current, that suddenly changing current is located in the loop formed by the power supply (or the local bypass capacitor), the switching element and the diode but not the wiring between the diode and the inductor. The need is thus to minimise the length of that supply - switch - diode loop by placing the diode as close as possible to the switch and power supply (bypass). It is these three that must be close together. Suggesting you need to place the diode close to the inductor (or motor) is actually quite wrong! :astonished:

On the other hand, there is a voltage transient caused by the switching which can capacitively radiate interference. This impulse is - again - caused not by the inductor but by the switching element so it actually radiates - possibly counter-intuitively - from the switching element to the inductor however to all intents and purposes, all points on the wire connecting switch, diode and inductor experience the same transient so this is not affected either way by the location of the diode.

So now let's take a look at that transmission line. :grinning:

I won't consider resistance; the simple model of a transmission line is a series inductor and parallel capacitance. The capacitance can perhaps be considered at each end. Well, the transmission line inductance is in series with the primary inductor. If you put the diode at the switching device end, then the inductance acts with the primary inductance and as described, resists sudden changes in the current which is to say, minimises inductive transient radiation.

If you place the diode at the primary inductance end however, you have now created in the transmission line, a second inductor in series with the primary which will add to the voltage transient at the switching device and enhance inductive transient radiation. It may not in itself contain enough energy to damage the unprotected switching device.

Capacitance at either end of the transmission line will indeed serve to slow the voltage transient but will conversely cause a transient when the inductor is switched on. Capacitance toward the inductor end will tend to cause radiation from the transmission line while capacitance at the switching device end will increase more the current surge seen by the switching device.

Note the general principle that it is the transmission line which radiates interference due to switching transients and the current transients occur in that part of the transmission line which is on the switching device side of the diode, so placing that diode near the primary inductor causes all of the transmission line to be such a potential radiator while placing it at the switching device limits this to the loop originally described, formed by the power supply (or the local bypass capacitor), the switching element and the diode.

Very good comments Paul.

20ga (0.032”) x 4 feet has L= 2 uH and 0.040 Ohms. With the additional capacitance not much of an issue.

Who switches a motor or solenoids with large current from long runs? Generally you follow the same rule, keep the diodes near the inductive load and also the switching device near the same. It’s not efficient to push current through long runs. That’s why we use low voltage digital controls.

If you must then you should place fly back at the switching device and power supplies should have additional protection, Arduinos are not designed to be used in demanding environments.