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!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
.... 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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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!
more posts ...
.... 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.
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.