<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Writing variable 'On change'</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5163b2ddc5/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5163b2ddc5/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/5163b2ddc5/</id><updated>2020-02-27T13:52:03.382000Z</updated><subtitle>Recent posts to Writing variable 'On change'</subtitle><entry><title>Writing variable 'On change'</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5163b2ddc5/?limit=25#b67e" rel="alternate"/><published>2020-02-27T13:52:03.382000Z</published><updated>2020-02-27T13:52:03.382000Z</updated><author><name>kallileo</name><uri>https://forge.codesys.com/u/kallileo/</uri></author><id>https://forge.codesys.com8a1adf2c763f6b3947210364025e3663bd985378</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Made it work for coils and now have to find a way so it works for holding registers as well.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;GVL&lt;/span&gt;.&lt;span class="nv"&gt;Input0&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;GVL&lt;/span&gt;.&lt;span class="nv"&gt;CoilIn&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;Write&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;FALSE&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;R_TRIG_0&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;CLK&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;GVL&lt;/span&gt;.&lt;span class="nv"&gt;Output0&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;F_TRIG_0&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;CLK&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;GVL&lt;/span&gt;.&lt;span class="nv"&gt;Output0&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nv"&gt;Trigger&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;Modbus&lt;/span&gt; &lt;span class="nv"&gt;coil&lt;/span&gt; &lt;span class="nv"&gt;write&lt;/span&gt;
&lt;span class="nv"&gt;Write&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;R_TRIG_0&lt;/span&gt;.&lt;span class="nv"&gt;Q&lt;/span&gt; &lt;span class="nv"&gt;OR&lt;/span&gt; &lt;span class="nv"&gt;F_TRIG_0&lt;/span&gt;.&lt;span class="nv"&gt;Q&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;Write&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
   &lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;GVL&lt;/span&gt;.&lt;span class="nv"&gt;Input0&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
      &lt;span class="nv"&gt;GVL&lt;/span&gt;.&lt;span class="nv"&gt;CoilOut&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;FALSE&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
   &lt;span class="k"&gt;ELSE&lt;/span&gt;
      &lt;span class="nv"&gt;GVL&lt;/span&gt;.&lt;span class="nv"&gt;CoilOut&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;TRUE&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
   &lt;span class="nv"&gt;END_IF&lt;/span&gt;
   &lt;span class="nv"&gt;Write&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;TRUE&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;END_IF&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>Writing variable 'On change'</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5163b2ddc5/?limit=25#11bc" rel="alternate"/><published>2020-02-27T13:52:03.169000Z</published><updated>2020-02-27T13:52:03.169000Z</updated><author><name>kallileo</name><uri>https://forge.codesys.com/u/kallileo/</uri></author><id>https://forge.codesys.coma887a0f7c75cd97a8498ac0bc686c39685091ce2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I have the same issue with Modbus Master and writing to coils.&lt;br/&gt;
The GVL.CoilIn variable is mapped to a reading channel that is polling the server in "Cyclic" mode.&lt;br/&gt;
The GVL.CoilOut variable is mapped to the same coil in writing channel in "Rising edge" mode. &lt;/p&gt;
&lt;p&gt;The code below is toggling the coil on the Modbus Server every time the variable GVL.Output0 is set to TRUE.&lt;br/&gt;
What I want is the Modbus coil to be set to 1 when the GVL.Output0 is TRUE and reset to 0 when then GVL.Output0 is FALSE.&lt;br/&gt;
I tried to take the falling edge of the GVL.Output0 to reset the coil to 0 but it doesn't work.&lt;/p&gt;
&lt;p&gt;Any suggestions?&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;GVL&lt;/span&gt;.&lt;span class="nv"&gt;Input0&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;GVL&lt;/span&gt;.&lt;span class="nv"&gt;CoilIn0&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;R_TRIG_0&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;CLK&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;GVL&lt;/span&gt;.&lt;span class="nv"&gt;Output0&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;R_TRIG_0&lt;/span&gt;.&lt;span class="nv"&gt;Q&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
   &lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;GVL&lt;/span&gt;.&lt;span class="nv"&gt;CoilIn0&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
      &lt;span class="nv"&gt;GVL&lt;/span&gt;.&lt;span class="nv"&gt;CoilOut0&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;FALSE&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
   &lt;span class="k"&gt;ELSE&lt;/span&gt;
      &lt;span class="nv"&gt;GVL&lt;/span&gt;.&lt;span class="nv"&gt;CoilOut0&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;TRUE&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
   &lt;span class="nv"&gt;END_IF&lt;/span&gt;
&lt;span class="nv"&gt;END_IF&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>Writing variable 'On change'</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5163b2ddc5/?limit=25#d3fa" rel="alternate"/><published>2020-02-27T13:52:02.917000Z</published><updated>2020-02-27T13:52:02.917000Z</updated><author><name>Vijolica555</name><uri>https://forge.codesys.com/u/vijolica555/</uri></author><id>https://forge.codesys.comcf39a6810acae7e6166860345e5c9b74702e5bb9</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I tested it with real inputs and looks like that my delta was approx equally big as the position difference. I look it one more time now a bit longer and yes you have right. THANK YOU!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Writing variable 'On change'</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5163b2ddc5/?limit=25#05ea" rel="alternate"/><published>2020-02-27T13:52:02.695000Z</published><updated>2020-02-27T13:52:02.695000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com230582cfa955ab7a5ec3a5953a75070147e8f922</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;Did you actually test this, because when you do this: pbuf1- pBuf2, you are asking the compiler to subtract pointer positions, not the value inside...&lt;/p&gt;
&lt;p&gt;If you have UDINTs to compare:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;Val1&lt;/span&gt; : &lt;span class="nv"&gt;UDINT&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;Val2&lt;/span&gt; : &lt;span class="nv"&gt;UDINT&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;ABS&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Val2&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;Val1&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
   ...
&lt;span class="nv"&gt;END_IF&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;You need the Absolute value in case Val1 is bigger than Val2.  Again, you can do math and less than/greater than/equal compares with any number data type.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Writing variable 'On change'</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5163b2ddc5/?limit=25#880d" rel="alternate"/><published>2020-02-27T13:52:02.048000Z</published><updated>2020-02-27T13:52:02.048000Z</updated><author><name>Vijolica555</name><uri>https://forge.codesys.com/u/vijolica555/</uri></author><id>https://forge.codesys.com444d25228e0b9633e4e5379ca8f387bbe325d48a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Yes I used memcmp and memcpy and it worked for comparing it. But.. How do I say I want to know if the difference is more then 5 for ex. MEMCMP has outputs just less, equal or more.. &lt;/p&gt;
&lt;p&gt;Just comparing:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;MEMCMP&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;pBuf1&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;ADR&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Byte1&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; , &lt;span class="nv"&gt;pBuf2&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;ADR&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;SaveByte1&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; , &lt;span class="nv"&gt;n&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
      &lt;span class="nv"&gt;Trig_Byte1&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;TRUE&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
      &lt;span class="nv"&gt;MEMCPY&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;destAddr&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;ADR&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;SaveByte1&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; , &lt;span class="nv"&gt;srcAddr&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;ADR&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Byte1&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; , &lt;span class="nv"&gt;n&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;END_IF&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;br/&gt;
Smt like that: save input into pointer, save also saved value (new value with thich you compare to the pointer) that compare that..&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;VAR&lt;/span&gt;
&lt;span class="nv"&gt;Input_Byte1&lt;/span&gt;   &lt;span class="nv"&gt;AT&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="nv"&gt;IB1&lt;/span&gt;    : &lt;span class="nv"&gt;BYTE&lt;/span&gt;&lt;span class="c1"&gt;; //our read variable&lt;/span&gt;
&lt;span class="nv"&gt;new_Byte1&lt;/span&gt;         : &lt;span class="nv"&gt;BYTE&lt;/span&gt;&lt;span class="c1"&gt;;//variable into which we save it&lt;/span&gt;
 
&lt;span class="nv"&gt;pBUf1&lt;/span&gt;   : &lt;span class="nv"&gt;POINTER&lt;/span&gt; &lt;span class="nv"&gt;TO&lt;/span&gt; &lt;span class="nv"&gt;UDINT&lt;/span&gt;&lt;span class="c1"&gt;; //pointer for our variable&lt;/span&gt;
&lt;span class="nv"&gt;pBuf2&lt;/span&gt;   : &lt;span class="nv"&gt;POINTER&lt;/span&gt; &lt;span class="nv"&gt;TO&lt;/span&gt; &lt;span class="nv"&gt;UDINT&lt;/span&gt;&lt;span class="c1"&gt;;//pointer to variable where we save readed variable&lt;/span&gt;
&lt;span class="nv"&gt;delta&lt;/span&gt;      : &lt;span class="nv"&gt;UDINT&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;END_VAR&lt;/span&gt;
&lt;span class="nv"&gt;pBuf1&lt;/span&gt;    :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;Input_Byte1&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;pBuf2&lt;/span&gt;   :&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;new_Byte1&lt;/span&gt;
&lt;span class="nv"&gt;CASE&lt;/span&gt; &lt;span class="nv"&gt;nSTEP&lt;/span&gt; &lt;span class="nv"&gt;OF&lt;/span&gt;
&lt;span class="mi"&gt;0&lt;/span&gt;:
   &lt;span class="nv"&gt;MEMCPY&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;destAddr&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;ADR&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;new_Byte1&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;, &lt;span class="nv"&gt;srcAddr&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;ADR&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Input_byte1&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,&lt;span class="nv"&gt;n&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;; &lt;/span&gt;
   &lt;span class="nv"&gt;nStep&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
   
&lt;span class="mi"&gt;1&lt;/span&gt;:
   &lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="ss"&gt;((&lt;/span&gt;&lt;span class="nv"&gt;pbuf1&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nv"&gt;pBuf2&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;delta&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;OR&lt;/span&gt; &lt;span class="ss"&gt;((&lt;/span&gt;&lt;span class="nv"&gt;pBuf1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nv"&gt;pbuf2&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;delta&lt;/span&gt;&lt;span class="ss"&gt;))&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
   &lt;span class="nv"&gt;MEMCPY&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;destAddr&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;ADR&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;new_Byte1&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;, &lt;span class="nv"&gt;srcAddr&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;ADR&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Input_byte1&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,&lt;span class="nv"&gt;n&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;; //save if delta&lt;/span&gt;
   &lt;span class="nv"&gt;END_IF&lt;/span&gt;
&lt;span class="nv"&gt;END_CASE&lt;/span&gt;
   
   
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>Writing variable 'On change'</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5163b2ddc5/?limit=25#5ce0" rel="alternate"/><published>2020-02-27T13:52:01.809000Z</published><updated>2020-02-27T13:52:01.809000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comde9fe03a288551ae3ceed172ca92ad9415812926</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;The statement IF NOT xxx = yyy will only work for BOOLs.  For other types simply use IF New &amp;lt;&amp;gt; Old.  Use memcmp when you have complicated variables like structures or arrays - I am not sure this always works: IF structX = structY... (aka deep compare)&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Writing variable 'On change'</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5163b2ddc5/?limit=25#6753" rel="alternate"/><published>2020-02-27T13:52:01.627000Z</published><updated>2020-02-27T13:52:01.627000Z</updated><author><name>Vijolica555</name><uri>https://forge.codesys.com/u/vijolica555/</uri></author><id>https://forge.codesys.come2384746cd11d6c04c4bef73c77819bcbd52a8bf</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Well.. I have problem with comparing bytes. With BOOL variable works fine:&lt;br/&gt;
IF NOT new = Old THEN &lt;br/&gt;
Save := TRUE;&lt;br/&gt;
Old := New;&lt;br/&gt;
END_IF&lt;/p&gt;
&lt;p&gt;With BOOL All good, Save goes TRUE but with BYTE not.. Nothing happens.. Any ideas?&lt;/p&gt;
&lt;p&gt;Update: I used memcmp and memcpy. It works now.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Writing variable 'On change'</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5163b2ddc5/?limit=25#60dc" rel="alternate"/><published>2020-02-27T13:52:01.482000Z</published><updated>2020-02-27T13:52:01.482000Z</updated><author><name>dFx</name><uri>https://forge.codesys.com/u/dfx/</uri></author><id>https://forge.codesys.com57b8fd09877b12458ebfda9009c936d978ad0f31</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;just read the source variable cyclically to know the value. Then compare with one you previously saved. If values are different, then trigger your write.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Writing variable 'On change'</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5163b2ddc5/?limit=25#1cf4" rel="alternate"/><published>2020-02-27T13:52:01.329000Z</published><updated>2020-02-27T13:52:01.329000Z</updated><author><name>Vijolica555</name><uri>https://forge.codesys.com/u/vijolica555/</uri></author><id>https://forge.codesys.com434ba1b9dfbdb161f73932998ee3515852f1eabc</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello,&lt;br/&gt;
I would like to do smt simmilar.. I want to save value everytime it changes and cyclicly every 15 min for ex.. How i detect change? Did you succed to write program for it?&lt;br/&gt;
Thank you.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Writing variable 'On change'</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5163b2ddc5/?limit=25#25ba" rel="alternate"/><published>2020-02-27T13:52:01.183000Z</published><updated>2020-02-27T13:52:01.183000Z</updated><author><name>micelan</name><uri>https://forge.codesys.com/u/micelan/</uri></author><id>https://forge.codesys.com56ef003135ee2cab7bab161a2600e77d358ebb5d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thankyou very much for the respons.&lt;/p&gt;
&lt;p&gt;I made something like this:&lt;/p&gt;
&lt;p&gt;2 writing, one is for the trigger variable and the other for the value I want to change.&lt;br/&gt;
1 reading, that is pointed to the same value of the second reading.&lt;/p&gt;
&lt;p&gt;I was espected that if I put one on the trigger variable (which come to true), the value on the writing should pass to the reading as well. But no way to connect the trigger variable to the action that identify the changing of the value on the plc?&lt;/p&gt;
&lt;p&gt;Thank you very much.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>