Explainer
What the XSUB1 Block in a 505 Program Actually Does
Short answer
XSUB1 in a TISOFT 505 program is compiled special-function code that runs PID loops; it is not a serial driver for the MP370 panel. The RS-232 link to the panel needs no XSUB and no special program — the panel project carries its own 505 driver and the CPU port only has to match it. On TI545, TI555 and CTI 2500 CPUs the loops are integrated, so the block's job moves to native PID at the next planned change.
On this page
The XSUB1 you found in a SIMATIC 505 TISOFT program is compiled special-function code that executes PID loops. It is not a serial driver for the MP370 panel. The RS-232 link between the CPU and the panel needs no XSUB and no special program at all: the panel project carries its own 505 communication driver, and the CPU side only has to present matching port parameters. On TI545, TI555 and CTI 2500 CPUs the PID loops are integrated as a standard function, so the block has no job there either. This article shows what the block is, how to prove from the program itself what it touches, and when to keep it or migrate it to native loops.
What an XSUB block is #
An XSUB is the most unusual construct in the TISOFT instruction set. The routine behind the call is written in the C programming language, compiled to executable object code and stored inside the program as a numbered call such as XSUB1. It was used rarely, so many 505 programs never contain one.
The compiled form hides the source. In TISOFT you see the call and its operand list; the statements doing the work are not displayed. 505 programming packages expose the routine through a dedicated special-function editor — PLC WorkShop, for example, names its editor the SF Program and Subroutine Editor. That shape sets the method for the whole article: you cannot read what XSUB1 does, so you test what the machine depends on and record what the block touches. Those two checks identify it completely.
Why XSUB1 is not the MP370 driver #
A serial connection from a 505 CPU to an MP370 needs no XSUB and no special program. The 505 driver lives on the panel: the HMI project, configured in ProTool or ProTool Pro, selects the driver and holds the port settings, and the CPU side supplies the matching parameters on its serial port. The chain therefore runs whether or not any XSUB is called — the worked example below runs that test end to end.
The confusion has a source. A document reference titled "505 XSUB driver to support COROS HMI Protool Rel 5.2x" exists for this class of block, and the word driver in the title reads like panel communication. Judge the block by dependence, not by a title: if the panel keeps updating while the call is bypassed, the block carries no communication function, whatever the paperwork is called. The description available for XSUB1 covers loop execution, not panel communication.
Five parameters actually carry the link: baud rate, data bits, parity, stop bits and station address, set once on each side. The same five settings travel with the link if it later moves off the RS-232 port onto a two-wire RS-485 line, as walked through in Migrating an HMI serial connection from RS-232 to RS-485. For the cable and connector side of the check, the same end-by-end method is set out in Wiring a Host Link serial cable from PLC to HMI.
What the operand list tells you #
Identify XSUB1 from its call interface. Find every rung that calls it and record three things for each operand: the type (V memory, WX or WY word I/O, K constant), the address, and the direction — read, write, or both. A PID loop executor shows a recognizable pattern:
- a setpoint and a process variable, read from analog input words or from scaled values in V memory;
- a control output, written to an analog output word or a V location;
- tuning constants (gain, reset, rate) and mode flags, held in one contiguous block of V memory.
If the list matches that pattern, treat XSUB1 as a loop executor and stop looking for a communication role. Next, cross-reference the block's addresses in the data-use listing: the ladder rungs and the HMI tags that read or write the same words are the block's real connections. The panel displays setpoint, PV, output and mode from that block through ordinary driver reads and writes, so the tags — not the block — are the link between panel and loop.
Two checks sharpen the picture. Confirm the analog words map to physical points on the I/O modules, which pins the loop to hardware. Then look at the scan path around the call: a loop executed from program code updates when its call runs, so a conditionally executed call means a varying update rate.
Working the case: XSUB1 beside an MP370 on RS-232 #
Inputs, and where each comes from. The program contains an XSUB1 call, the panel is an MP370 configured in ProTool Pro, and the link runs on the CPU's onboard RS-232 port — the reader's own case. For numbers, take the five port readings from each side. Example readings: the panel project shows 9600 baud, 8 data bits, even parity, 1 stop bit and station address 1; the CPU port, as found, shows 9600 baud, 8 data bits, odd parity, 1 stop bit and station address 1. Your own project and port screen hold your own values.
The rule in words. A serial HMI link needs all five port parameters identical on both ends, and a program block belongs to the link only if the panel stops communicating when that block is bypassed.
The arithmetic. Compare the five parameters: baud equal, data bits equal, stop bits equal, station address equal, parity different — even against odd. That is 4 of 5 matching and 1 mismatch. One mismatch is fatal, because with opposite parity the panel cannot frame the CPU's characters and the link fails at the port before any program code is reached. Set the CPU port to even parity: the comparison becomes 5 of 5. Now bypass the XSUB1 call — on a bench CPU or with the loop in manual, never on a live automatic loop, because bypassing it takes the loop's output update with it — and watch the panel: live values keep updating.
The result. The link runs on the panel's own 505 driver plus five matched port parameters, and XSUB1 contributes zero functions to it.
The decision, with its threshold. Zero parameter mismatches plus live data with the call bypassed proves XSUB1 is not the driver. Read the operand list next: if it shows the setpoint, PV, gain and output pattern, XSUB1 is loop code — keep it on a CPU without integrated loops, migrate it on the integrated-loop CPUs described below.
Keep or migrate: the CPU decides #
Read the CPU type from the hardware, not from the project file name. The decision splits in two:
- TI545, TI555 and CTI 2500 CPUs integrate PID loops as a standard function. There is no reason to run loops through an XSUB on them, and the approach is not recommended for new implementations. Plan the migration into the next planned change and leave the working loop alone until then.
- Older CPUs without integrated loops have no native replacement, so the XSUB stays exactly as it is with a verified backup, and the program does not move to another CPU type without a loop-by-loop equivalence check.
Migration, in order. Back up the complete program and the current V-memory values, including every tuning constant and mode flag the XSUB uses. Obtain the functional description through the controller vendor's support channel, then map each XSUB parameter to its native counterpart: setpoint, PV, output, gain, reset, rate, sample time, direct/reverse action, output limits, manual/auto. Confirm units and scaling for every mapped value — a compiled block can take scaled engineering values where the native loop expects raw counts — and write the conversion for each parameter, not just the first. Configure one native loop for each XSUB loop, keep the same analog input and output points, repoint the ladder and the panel tags to the native loop data, and update the HMI project so setpoint, PV, output and mode follow. Remove the XSUB call only after the native loop has run in manual and then in auto against the process.
Do not copy tuning constants across blindly: the native loop's algorithm form, sample time and scaling can differ from the compiled block, so identical numbers can produce a different response in the same process.
Pin down what you are changing first: compare a saved program copy against the running one so every rung that calls XSUB1 is known — the methods are set out in comparing a saved TISOFT program against the running one. If the panel side is being retired with the block because the ProTool source is lost, the replacement decision follows the path in Replacing an old HMI when no project files exist. And if the link moves onto a plant SCADA client instead of a replacement panel, the OPC route from these CPUs is laid out in moving a TI505 HMI link onto an OPC SCADA client.
Questions asked
Can I recover the C source code of XSUB1 from the TISOFT project?
No. The block is stored as compiled executable code, so the project file contains the call, its operands and the code object, but not the C statements it was built from. Work from the call interface instead: record every operand, its address and whether the block reads or writes it, then map the V-memory block it touches. The vendor's functional description fills in what the operands cannot show.
Do the ProTool manuals document this block?
No. The ProTool user documentation covers the configuration tool and the panel side of the project: screens, tags, alarms and the communication driver the panel itself runs. A special function block inside the 505 program is controller-side code, which sits outside that scope, so searching the panel manuals for XSUB will not find it. The functional description travels with the controller documentation and comes from the controller vendor's support channel.
How do I transfer a migrated loop from manual to auto without bumping the output?
Set the native loop's setpoint equal to the current process variable first, hold the output where the manual step left it, then switch the mode. The loop should take over with no output step. After that, apply a small setpoint change and check that the response matches the old XSUB loop within process tolerance; if it does not, retune the native loop rather than copying the old constants a second time.
Is it safe to disable the XSUB1 call on a running process to test the panel link?
Not while the loop it runs is in automatic. Bypassing the call takes the loop's output update with it, and the controlled device can drift while you watch the panel. Put the loop in manual with the output held, or run the test on an offline copy of the program against a bench CPU, and keep an eye on the process variable. If the panel keeps updating with the call bypassed, the link never depended on it.