RSLogix Integer(N) to Ascii (A)

Vetteboy

Member
Join Date
Jul 2002
Posts
380
If I have an integer, lets say N7:0 with a value of 10 in it, what's the simplest way to covert it to ascii and put it A29:700? My attempts at copying and moving won't covert it, so it's displaying ascii equivalents of the decimal numbers rather than converting it.
All my documentation refers to ST files, of which I have none, and would like to avoid.

Vetteboy
 
Vetteboy-
I don't know of a way to do the conversion directly into an ASCII file. However, if you don't mind using the string data type (ST) as an intermediate step you can probably do it. Use the AIC instruction to convert the integer and put it into the string variable (ST10:0). The use a copy to go from the string variable to the ACSII file:
(COP #ST10:0, #A29:700, 3). This should copy over an ASCII representation of up to -32767. Be careful as the number will be justified to A29:700 and use only as many ASCII file elements as it needs. The number 12 would all be in A29:700. 123 would have ASCII 1 and 2 in A29:700 and ASCII 3 in A29:701.

Just so you know, I've never tried this but Logix lets me enter it so it will at least do something.

Keith
 
Thanks for the Quick reply Keith, I guess I'll do that, I can't find any other way either. If anyone knows of a better way, please let me know.
 
I don't know what you have for a plc platform. I entered the suggestion into a PLC5/40 and it worked OK. The first ASCII element gets what appears to be a length value so you either need to start your copy one ASCII element sooner or start picking your digits off one ASCII element later. Also, make the element count for the copy command 4 since the first element is not part of the number and you need 3 full elements to store a 5 digit signed number. And finally, put an (FLL 0, #ST10:0, 1) in front of the AIC instruction. The AIC instruction doesn't fill the string with zeros on anything it doesn't convert so if you don't explicitly set reset the string you may end up with old garbage in the string after the conversion.

Good luck,
Keith
 
Thanks Keith, that did the trick. Without the heads up I would have been scratching my head for awhile. What I had to do is up and running, so all is well. I owe you a beer.

Vetteboy
 

Similar Topics

I've got a Keyence barcode scanner I've got coming in via Ethernet to a Micrologic 1100. I've got the data coming into N Type Data Files and when...
Replies
12
Views
7,094
While designing a project in RSLogix5000, I came upon the information that using DINTs is more efficient than using SINTs or INTs (Reference...
Replies
5
Views
3,642
Hello, I've got a tricky math problem. I have a double integer that I need to divide by 10,000, and separate it into quotient and remainder. I...
Replies
9
Views
7,533
We are having intermittent problems with the transfer of data in a sequence of events where the data is being lost or overwritten and the problem...
Replies
9
Views
5,993
Hi Everyone, I am not proficient in RSLogix 500 so I have a question regarding the evaluation of N7:0 data as an input. So as I understand in...
Replies
1
Views
85
Back
Top Bottom