The variable define question???

renesas
2012-02-03
2023-08-17
  • renesas - 2012-02-03

    Hello all:
    I had see a example ,the variable define like:
    VAR
    STATE AT %I: BYTE;
    DATAIN AT %I
    : WORD;
    CTRL AT %Q: BYTE;
    DATAOUT AT %Q
    : WORD;
    END_VAR

    My question is "%I*" ???What is it mean???

     
  • RolandWagner

    RolandWagner - 2012-02-03

    This is the so called VAR_CONFIG.

    The idea is that you can define FB with I/O access. If you do that in the standard way

    VAR
    STATE AT %IX0.0: BYTE;
    ...
    END_VAR
    

    you will not be able to use instances of FBs with different I/Os, because the access to the process image is fixed.

    With the VAR_CONFIGs you can leave the implementation of the acccess to the I/Os open to the instances. In the object "Variable_configuration" under the register card "Resources" in the folder "Global Variables" you can the terminate, which instance should use which I/O.

    Example:
    You define an FB with your declarations.
    You declare two instances of the FB (Inst1, Inst2)
    * You terminate which I/Os the instances should access to: Open the "Variable_configuration", mark everything (including the VAR_CONFIG/ END_VAR), call the command under "Insert/All instance Paths" ==>

    VAR_CONFIG
       PLC_PRG.inst1.STATE AT %I : BYTE;
       PLC_PRG.inst1.DATAIN AT %I : WORD;
       PLC_PRG.inst1.CTRL AT %Q : BYTE;
       PLC_PRG.inst1.DATAOUT AT %Q : WORD;
       PLC_PRG.inst2.STATE AT %I : BYTE;
       PLC_PRG.inst2.DATAIN AT %I : WORD;
       PLC_PRG.inst2.CTRL AT %Q : BYTE;
       PLC_PRG.inst2.DATAOUT AT %Q : WORD;
    END_VAR
    

    Now you can write the specific address in it. E.g.

    VAR_CONFIG
       PLC_PRG.inst1.STATE AT %IB0 : BYTE;
       PLC_PRG.inst1.DATAIN AT %IW10 : WORD;
       PLC_PRG.inst1.CTRL AT %QB0 : BYTE;
       PLC_PRG.inst1.DATAOUT AT %QW10 : WORD;
       PLC_PRG.inst2.STATE AT %I B1: BYTE;
       PLC_PRG.inst2.DATAIN AT %IW11 : WORD;
       PLC_PRG.inst2.CTRL AT %QB1 : BYTE;
       PLC_PRG.inst2.DATAOUT AT %QW11 : WORD;
    END_VAR
    

    I hope this will explain you the function

     
  • renesas - 2012-02-05

    Thank you for your explain!!

     

Log in to post a comment.