×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

SINT to STRING to REAL

SINT to STRING to REAL

SINT to STRING to REAL

(OP)
If anyone is up to a challenge, I have been working all day to figure out a good way to convert data retrieved from some legacy devices from ASCII format via SINT array to floating point. Putty returns the following;

My communication module returns each individual character as a SINT data type in an array (SINT[4000]). I need to pick out the 5 digits of data, apply the appropriate sign and exponent to create the floating point number. I have a few ways to do that but none of them are very pretty, because each digit is a separate SINT register. ControlLogix version 30 is the platform I'm using. Any good ideas out there? I hate working with ASCII data to begin with, but when it's reall SINT data to begin with it's even worse.

Brad Waybright

It's all okay as long as it's okay.

RE: SINT to STRING to REAL

(OP)
Sorry about the small screenshot. It was late in the day and I had to go to an appointment.

To clarify my situation, each character, including space, is returned as ASCII code in a single SINT in an array. The data shown here is actually 710 characters.
SO-- I have to capture each digit, rebuild it into an integer, apply the exponent and modify the sign if necessary. I can do this with ladder code but in all there are 110 data points I have to log so that's a lot of work for a PLC that has other jobs to do too. I find references to this problem in other places but they mostly explain how the ASCII/DINT conversion works which isn't applicable.

Brad Waybright

It's all okay as long as it's okay.

RE: SINT to STRING to REAL

Is there anyway to change the format coming out of the asc2 device? better to work with a real than an exponent. Even if you could have a whole number where the decimal place is understood to be at a certain position.

Otherwise your building a look up table with exponents to put the decimal place at a certain position in the string that represents the number. Then convert the string to real or dint.

I remember there is a feature I thought where if you use real that some of the precision is lost in the conversion. This might be a past bug in there conversion blocks, only way to see if when you test the data.

Process
1st thing is how you bring the data in. Some methods are slow and some are faster, you choose.
1 character at a time
or a large string in a holding register
2nd is convert the string to whole or real numbers
3rd is how do you store it for easy retrieval maybe in an array to be used in some other process in PLC.




RE: SINT to STRING to REAL

You might be better off using some type of programmable gateway. I believe the the AnyBus line has the ability to decode custom protocols.

RE: SINT to STRING to REAL

(OP)
My comm module returns data in a 4000 element array of SINT format. There are no options for that. Each character in the string is an ASCII code in a single SINT element. There are 709 SINT elements in the example shown above. If I try to copy SINT elements into a string data type, I get an excessively long STRING type length and cannot extract the wanted characters (I really only need the 5 value digits). If I search the PLC forums there are numerous instances of this question without any good answers. I think I'm going to have to convert each character one by one and do conversion math to make it work.

Brad Waybright

It's all okay as long as it's okay.

RE: SINT to STRING to REAL

(OP)
djs-
I am using ProSoft MVI56-GEC generic ASCII module.

Brad Waybright

It's all okay as long as it's okay.

RE: SINT to STRING to REAL

(OP)
I thought I had it, and was using the copy COP object to move array data into a STRING tag and then use the MID instruction to remove the desired characters. This has the unfortunate effect of making the string tag length LEN 168645424! Atomic STRING tags are limited to 82 characters so I don't know how that doesn't fault the processor or something, but the COP instruction isn't meant to work with STRING data type anyway.
I have created a way to generate the floating point tags from the SINT[4000] array, but it isn't really pretty. As with my past experiences, I'll just declare that ASCII sucks, at least to me.

Brad Waybright

It's all okay as long as it's okay.

RE: SINT to STRING to REAL

COP instruction sometimes you have to put length in from the string.len or really look at data to see what you are coping in that variable if coping from one data type to another. Its not straight forward as you see. When you copy to one different variable its inconsistent on what it copies.

I agree ASC instructions have a lot to be desired.
I always thought servers or pc did a better job of bringing in asc data.

Asc data programming is convoluted especially now that a lot of interfaces have gone to string data messaging. Makes PLC programmers job harder.

RE: SINT to STRING to REAL

> If I search the PLC forums there are numerous instances

Have you actually posed the question on PLCs.net?

http://www.plctalk.net/qanda/

Posting requires registration; it's instantaneous after replying to their email (no moderator review), as I recall.

RE: SINT to STRING to REAL

(OP)
Danw2- I did check those and found similar questions but no snswers so I thought I'd try this forum. No worries, it is up and running, I was just hoping I could find a better way.

Brad Waybright

It's all okay as long as it's okay.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close