Automatic xExecute NBS.TCP_write

brell
2024-03-05
2024-03-05
  • brell - 2024-03-05

    I've recently started experimenting with CODESYS for a project and am fairly new to it. I'm currently working with Function Block Diagrams (FBD) to set up TCP communication between a server and a client, where the client is implemented as a Python script. Once the communication is established, my connection status changes to True, which is the expected behavior.

    My challenge arises with the TCP write module, which requires the xEnable_write flag to toggle between True and False. If xEnable_write remains True, the module only performs a single write operation. To address this, I introduced a falling edge trigger (F_TRIG), expecting it to help in toggling xEnable_write and it does, However, I've encountered an issue where in the beginning after connxion established I need to manually set xEnable_write to True for the system to work as intended. I'm looking for a way to automate this process so that xEnable_write becomes True automatically upon establishing a connection .

    Initially, I tried setting xEnable_write to True from the start, but this approach didn't work well since it left the flag permanently True, preventing further toggling. I also experimented with using a TON timer, but I faced similar issues.

    I am seeking a solution that automatically toggles xEnable_write between True and False after a connection is established, ensuring continuous write operations without manual intervention. Any advice or guidance on how to achieve this would be greatly appreciated."

     
  • TimvH

    TimvH - 2024-03-05

    Use e.g. the condition:
    TCP_Connection_0.xActive AND NOT(TCP_Write_0.xDone)

     

Log in to post a comment.