nealmp

ASCII Conversion in RSLogix5000

6 posts in this topic

I have been using RSLogix programming for a little time now, and I have run into a problem with converting ASCII characters coming in from a remote console into usable data in my program. Right now they are stored in tags of a data type SINT, or signed integer. I would like to convert them to a string of an equivalent value to the incoming data for comparison. For example, a character of incoming data could contain a value of 121, which is equivalent to 'y' as an ASCII string. I would like to convert it into that character so that I can compare and evaluate the next step of my project. I am aware of the DTOS and STOD functions that are at my disposal, but I am missing some in between step. Or perhaps I am on the wrong thought process altogether. I am not sure.

 

My work associate described them as having 8 bits of data in which I have to pack into a new string whose length I must define. Does anyone know what I am missing?

Share this post


Link to post
Share on other sites

Okay, I figured something out. Earlier when I tried copying it straight from the tag reading from the console into a string, it had been copying into the length instead of data. I can tell it to copy into the data set of my string and it will give me the ascii character. Might have been what I was missing.

Share this post


Link to post
Share on other sites
16 hours ago, TravisPedley said:

string.JPG

Yep, I had realized that about 5 minutes after I posted this thread that I had forgotten to add the .DATA[0] suffix in my copy instruction, therefore when I executed the instruction it was copying into the length of the string rather than its data, giving me a length of the ASCII value I was copying. A newbie mistake on my part.

Edited by nealmp

Share this post


Link to post
Share on other sites

Travis,

Saved my tail.  Thanks for the solution!

Share this post


Link to post
Share on other sites

Hi Travis,

Thanks so much for your post (4 years ago now!), this has really helped me!

Stuart :)

 

 

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