Quantcast
Channel: Allen Bradley / Rockwell Automation Latest Topics
Viewing all articles
Browse latest Browse all 3762

Converting REAL to STRING, with defined precision

$
0
0

Hi gurus,

I am running Studio 5000 and am building a comma delimited data string to send out via ASCII with the 5069-SERIAL card (CompactLogix).

I am more familiar with Siemens on this, and there is a function called VAL_STRG in which you can convert a real to a string and define the precision or how many decimal places it will have (attached).

I am unable to find something similar and am scratching my head at how to write something robust enough to accommodate a real number that can have one or two decimal places and convert it to a string that will HOLD that precision throughout the range of the number. I guess for a number with one decimal place I could multiply by 100, convert to STRING, and then insert the decimal place, but it sounds like maybe overkill....? Currently if I bring the real even to a user-defined STRING of say 5 characters, the decimal "moves" as the number grows or shrinks.

Any help or hint in the right direction would be greatly appreciated.

 

Siemens_Val_String.PNG

AB_RTOS_too_many_decimal_places.PNG


Viewing all articles
Browse latest Browse all 3762


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>