Change modbus server parameters from program

brzozka100
2024-07-16
2024-07-17
  • brzozka100 - 2024-07-16

    Hello,
    is there a possibility to change modbus server parameters (baud rate, parity, etc.) configured in devices tree from PRG?
    I need to be able to change them, for example, from HMI.

     
  • kislov - 2024-07-17

    Use in IEC-code:
    Modbus_Serial_Device.UpdateComPortSettings(...)
    https://content.helpme-codesys.com/en/libs/IoDrvModbusSerialSlave/Current/pou-ModbusSerialDeviceDiag/UpdateComPortSettings.html

    Take note: "Only possible if server is disabled (see xEnable Input)"

    So:

    1. Modbus_Serial_Device.xEnable := FALSE;
    2. Modbus_Serial_Device.UpdateComPortSettings(...)
    3. Modbus_Serial_Device.xEnable := TRUE;

    Please note that after PLC reboot the values from the GUI (from your screenshot) will be applied again. So you need to save values from HMI in RETAIN and restore them after start of application.

     

    Last edit: kislov 2024-07-17

Log in to post a comment.