Hi everyone,
I'm new to PLC development, specifically, this question pertains structural text program-only workflow.
I’m currently trying to get together a basic workflow for creating a structural text program-only based environment in Sysmac Studio.
My setup is:
NX1P2-9024DT1
Sysmac Studio v1.54
Windows 11 Pro
I’ve been able to create a new project -> delete the default ladder program0 -> add in a new ST program0 -> and pasted the following: IF (InputSignal = TRUE) THEN
BIO_Output_Bit_00 := TRUE; // Turns on '00' output
BIO_Output_Bit_09 := TRUE; // Turns on '09' output
ELSE
BIO_Output_Bit_00 := FALSE;
BIO_Output_Bit_09:= FALSE;
END_IF;
And I can add in an HMI with a linked-InputSignal button and linked-BIO_Output_Bit_00 and it will simulate with no issues.
However, I’m trying to achieve a basic hello world-like skeleton ST base script where there is a program entry, variable declarations, etc.
In C, it would be the equivalent:
#include <headers>
#global variables here…
int main()
{
# some local variables
# main code, etc…
}
In the case of Structural Text, I’ve been reading online and seeing in tutorials, the basic program appears to be:
PROGRAM Main
VAR
Counter: INT := 0;
END_VAR
METHOD IncrementCounter : BOOL
Counter := Counter + 1;
RETURN TRUE;
END_METHOD
METHOD MainTask : BOOL
IF IncrementCounter() THEN
// Do something when the counter is incremented successfully
END_IF
RETURN TRUE;
END_METHOD
However, when I try to add this code or anything similar, Sysmac Studio does not recognize the PROGRAM or VAR/END_VAR or METHOD/END_METHOD keywords.
I’ve gone into more detail in W501 – NJ/NX-series CPU Unit Software User’s Manual but it provides usage details for the different variable types, constructs and expression definitions etc.
There isn’t details on how to set-up a generic program and how to implement it into a new project. Is there any literature separate from W501, are you able to provide an example ST project script that can demonstrate what I am trying to achieve?
My guess is that it should be possible – I’ve seen MATLAB generated PLC ST code that uses the VAR/END_VAR, FUNCTION_BLOCK/END_FUNCTION_BLOCK etc keywords and simulated with no errors. Probably an implementation detail on my end(?).
Please and thank you – much appreciated in advance for your help/assistance.
Regards,
Ron.