ASCII array to REAL

LHiddle

Member
Join Date
Apr 2018
Location
Ohio
Posts
3
I have a SINT[500] array that is pulling data from a scale. The maximum number of characters that can be sent by the scale is 6, and there are two termination characters following the data (r and 1). If 123 is sent, is would show as:
1
2
3
$r
$1

If 13.264:
1
3
.
2
6
4
$r
$1

I need to take this array and convert it to REAL. Any ideas of how this could be done?
 
I assume you are using RS5000 you didn't say
use the STOR String to Real function (String to Real )
Strings in RS5000 are stored as an array of SINT's representing the ASCII value of the characters
you may have to strip off characters to show the true value
 
I corrected this post. The STOR works accurately up to the 5th decimal whereas the RTOS does not.

The RTOS has too many deviations. The DTOS is accurate and using a sub routine that breaks down a REAL into DINTs using math and concatenates can be as accurate as the programmer wants it to be. Even Rockwell understands that the Real To String has its problems.

Move or copy SINTs into Temporary_String.DATA[X], run the string through STOR.
 
Last edited:
"You can use a combination of STOD (String to DINT)and math instructions. Move or copy SINTs into Temporary_String.DATA[X], run each string through STOD. Multiply by the necessary 10s, and add together."

Thanks! How would I address the decimal place and termination characters?
 
I don't think the (STRING to DINT) can handle the decimal point very well I would us the (STRING to REAL) the REAL data type has a decimal point
 
I would just use like 10 (to cover the longest number of digits) conditional (not equal to terminator) CONCAT functions to build a string then use the string to real. That will handle the moving decimal point as well.
 

Similar Topics

hi, i try to capture barcode data using UDT with SINT ascii array. i have all the data i need but it in array format, how can i convert to 1...
Replies
5
Views
3,069
Using a ControlLogix processor, with version 12 firmware. I have a an array of INTs, where each INT contains a single ASCII character. I am...
Replies
6
Views
2,028
Greetings, I am currently working on a bit of code reset a work cell after a specific fault. It will be the scanning of a supervisors barcode...
Replies
5
Views
3,347
Problem: The new panel view plus doesn't support character arrays. The old Panel View program had them. What I did was just set multiple string...
Replies
4
Views
5,872
Hi, We couldn’t find anything specific, so am starting a new thread. I’m trying to migrate a config from a ML1400 to a micro820 & am experiencing...
Replies
1
Views
105
Back
Top Bottom