Hi, I think a 7805 could be a solution for the output from the PLC to the PIC, but what about the output from the PIC to the PLC?
I still prefer the optocoupler solution for both sides.
Alfredo
Please don't go with the 7805. I tried this and was bad idea, i couldn't hunt down a counting problem i was having and it turned out to be the regulator. Regulators will only work if your inputs don't change very fast, the regulators are kinda slow. I used it to interface to a gear sensor and was losing a lot of pulses. Def stay with the optos. Good isolation and reliable.
Does your PLC have some kind of monitor function from a serial port? You could just hook up the PIC to the PLC serially then and just process the monitor codes the PLC sends out.
Or are you planning to use the PIC to watchdog the PLC?
Otherwise, using optos is the best way. All the signals to the PIC would be inputs, because you are monitoring the inputs and outputs of the PLC. So the optos would be all connected the same way, with the LED connected to the PLC signals on the anodes through a current limiting resistor, and gnd on the cathodes. Pick your resistor so you get minimum on current for the LED with about 5VDC and less than maximum with 24VDC. Remember that the LED has a forward voltage that needs to be subtracted before you calculate the current though the resistor. On the PIC side, connect the emitter to gnd and the collector to +5VDC though a 500-1k ohm resistor. Connect the PIC pin between the resistor and the opto collector. This will create an inverter, so remember to invert the signals in the PIC code.
Tim Barr
Bookmarks