first:
the relays you've got can't wired directly to a arduino.
the data sheet isn't doesn't tell what current it draws / peek current not even the coil resistance or the build in resistor in series with the coil.
outgoing form the average power consumption of the coil divided by the max arduino output voltage delivers the lowest average current
P = V * I ==> I = P / U --> I = .29W / 5V = 58mA
the maximum current drawn or shucked to a IO is generally ± 25mA
the absolute maximum generally ±40 - 50mA
maybe the arduino survives the current of 58mA but it can die,
here you can find more info about not exceeding the max current.
also always put a diode across the relay coil to prevent frying the micro controller from the reverse voltage spikes coils generate when they are unloaded
it is not deadly if you don't put the diode, because the arduino outputs are push-pull; which means that that a output is shorted 5V (high) or shorted to gnd(0V) (low). So the coil is never be unloaded / floating. (but for transistors is it needed).
something like this, the transistor can handle more current than a relay.
the 12V in your case can variate between 5V and 24V.
the transistor type can be any type where
- max Vce higher is than the supply voltage (the 5 to 24V) (almost any common transistor is can handle that)
- max IC is higher than 100mA
- max Power doesn't care because the transistor will act like a switch
by example the BC547B is an excellent very common transistor
and has a gain (HFE) about 200 - 250.
the resistor value can be calculated with ohms law.
R = V / I
- V = (5V -.07V) 5V is the max output voltage of the arduino, 0.7V is the voltage drop in the BE of the transistor.
- I = Ic / HFe
- IC = the max current drawn by the relay the previous maths says 58mA but I 'm not sure if more or less. thus i take 100mA
- HFe is the HFe of the transistor 200
I = 100mA / 200 = .5mA = 500μA
R = 5V / 500μA = 10kΩ
important
the HFe is very dependent from time, temperature, even the collector current and base current may affect the HFe.
so to be sure mostly the resistor value is divided by 2 or more.
but because we've taken the current almost twice as high, and the minimum HFe (the BC547b's HFe is between 200 and 450) and it is not a disaster is the transistor is not fully saturated but maybe 90% (VCE about 1V in stead of 0.3V) and 10kΩ a very common resistor we can take 10kΩ but if you want to be really safe, you can take a 5.6kΩ or less.
Second:
multiplexing
there are several ways to multiplex
very common is matrixing:
just replace every led by a relay
how it works
first select a column than the row
the image is for demonstrating only, don't care about pin numbers
connect each column pin and row trough a transistor / transistor chip
to the arduino
if you want 48 relays then a 6 by 8 matrix may do the trick
there exist ICs that can do something similar
More IO
there exist io expanders over I2C or SPI
with a lot of libraries for arduino
generally a io expander acts like a io on the arduino and can handle about the same current maybe more or less
bcd to decimal
converts a binary number to a single high output
the 74HC42 (by example) can do this
I don't know if there exist a library for a arduino. but if necessary, I can write you a code example that works (or a library is also possible)
- shift registers
explained on the arduino site shiftout()
the 74hc595 can do this
The environment in a car is quite different from that experienced by electronic components in a box on a table in your office. There are several characteristics in particular that stress electronics components more in a car than a office environment:
- Temperature. A car still has to start on a cold winter morning in Nome or after baking in the hot July sun until mid afternoon in Yuma. Not only do these extremes pose a challenge to operating ability, but the daily thermal cycling causes mechanical stresses.
- Vibration.
- Noisy power. "12V" car power is nowhere near as nice as what a 12 V regulated power supply provides. It can drop significantly during starting, goes to 14 V when the engine is running, and can have 10s of volts of nasty spikes on it. For example, the normal 7805 regulator can be damaged by car power, even though it is rated to 35 V. There is a special regulator series that is rated for car power, which of course costs more.
- Humidity. The relative humidity is unpredictable and can be at one extreme or the other for extended periods of time.
In addition to this, the end users generally don't tolerate failures as well in cars as they do in ordinary office appliances.
I can't say how much of this is relevant to your situation since you haven't told us what you are really trying to do. However, keep in mind that there are millions of cars sold every year, so the volumes are high and there is considerable competition. If manufacturers didn't have to pay for the extra robust characteristics of the components, they wouldn't. The fact that a car company is willing to pay the extra $.50 for a relay that goes into a million cars, should tell you that it matters. That's $500k they could save if they didn't. Put another way, that's about 3-4 engineers for a year to come up with a cheaper alternative.
Best Answer
This suggests to me that the relay coil may be saturating its core.
Consider this : if you are measuring the inductance in-circuit, while operating the relay, there are two important states : open and closed.
In the open state, the inductor is gapped and therefore its reluctance is relatively low. You can apply all the power you like and it won't saturate, therefore your inductance measurements (using the AC component of the PWM signal, right?) reflect the true inductance of the (gapped) coil.
However, it will pull in, closing the magnetic circuit. And here I'm speculating. The closed circuit saturates, so the inductance you can measure is a small-signal value on the relatively flat saturated portion of the B-H curve.
Then you reduce the PWM duty cycle, but presumably not quite far enough to bring the core out of saturation (or you'd see an increase in inductance).
If this is the case, then inductance measurements made unpowered, on an opened relay, operating it with a finger or screwdriver, would show the expected increase in inductance when closed.