Karl_Tanner
Member
I've made a function that spurts out an adjustable bistable output, how do I call it in from another function block? I'm new to Beckhoff and ST programming, any help would be appreciated.
FUNCTION FN_PulseGen : BOOL
VAR_INPUT
SPin : INT;
END_VAR
VAR
(* Variables required to convert INT to Time *)
Val : INT;
SPVal :TIME;
(* Timer Off Variable setups *)
TON1 : TON;
TON2 : TON;
TmrOn : BOOL;
Tmr2On : BOOL;
END_VAR
SPin:= Val;
SPVal:=INT_TO_TIME(1000 * Val);
(* Set varibles up *)
(* Adjustable bistable output created by timers TON1 and TON2 *)
TON1( IN:= NOT Tmr2On, PT:= SPval, Q=>TmrOn, ET=>);
TON2( IN:= TmrOn, PT:= SPval, Q=>Tmr2On,ET=>);
I had a piece of code at the bottom to drive an output to prove it worked (which it did )
SPin picks up the variable setpoint. The idea that 4 instances will be using this Function, and each one has it's own setpoint defined elsewhere.. That's why I thought the use of Functions over Function Blocks...?
How do I get the timer pulse TmrOn result out of the Fn?
Kind regards,
Karl
FUNCTION FN_PulseGen : BOOL
VAR_INPUT
SPin : INT;
END_VAR
VAR
(* Variables required to convert INT to Time *)
Val : INT;
SPVal :TIME;
(* Timer Off Variable setups *)
TON1 : TON;
TON2 : TON;
TmrOn : BOOL;
Tmr2On : BOOL;
END_VAR
SPin:= Val;
SPVal:=INT_TO_TIME(1000 * Val);
(* Set varibles up *)
(* Adjustable bistable output created by timers TON1 and TON2 *)
TON1( IN:= NOT Tmr2On, PT:= SPval, Q=>TmrOn, ET=>);
TON2( IN:= TmrOn, PT:= SPval, Q=>Tmr2On,ET=>);
I had a piece of code at the bottom to drive an output to prove it worked (which it did )
SPin picks up the variable setpoint. The idea that 4 instances will be using this Function, and each one has it's own setpoint defined elsewhere.. That's why I thought the use of Functions over Function Blocks...?
How do I get the timer pulse TmrOn result out of the Fn?
Kind regards,
Karl