We added a set of Structured Text capable AOI’s so that Rockwell users can now use the ST language for writing MotoLogix programs.
With Library 2.0.0 for Rockwell we added the possibility to call MotoLogix functions from a Structured Text (ST) program.
Switching to ST
Although Ladder programming is very common among Rockwell users, switching to ST could be interesting – especially when you need to support multiple PLC platforms (e.g. Siemens S7-1500 and Rockwell).
Programs written in ST are easier to port between platforms and often this work can be (partly) automated, e.g. using find/replace with regular expressions .
Due to the way Rockwell functions (AOI’s) internally work we had to create an
additional set of AOI’s for ST.
These can be identified by the ST_
prefix (e.g. ST_MLxRobotMoveLinearAbsolute
).
ST_
functions for Ladder programming.Syntax
Rockwell uses a slightly different syntax for function calls compared to some other PLC platforms. Below table shows the comparison.
Rockwell | Others | |
---|---|---|
Function call | Function name followed by instance name: <function name>(<instance> …) | Only instance name: <instance>(…) |
Parameters | Only tag/value (without parameter name): (…, <1st parameter value/tag>, <2nd parameter value/tag> …) | Parameter name followed by assignment of tag/value: (…, <1st parameter>:= <value/tag>, <2nd parameter>:= <value/tag> …) |
Unfortunately, Rockwell does not allow the usage of user-defined data types for
function INPUT
parameters.
Therefore, we had to change these to IN_OUT
parameters.
IN_OUT
parameters are more efficient (call by reference),
the downside is that every IN_OUT
parameter has to be entered directly in the
function call.
If you want to write such a parameter from elsewhere (e.g. in a state machine),
it might require the use of an additional variable.This results in some incompatibility when porting ST logic from one of the other MotoLogix PLC platforms to Rockwell, as shown in below example.
// -----------------------------------------------------------------------------
// example: Rockwell
// note: TargetPosition must be in the call since it is an IN_OUT.
// -----------------------------------------------------------------------------
// AOI call
ST_MLxRobotMoveAxisAbsolute(FB_Move_Rest, Pos[0], MLX[0]);
// -----------------------------------------------------------------------------
// example: Codesys
// note: TargetPosition can be anywhere since it is an INPUT.
// -----------------------------------------------------------------------------
// declaration
FB_Move_Rest : MLxRobotMoveAxisAbsolute;
// somewhere in the program
FB_Move_Rest.TargetPosition := Pos[0];
// FB call
FB_Move_Rest(MLX:= GlobalVar.MLX[0]);