...then I can use implict checks to limit the value of TestVar to the lower and upper limits.
Is there a way to access the upper and lower limits of a variable? A function I can call or something? How are the lower and upper input variables passed to the CheckRangeSigned implicit check function?
I am also interested in knowing if there is a way to get the lower and upper limit.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2019-01-31
Originally created by: scott_cunningham
Brute-force method (assuming you have control of the whole project and can add implicit checks):
Turn on implicit checks for subrange (CheckRangeSigned and CheckRangeUnsigned). These POUs will return the value or the limited version of the value.
PROGRAMPLC_PRGVAR
  SubrangeINT:INT(-4096..4096);
  MaxInt:INT:=32767;
  MinInt:INT:=-32768;
  Highest:INT;
  Lowest:INT;END_VARSubrangeINT:=MaxInt;Highest:=SubrangeINT;SubrangeINT:=MinInt;Lowest:=SubrangeINT;
But really, if you have access to the whole project, then you can see the limits by looking at the var definition. So I don't think this is much help...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That's an interesting idea, and it almost works for what I have in mind. The only problem is that I would actually have to change the value of the variable in question in order to test it.
I set a breakpoint in the CheckRangeSigned function, and it gets the min and max range as inputs to the function, but there's nothing in the call stack to indicate where the inputs come from--the values must be stored in memory somewhere.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If I declare a variable like this...
...then I can use implict checks to limit the value of TestVar to the lower and upper limits.
Is there a way to access the upper and lower limits of a variable? A function I can call or something? How are the lower and upper input variables passed to the CheckRangeSigned implicit check function?
thanks
Tim
Using constants in déclaration ? Then you may just use thoses constants.
I am also interested in knowing if there is a way to get the lower and upper limit.
Originally created by: scott_cunningham
Brute-force method (assuming you have control of the whole project and can add implicit checks):
Turn on implicit checks for subrange (CheckRangeSigned and CheckRangeUnsigned). These POUs will return the value or the limited version of the value.
But really, if you have access to the whole project, then you can see the limits by looking at the var definition. So I don't think this is much help...
That's an interesting idea, and it almost works for what I have in mind. The only problem is that I would actually have to change the value of the variable in question in order to test it.
I set a breakpoint in the CheckRangeSigned function, and it gets the min and max range as inputs to the function, but there's nothing in the call stack to indicate where the inputs come from--the values must be stored in memory somewhere.