I have question how to reset output of the pulse timer TP.
By the rising triger condition "A", I activate timer TP for fixed time, I wish to reset this time in case when comming another condition "B"
I writing program for Beckhoff PLC in CFC.
Is possible to manage this logic with SR, trigers etc by I looking for simplest reset of the timer.
Best regards
Ed
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2016-11-07
Originally created by: scott_cunningham
What should happen when Condition B is held high? Should the output stay ON, if it was on? What if the output was already OFF (TP expired) and you set Condition B high? Should the output stay OFF?
You may be best to program your special need using ST as it's own FB, instead of trying to use a combination of TONs, TOFs, SRs, etc. Here is an example that assumes holding CondB high will keep timer at 0 until dropped low. Maybe CondB should be edge triggered?
The code below seems to work, but please test it yourself. Maybe this can be handled with a CFC solution without a state machine, but I didn't try.
FUNCTION_BLOCKTP_RSTVAR_INPUT
  IN : BOOL;
  PT : TIME;
  RST : BOOL;END_VARVAR_OUTPUT
  Q : BOOL;
  ET : TIME;END_VARVARCONSTANT
  INIT : INT :=0;
  RUN_PULSE : INT :=1;
  PULSE_DONE : INT :=2;
  RESET_TIME : INT :=3;END_VARVAR
  Timer : Standard.TON;
  State : INT;END_VARCASEStateOF
  INIT://Makesureoutputandtimerareoff
    Timer(IN:=FALSE, PT:=PT, ET=>ET);
    Q :=FALSE;
    //Seeifuserwantstostartpulse
    IFINTHEN
      State :=RUN_PULSE;
    END_IF
   Â
  RUN_PULSE://Normalpulse(outputistrue)
    Timer(IN:=TRUE, PT:=PT, ET=>ET);
    Q :=TRUE;
    //Seeiftimerresetrequested
    IFRSTTHEN
      State :=RESET_TIME;
    END_IF
    //Seeiftimerexpired(thisoverridesRSTsignaliftimerisalreadydone)
    IFTimer.QTHEN
      State :=PULSE_DONE;
    END_IF
 Â
  PULSE_DONE://Pulseisdone-ignoreRSTinput
    //KeeptimerTRUEtomaintainETlikenormalTP
    Timer(IN:=TRUE, PT:=PT, ET=>ET);
    Q :=FALSE;
    //Seeifusershutsofftimer
    IFNOTINTHEN
      State :=INIT;
    END_IF
   Â
  RESET_TIME://Userwantstoextendpulseoutput(keepoutputhigh)
    //Resettimer(ET=0again)
    Timer(IN:=FALSE, PT:=PT, ET=>ET);
    Q :=TRUE;
    //WatchfordropofRST-andgobacktonormalpulseoutput
    IFNOTRSTTHEN
      State :=RUN_PULSE;
    END_IF
   Â
  ELSE//problemincode-resetstatemachinesoFBdoesn't freeze
    State :=INIT;
   Â
END_CASE
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I'm new in the forum so Regards to All
I have question how to reset output of the pulse timer TP.
By the rising triger condition "A", I activate timer TP for fixed time, I wish to reset this time in case when comming another condition "B"
I writing program for Beckhoff PLC in CFC.
Is possible to manage this logic with SR, trigers etc by I looking for simplest reset of the timer.
Best regards
Ed
Originally created by: scott_cunningham
What should happen when Condition B is held high? Should the output stay ON, if it was on? What if the output was already OFF (TP expired) and you set Condition B high? Should the output stay OFF?
You may be best to program your special need using ST as it's own FB, instead of trying to use a combination of TONs, TOFs, SRs, etc. Here is an example that assumes holding CondB high will keep timer at 0 until dropped low. Maybe CondB should be edge triggered?
The code below seems to work, but please test it yourself. Maybe this can be handled with a CFC solution without a state machine, but I didn't try.