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

Tasks πŸ†šοΈ TCP/IP πŸ†š Serial

2020-11-23
2020-11-23
  • andras-mozes - 2020-11-23

    Hello,

    I would like to ask for some advice.
    I mainly use the PLC as an IoT gateway, I mean, collecting signals, forwarding to MQTT broker.

    Now I have PROFINET devices, a serial device and a TCP/IP device.
    I don't want to put all the serial, TCP/IP communication into the main task as I want to use it only to forward signals to MQTT broker.

    I don't know how should I handle this case.

    I have an idea that I will create a global variable list in which I put data (write access) from TCP/IP Task and Serial Task while reading this GVL from Main task.

    I don't know if a GVL is enough itself or I have to use some task-local GVL for inter task communication?

    What approach should I use in order to avoid the blocking of the main (IEC) task?

    Thanks for your help in advance!

     
  • Morberis

    Morberis - 2020-11-23

    .... To cloud things more for you there is also the asynchronous job manager that you might find helpful.

    But why not put that bus communication in its own lower priority task? You could definately have that task write to a GVL, you could even have a seperate GVL for each communication bus. If you do it like that the MQTT task will execute first and then the lower priority tasks will execute. Just means that the MQTT will be reporting the status of the variables from the last read cycle. Also make sure that each task has enough cycle time to execute.

     
    πŸ‘
    1
  • aliazzz

    aliazzz - 2020-11-23

    I suggest a simple approach ;-)
    Divide all jobs in a separate task:

    1) A serial task with a Serial Program.
    2) A TCP/IP communication task with a tcp program.
    3) A Mqtt to forward signals to MQTT broker.

    Individual issues can solved in task 1, 2 and 3 appropriatly.

    Declare a central datastructure in a GVL and write to it from task 1 and 2.
    Then consume (read) from the GVL datastructure in task 3, which should suffice.

     
    πŸ‘
    2

Log in to post a comment.