Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Create a "standard project" and select "CODESYS Control for Raspberry Pi SL" as the device.
  • Define the target system via Network search.
    Image Removed
    Image Added

  • Insert an Ethernet adapter, a Modbus_TCP_Master and a Modbus_TCP_Slave in the device tree.
    Image Removed
    Image Added

  • Adapt the "PLC_PRG" as follows:
    Image Removed
    Image Added


Requirements for the Modbus slave

  • Create a "standard project" and select "CODESYS Control Win V3" as the device.
  • Define the target system via Network search (see Modbus master).
  • Insert an Ethernet adapter and a Modbus_TCP_Slave_Device in the device tree.
    Image Removed
    Image Added

Setting on the Ethernet adapter (master and slave)

...

Note

If no target system is determined, an error message appears, "Gateway not configured"


Image RemovedImage Added

Setting on the Modbus_TCP_Slave (master)

...

  • Enter the IP address of the slave device (in this case the CODESYS Control Win V3)
  • Issue a unique ID for the Modbus configuration

...


  • Image Added

Tab 'Channel'

  • Create an input register (counter that is sent by the Modbus slave device) – cyclic update every 100 ms.
    Image Removed
    Image Added

  • Create an output register for writing your own counter.
    Image Removed
    Image Added

  => Image RemovedImage Added

I/O mapping

  • Assign input and output variables.

Note

The setting of the option "Enabled 1" is necessary, since the variable "xExec" is not used in any task and writing would therefore not work.

...


Image Added


Settings on the Modbus_TCP_Slave_Device (slave)

Tab 'General'

  • Activate monitoring of the communication

    .

...

  • .

    Image Added

    Warning

    The unit ID must not be used for Modbus TCP!
    This is only used for TCP/RTU gateways.

    Info

    The unit ID is only used for forwarding (gateway) to a Modbus Serial Bus.
    For TCP/IP, the MODBUS-Server is addressed by means of the IP address. In this case, the MODBUS unit ID is not used (the value 0xFF has to be used).
    For a serial connection, the Modbus devices are addressed with unit IDs from 1 to 247 (0 is used for broadcast addresses).

Tab 'I/O mapping'

  • Assign input and output variables.

...


  • Image Added


Downloading and starting the projects

...

  • Load the application to the controller.  
    Image Removed
    Image Added

Slave

  • Load the application to the controller

Note

The value changes only after transmission has been triggered manually in the master.


Image RemovedImage Added