Maths problems while totalising pulses

Outrage

Member
Join Date
Jul 2006
Location
Nottinghamshire
Posts
173
Hi All,

Rockwell Compact Logix processor.

I'm using an Add function that I trigger by a using an XIC instruction followed by a ONS. The add takes a value of 0.1 and adds it to my accumulated value and stores the resultant in the accumulated value therefore increasing the accumulated value by 0.1 every pulse.

I've set my accumulator tag up as a Real but I get occurances of the value reading to several decimal places i.e. 1.000001 for example. whereas I would have expected the maths to always give me only one decimal place?

This one rung forms part of an add on instruction, there is no other data manipulation of the accumulator other than writing it to zero on occasion.

Any ideas where the weird maths is coming from?

Cheers,

Lee
 
I recommend you store the total number of pulses, and then do the math to obtain a real number once, starting with that whole integer value which will not lose accuracy.

I agree. A DINT will store a better representation. If you actually need the decimal representation within the program then you can do the division by 10.0 and store the result in a real. Otherwise if it's only for display then let the disply show the decimal.

In the same manner that a decimal point number can't store an exact representation of 1/3 (it just keeps getting closer and closer as the threes are added), the real in computers can't store an exact representation of 1/10. All number systems have problems.
 
Thanks Chaps, that's a useful response.

I'll change the program to store the pulses and then do the division. I do need the decimal point as I'm using the accumulated value in a compare to dose in chemicals to a fractions of 0.1 of a litre. The dose values are typically only a few litres but at the moment I'm finding that I might be out by around 0.2 of a litre depending on the rounding, The dosing accuracy isn't that critical but I'd like to get it on the money.

jkerekes - Thanks for the suggestion but I'm a ladder programmer through and through!

Cheers,

Lee
 
Thanks Chaps, that's a useful response.

I'll change the program to store the pulses and then do the division. I do need the decimal point as I'm using the accumulated value in a compare to dose in chemicals to a fractions of 0.1 of a litre. The dose values are typically only a few litres but at the moment I'm finding that I might be out by around 0.2 of a litre depending on the rounding, The dosing accuracy isn't that critical but I'd like to get it on the money.

jkerekes - Thanks for the suggestion but I'm a ladder programmer through and through!

Cheers,

Lee


Well you don't need to use FBD to use the totalizer. You could use an add-on instruction to use the FBD totalizer. Then the toalizer function could be used in ladder.
 

Similar Topics

Hi Folks I hope this is not a dumb question,I am a newbie . I want to perform simple math functions like multiplication, addition etc in TIA...
Replies
6
Views
2,817
Hi all, I am trying to copy paste a routine from rs logix500 into rs logix5000, I get an error on rung where they are searching for scada values...
Replies
1
Views
1,853
Hi I am fairly new to PLC programming and I am self learning. I have written a simple program to detect and store the RPM and ultimately the...
Replies
0
Views
1,413
Hi everyone, I am generally comfortable with AB PLC's and programming but have recently acquaired a job where I need to modify an Omron Cqm1h...
Replies
2
Views
3,720
HI all - am hoping someone could help me a little... I am something of a novice and need to sort out my analogue Outs and Ins for a small...
Replies
3
Views
6,212
Back
Top Bottom