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

about TYPE AND END_TYPE

2014-10-19
2014-10-22
  • peterchowhe - 2014-10-19

    Good days,:

    Please give us the explainantion how to use the TYPE AND END_TYPE, NO Sturecture

    like below:
    "
    TYPE DataTypeEnum_EngineType :
    (MtuT4, CATT3, PerkingsT3);
    END_TYPE

    "
    HOW TO Define the value to " DataTypeEnum_EngineType" inside of "()"

     
  • Anonymous - 2014-10-20

    Originally created by: scott_cunningham

    To define an ENUM, use TYPE and END_TYPE with ( and ); inside like this:

    TYPE T_MACHINE_STATE :
    (
       BOOTING,                           //0
       INIT,
       WAITING_FOR_ETHERCAT_BUS,
       STARTING_DEVICE_CHECK,
       CHARGING,
       WAITING_FOR_INPUT_RUN,  //5
       RUN_ACCELERATION,
       RUN_AT_SPEED,
       STOPPING,
       ESTOP,
       ESTOP_RESET,                 //10
       CODE_FAULT
    );
    END_TYPE
    

    It is also possible to force certain values and the datatype (in this example it should be a DINT) like this:

    TYPE BigEnum :
    (
       yellow,
       blue,
       green:=16#8000
    ) DINT; 
    END_TYPE
    

    NOTE! I believe it is important to NOT have a comma (",") after the last ENUM item!

     
  • shooter - 2014-10-22

    to give a value:
    etype : DataTypeEnum_EngineType ;
    in declaration
    (MtuT4, CATT3, PerkingsT3);

    in program etype.MtuT4:=value;

     

Log in to post a comment.