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.



  • Insert an Ethernet adapter in the device tree and specify the interface to be used.

    Note

    If a target system is not defined yet, then the error message "Gateway not configured" is displayed.




  • Insert a Modbus TCP Master below the Ethernet adapter in the device tree.

  • Insert a Modbus TCP Slave below the Modbus TCP Master in the device tree.



  • Insert it in the Modbus Slave Channel tab and set the properties as follows:



  • Adapt the POU PLC_PRG as follows:



    Section
    Column
    width7

    Declaration

    Column
    width93
    Code Block
    themeConfluence
    VAR
        xExec                :    BOOL;
        wMasterSend          :    WORD := 100;
        mbChannel            :    ModbusChannel;
    END_VAR




    Section
    Column
    width7

    Implementation

    Column
    width93
    Code Block
    themeConfluence
    mbChannel(slave := Modbus_TCP_Slave, xExecute := xExec);




  • Assign the variable wMasterSend to the output Channel 0[0] in the tab ModbusTCPSlave I/O Mapping.

    Image Modified

Info

Please note, that under the ModbusTCPSlave I/O Mapping tab, the 'Always update variables' is set to 'Enabled 1' :

Image Added

See also our OLH for Basic settings with Fieldbus Devices and I/O Drivers.


  • Start the project and set the variable xExecute to TRUE so that the new value is passed to the slave.