# rounding a value to nearest 10

## 5 posts in this topic

Hi

I have flow meters and have them counting up to a value and stopping a pump.

it all works but the display on the hmi counts up in decimal places because of the scale factor of the flow meters.

To scale them because of inacuracy I basically multiply what I want to count to by 1000 and i basically add for every pulse of the flow meters a value between 1500 and 500 to count to scale the flow meters then compair the two to stop the pump if the count is equal to or greater than the dialed in amount.

Is there an easy way to round this value to the nearest bigest 10's value?

I'm guessing convert to a floating point use the FIXL instruction?

is there an easy way im missing as I could not seem to find a rounding instruction?

##### Share on other sites

What screen are you using?

If it is only for display, the NS screens will round the value automatically to the number of digits shown. FYI... the NS screens will also scale for you.

##### Share on other sites

1 person likes this

##### Share on other sites

I'm using a mixture of NB and NS screens currently and possibly in the future ignition scada.

That is one option I guess but it is screen dependant and would be nice to do it in the plc.

##### Share on other sites

Hi,

Here's a suggestion for the logic to use

1. Add 5 (half of 10) to make the result to round up or round down
2. Divide by 10
3. Convert to INT type to truncate.
4. Multiply by 10

So 32 would become (INT((32+5)/10)) * 10 = 30 or 37 would become 40. Sorted?
Regards,

BB