Ascii data value to integer file

mohamed_idris

Member
Join Date
Feb 2011
Location
nairobi
Posts
41
Please Help On Allen Bradley PLC SLC500

I'm receiving Ascii string data values from a serial devices and put the value into a string file; How can I transfer these Ascii value to integer file (N) for manipulation

<DLE><STX>1A1L000015000505IÁ<DLE><ETX>
My Ascii Data is: 1A1L000015000505

I have tried to use string to integer instruction (ACI) does not give out the result.
Hex value: 10023141314C30303030313530303035303549C11003
 
Shifting values from N file 16 bit to 8bit

Hi Thanks

I have done copy now it working but the values are on 16bit registers
On Hex\BCD Radix it gives 3155 3133
How can represent into this format on the same Radix:
31 55 31 33
Open attachment for the image

20140105_165056.jpg 20140105_165122.jpg
 
How can I represent [the original string] into this format on the same Radix:
31 55 31 33
It is not clear what you want to do. What is the type of number that you want to end up with (String, Integer, ASCII, Floating Point)?

If you want to convert a String (that has unwanted characters at beginning and end) to an Integer number, then first do a String Extract (AEX), with Index = 5, Number = 12. This will pull out only the number that you want. Then do ACI to convert those 12 characters to an Integer number.

Step 1: Create a ST (String) file, say "ST9" of type STRING. Then use AEX (String Extract) with an Index = 5, Length = 12, to extract only the portion of the string that you wish to convert to a number. Step 2: Convert the new 12-character string to an integer number.
 
Hi

Yes I have done that using String Extract (AEX)
My string Values are: ^P^B1U13\00)7^P^C
Extracted Ascii value: 1U13\00
Hexadecimal values: 3155 3133

But when I use string to integer (ACI)
I'm getting: ^A at N file
Open attachment for the pictures:

20140105_182233.jpg 20140105_182023.jpg 20140105_182124.jpg
 
You are trying to put a String into an Integer file register (mixing file types does not usually work very well).

Try reversing the order of your last two instructions.
(1) Do AEX to a ST-type file location, then
(2) ACI to convert the extracted String to an Integer number type and store at N38:110, then
(3)do the COP (only if you want a copy of the Integer number at another Integer location).

For the AEX to always work, your Strings must be the same length with the same number of unwanted characters at the beginning and end. If your Strings vary in length, you will have to do some other operations to find the number you want to extract.

When using the ACI, your ASCII number must be in the range of -32767 to 32767. If it is bigger or smaller, you must not use ACI, but will have to write a routine to convert from ASCII characters to a F8 floating-point number. There have been routines posted on this site to do that conversion.
 
Last edited:
Hi
I was just showing that on the copy function (COP)I'm able to get these value but on 16 bit register representation
(3155) (3133)
While I need my values to be (31) (55) (31) (33)
Still once I do AIC the string length is indicating less than one 1<
Let me do on a new string file
 
Do you want to convert the initial String into a Hexadecimal number (and NOT a Decimal number of any type (Integer, Long Integer, Floating Point)? If so, you cannot do that using the ACI (ASCII to Integer conversion).

I think you need a routine to convert an ASCII character string into a Hexadecimal number. See the solutions in these threads:

http://www.plctalk.net/qanda/showthread.php?t=28833&highlight=ASCII+hexadecimal+number

http://www.plctalk.net/qanda/showthread.php?t=2012&highlight=ASCII+hexadecimal+number

If you want to convert an ASCII string into 4 hexadecimal numbers, then first use AEX for 4 cases, where your extract the string part that represents each of the 4 numbers and store it into a new string, then use a conversion routine to convert each of the 4 new strings into a Hexadecimal number.
 
Last edited:
I have gone through the link and it is working on both cases
Case One: Extract the single Ascii character from the string file by use of AEX and convert that SINGLE character to integer by use of ACI and copy to N file.
Case Two: Use what has been proposed by Allen Nelson on the link: http://www.plctalk.net/qanda/showthread.php?t=2012&highlight=ASCII+hexadecimal+number
Which method do you think is much better to work with ASCII data.
 
If Case 1 is working for you, it means you really wanted an Integer-type number (not a hexadecimal output), so use this one because it is much easier and shorter.
 

Similar Topics

Hello, Thanks in advance. How can I send more than 82 characters using AWA or AWT? to Zepra Printer via serial Rs232 communication? Normally I...
Replies
1
Views
770
Does anyone know how to inhibit the 232 module from sending data during PLC power-up? To send data during normal operation, the Transmit Record...
Replies
3
Views
1,908
I am working on a project, inside an AB CLX, I implemented the Modbus TCP Client AOI published on AB website, to interreact with a Modbus ASCII...
Replies
7
Views
3,587
Hey working on a project where I need to send a String Command to a device in order for the device to perform an operation. It's over Profinet but...
Replies
2
Views
1,875
Hello all, as you probably are all aware I have been trying to interface an A&D GX4002A balance to a 1769-L24ER-QBFC1B controller by the use of a...
Replies
7
Views
1,488
Back
Top Bottom