"Limit Minimum" syntax help
lardom
Posts: 1,659
I'm building a method that modifies a variable by multiplying it with a 'percentage' value. I want minimum to maximum limits of 100 to 4000.
if percentage <> 0 PW := percentage * PW / 100'PW" is initialized with 1_200. The conditional statement prevents PW from clearing to 0, a fatal error. It would be great if I could put the limits in the CON block.
Comments
Something like this?
To limit to a maximum you can do this -
And to limit within a range you can do this -
Edit: You can also do this to limit min/max = pw #> 1000, pw <# 2000
Start_Speed = 1600 clocks per negative edge. The CurrentSpeed is compared to 1600 clocks and PW is modified by the same percentage that they don't match. PW can be any number from 1 to 4000. If I could configure the limits as constants I could eliminate at least two lines of code.