pritesh07
Hi, I am having multiple issues with userdefined data types and timer initialization

Part 1: - userdefined data types (see screenshots below)
I am trying to call in my ST program 'datatype0' which is a Structure with 'Start : DINT := 5;' and 'finish : BOOL := 0';

I am assign a variable 'x.datatype0.finish' and the system keeps generating invalid statement error and I don't know how to solve this. I've used codesys before and I am declaring it just like codesys and having issues. 

Part 2: timer initialization

Is there a way to initialize timers by inputting parameters in the initial value field. After I compile it, it ignores the initial value field in the VAR portion of the .st file.
 I wanted "timer:TON:=(0,5000,0);" in lieu of  "timer : TON;"

Part1_1.png

Part1_2.png
Quote 0 0
thiagoralves
The syntax is x.start and x.finish instead of x.datatype0.start and x.datatype0.finish.
You cannot put values in the initial value field for timers. Timers are function blocks, and therefore their values are initialized upon declaration (i.e. when you use them on the code).
Quote 0 0
pritesh07
Thanks for the reply!

'M12' to class= external and type=datatype0 (datatype0 is a structure consisted of finish = Bool and start = DINT)
'Q4' to class = local and type = bool

In my main program I've assigned  (per the picture above in my original post. When I write a simple program Q4 : = M12.finish; I still get error: invalid statement in ST statement.

----------------------------------------------------------------------
I also tried the following and I still get the same error

'integer1' to class= external and type=datatype0
'integer2' to class = local and type = DINT

integer2:= integer1.start;
Quote 0 0
pritesh07
Hi,

Never mind, I figured it out. I had an extra space between ': ='.  Thanks for your guidance.
Quote 0 0
pritesh07
Hi,
I have another question related to datatypes....

I am trying to do the following and I get an error when I assign an LocalVar2 in the global var declaration. The LocalVar0 and LocalVar1 compiles fine

VAR_GLOBAL
LocalVar0 : datatype1;
LocalVar1 : ARRAY [1..50] OF INT;
LocalVar2 : ARRAY [1..50] OF datatype1;
END_VAR


I get the following error....
PLC :
[CC] Config0.c -> Config0.o
C:\temp\openplc\build\Config0.c: In function 'config_init__':
C:\temp\openplc\build\Config0.c:24:3: error: expected expression before ',' token
"gcc" -c "C:\temp\openplc\build\Config0.c" -o "C:\temp\openplc\build\Config0.o" -O2 "-IC:\temp\Downloads\OpenPLC Editor v1.0 - Windows\OpenPLC Editor\matiec\lib\C" -Wno-unused-function
exited with status 1 (pid 19984)
C compilation of Config0.c failed.
C Build failed.


Please advise!
Quote 0 0
pritesh07
Hi,

To clarify further datatype1 is an Array

datatype1 : ARRAY [1..50] OF BOOL;
Quote 0 0
thiagoralves
It looks like there is a bug in MatIEC about arrays of user datatypes. I'll put it on my to-do list of items to fix. Thanks for reporting.
Quote 0 0