[quote author=Mitchell Christensen link=topic=90600.msg681161#msg681161 date=1328586828]
I'm afraid there is something else going on here. I pulled the TLP521 out of its socket and decided to measure the current being provided by digital pin 4 on the Atmega328. Given +5v through a 180 ohm resistor I expected to see 27+ma, but I only see 13ma. Forget the optocoupler and the relay, setting pin 4 high (+5v) and feeding across a 180 ohm resistor to GND only draws 13ma? That seems to violate Ohm's Law, and I believe thats why my relay doesn't fire.
I have double checked that the total resistance of the circuit (pin 4, through the resistor, all the way to GND) is 178.8 ohms. I have confirmed that I have set pin 4 to OUTPUT in setup(). I have tried two separate Atmega328 chips running the same program (one brand new, and the other is older), both stop at ~13ma (the second is slightly higher...14ma). I am running the Atmega328 in my own board (i.e. not an Arduino). Could I have an assembly/solder problem? I eliminated my power supply completely by powering my board entirely from an off-board Arduino I wired in. Still 13ma on pin 4.
[/quote]
There is definitely something wrong there. The data sheet guarantees Voh to be at least 4.2v with a 5v supply and 20mA load, meaning that a 210 ohm resistor as load will draw at least 20mA. I think either your supply is lower than 5v, or you have a bad connection, or the meter you are using to measure current has significant resistance, or your meter is faulty.
[quote author=Mitchell Christensen link=topic=90600.msg681104#msg681104 date=1328582418]
Are you suggesting that dropping the 180 ohm resistor value to accomodate the voltage drop across the IR emitter in the optocoupler is all that is necessary on that side of the optocoupler?
[/quote]
That should be the case, however it sounds as though something else is wrong if you are only measuring 13mA with the optoisolator replaced with a meter.
[quote author=Mitchell Christensen link=topic=90600.msg681104#msg681104 date=1328582418]
As for increasing the voltage to the coil, that would be a big problem. I'd have to redesign my power supply significantly to get the 6v you recommend. Also, how does this account for the fact that the 5v out of my power supply operates the relay just fine? Are you asserting that the addition of any switching electronics (NPN, etc.) would introduce a voltage drop that would render my +5v insufficient?
[/quote]
You can get a low voltage drop across an NPN transistor if you choose one that has a low saturation voltage at the current concerned and you overdrive it, i.e. give it much more base current than its hfe suggests is needed for the collector current it has to pass. The transistor in an optoisolator isn't designed or low Vcs(sat) at moderate current, neither is it practical to overdrive it sufficiently with light from the emitter. However, you could use an NPN transistor to amplify the current from the optoisolator. This would also allow a much smaller drive current to be used for the IR emitter.
[/quote]