Set/reset
The function block SR (set/reset) allows you to both set and reset an output.
Input
Set
The output Q1 is set for each rising edge at S1
Reset
The output Q1 is reset for each rising edge detected at R, except when S1 is set (see time chart)
Output
Set or reset depending on inputs
set if a rising edge is detected at S1
reset if a rising edge is detected at R if S1 is not set.
set if a rising edge is detected at both inputs (S1 and R).
Upon initialising, Q1 always has the status zero (reset).
All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.
VAR
copy_name: SR;
set: BOOL:=FALSE;
(*output_value is set for each
rising edge at set_input,
if reset_input is not set*)
reset: BOOL:=FALSE;
(*output_value is reset for each
rising edge at reset_input*)
signal_output: BOOL:=FALSE;
END_VAR
If set is set (status = TRUE), signal_output will be set. If only reset is set, the signal_output will be reset (status = FALSE). If both set and reset are set, signal_output will be set.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 5 ;
NETWORK_BODY
B(B_VAROUT,,signal_output,13,2,15,4,);
B(B_CONTACT,,set,3,1,5,3,);
B(B_CONTACT,,reset,3,3,5,5,);
B(B_FB,SR!,copy_name,8,1,13,5,,?BS1?BR?AQ1);
L(1,2,3,2);
L(1,4,3,4);
L(5,4,8,4);
L(5,2,5,3);
L(5,3,8,3);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
copy_name( SET:= set, RESET:= reset);
signal_output:= signal_output;