RSLogix 5000 REAL to DINT

awaege

Member
Join Date
Jun 2019
Location
Appleton WI
Posts
10
I've always been a bit confused as to how RSLogix 5000 converts between data types of floating point to whole numbers. For the application I am working on I want to use a "floor" type function to simply round down a real value to the nearest whole number. Will simply passing the real output of the computation truncate the decimal? How is this handled?

Thanks for any insight.
 
Logix controllers use a "Dutch rounding" method (also known as convergent rounding, statistician's rounding, Gaussian rounding, or bankers' rounding) when converting from REAL to DINT. This means that it rounds to the nearest integer. When the REAL is exactly halfway between integers (e.g. 1.5), it rounds to the nearest even integer. So:


1.499999 >> 1
1.5 >> 2
2.5 >> 2
2.500001 >> 3
3.5 >> 4
4.5 >> 4


and so on.
 
5000 converts between data types of floating point to For the application I am working on I want to use a "floor" type function to simply round down a real value to the nearest whole number.
Thanks for any insight.


If you want it to round down then subtract .5 ,then move it.
 
Or just use the TRN (truncate) instruction. You can also use the TRN operator inside a CPT instruction.

1.00001 >> 1
1.99999 >> 1

Obviously, this only applies if you always want to round down, as opposed to rounding to nearest. Given your description of a "floor" function, I expect you want the former.
 

Similar Topics

Hi Everyone, Im here to ask how to convert DINT to REAL. Im using modscan32 to inject current & read from 2 word address register, eg: 40001 &...
Replies
2
Views
31,770
I am trying to automatically send an email via RSLogix 5k. I have already set up my msg instructions to configure the mail server and created a...
Replies
5
Views
4,630
Hi, I am new to contrologix's. I want to read few bits of tag type real. Consider 'Out_real' tag declared as real. I want to read 14, 20, 31st...
Replies
8
Views
9,722
Hello, I am trying to read a barcode scanner input using a cognex dataman 280 barcode reader, store it another string, the compare with another...
Replies
1
Views
101
Hi folks, in the alarm manager of Rslogix 5000, the tag-based alarm has been created. But when I tried to change the condition, it was found the...
Replies
2
Views
202
Back
Top Bottom