Relatively new here to PLC's and the Codesys environment. I have a small task where I need to start/stop a simple timer depending on digital/analog inputs (think starting and stopping a stopwatch). For example:
VAR
  trigger1: F_TRIG;
  trigger2: F_TRIG;
  trigger1Count: CTU;
  trigger2Count: CTU;
  delayTimer: TON;END_VARtrigger1(CLK :=digital1);trigger2(CLK :=digital2);trigger1Count(CU :=trigger1.Q);trigger2Count(CU :=trigger2.Q);IFtrigger1Count.CV=1ANDtrigger2Count.CV=0ANDanalog1<100THEN
  (*StartTimer1*)
  (*StartTimer2*)
  delayTimer(IN :=TRUE, PT :=T#5s);ELSEtrigger2Count.CV=1THEN
  (*EndTimer1*)
  IFdelayTimer.QANDanalog1<100THEN
    (*EndTimer2*)
  END_IFEND_IF
This does not seem conducive to the pre-built functions (IE - TON/TOF/TP). Can anyone recommend a technique for how to build one? Note that the output of the timers would need to be passed to another variable (to be held in memory) and then reset. Ideally, I'm shooting for a resolution of ~10ms.
Thanks,
Nick
Edit to add:
Thus far I have tried two approaches to this. The first, just a simple counter (IE- i:= i+1), but I was getting different results, I assume dependent on the cycle time. The second, I tried just using a TON, but could not figure out how to correctly stop the TON (it would continue running until it reached PT), nor how to correctly reset it.
Additionally, can anyone recommend a good reference/instruction manual for ST (or IEC 61131-3 in general)? Preferably one that is available in the US.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
start simpler by using a timer:
your IF statements are not working.
No comments are used.
program is not complete
If above send it again and we will have a look at it.
time1(IN:=bstart , PT:=tprocestime , Q=>btimeexpired , ET=>tmssincestart );
yes you can define them elsewhere like time1.in:= true;
You should set the PT outside your program as whenever you run over this command the time will change.
there is an internal timer running better to use that one.
if new please download w www.oscat.de w the txt version of it. you will understand a lot in ST.
if you download the lib too you can make whatever you like.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
shooter hat geschrieben:
start simpler by using a timer:
your IF statements are not working.
No comments are used.
program is not complete
If above send it again and we will have a look at it.
The comments were merely to indicate functionality. IE - I'd like to start two timers at the same time, but stop them at different times.
shooter hat geschrieben:
time1(IN:=bstart , PT:=tprocestime , Q=>btimeexpired , ET=>tmssincestart );
yes you can define them elsewhere like time1.in:= true;
You should set the PT outside your program as whenever you run over this command the time will change.
there is an internal timer running better to use that one.
I haven't had luck using a TON, because I cannot stop it (even by setting time1.IN := FALSE, it continues to run). I do not have a use for PT, as I do not want to set an "upper bound" on when the timer stops (nor do I know when it needs to stop).
shooter hat geschrieben:
if new please download http://www.oscat.de the txt version of it. you will understand a lot in ST.
if you download the lib too you can make whatever you like.
Is there an english version?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
oscat is in english written.
there is even a PDF file in english now.
A timer is used to give a signal after a PT time.
so you must set a time in it.
You can otherwise use a internal timer in mseconds.
in oscat it is called now().
If you like to know the expired time you can calculate the ET and use it in a formula.
please be a little more clearer what you are looking for.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One thing to be careful about is you are trapping the Timer function block call in an IF statement. You need to reset the timer some where else by calling it's instance with IN := FALSE other wise next time you enter the IF statement the timer will have saved the state and will not reset.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all-
Relatively new here to PLC's and the Codesys environment. I have a small task where I need to start/stop a simple timer depending on digital/analog inputs (think starting and stopping a stopwatch). For example:
This does not seem conducive to the pre-built functions (IE - TON/TOF/TP). Can anyone recommend a technique for how to build one? Note that the output of the timers would need to be passed to another variable (to be held in memory) and then reset. Ideally, I'm shooting for a resolution of ~10ms.
Thanks,
Nick
Edit to add:
Thus far I have tried two approaches to this. The first, just a simple counter (IE- i:= i+1), but I was getting different results, I assume dependent on the cycle time. The second, I tried just using a TON, but could not figure out how to correctly stop the TON (it would continue running until it reached PT), nor how to correctly reset it.
Additionally, can anyone recommend a good reference/instruction manual for ST (or IEC 61131-3 in general)? Preferably one that is available in the US.
start simpler by using a timer:
your IF statements are not working.
No comments are used.
program is not complete
If above send it again and we will have a look at it.
time1(IN:=bstart , PT:=tprocestime , Q=>btimeexpired , ET=>tmssincestart );
yes you can define them elsewhere like time1.in:= true;
You should set the PT outside your program as whenever you run over this command the time will change.
there is an internal timer running better to use that one.
if new please download w www.oscat.de w the txt version of it. you will understand a lot in ST.
if you download the lib too you can make whatever you like.
The comments were merely to indicate functionality. IE - I'd like to start two timers at the same time, but stop them at different times.
I haven't had luck using a TON, because I cannot stop it (even by setting time1.IN := FALSE, it continues to run). I do not have a use for PT, as I do not want to set an "upper bound" on when the timer stops (nor do I know when it needs to stop).
Is there an english version?
oscat is in english written.
there is even a PDF file in english now.
A timer is used to give a signal after a PT time.
so you must set a time in it.
You can otherwise use a internal timer in mseconds.
in oscat it is called now().
If you like to know the expired time you can calculate the ET and use it in a formula.
please be a little more clearer what you are looking for.
One thing to be careful about is you are trapping the Timer function block call in an IF statement. You need to reset the timer some where else by calling it's instance with IN := FALSE other wise next time you enter the IF statement the timer will have saved the state and will not reset.