RocketTester
Member
Peter,
I am shooting from the hip and out of my league, but offer a bit. I just reviewed some of my code in VB.net and TwinCAT (CodeSys variant).
In VB.net, you define a structure with:
Structure StructureName
element AS vartype
...
End Structure
You can then declare variables to be that structure type, and they can be arrays. Help says you can declare a structure within a structure (haven't tried). It also says structures can include procedures (subroutines), similar to classes (above my pay grade).
In TwinCAT, you define structures in the "Data Types" tab. Below is one of mine:
TYPE TraceHistory :
STRUCT
TseqTime : LREAL;
event : UINT;
CHjmp : USINT;
level : REAL;
END_STRUCT
END_TYPE
You can then define variables to be of that structure type, and they can be arrays. I don't know if you can put a structure within a structure. The variables can be declared local to the POU by putting them at the top of the program block as:
PROGRAM Sequence
Var
TraceCurr : TraceHistory;
END_VAR
or under "Global Variables" in the "Resources" tab:
VAR_GLOBAL
Trace : ARRAY [1..Ntrace] OF TraceHistory;
END_VAR
Variable declarations are the same whether using ST, LD, or any of the IEC61131-3 languages, though the syntax is like ST.
In sum, TwinCAT variable declarations appear similar to VB.net, but the nomeclature varies. As I recall, structures were declared in VB6 using TYPE ... END_TYPE. I am clueless about what all this means at the compiler level.
Glad you are developing an ST compiler. We use several of your Delta Motion controllers and several engineers have started writing code for them in Delta's current language. Having more standard PLC programming would be very helpful and ST is best for engineers with no prior exposure to PLC's.
I am shooting from the hip and out of my league, but offer a bit. I just reviewed some of my code in VB.net and TwinCAT (CodeSys variant).
In VB.net, you define a structure with:
Structure StructureName
element AS vartype
...
End Structure
You can then declare variables to be that structure type, and they can be arrays. Help says you can declare a structure within a structure (haven't tried). It also says structures can include procedures (subroutines), similar to classes (above my pay grade).
In TwinCAT, you define structures in the "Data Types" tab. Below is one of mine:
TYPE TraceHistory :
STRUCT
TseqTime : LREAL;
event : UINT;
CHjmp : USINT;
level : REAL;
END_STRUCT
END_TYPE
You can then define variables to be of that structure type, and they can be arrays. I don't know if you can put a structure within a structure. The variables can be declared local to the POU by putting them at the top of the program block as:
PROGRAM Sequence
Var
TraceCurr : TraceHistory;
END_VAR
or under "Global Variables" in the "Resources" tab:
VAR_GLOBAL
Trace : ARRAY [1..Ntrace] OF TraceHistory;
END_VAR
Variable declarations are the same whether using ST, LD, or any of the IEC61131-3 languages, though the syntax is like ST.
In sum, TwinCAT variable declarations appear similar to VB.net, but the nomeclature varies. As I recall, structures were declared in VB6 using TYPE ... END_TYPE. I am clueless about what all this means at the compiler level.
Glad you are developing an ST compiler. We use several of your Delta Motion controllers and several engineers have started writing code for them in Delta's current language. Having more standard PLC programming would be very helpful and ST is best for engineers with no prior exposure to PLC's.