I want to know if it's possible to use an Arduino output to directly power the coils of a subminiature latching relay. The one I have in mind is the Hongfa HFD3/5-L2, which looking at the data sheet takes a 5v supply to energize the coils.
Will the Arduino be able to reliably supply the current to do this? The relay itself would only have to deal with about 20v AC (model railroad supply) and would be used to reverse the polarity of the supply. The feeling I get is that the relay would mess up the Arduino but would appreciate advice
It looks like each coil would require 40mA. An Arduino might do that, but it would be safer to use a transistor. You would just need a transistor and a resistor for each coil, plus the diode of course which you would need in any case.
The answer is No. Never place anything inductive on an arduino pin. You need a relay either solid state or mechanical. You are switching AC, placing that on a 5V pin will make your Arduino supplier happy because you will blow it. Here is some helpful information:
Gil's Crispy Critter Rules for Processor Hardware:
Rule #1: An Arduino is NOT a Power Supply!
Rule #2: Never connect anything inductive (motors, speakers) directly to an Arduino!
Rule #3: Avoid connecting or disconnecting wires while the power is on.
Rule #4: Do not apply power to any pin unless you are certain of what you're doing.
Rule #5: Do not exceed the maximum voltage ratings.
Rule #6: Many Arduinos cannot power transmitters directly.
Rule #7: Before powering your project, take a break and double-check the wiring.
LaryD’s Corollaries:
Coro #1: When starting out, add a 220Ω resistor in series with both input and output pins to protect against shorts.
Coro #2: Invest in a Digital Multi-Meter (DMM) to measure voltages, currents, and resistance.
Note: Violating these rules can turn your Arduinos into crispy critters. For optimal performance, keep your wires under 25 cm (10 inches).
Additional Tips:
The L293 motor driver, though common, is inefficient as it can lose around 3V as heat when driving both legs of a motor. Consider using a motor driver with MOSFET outputs to reduce heat loss and conserve battery power.
Go with that feeling. Coils, even those that draw 40 mA, are bad news for Arduino I/O pins. As I read your text, your relay contacts are switching the 20 VAC - that's okay, but tell us about the device receiving that - how much current does it require, and how do you "reverse" it? I think a schematic of your intended circuit is required.
Thanks for the advice - I'll look at the methods you all have pointed out
as for the AC part, if you look for model railroad switches, they have a part called a 'frog' which has to match the polarity of the correct rail, so on DC it has to switch from -ve to +ve and vice versa, and with new DCC control systems that use AC has to invert the voltage
Re @jim-p 's post #7, I was wondering in particular why you needed a latching relay and an Arduino? Not sure what triggering you are using, but I'm sure the Arduino could do the toggling (latching/unlatching).
If so a circuit of the familiar sort that @ShermanP suggested, like this: