How to convert Ascii to a Number

willer1998

Member
Join Date
Jun 2006
Location
Columbus, ohio
Posts
1
I am working on a problem with a scanner. The data comes in as ASCII. I am scanning the quantity. The data looks like Q1^M or Q21^M (They can have 1 or 2 digit quantity)
I need to tie in the qty with the machine to make sure it does not over produce or under produce. I cannot seem to convert the Ascii into an integer.
I am using SLC500. The data comes into a INTEGER file. I have tried copy, moving to ASCII, then to a STRING. And directly to a string. (Then I could use the ACI) But - nothing shows up in the STRING file. When I copy it I have to address it as ST9:0.DATA[0]
When you look at it in the ladder - it appears to have the value, but when you go to the data file - there is nothing.
When I copy the INTEGER file to the ST file - the ST file is 1330+ in length and when I try the AEX, I do not get any data.
Any suggestions?
 
what are the HEX values of the characters you receive
and what is the value they represent? (^M should be 0x0D etc.)
is Q indicating start and ^M end of a string, meaning values are 1 and 21 etc.?
 
Last edited:
Can you see the number in the ST file?

The ^M should tell the PLC that's the end of the number. Make sure your COP is set for length of 1 only. COP #N7:50 #ST10:50 1

Once you got it into a sting file then use AEX to extract out the number. So if you have a number "^Q3^M", do AEX ST10:50 2 1. ST10:51.

After that, use ACI to covert ST10:51 to an interger. ACI ST10:51 N7:51

Oh, since your integer length varies. You need to find our the length of your string, ie, the value of ST10:50.LEN
 

Similar Topics

Hi guys I have a barcode scannes which gives me some numbers (SINT) that I want to convert into ASCII, so that I can see that ASCII char insted...
Replies
6
Views
2,805
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,064
Found an awesome point of sale for $500. It sends an ascii string when a product is sold. Need to convert this into a number between 0 and 255 or...
Replies
1
Views
2,278
This pertains to RSLOGIX 5000. I have a machine that sends me back a single ASCII character in a SINT and I need to convert it into its decimal...
Replies
2
Views
2,372
Hello, I am a veteran Mitsubishi programmer, but am new to AB. I have a Micrologix 1500. I am receiving a string via RS232 on Channel 1. In...
Replies
3
Views
5,014
Back
Top Bottom