PLUS+1 User Forum
PLUS+1 Hardware => Controllers => Topic started by: macbahi on August 01, 2022, 03:03:29 PM
-
Hello,
I am using POU with structured text ST as you see in my example.
I do average of some numbers.
Like you see when I use Retain Variable I have problem as you see in picture.
Please could you tell me where the problem
Thanks for your help
With best regards
-
You've got a colon instead of a semicolon at the end of your first RETAIN variable declaration.
-
Hi Tom,
Tank you very much to replay me.
But I didn't understand. Please could you give more detail. Or Correct example.
I am not familiarized with POU ST
Thanks in advance.
With best regards
-
HI Tom,
Sorry Tom It's ok but now I have another problem. Please see image.
My function is working without VAR RETAIN but the result is not good.
As example When NbIncrement_Scan =1 the output is equal to input. It's Ok.
But when My NbIncrement_Scan est >1 then the output is equal to zero.
That's why I tried to use VAR RETAIN.
I hope you understand my problem.
Thanks in advance for your help
Best regards
-
If you want to keep the valve of NbIncrument and CounteurIncrement between calls use a Function Block instead of a Function.
A Function does not store the valve of it's variables between calls so each time the function is called NbIncrument and CounteurIncrement will always be initialised to 0. A Function Block will store the value variables.
-
Hi!
Thank you Sir.
With best regards
-
Hi acmall,
I do it but still the same problem. NbIncrument and CounteurIncrement are also initialized to 0 every call.
Thanks
Best regards
-
Can you post your code as it is now?
-
Hi Acmall,
Sorry to be late I was in vacancy.
It's ok now. It was mistake in call function.
Thank you very much.
With best regards