<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to SpinControl Rounding "Error"</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4364b3b39a/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4364b3b39a/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/4364b3b39a/</id><updated>2020-02-27T13:48:02.832000Z</updated><subtitle>Recent posts to SpinControl Rounding "Error"</subtitle><entry><title>SpinControl Rounding "Error"</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4364b3b39a/?limit=25#d6d1" rel="alternate"/><published>2020-02-27T13:48:02.832000Z</published><updated>2020-02-27T13:48:02.832000Z</updated><author><name>ndzied1</name><uri>https://forge.codesys.com/u/ndzied1/</uri></author><id>https://forge.codesys.com8447cb5a9e643394c22cc6b65f76268280dc8630</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Wiljan hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
Hi&lt;br/&gt;
The user need to adjust a var Test (REAL)in 0.1 step in range 0..2 so I have added in a SpinControl in the visualization and I set that to a variable Test REAL, added in a interval of 0.1 and a limit of 0 and 2.&lt;br/&gt;
Thant works somehow fine ....but you would expect it step like 0.0, 0.1, 0.2, 0.3 etc to 2.0 in both directions, but what happens are &lt;br/&gt;
0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6,  0.700000048, 0.8000001, 0.9000001, 1.00000012 etc..&lt;br/&gt;
and if you spin negative then the value are getting even more off some kind of rounding error&lt;br/&gt;
So what does happens here it it a conversion to/from some other number base ?&lt;br/&gt;
Sure I can start to change it to integer and the do some math forth and back divide etc but is that really intended?&lt;br/&gt;
Any nice trick?&lt;br/&gt;
Codesys V3.5 SP12 Patch 6pbF&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The reason this happens is because 0.1 cannot be exactly represented in a REAL which follows the IEEE-754 Floating point number convention.&lt;/p&gt;
&lt;p&gt;Your 0.1 value is actually 0.100000001490116119384765625 inside the computer. After adding a few time, those extra bits start to show up in your summed number.&lt;/p&gt;
&lt;p&gt;You can check out this site (and several others) to see how floats/REAL are stored in the computer.&lt;br/&gt;
&lt;a class="" href="https://www.h-schmidt.net/FloatConverter/IEEE754.html" rel="nofollow"&gt;https://www.h-schmidt.net/FloatConverter/IEEE754.html&lt;/a&gt; m &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>SpinControl Rounding "Error"</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4364b3b39a/?limit=25#c808" rel="alternate"/><published>2020-02-27T13:48:02.770000Z</published><updated>2020-02-27T13:48:02.770000Z</updated><author><name>Wiljan</name><uri>https://forge.codesys.com/u/wiljan/</uri></author><id>https://forge.codesys.com935d3621d1a19ef21acd532f29f67c35f72195e6</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Aliazzz hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
option 1&lt;br/&gt;
Build the element yourself using the readily provided primitives (99.9 percent of the time this will suffice!)&lt;br/&gt;
There is a readymade bargraph element, but you can design your own bargraph (tip: use a rectangle or so).&lt;br/&gt;
When designing it yourself you will learn new cool stuff about the visualisation as a bonus.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I'm already doing that, but was wondering if there were some free open add-on somewhere or a description how to build your own eg if they are save in a xml style or so.&lt;br/&gt;
Since I work with Festo and they do have a HMI libray where you use studio designer where you have a lot of ready very nice symbols available, (whic for sure only work with Festo HMI scereens) and thereby are "Paid" it makes sense.&lt;/p&gt;
&lt;p&gt;It might be the same if you could add in a library with symbols for web visu on certain models of PLC&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Aliazzz hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
option 2&lt;br/&gt;
Try google?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Yeah I know Google.... but I really did not find what I had in mind   &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Aliazzz hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
option 3 &lt;br/&gt;
obtain the "visu-toolkit" which is a professional CODESYS add-on which you have to pay for.&lt;br/&gt;
As far as I know it comes with a mandatory training at CODESYS or on site.&lt;br/&gt;
For further details on it you should contact sales (or search this forum as there are some topics on it)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That might be a route, need to loo into symbols and pricing&lt;/p&gt;
&lt;p&gt;Thank You&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>SpinControl Rounding "Error"</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4364b3b39a/?limit=100#b19f" rel="alternate"/><published>2020-02-27T13:48:02.707000Z</published><updated>2020-02-27T13:48:02.707000Z</updated><author><name>aliazzz</name><uri>https://forge.codesys.com/u/aliazzz/</uri></author><id>https://forge.codesys.comf264e3703e29373a4596d3b6c4f3d1ebd1d909ca</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;option 1&lt;br/&gt;
Build the element yourself using the readily provided primitives (99.9 percent of the time this will suffice!)&lt;br/&gt;
There is a readymade bargraph element, but you can design your own bargraph (tip: use a rectangle or so).&lt;br/&gt;
When designing it yourself you will learn new cool stuff about the visualisation as a bonus.&lt;/p&gt;
&lt;p&gt;option 2&lt;br/&gt;
Try google?&lt;/p&gt;
&lt;p&gt;option 3 &lt;br/&gt;
obtain the "visu-toolkit" which is a professional CODESYS add-on which you have to pay for.&lt;br/&gt;
As far as I know it comes with a mandatory training at CODESYS or on site.&lt;br/&gt;
For further details on it you should contact sales (or search this forum as there are some topics on it)&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>SpinControl Rounding "Error"</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4364b3b39a/?limit=25#b797" rel="alternate"/><published>2020-02-27T13:48:02.631000Z</published><updated>2020-02-27T13:48:02.631000Z</updated><author><name>Wiljan</name><uri>https://forge.codesys.com/u/wiljan/</uri></author><id>https://forge.codesys.com265dbc9cc1aeb49b9bcf2dcae61b94ef981cd177</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Yeah, so just tried with integer in the SpinControl and interval of 1 the  calc a real &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nt"&gt;Test3_Value&lt;/span&gt;&lt;span class="o"&gt;:=(&lt;/span&gt;&lt;span class="nt"&gt;int_to_real&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;spin2_value&lt;/span&gt;&lt;span class="o"&gt;)/&lt;/span&gt;&lt;span class="nt"&gt;10&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;and put it in a textbox instead of the build in textbox in the the SpinControl&lt;/p&gt;
&lt;p&gt;I does work but a bit odd in codesys ... &lt;br/&gt;
I tried the the spincontrol in C# just for a test with a interval of 0.1 and there it works as expected&lt;/p&gt;
&lt;p&gt;Anyway I have another question:&lt;br/&gt;
In Webvisualition I need a symbol as a "Tank" of liquid and to show the level of the  liquid&lt;br/&gt;
I do not see any "Tank" in the webvisui, are there a place to get more symbols than what's standard in codesys?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>SpinControl Rounding "Error"</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4364b3b39a/?limit=25#3a9b" rel="alternate"/><published>2020-02-27T13:48:02.574000Z</published><updated>2020-02-27T13:48:02.574000Z</updated><author><name>josepmariarams</name><uri>https://forge.codesys.com/u/josepmariarams/</uri></author><id>https://forge.codesys.com65a7cb6ffce6fe1ef03fd9608627c88406d5a3c5</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Use s long integer instead.&lt;/p&gt;
&lt;p&gt;T:lint&lt;br/&gt;
Timeon: lreal&lt;/p&gt;
&lt;p&gt;T:=t+10&lt;/p&gt;
&lt;p&gt;Timeon:=to_lreal(t)/10.0&lt;/p&gt;
&lt;p&gt;Sent from my Moto G (5S) Plus using Tapatalk&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>SpinControl Rounding "Error"</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4364b3b39a/?limit=25#e194" rel="alternate"/><published>2020-02-27T13:48:02.515000Z</published><updated>2020-02-27T13:48:02.515000Z</updated><author><name>Wiljan</name><uri>https://forge.codesys.com/u/wiljan/</uri></author><id>https://forge.codesys.combc1c827368597d1f0b2183298cf82089edaf7fd6</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;The user need to adjust a var Test (REAL)in 0.1 step in range 0..2 so I have added in a SpinControl in the visualization and I set that to a variable Test REAL, added in a interval of 0.1 and a limit of 0 and 2.&lt;/p&gt;
&lt;p&gt;Thant works somehow fine ....but you would expect it step like 0.0, 0.1, 0.2, 0.3 etc to 2.0 in both directions, but what happens are &lt;br/&gt;
0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6,  0.700000048, 0.8000001, 0.9000001, 1.00000012 etc..&lt;br/&gt;
and if you spin negative then the value are getting even more off some kind of rounding error&lt;/p&gt;
&lt;p&gt;So what does happens here it it a conversion to/from some other number base ?&lt;br/&gt;
Sure I can start to change it to integer and the do some math forth and back divide etc but is that really intended?&lt;/p&gt;
&lt;p&gt;Any nice trick?&lt;/p&gt;
&lt;p&gt;Codesys V3.5 SP12 Patch 6pbF&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>