helphelphelp
Member
Hello again,
I'm using an Allen Bradley PLC connected to a laser marker which marks the data from a string tag to a part. The data in the string tag is a counter, for example 0001, 0002, 0003, etc. It's always 4 places.
The problem I'm running into is rounding with the RTOS instruction. I am dividing the real number by 10000 in order to get 4 decimal places after the zero. For example, the part count could be 880. The result looks like '0.0880'. I then use a middle string instruction to extract those 4 values to my string output to the laser marker.
Occasionally, I'll get a result of '0.17219999999999' or something similar in my RTOS instruction. This value should be '.01722'. My middle string conversion then pulls the '0.1721' instead of what should be a '0.1722'.
It's pretty difficult to explain what is happening in words but what I'd like to know is what can I do to limit my RTOS string to 4 decimal places so that it rounds correctly.
Thanks in advance!
Cheers
I'm using an Allen Bradley PLC connected to a laser marker which marks the data from a string tag to a part. The data in the string tag is a counter, for example 0001, 0002, 0003, etc. It's always 4 places.
The problem I'm running into is rounding with the RTOS instruction. I am dividing the real number by 10000 in order to get 4 decimal places after the zero. For example, the part count could be 880. The result looks like '0.0880'. I then use a middle string instruction to extract those 4 values to my string output to the laser marker.
Occasionally, I'll get a result of '0.17219999999999' or something similar in my RTOS instruction. This value should be '.01722'. My middle string conversion then pulls the '0.1721' instead of what should be a '0.1722'.
It's pretty difficult to explain what is happening in words but what I'd like to know is what can I do to limit my RTOS string to 4 decimal places so that it rounds correctly.
Thanks in advance!
Cheers