Hi all,
I know this topic has been discussed before, but i was having a hard time wrapping my head around circuit design with optocouplers and wanted some feedback. Also wanted to be sure this would work with the PLC i am currently using. Also I hope this post is in the right category.
I am in the process of designing a custom ATMega328P-based PCB(5V) that needs to receive and send discrete digital signals to a PLC(24V). I will be communicating with this DL05 PLC from automation direct: https://cdn.automationdirect.com/static/specs/d005dr.pdf
I am using EL817(c) optocouplers: https://www.mouser.com/datasheet/2/143/EVER_S_A0008471837_1-2548735.pdf
below is the schematic that i have so far:
The notes indicate which sub-circuit is for the receiving of signals and which is for the sending of signals to and from my PLC and ATMega328P. The ATMega328P sub-circuit will be powered by 5V and i will receive 24V from the PLC power supply, but these two supplies need to be isolated. The signals from and to the PLC need to operate on 24V. The output from the PLC is a sinking output. The PLC can receive a sinking or a sourcing input. (i believe for the circuit up above it will be sinking input).
For receiving a signal from the PLC:
This will be a 24V signal going to a 5V signal. I aimed for 10mA to go to the LED. with Vf = 1.2V(1.4 MAX), i calculated a resistor value >2200Ohms, the max CTR = 400%(for the c version of the EL817) i settled on 2.7kOhms because the ATMega328P input can handle a max of 40mA input. With the max CTR, the ATMega328P will see a max of 33.6mA. Also i included a reverse voltage diode between pin a1 and 2 of the optocoupler to protect the PLC. Questions for this portion: 1. Is the LED portion and the collector/emitter version of the optocoupler wired in a way that when the 24V PLC signal is high i will get a 5V high signal on the D0_PLC channel? 2. is the current-limiting-resistor the correct resistance? 3. is the reverse voltage diode needed?(for the each circuit really)
For Sending a signal to the PLC:
This will be a 5V signal going to a 24V signal. Again, i aimed for 10mA going to the LED. With a 5V signal, i calculated a resistance value >360Ohms. With the max CTR of 400%, that would mean that 40mA would be output and headed for the PLC. According to the data sheet for the PLC, a 'ON' signal needs >5mA @ 10V. Will this output from the optocoupler alone be able to switch the PLC input signal on? or do I need some kind of transistor circuit? like the one below:

I again have a reverse voltage diode to protect the ATMega328P. Questions regarding this: 1. the above question regarding the transistor. 2. Am i correct to say that the above is a sinking input? 3. is the current-limiting resistor values correct for this sub circuit? 4. is the wiring correct?
Any input would be greatly appreciated.
Best,
KE
