>
>Looking at Pg 1 of the data sheet, we have just the LED for input. On Pg 2,
>under Electrical Characteristics, we need 5 to 50 mA for input control. The
>AVR will source 10 mA at an output voltage of 4.3 V when operated @ 5V. The
>LED will drop 1.2 V @ 5 mA. Let's assume 1.3 V @ 10 mA: 4.3V - 1.3V = 3.0V.
>Since R = E/I (Ohm's Law), R = 3.0V / 0.01A = 300 Ohm. So put a 300 ohm
>resistor in series with the input LED and it should work.
What? Not in my world. IF the pin would drive 50mA at all, then you'd be looking at nearly zero ohms between the AVR pin, and the SSR diode.
You are assuming that the output pin will hold up 4.3V under a 50mA load.
It won't.
The output pin of the AVR is driven by a small mosfet, sort of a non-linear resistor. When the spec says that it will output 10mA at 4.3V does NOT mean that it will output 50mA in any case, from a 5V supply.
What they ARE saying, is that if you pull 10mA from an AVR I/O pin set as output high, that it's output voltage will not drop below 4.3V under the specified conditions.
Taking that spec sheet parameter, we get 0.7V drop at 10mA or roughly 70 ohms for the internal mosfet AT THIS CURRENT AND VCC. Assuming it is linear and resistive, then we might think that we could get a maximum of 70mA into a short to ground, or 52mA into the SSR's LED, with no current limiting resistor at all. But, that's not how I/O pins act. At higher currents the output mosfet gets hot, and the equivalent resistor value increases.
Also, there's a maximum per-pin output current spec, that forbids anything like 50mA.
So, in order to drive the SSR's led with at least 50mA, you'll need an NPN, like a 2N3904, and a series resistor. (you can also do it with a PNP, but upside down)
The resistor should be calculated from (VCC-(Vledmax+VCEmax)/Iledmax Vledmax at about 1.3V and VCEmax of about 0.6V, without running to the data sheets, so 3.1V available to drive the LED, and Iledmax of 50mA gives us a series resistor of 62 ohms. Conveniently, a standard value.
You'll need a series resistor from the AVR pin into the base pin of the transistor, which you can calculate, but is hardly worth it. If you figure a gain of 100 in the transistor, then you need 500uA into the base to turn it on. (Iout/Gain) So, since the current is very low here, we can figure the AVR to source 5V, and the BE junction to be about 1V, so 4V/0.0005A = 8k maximum resistor. I'd use a 4.7k, or a 2.2k.
Don't forget the resistor to ground on the AVR output pin though. 10k would work, but lower is better. When the AVR is in reset, that pin is an input and very high impedance. The component leads connected to the transistor act as antennas, and the base diode makes a decent detector, turning RF energy into base current.
Here, you analyze the other case, minimum current that will keep the SSR off, being about 400uA so a base current of 4uA induced into the transistor from RF energy, COULD turn your relay on. Wether this is a real problem for you, I can't say, but I think the extra $0.01 for the turn-off resistor is a good investment.
There's also leakage current through the transistor to consider, but it will be low enough not to cause you any problems in this case.
This is the difference between a hobby project that may or may not work for you, and a production design, where we expect to make 10,000 of them over a several year period, with different batches of parts, and have all of them work.