Codesys Instantiation Help

Join Date
Jul 2007
Location
Kiruna
Posts
600
Hi,


Has anyone ever done indirect addressing /instantiation in CodeSys 3.5?


I have an application where I have a lot of similar objects.(Valves, Pumps, instruments) etc. I've built the function blocks but can't for the life of me figure out how to instantiate them in CodeSys visualisation.


Any links or sample projects would be greatly appreciated.


Thanks
 
Hi,
Has anyone ever done indirect addressing /instantiation in CodeSys 3.5?
No sure whether this can help. I wrote a Codesys program to test three devices that my company developed. The devices work in EtherCAT, EtherNet/IP and PROFINET IO. The cyclic data or PDO is the same for the three protocols. I did a visualization that can select the device so the visualization shows the value of the selected device on the same screen, by means of indirect addressing.

First I defined some global variables, based on some user-defined data type, and as you can see the variables are mapped to actual IO. The I defined two pointers, one for the input and one for the output user-defined data type.
Code:
    AdvInpEIP       AT %ID0    :    T_LSM_InAdv;
    LSM_DatOutEIP   AT %QW0    :    T_LSM_Out;
    
    AdvInpPN        AT %IB184  :    T_LSM_InAdv;
    LSM_DatOutPN    AT %QB4    :    T_LSM_Out;
    
    AdvInpECAT      AT %IB368  :     T_LSM_InAdv;
    LSM_DatOutEC    AT %QB8    :     T_LSM_Out;
    
    pAdvInp            : POINTER TO T_LSM_InAdv;
    pLSM_DatOut        : POINTER TO T_LSM_Out;

    b_EIP_Selected        : BOOL := FALSE;
    b_PN_Selected        : BOOL := FALSE;
    b_EC_Selected        : BOOL := TRUE;
In one of the programs, the following happens, while in the visualizations I am using the pointers, not the actual variables. The functions below starting with T_ are rising triggers.

Code:
     T_Profi(CLK := GVL.b_PN_Selected);
    IF T_Profi.Q THEN
        GVL.pAdvInp            := ADR( GVL.AdvInpPN );
        GVL.pLSM_DatOut        := ADR( GVL.LSM_DatOutPN );
        GVL.b_EIP_Selected         := FALSE;
        GVL.b_EC_Selected        := FALSE;
    END_IF
    
    T_EIP(CLK := GVL.b_EIP_Selected);
    IF T_EIP.Q THEN
        GVL.pAdvInp            := ADR( GVL.AdvInpEIP );
        GVL.pLSM_DatOut        := ADR( GVL.LSM_DatOutEIP );
        GVL.b_PN_Selected         := FALSE;
        GVL.b_EC_Selected        := FALSE;
    END_IF

    T_ECAT(CLK := GVL.b_EC_Selected);
    IF T_ECAT.Q THEN
        GVL.pAdvInp            := ADR( GVL.AdvInpECAT );
        GVL.pLSM_DatOut        := ADR( GVL.LSM_DatOutEC );
        GVL.b_PN_Selected         := FALSE;
        GVL.b_EIP_Selected        := FALSE;
    END_IF
Finally, in the visualization, you need to address the text variables as, for example "GVL.pAdvInp^.STS._16iVALNUMDATA":
Hope this is useful.

2022-06-03_CodesysVisu_IndirectRef.PNG.jpg
 

Similar Topics

Hello to all, I'm just starting with using CodeSys. Immediately, I have noticed that Codesys doesn't use data blocks like for example S7 does...
Replies
11
Views
183
Hello, I am using a Hitachi Micro EHV+ for a small project, and I wanted to have a Web visu, done with Codesys V3.5 SP13 Patch 2. I test the...
Replies
7
Views
410
Hello, I have a requirement to manage the text alignment dynamically. So, for example: 1. English Texts should be displayed from Left in...
Replies
0
Views
107
Hello, I am new to Codesys, and am trying to learn about it for a project we're developing. I've got a couple questions, but first a little...
Replies
1
Views
183
Hi everyone, as this is my first experience with Rockwell Software i would like to know what's the best way to make Enumerations?
Replies
10
Views
537
Back
Top Bottom