<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Life Sign Generation (TON does not work as required.)</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ca0570c22b/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ca0570c22b/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/ca0570c22b/</id><updated>2022-12-11T22:16:56.493000Z</updated><subtitle>Recent posts to Life Sign Generation (TON does not work as required.)</subtitle><entry><title>Life Sign Generation (TON does not work as required.)</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ca0570c22b/?limit=250#ca36" rel="alternate"/><published>2022-12-11T22:16:56.493000Z</published><updated>2022-12-11T22:16:56.493000Z</updated><author><name>h-hermsen</name><uri>https://forge.codesys.com/u/hermsen/</uri></author><id>https://forge.codesys.com41e65e6a9babccc5dd8824d7adf8bd29fc3ad33a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;a super easy way for a Watchdog signal is just to add a global var iWdTaskX and tally it up every cycle. If you have more tasks running just name them accordingly&lt;/p&gt;
&lt;p&gt;so in task XYZ we program a single line of code somewhere;&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;GVL.iTaskXYZ := GVL.iTaskXYZ + 1;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Remember that a change in value matters and as long as the current value differs from the last received value we are gold.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Life Sign Generation (TON does not work as required.)</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ca0570c22b/?limit=250#6fe3" rel="alternate"/><published>2022-12-11T22:16:41.887000Z</published><updated>2022-12-11T22:16:41.887000Z</updated><author><name>h-hermsen</name><uri>https://forge.codesys.com/u/hermsen/</uri></author><id>https://forge.codesys.comfcd31f225005bf35e9096b413bb1c1aa56ced6a4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;a super easy way for a Watchdog signal is just to add a global var iWdTaskX and tally it up every cycle. If you have more tasks running just name them accordingly&lt;/p&gt;
&lt;p&gt;so in task XYZ we program a single line of code somewhere;&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;GVL.iTaskXYZ := GVL.iTaskXYZ + 1;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Remember that a change in value matters and as long as the current value differs from the last received value we are gold.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Life Sign Generation (TON does not work as required.)</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ca0570c22b/?limit=25#df6d" rel="alternate"/><published>2022-12-11T21:05:32.869000Z</published><updated>2022-12-11T21:05:32.869000Z</updated><author><name>sgronchi</name><uri>https://forge.codesys.com/u/sgronchi/</uri></author><id>https://forge.codesys.com1f82044f3f3fd874747cf416f974f4dbc0ca5efa</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Anyway a better way for what you want to achieve is executing the task with 32 ms (or submultiple like 16, 8, 4 ms...) execution time and increment the counter every 1 (2, 4, 8...) cycles without timers. You'll get the best behaviour your platform can provide.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Life Sign Generation (TON does not work as required.)</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ca0570c22b/?limit=25#9d2d" rel="alternate"/><published>2022-12-11T21:00:20.092000Z</published><updated>2022-12-11T21:00:20.092000Z</updated><author><name>sgronchi</name><uri>https://forge.codesys.com/u/sgronchi/</uri></author><id>https://forge.codesys.com66fc9df03373ca05fed4d5d5e59d29fa847e0993</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;First - what's the task cycle time? Timers cannot have better resolution than that.&lt;br/&gt;
E.g. if your task cycle time is 20 ms, the following happens (every bullet is a cycle - the first is the global clock):&lt;/p&gt;
&lt;p&gt;1) t#000ms - IN = TRUE - ET = t#0ms - Q = FALSE&lt;br/&gt;
2) t#020ms - IN = TRUE - ET = t#20ms - Q = FALSE&lt;br/&gt;
3) t#040ms - IN = TRUE - ET = t#40ms - Q = TRUE&lt;br/&gt;
4) t#060ms - IN = FALSE - ET = t#0ms - Q = FALSE&lt;br/&gt;
5) t#080ms - IN = TRUE - ET = t#0ms - Q = FALSE&lt;br/&gt;
6) t#100ms - IN = TRUE - ET = t#20ms - Q = FALSE&lt;br/&gt;
7) t#120ms - IN = TRUE - ET = t#40ms - Q = TRUE&lt;/p&gt;
&lt;p&gt;As you can see, the interval between two Q = TRUE is 80 ms. Remember, Q = (ET &amp;gt;= PT).&lt;/p&gt;
&lt;p&gt;Furthermore, you should notice that in this way you need two cycles for resetting (point 4 and 5) - if you want to avoid that, you should call the timer with IN = FALSE and then IN = TRUE in the same cycle as the one when Q got TRUE, for a total of three times in a single cycle.&lt;/p&gt;
&lt;p&gt;The ST way is the most elegant (below), in LD/FBD is a bit uglier (Q starts an EN/ENO line on the same timer called two times - it SHOULD work), in CFC is horrible (you should set a variable and then use that to call the timer two times and finally reset it):&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;tmr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;TRUE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="n"&gt;tmr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
    &lt;span class="n"&gt;tmr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;FALSE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;tmr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;TRUE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="n"&gt;be&lt;/span&gt; &lt;span class="n"&gt;executed&lt;/span&gt;
&lt;span class="n"&gt;END_IF&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>Life Sign Generation (TON does not work as required.)</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ca0570c22b/?limit=250#6854" rel="alternate"/><published>2022-12-08T18:08:36.402000Z</published><updated>2022-12-08T18:08:36.402000Z</updated><author><name>necatibilgin</name><uri>https://forge.codesys.com/u/necatibilgin/</uri></author><id>https://forge.codesys.com9b54acc967fa7739d6a6830a2f7c0f89b33dec17</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Dear All,&lt;/p&gt;
&lt;p&gt;I am trying to generate a life sign which increases by 1 in every 32ms. My program which shown below, increases life sign in approximately every 80 ms. How can fix it to 32ms? Could you please help me? &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;PROGRAM POU_2&lt;/span&gt;
&lt;span class="err"&gt;VAR_INPUT&lt;/span&gt;
&lt;span class="err"&gt;    cycle_time: TIME:= T#32ms;&lt;/span&gt;
&lt;span class="err"&gt;END_VAR&lt;/span&gt;
&lt;span class="err"&gt;VAR_OUTPUT&lt;/span&gt;
&lt;span class="err"&gt;    life_sign: USINT:= 0;&lt;/span&gt;
&lt;span class="err"&gt;END_VAR&lt;/span&gt;
&lt;span class="err"&gt;VAR&lt;/span&gt;
&lt;span class="err"&gt;    TON_0: TON;&lt;/span&gt;
&lt;span class="err"&gt;    R_TRIG_0: R_TRIG;&lt;/span&gt;
&lt;span class="err"&gt;    time_ms: SysTimeRtc.SYSTIME;&lt;/span&gt;
&lt;span class="err"&gt;    time_array: ARRAY[0..999, 0..1] OF ULINT;&lt;/span&gt;
&lt;span class="err"&gt;    prev_time: ULINT:= 0;&lt;/span&gt;
&lt;span class="err"&gt;    i: INT:= 0;&lt;/span&gt;
&lt;span class="err"&gt;END_VAR&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;img src="./attachment/CFC.PNG" width="50%"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>