Is it possible in CODESYS to access the value that a variable held in the previous cycle and compare it with it's present value? I am used to working with ABB's tool, which had the option of defining an attribute called STATE to a variable, which helps in accessing it's previous cycle value in the ST code. Thank you!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, pardon my ignorance, I am a bit new to this, but to compare the Old & New values, I would need to have access to them. My doubt is, for a particular variable, say X, how do I go about getting the value of X:Old (as in the value it held in the previous scan cycle)? Thank you!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is it possible in CODESYS to access the value that a variable held in the previous cycle and compare it with it's present value? I am used to working with ABB's tool, which had the option of defining an attribute called STATE to a variable, which helps in accessing it's previous cycle value in the ST code. Thank you!
more posts ...
Changed := Old <> New;
Old := New;
Hi, pardon my ignorance, I am a bit new to this, but to compare the Old & New values, I would need to have access to them. My doubt is, for a particular variable, say X, how do I go about getting the value of X:Old (as in the value it held in the previous scan cycle)? Thank you!
therr is no special command for this, you would need create a new variable called "previous_x" and do
previous_x := x;
Right, this is what I typically do to compare past and present values as well.