<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Can't CodeSys count right?</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/40905c3ff6/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/40905c3ff6/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/40905c3ff6/</id><updated>2020-02-27T23:11:40.960000Z</updated><subtitle>Recent posts to Can't CodeSys count right?</subtitle><entry><title>Can't CodeSys count right?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/40905c3ff6/?limit=25#952a" rel="alternate"/><published>2020-02-27T23:11:40.960000Z</published><updated>2020-02-27T23:11:40.960000Z</updated><author><name>k2teknik</name><uri>https://forge.codesys.com/u/k2teknik/</uri></author><id>https://forge.codesys.com71ccf88e185830d8ec8efd40caf1081e071c2b5c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;shooter hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
A real is not exact, so it is close but can have a difference in result.&lt;br/&gt;
As the printing is not nicely rounded but just cut off, you can have strange results, i do expect more problems like is it a global var or do you do anything starnge with it, the only answer is when you send the complete program.&lt;br/&gt;
It is a global var, and I just add 0,1 to it every time my water counter tells me to do so. First I was afraid that the switch in the water counter was bouncing due to the fact that I was counting more that the mechanically meter showed on the water counter, but when I looked into the var during execution, and I see this strange counting rhythm/gait and was thinking WTF is this?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Zitat:&lt;/strong&gt;&lt;br/&gt;
counting is best done as an Unsigned Integer and the transfered to real.&lt;br/&gt;
so your formula is better when adding one&lt;br/&gt;
and then the result Int_to_real and div by 10&lt;br/&gt;
This was my next approach, I will try that out.&lt;/p&gt;
&lt;/blockquote&gt;&lt;/div&gt;</summary></entry><entry><title>Can't CodeSys count right?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/40905c3ff6/?limit=25#05a0" rel="alternate"/><published>2020-02-27T23:11:36.420000Z</published><updated>2020-02-27T23:11:36.420000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.com1fe1584e15947fcd315efe155074fcdcd8facbd0</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;A real is not exact, so it is close but can have a difference in result.&lt;br/&gt;
As the printing is not nicely rounded but just cut off, you can have strange results, i do expect more problems like is it a global var or do you do anything starnge with it, the only answer is when you send the complete program.&lt;br/&gt;
counting is best done as an Unsigned Integer and the transfered to real.&lt;br/&gt;
so your formula is better when adding one&lt;br/&gt;
and then the result Int_to_real and div by 10&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Can't CodeSys count right?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/40905c3ff6/?limit=25#2f3c" rel="alternate"/><published>2020-02-27T23:11:34.761000Z</published><updated>2020-02-27T23:11:34.761000Z</updated><author><name>k2teknik</name><uri>https://forge.codesys.com/u/k2teknik/</uri></author><id>https://forge.codesys.com3fe31e458e69966aa6441894d47f262541285f4f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I have a strange problem, I have a variable, declared as a REAL.&lt;br/&gt;
A line in my code goes like this:&lt;br/&gt;
MyVarA:=MyVarA + 0.1;&lt;/p&gt;
&lt;p&gt;That should, in my world, gives:&lt;br/&gt;
0.0&lt;br/&gt;
0.1&lt;br/&gt;
0.2&lt;br/&gt;
0.3&lt;br/&gt;
0.4&lt;br/&gt;
0.5&lt;br/&gt;
0.6&lt;br/&gt;
0.7&lt;br/&gt;
Aso.&lt;/p&gt;
&lt;p&gt;But for some reason it goes like:&lt;br/&gt;
0.04&lt;br/&gt;
0.14&lt;br/&gt;
0.25&lt;br/&gt;
0.35&lt;br/&gt;
0.45&lt;br/&gt;
0.55&lt;br/&gt;
0.65&lt;br/&gt;
0.75&lt;br/&gt;
0.86&lt;/p&gt;
&lt;p&gt;What is going on?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>