Most process or manufacturing plants have PLC control panels which get inputs from variety buttons, switches and to activate relays, solenoid valves etc. In many cases, they use 24V DC power supply for PLC CPUs and/or for I/O modules. For 24V DC relays, they can drive directly to 24V DC solenoid valves, coils etc. To activate higher voltage such as 380-460V AC 3 phase motor , these relays will switch to other 3 phase relays or contactors.
For non-critical use and not worrying the latency , we can build simple 5V to 24V DC I/O adapter which can be used with our Microcontrollers to drive 24V DC rating relays or supplying those switches/buttons.
Don’t get confused with the schematic above !. Yes., it works. The reason there are two “optocouplers” above ( well ,actually only one optocoupler, I will explain later) is that we can use GPIO from our AVR, PC , Arduino boards etc like we intended. For example we can use Pin 1 as input OR output from the same block diagram above. Let says we have 8 I/O pins, each pin will go to both red and green block so we just need to focus on our code/program without worrying which one is for input or output.
HOW IT WORKS:
(See the picture) The main part here is 4N29 optocoupler which “drive ” either 5V DC to 24V DC or from 24V DC to 5V DC. The red square on the picture is a 4N29 socket for output ,and the green one is a socket for input. We have two sockets but we only need one optocoupler IC . When output signal needed , move this IC to the red one, otherwise we put it on green socket. Never never put ICs on both them at same time. So where is real hardware/devices can be attached to ? It is on blue square. Put these relays, bulbs, solenoids and 24V DC rating switches, buttons here .