radsett
Member
I have what should be a simple question but even after fighting with Proficy ME and their help system for hours I'm not much closer to an answer than when I started. I just want to create a simple function like
(* Simple function to limit a values ramping by limiting the step it can take.
Note depends on the maxiumum and minimum being at least step away from
the maximum int to avoid overflow issues. *)
FUNCTION ramp : INT
VAR_INPUT
in: INT; (* The requested value *)
old: INT; (* The previously used value. *)
step: INT; (* The maximum step size. *)
END_VAR
VAR
max_out: INT; (* The maximum allowable output *)
min_out: INT; (* The minimum allowable output *)
END_VAR
max_out := old + step;
min_out := old - step;
IF in > max_out THEN
ramp := max_out;
ELSE
IF in < min_out THEN
ramp := min_out;
ELSE
ramp := in;
END_IF;
END_IF;
END_FUNCTION
That would then be called as
cur_setpt_rmp := ramp( in:=cur_setpt, old:=cur_setpt_rmp, step:=cur_step);
This appears to me to be pretty basic structured text but I don't see a way to implement it in Proficy. I can create input vars in the parameters, but I don't see a way to create local vars that ar enot retentive and the return value also doesn't seem to be assignable.
Robert
Hmm, I see the post doesn't retain indenting.
(* Simple function to limit a values ramping by limiting the step it can take.
Note depends on the maxiumum and minimum being at least step away from
the maximum int to avoid overflow issues. *)
FUNCTION ramp : INT
VAR_INPUT
in: INT; (* The requested value *)
old: INT; (* The previously used value. *)
step: INT; (* The maximum step size. *)
END_VAR
VAR
max_out: INT; (* The maximum allowable output *)
min_out: INT; (* The minimum allowable output *)
END_VAR
max_out := old + step;
min_out := old - step;
IF in > max_out THEN
ramp := max_out;
ELSE
IF in < min_out THEN
ramp := min_out;
ELSE
ramp := in;
END_IF;
END_IF;
END_FUNCTION
That would then be called as
cur_setpt_rmp := ramp( in:=cur_setpt, old:=cur_setpt_rmp, step:=cur_step);
This appears to me to be pretty basic structured text but I don't see a way to implement it in Proficy. I can create input vars in the parameters, but I don't see a way to create local vars that ar enot retentive and the return value also doesn't seem to be assignable.
Robert
Hmm, I see the post doesn't retain indenting.