I want to connect a load to one of the data lines on a 32U4. The load is a relay coil, which will will use between 25 and 30 ma, for a brief pulse (10-15 ms). The relay is a latching small-signal relay, with two coils, so there will be two such connections, but not both driven at the same time. One coil pulsed to latch the relay, one to unlatch the relay. This is for a 32U4 running at 5V.
So the question in my mind is, is it better to connect the load (relay coil) between the data line and Vcc, and trigger the relay by setting the output to a low state, or is it better to connect between the data line and ground, and trigger the relay by setting the output to a high state ? Is there a functional difference, or is this the choice of the circuit designer ?
Along with the relay, I have some TVS Zeners on order to suppress the kickback spike when stopping the current flow.
To solve your engineering problem you also need to know the operate and release voltage of the relay coils. Some relays need that 25mA at 12v or more. Some only need 3v. If it’s 3v then you probably can drive it directly from the ATmega. If it’s 5V that might be iffy. If it’s more than 5 then you will need a separate supply for the relay and control it on the ground side through a transistor (and be very careful about your “off” voltage). Read your specs carefully. The ATmega does not necessarily generate 5V or 0V as outputs. That is, those outputs are circuits whose function is affected by the load.
My intention is to put a 43 ohm resistor in series with the coil. That would reduce the coil voltage to around 4V, and diminish the current by a few mA.
This is a two coil latching relay. Pulse one coil to set the latch, pulse the other coil to release the latch. No current used other than for the pulses.
ETA: the part number is NEC/Tokin EB2-4.5TNF. The trailing F is curious, and does not appear on any datasheet I’ve been able to locate for the series. In fact, there are quite a few NEC small signal relays on eBay, which also have an undefined trailing ‘F’.
uChip:
Read your specs carefully. The ATmega does not necessarily generate 5V or 0V as outputs. That is, those outputs are circuits whose function is affected by the load.
Yes, I'm looking at the chart on page 396 of the ATMega32U4 datasheet ("Figure 30-20. I/O Pin Output Voltage vs. Source Current (VCC = 5 V)"). The chart only goes out to 20mA source current, but I do see what you're referring to (about the voltage degrading as the current rises). Perhaps the 43 ohm resistor is not necessary after all. Extrapolating from the chart, I'm guessing around 3.8V at the needed current flow. Still above the Set/Reset voltage, but a bit closer than I had expected.
Do you know the pull-in and release times ? Or the coils inductance ? Is a 15 msec pulse going to be long enough ? I guess you could make it longer if needed but don’t expect msec precise open/close times.
Before you add the 43 ohm resistor you may want to look at section 30.6 of the 32U4 datasheet. It specifies the pin driver strength as a current source and sink for Vcc = 5V and 3V. At 5V a pin drops 0.8V sourcing 20 mA (the max shown by the table) and rises 0.7V trying to sink 20 mA. IIRC the curves for a 328 are similar but go increasingly non-linear above a 20 mA level.
I don’t think it much matters as to whether you source or sink current to energize your relay. I’d pick a sink type configuration if forced too. It depends on how you handle the “kick”. Personally I’d use a driver for a relay as rumor has i that while PIC pins are tough, AVR pins are fragile.
EDIT : I see (from the post now above) I shouldn’t have a bite to eat while typing this. :mrgreen:
To check just how much the voltage will drag down, I will set up a simulated relay with a resistor load, then measure the voltage. That should give me a clue if I have a problem.
Do you know the pull-in and release times ? Or the coils inductance ? Is a 15 msec pulse going to be long enough ? I guess you could make it longer if needed but don’t expect msec precise open/close times.
Specs say that I need a minimum 10 ms pulse, with fast rise and fall. I figure 12-15 should be sufficient excess to cover it.
Also, one other interesting side note. The two charts (one for voltage drop when source, and the other for voltage rise for sink) leave me with the impression that sinking may yield a slightly higher voltage across the relay coil. Difference may be around 0.2V better for sink.