ZhivkoPetkov
ZhivkoPetkov

Reputation: 33

Twincat 2: Initial values are not zero

In my TwinCat 2 project, when I am initializing variables, their default value is not zero.

TPS750 : BOOL;
TPS750_OEE : REAL;
TP750_Perf : REAL;
TP750_Aval : REAL;
TP750_Qual : REAL;

When I start the project, the values are:

TPS750 = FALSE;
TPS750_OEE = 0;
TP750_Perf = 524288;
TP750_Aval = 3380.893;
TP750_Qual = 656709.1;

You can see, the first two are ok, but next ones are with a strange value for me. What can be the cause of this problem?

Upvotes: 1

Views: 222

Answers (2)

owillebo
owillebo

Reputation: 665

Please initialize variables explicitly. If you don't it is up to the compiler to do this or not and how. Note that many compilers do not zero out uninitialized variables so that these variables get a value based upon what happens to be in memory when you run your code.

Upvotes: 0

Filippo Boido
Filippo Boido

Reputation: 1206

Either those are initialized somewhere in the project and you don't see it or they are persistent values.

Persistent values are declared inside the

VAR PERSISTENT

END_VAR

definition.

Upvotes: 0

Related Questions