Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  • Create a "Standard project" and select CODESYS Control Win V3 as the device.
  • Define the target system by means of the Network scan.



  • Open the Library Manager and add the following libraries:
    CmpApp
    SysTypes2 interfaces


    Activate the automatic generation of the project information in Project/Project information:
    Image Removed

  • Create a persistent variable named PersistentVars.

    Adapt PersistentVars as follows:



    Section
    Column
    width7

    Declaration

    Column
    width93
    Code Block
    themeConfluence
    {attribute 'qualified_only'}
    VAR_GLOBAL PERSISTENT RETAIN
        xAutoRestart     : BOOL;
        udiCnt            : UDINT;    
    END_VAR




...

  • Adapt the POU PLC_PRG as follows:


    Section
    Column
    width7

    Declaration

    Column
    width93
    Code Block
    themeConfluence
    VAR
    	sAppName      :    STRING := 'Application';
        result        :    RTS_IEC_RESULT;
        
        instPrjInfo   :    CmpApp.PROJECT_INFO;
        pPrjInfo      :    POINTER TO CmpApp.PROJECT_INFO := ADR(instPrjInfo);
        pApp          :    POINTER TO CmpApp.APPLICATION;
        udiState      :    UDINT;
        udiOpState    :    UDINT;
        xInit         :    BOOL := TRUE;
        xReset        :    BOOL;
    END_VAR




    Section
    Column
    width7

    Implementation

    Column
    width93
    Code Block
    themeConfluence
    IF xInit THEN
        pApp := CmpApp.AppFindApplicationByName(pszString := sAppName, pResult := ADR(result));    
        // Flag "Automatically generate 'Project Information' POU's must be set
        CmpApp.AppGetProjectInformation(pApp := pApp, pInfo :=pPrjInfo);
        xInit := False;
        PersistentVars.xAutoRestart := False;
    END_IF
    
    IF xReset THEN
        xReset := FALSE;
        PersistentVars.xAutoRestart := True;        
        CmpApp.AppReset(pApp := pApp, usResetOption := CmpApp.RTS_RESET);
    END_IF




...