IΒ΄m looking for a function/way to get the = function (or similar) to accept numbers that are not exactly alike.
For example,
VAR
Incoming_REAL:Real; //This variable increases every cycle and depends on how log the Incoming_Real has been active and can therefore differ from run to run.
VAR
Incoming_REAL:Real; //This variable increases every cycle and depends on how log the Incoming_Real has been active and can therefore differ from run to run.
Depending on what environment you're using, you might be able to find a LIM function in one of the libraries (NOTE: not the same as the LIMIT operator). If not, it's easy to make one:
Thank you so much tvm, this was exactly what i was looking for!
I did not find one among my library's so i built one and it works great.
If someone that is (even) newer to codesys than me and tries so build this there is a small typo in the program above, there are two i_Lower where one of them should be i_Upper but with that change it works great.
Many thanks!
Martin
π
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
IΒ΄m looking for a function/way to get the = function (or similar) to accept numbers that are not exactly alike.
For example,
VAR
Incoming_REAL:Real; //This variable increases every cycle and depends on how log the Incoming_Real has been active and can therefore differ from run to run.
Add_On:Real:=10.5;
Gate_Bool:Bool;
Start_Clapping:Bool;
END_VAR
If Gate_Bool=true
then
Add_on:=Incoming_REAL + Add_on // This increases the Add_On variable with the number from Incoming_Real.
End_IF
If Add_On=Incoming_REAL
then
Start_Clapping:=True;
So i would like the Add_on=Incoming_Real to be a bit accepting and
having something like
Start_Clapping:= Add_on=Incoming_Real (+ 0-8 or - 0.8)
This code is just to explain, it probably holds some errors but hopefully you will understand what iΒ΄m looking for.
IS there a way to do something like
Add_on>= 0.8 or <= 0.8 from Incoming_REAL
Best,
Martin
more posts ...
Right now i have solved with
VAR
Incoming_REAL:Real; //This variable increases every cycle and depends on how log the Incoming_Real has been active and can therefore differ from run to run.
Add_On:Real:=10.5;
Gate_Bool:Bool;
Start_Clapping:Bool;
Upper_limit:REAL :=1;
Lower_limit:REAL :=2;
High:REAL;
LOW:REAL;
END_VAR
(with R_trig before both high and low)
HIGH:=Incoming_REAL + upper_limit + Add_on;
LOW:=Incoming_REAL + upper_Limit + Add_on;
and then made a GT on the lower limit and LT on the upper limit. This works but its everything but well written code.
Any other ideas for a better/easier code?
Depending on what environment you're using, you might be able to find a LIM function in one of the libraries (NOTE: not the same as the LIMIT operator). If not, it's easy to make one:
Last edit: tvm 2021-10-20
Thank you so much tvm, this was exactly what i was looking for!
I did not find one among my library's so i built one and it works great.
If someone that is (even) newer to codesys than me and tries so build this there is a small typo in the program above, there are two i_Lower where one of them should be i_Upper but with that change it works great.
Many thanks!
Martin
fixed it