12/14/2011 11:56 AM  
Posts: 9 Rating: (0) 
Dear all, We're having a small when programming an totalizer. Every pulse we get from the flowmeter we add 0.1 to a realValue Now when the number gets bigger it sometimes doesn't add 0,1 but 0,09. I've checked the sequence and came across this We start with 19000 NExt time he adds 0,09 is at 19001,2 the we get 19001,29 (+1,29) next 19003,88 (+2,59) next 19006,47 (+2,59) next 19008,96 (+2,49) Does anyone know how this is possible? I've checked this: https://support.automation.siemens.com/WW/llisapi.dll?func=cslib.csinfo&objId=22172161&load=treecontent&lang=en&siteid=cseus&aktprim=0&objaction=csview&extranet=standard&viewreg=WW but did not found an answer to this problem. Tnx in advance 
12/14/2011 12:07 PM  
Joined: 9/28/2005 Last visit: 7/10/2024 Posts: 2957 Rating: (242) 
Hello, Indeed, your numbers aren't so big to cause the problem. Very strange issue. I also would like to see feedback from other users about this issue. In the mean time maybe you could post part of your code where you calculate the totalizer ? One tip from me. I use REAL values only for represent analog sensors in engineering units format, but for totalizers allways use DINT. Its the same size, but allows to count much much more and still have required precision. 
Best regards, 

12/14/2011 2:42 PM  
Joined: 8/31/2005 Last visit: 7/18/2024 Posts: 2198 Rating: (328) 
Hello, AttachmentREAL.pdf (376 Downloads) 


This contribution was helpful to3 thankful Users 
12/15/2011 12:15 PM  
Joined: 11/25/2011 Last visit: 6/11/2022 Posts: 16 Rating: (1) 
Hi Csar1985, could you please post a screenshot how you make the sum? best Regards,

12/15/2011 1:06 PM  
Posts: 5 Rating: (1) 
We do a totaliser with 2 counters (reals). First one just counts up to a certain limit. Ones this value exceeds this limit, we substract the limit from this first counter and add it to the second counter value. Like this, the first counter value always stays small enough so there is no rounding error and the second value ensures that we can have big totalised values. Its a bit more complicated to work with, but we are able to make a totaliser with reals 
12/15/2011 1:37 PM  
Joined: 9/8/2009 Last visit: 7/17/2023 Posts: 1410 Rating: (152) 
you can use oscat library to implement quasi LREAL variable: VAR_INPUT BEGIN temp := X.RX; R2_ADD := tR2_ADD; (* revision history *) 
Last edited by: Marko Bursic at: 12/15/2011 1:50 PM 

11/1/2017 10:42 AM  
Joined: 9/11/2015 Last visit: 8/29/2023 Posts: 6 Rating: (2) 
Siemens REAL precision fault: Same problem on a 1518 fw2.1, and its not that I am reaching the last significant number. Problem starts right from 0.0. Try to run on each cycle: fRealNumber := fRealNumber + 0.1; You will get numbers like 28.70007 100.399 149.6999 229.8048 1768.015 and so on. Same problem with LReal, seems like last bit of the number is random. 
11/1/2017 11:08 AM  
Posts: 103 Rating: (37) 
It is time you make a study of how floating point numbers (REAL) are represented by digital computers. Wikipedia's description should help but this calculator makes it more visual: Perhaps it is best for you to use 64bit integer with a whole number divider. 
This contribution was helpful to2 thankful Users 
11/2/2017 10:31 AM  
Joined: 6/24/2013 Last visit: 7/13/2024 Posts: 1612 Rating: (416)

Hi You may need to use Long Real (64bit Real) for Totalizer and covert result to Real just for processing/display. Library can be found on this forum. 1. convert value to be added to Long Real 2. Add to Totalizer (using Long Real Add function) 3. convert Totalizer to Real for rest of your program (to a different memory location so Long Real value is not overwritten during conversion) 
2/15/2020 10:21 AM  
Joined: 1/28/2010 Last visit: 6/19/2024 Posts: 66 Rating: (0) 
Hello experts, With reference to below query and discussion, Shall we consider it the software issue in Siemens PLC? I have also faced same issue for totalizer but instead of adding 0.1 in real , 1 added in DINT , converted DINT to real and then divide by 10.0. But in some cases if we need to calculate deltaP it creates issue If P1= 10.0 & P2=0.9 then P1P2=10.010.9= 0.9 but sometimes it gives result as 1.0. Shankar

Follow us on