It depends on the model PLC that you have. Many have this capability built into their operating system. The brand I am most familiar with, Koyo (Automation Direct), has specific memory locations that can be written to and output through their RS232 ports. The necessary coding is well documented in their programming manual.
__________________
The older I am, the better I used to be