Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Modbus cycle timing compared to PLC cycle timing

mikeardy
2018-07-12
2018-07-13
  • mikeardy - 2018-07-12

    Hi,
    I'm not completely sure on how Modbus cycle time operates compared to PLC cycle time.
    In an application, I need to read a lot of Modbus variables from remote devices.
    I'm wondering if the reading cycle of the Modbus was connected or not connected with the PLC.
    Let me explain clearly using a real case. To permit data consistency inside the application program, all data must be acquired before the PLC program execution cycle starts. If the Modbus reading process is not "synchronized" with the PLC, it could happen a consistency data lost: that means that a variable can change during running (due to Modbus cycle reading process) with not predictable results.
    Searching inside MODBUS MASTER Parameters I discovered a setting called "OptimizationOn" that was TRUE (see picture).
    Is this flag responsible for the cycle time of the Modbus?

    IMG: CODESYS_MODBUS_SETTINGS_1.PNG

     
  • fleaplc

    fleaplc - 2018-07-13

    I suppose optimization it's related to reducing numbers of Modbus request (ex. you defined to read address from 40001 to 40010 and from 40020 to 40030: in stand of 2 reading call the optimization read the entire area (from 40001 to 40030).
    About sync between modbus scan and PLC cycle I think it's not possible..usually, when CPU starts, I set a certain number of "empty" cycle (just put a return in PLC_PRG). In the meantime empty cycles runs, Modbus updated required variables.
    Or you can manually defines (modbus library) a POU for Modbus client and "interlock" the execution of logic code with properly modbus response..but in this way you're depending on network delay, comm timout,...(in my opinion not the best way)

     

Log in to post a comment.