CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Wed Dec 19, 2018 10:15 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Sep 14, 2018 2:26 pm 
Offline

Joined: Wed Jan 31, 2018 1:08 pm
Posts: 8
I have several controls (ie motors) running that have a structure for all related tags


Code:
TYPE stSensors:
   STRUCT
      EU:          real;
      DU:         word;
      Level_L:      real;
      .. etc
   END_STRUCT
END_TYPE


then use the structure for sensors
Code:
   Sensor1:      stSensors;
   Sensor2:      stSensors;
   Motor1:      stMotors;
   etc



When you'd have these tags defined individually you could list an initial value so that it is not zero

Code:
Sensor1_LevelHH: REAL := 25.0;



I'd like to do the same with the tags defined in the structure, but the same structure is used several times, meaning I can't define these initial values in the structure definition.

My question: Is there a way to set initial values for each structure instance?

Code:
Sensor1.LevelHH := 25.0;
Sensor2.LevelHH := 23.3;
Sensor3.LevelHH := 5.0;
etc.


Thanks!


Top
   
PostPosted: Fri Sep 14, 2018 3:42 pm 
Offline
User avatar

Joined: Fri Feb 10, 2017 6:12 am
Posts: 56
Try something like this:

Code:
Poly1: TPolyData := ( coeff := [ 0, 0.1 ], lim := 6553.5 );
Poly2: TPolyData := ( coeff := [ 0, 0.2 ], lim := 6553.5 );


Top
   
PostPosted: Tue Sep 18, 2018 12:32 pm 
Offline

Joined: Wed Jan 31, 2018 1:08 pm
Posts: 8
Things can be so simple sometimes :) Thank you for that!!!!

Code:
Sensor1:          stSensors := (LevelL:=10, LevelH:=90);


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited