Hello guys,
I have another, very weird problem with Step 7 functions.
In the attachments, you can find sorces for OB1 and two functions. Both functions have only one input and one output.
They use temp variables.
1. Do temp variables preserver values between function calls?
2.Are temp variables local to the function in which they're defined? Until this moment I thought so.
Problem is like I'm having interference between local variables of two different functions.
I use PLCSIM. Every time I press I0.0 (input to FC2), local temp variable Step2 inside FC1 is changing value, thus changing execution of FC1.
How this is possible?
Is this maybe a PLCSIM bug? I don't thinki so.
It seems that when I press I0.0, tmp2 variable inside FC 2 is set. Address of inside of FC2 tmp2 is same (bool 0.1) as address of temp variable "Step2" inside of FC1.
I'm asking these questions because I'm preparing to modify a PLC program which was not written by me, and I need to use timers. If this is work this way on real PLC, I'm going to mess up.
Please, execute this code and let me know if you're experiencing the sam problem.
P.S. When you compile source choose View->Lad (but you all probably know that )
Thanks
I have another, very weird problem with Step 7 functions.
In the attachments, you can find sorces for OB1 and two functions. Both functions have only one input and one output.
They use temp variables.
1. Do temp variables preserver values between function calls?
2.Are temp variables local to the function in which they're defined? Until this moment I thought so.
Problem is like I'm having interference between local variables of two different functions.
I use PLCSIM. Every time I press I0.0 (input to FC2), local temp variable Step2 inside FC1 is changing value, thus changing execution of FC1.
How this is possible?
Is this maybe a PLCSIM bug? I don't thinki so.
It seems that when I press I0.0, tmp2 variable inside FC 2 is set. Address of inside of FC2 tmp2 is same (bool 0.1) as address of temp variable "Step2" inside of FC1.
I'm asking these questions because I'm preparing to modify a PLC program which was not written by me, and I need to use timers. If this is work this way on real PLC, I'm going to mess up.
Please, execute this code and let me know if you're experiencing the sam problem.
P.S. When you compile source choose View->Lad (but you all probably know that )
Thanks
Last edited: