Update of PLC TAGs (Use in a FUNCTION)


I would like to use a PLC TAG to do calculations in a function that can be called more than once before the update in the PLC is done.

Here is the result:
Does not work
Tags_1 Tags_1

To make it work I added a wait loop with IF instruction

Is there another way to sync it?

Thank you

Hello Christian,

Can you elaborate a little more on what you are trying to accomplish? Are you trying to add to a variable until it is equal to the PLC tag?

Keep in mind the script is going to call those two function one after another in quick succession. The eWon will most likely not have time to read from the PLC again before it is executed again.


Hello Deryck,

These are two examples of functions to demonstrate the nature of the problem. (It should only have 2 images and not 3, can you remove the second one which is the same as the first?)

The first example represents 2 quick modifications of a variable exchanged with a PLC (it is only the Flexy which modifies the value). Before exiting the first function, even after VarDINT@ = $Tempo% the 2 values ​​are not equal (110/111). It’s strange ???.

On the second function call, the result is always the same. We have lost the increment of 1 of the first call of the function.

To correct the situation (the second example), I had to wait before exiting the function for the 2 values ​​to be equal using a wait loop before continuing. It is strange that after the instruction VarDINT@ = $Tempo% that the 2 values ​​are not equal, this is the reason for using IF and GOTO.

I hope I explained my problem better.

Thank you

Hello @CFrancoeur,

Thank you this explanation helped me understand your question much better. I think my last statement still applied in this situation too. The ewon basic scripting is running independent of the Ewon IOserver communicating with the PLC. You are most likely calling the tag again too fast. The basic script is not interacting with the the PLC directly and is passing the requests to the IOserver. In your example what is most likely happening is the script reads the plc tag value stored on the ewon adding 1 then sending the write request. Write request are sent out immediately but read requests work on the cyclic poll rate for the IO server.