Interfacing between the PLC and the robot (which was controlled by a PC) was one of the key challenges that we had to deal over the course of this project. We needed to tell the robot when it needed to load a part, as well as when it needed to unload a part, and we also needed the robot to tell the PLC when it was done loading or unloading.
Our initial idea was to use a USB-relay module to both read inputs from the PLC and write outputs to it. However, we could not find a relay module that supported both reading and writing to relays. Therefore, we decided to use an Arduino Uno as a "signal adapter" between the PLC and PC on the input side. In this design, the PLC outputs flip I/O pins on the Arduino, and the Arduino then converts those signals to serial data and outputs that data to the PC. The USB-Relay module was used to tell the PLC when the robot was done loading or unloading (depending on which relay was flipped).
In order to convert the 24V signal from the PLC output to a 5V signal that the relay can understand, we designed a small voltage regulator circuit, as shown below.
The diagram of the robot interface subsystem.
The circuit I used to regulate the PLC output voltage for the Arduino pins. On the final design, two of these circuits (one for each Arduino pin) were soldered onto the perfboard.
One thing we later realized was that using Modbus would likely have made this interface much easier. We initially considered using Modbus, but we thought that the PLC we were using did not support it (which it did). When we later realized our mistake, we had made enough progress with the interface that we decided it would be easier to finish implementing it using our initial idea instead of trying to pivot. However, implementing Modbus communication would have saved us a significant amount of space in the control panel and would almost certainly be more reliable in the long-term, and if we are able to continue this project we will definitely implement it.