Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Initial values for structures

Triodes
2018-09-14
2018-09-18
  • Triodes - 2018-09-14

    I have several controls (ie motors) running that have a structure for all related tags

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

    then use the structure for sensors

       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

    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?

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

    Thanks!

     
  • Anonymous - 2018-09-14

    Originally created by: Viacheslav Mezentsev

    Try something like this:

    Poly1: TPolyData := ( coeff := [ 0, 0.1 ], lim := 6553.5 );
    Poly2: TPolyData := ( coeff := [ 0, 0.2 ], lim := 6553.5 );
    
     
  • Triodes - 2018-09-18

    Things can be so simple sometimes Thank you for that!!!!

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

Log in to post a comment.