AC554ETH-eco: Size of an Array variable differs in PLC and Simulator!
Size of user defined data types in the PLC and the simulator differs!
For the following ARRAY:
Unit AT %MW0.100: ARRAY [0..UNITNR] OF UNIT; with
TYPE UNIT :
DevSts: USTATE:=TURNOFF; (*TURNOFF, TURNON*)
DevMode: UMODE:=LMAN; (*NORM, LMAN, OS, FAILURE*)
OnPrc: WORD; (* PWM % On Time*)
TtlCycles: WORD; (*Total On/Off Cycles*)
TtlDayTime: REAL; (*Total On Time per day in minutes*)
TtlRunTime: REAL; (*Total Run Time *)
LastErrTime: DT; (*Time of last Error*)
ErrCnt: WORD; (*Unit Error Counter*)
TYPE USTATE :(TURNON,TURNOFF); END_TYPE
TYPE UMODE :(NORM, LMAN, OSMAN, FAILURE, NEWFAIL); END_TYPE
SIZEOF(UNIT) = 22 bytes and SIZEOF(UNIT) = 242 bytes when compiled for Simulation, corresponding target compilation numbers are 24 and 264 bytes!!!
All efforts to find something on the chosen method for alignment of STRUCT and ARRAY in the PLC memory led to no result!
Any hint will be appreciated!
Thnx in advance!
My guess is that bit are handled differently in simulation and inside the PLC.
Bool values take up 1 byte in the PLC memory and the simulation tool probably handles the bool values as bits.
The 2 first values in your struct are bool as I can see so that might be the issue.