CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Sun Aug 18, 2019 6:36 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Fri Jul 12, 2019 3:36 pm 
Offline

Joined: Wed Oct 26, 2016 7:34 pm
Posts: 6
Hi

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.

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
0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.700000048, 0.8000001, 0.9000001, 1.00000012 etc..
and if you spin negative then the value are getting even more off some kind of rounding error

So what does happens here it it a conversion to/from some other number base ?
Sure I can start to change it to integer and the do some math forth and back divide etc but is that really intended?

Any nice trick?

Codesys V3.5 SP12 Patch 6pbF


Top
   
PostPosted: Sat Jul 13, 2019 10:26 am 
Offline
Frequent User
Frequent User

Joined: Wed May 04, 2016 6:00 pm
Posts: 274
Use s long integer instead.

T:lint
Timeon: lreal

T:=t+10

Timeon:=to_lreal(t)/10.0

Sent from my Moto G (5S) Plus using Tapatalk


Top
   
PostPosted: Sat Jul 13, 2019 3:46 pm 
Offline

Joined: Wed Oct 26, 2016 7:34 pm
Posts: 6
Yeah, so just tried with integer in the SpinControl and interval of 1 the calc a real

Test3_Value:=(int_to_real (spin2_value)/10);

and put it in a textbox instead of the build in textbox in the the SpinControl

I does work but a bit odd in codesys ...
I tried the the spincontrol in C# just for a test with a interval of 0.1 and there it works as expected

Anyway I have another question:
In Webvisualition I need a symbol as a "Tank" of liquid and to show the level of the liquid
I do not see any "Tank" in the webvisui, are there a place to get more symbols than what's standard in codesys?


Top
   
PostPosted: Sat Jul 13, 2019 5:44 pm 
Offline
User avatar

Joined: Fri Jan 19, 2018 3:38 pm
Posts: 76
option 1
Build the element yourself using the readily provided primitives (99.9 percent of the time this will suffice!)
There is a readymade bargraph element, but you can design your own bargraph (tip: use a rectangle or so).
When designing it yourself you will learn new cool stuff about the visualisation as a bonus.

option 2
Try google?

option 3
obtain the "visu-toolkit" which is a professional CODESYS add-on which you have to pay for.
As far as I know it comes with a mandatory training at CODESYS or on site.
For further details on it you should contact sales (or search this forum as there are some topics on it)

_________________
CfUnit is a free and opensource Unit testing framework for CODESYS
My profile on cForge


Top
   
PostPosted: Sun Jul 14, 2019 10:01 am 
Offline

Joined: Wed Oct 26, 2016 7:34 pm
Posts: 6
Aliazzz wrote:
option 1
Build the element yourself using the readily provided primitives (99.9 percent of the time this will suffice!)
There is a readymade bargraph element, but you can design your own bargraph (tip: use a rectangle or so).
When designing it yourself you will learn new cool stuff about the visualisation as a bonus.


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.
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.

It might be the same if you could add in a library with symbols for web visu on certain models of PLC

Aliazzz wrote:
option 2
Try google?

Yeah I know Google.... but I really did not find what I had in mind :(

Aliazzz wrote:
option 3
obtain the "visu-toolkit" which is a professional CODESYS add-on which you have to pay for.
As far as I know it comes with a mandatory training at CODESYS or on site.
For further details on it you should contact sales (or search this forum as there are some topics on it)


That might be a route, need to loo into symbols and pricing

Thank You


Top
   
PostPosted: Fri Jul 26, 2019 3:11 pm 
Offline
Frequent User
Frequent User

Joined: Fri Dec 23, 2005 7:36 pm
Posts: 179
Wiljan wrote:
Hi

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.

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
0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.700000048, 0.8000001, 0.9000001, 1.00000012 etc..
and if you spin negative then the value are getting even more off some kind of rounding error

So what does happens here it it a conversion to/from some other number base ?
Sure I can start to change it to integer and the do some math forth and back divide etc but is that really intended?

Any nice trick?

Codesys V3.5 SP12 Patch 6pbF


The reason this happens is because 0.1 cannot be exactly represented in a REAL which follows the IEEE-754 Floating point number convention.

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.

You can check out this site (and several others) to see how floats/REAL are stored in the computer.
https://www.h-schmidt.net/FloatConverter/IEEE754.html

_________________
nOrM
=====
nOrM = Norman Dziedzic Jr.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 6 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited