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 Thu Feb 27, 2020 6:09 pm

All times are UTC+01:00

Post new topic  Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Oct 03, 2018 12:49 pm 

Joined: Mon Nov 21, 2016 3:00 pm
Posts: 11
I have a simple add function that can't add 0,048 to a real variable if the real value is higher than 1048576.
I can add 1.0 to 1048576 and 0.1 to 104857 but not 0.01 to 1048576.
Does anyone have any ideas what is going on why it stops at 1048576 ??
CountTrig(CLK:=Enable );
IF CountTrig.Q
THEN Result:=Result+ValueAdd;

PostPosted: Mon Oct 08, 2018 3:08 am 
Frequent User
Frequent User

Joined: Fri Sep 02, 2011 8:02 pm
Posts: 312
I think you are basically at the precision limit of a real (32 bit float). With a number such as a million, there will be digitization and round off errors. If you search the internet you will find some examples. Here is one that claims at 1000000 the resolution steps are only 0.0625. ... imitations

I don’t always believe what I read, but in this case it is intuitive. If you need the accuracy, you need to switch to an LREAl, if your platform supports it.

Scott Cunningham
KEB America, Inc.

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

All times are UTC+01:00

Who is online

Users browsing this forum: No registered users and 3 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