Sign in to follow this  
Followers 0
Evnttrggr

Problem with RTOS instruction in CLX

3 posts in this topic

Hi, I am using a RTOS instruction, CLX, to convert my data, which is in a UDT to string. The problem which I am facing can be expalined with the following example: my source contains value: 32000200.00. But the output is a string with value 3.20002000e+007. I was expecting the output to be just a string with value 3200200 (the fractional part being truncated). The project contraints do not allow me to change the type of the destination. I am using the source as Real, since it is part of a UDT with most of the components being Real. I've bunched all the Real values together. I would like to keep this structure. Currently I am using SoftLogix for testing. Later, I will be using the L63 controller. Any advises and/or insights? Thanks in advance for the help, Regards Evnttrggr

Share this post


Link to post
Share on other sites
Figured out another way. I first coonvert Real to DINT then to String. I then get the desired result. However I would like to know, why is it not working directly for the Real value. I might save on using one instruction!! Evnttrggr

Share this post


Link to post
Share on other sites
You can use DTOS which does a type conversion implicitly (drops the fraction) if you call it with a real. There is unfortunately no equivalent of the sprintf instruction which would allow for formatting control, unless you write your own (AOI).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0