Code for using the serial ports of PAC-S2


I need to use the serial ports in a PAC-S2 controller.
In my application, the controller will control a stepper motor drive by sending strings commands via serial port and will receive back values in plain strings with an EOT character at the end.

I got the ports configured by PAC Manager as RS485 - PPP - 4 Wire - No Termination - No Bias.

Is there any example code I can use as a reference?


Hi Rudy,

Be sure to check out this 101 post which includes links to some serial examples at the bottom.

However, you mention getting the ports configure by PAC Manager, which is lovely, but you might consider adding code to do the same in your strategy, so that all of your settings/logic are in one place, and if later you want to move this strategy to another PAC-S2 it’ll be 1 step, all self-contained. We have PAC Control commands to write to those memory map addresses, e.g. “Write Number to I/O Unit Memory Map” (where, in this case, you’d create an I/O Unit of type “Generic OptoMMP Device” w/ the loopback address of: and write the values to that).

Also, you mentioned PPP (I’m assuming you mean for that “Control Function…” setting) but I doubt that’s what you meant, most likely, for the application you have, you want “None” instead. You have your S2 wired directly to that serial 485 link, yes?