Allen Bradley SLC500 - STRING to INT

Join Date
Oct 2019
Location
UK - portsmouth
Posts
28
HI, My first post on here,

Using SLC500 I have a STRING LEN 30 that I need to convert just the first 2 characters (POS 0 , 1) into an INT. any help? I'm under the impression there is no function block for this.

I'm very unfamiliar with SLC500 and have only been programming for 4 months in Logix5000.

Thanks,
Tommy :)
 
Welcome to the PLCTalk forum community !

The SLC-500 instruction set includes an String to Integer instruction, "ACI".

It will act on all the numeric characters in the string, starting at the beginning and continuing until the end or when it encounters a character other than "0"-"9".

A string that contained "123ABC456" would result in an integer = 123.

It's actually more work to parse out just the first two characters of that original string, if the string contains more numeric digits after the first two.
 
not too familiar with SLC as stopped using it many moons ago but Assume that the string is in an array of registers i.e. 32,33,34, 31 (int. 2341)
then take word containing the two chars you want, AND the word with Hex F or Dec 15 this will give you the lower decimal value of 1 (units), then swap bytes in the word using SWP instruction AND this with Hex F this will give you the tens value (4)
multiply this by 10 then add to the units word.
instructions Move reg containing the two Chars into N7:0
AND N7:0 H0F N7:1 (units store)
SWP N7:0 Len 1 (Swap bytes)
AND N7:0 H0F N7:2 (tens store)
MUL N7:2 10 Dest N7:3 (multiply to get tens value)
ADD N7:2 N7:1 Dest. N7:3 (add units & tens and store in N7:3
N7:3 contains 41 the decimal value of the two chars
 
The ACI instruction does all that masking and moving and multiplying automatically. You just need to have a String that includes the to-be-converted numeric characters.

ACI_Example.PNG
 
Last edited:
Welcome to the PLCTalk forum community !

The SLC-500 instruction set includes an String to Integer instruction, "ACI".

It will act on all the numeric characters in the string, starting at the beginning and continuing until the end or when it encounters a character other than "0"-"9".

A string that contained "123ABC456" would result in an integer = 123.

It's actually more work to parse out just the first two characters of that original string, if the string contains more numeric digits after the first two.

an example of the STRING I need to turn into INT is "P7AX051" which should translate to INT 20535. If the ACI stops on characters, it would return a null as soon as it got to the first character P?
 
What is the logic behind that the string "P7AX051" translates into the integer 20535 ?
In the 1st post you mentioned only the 2 first characters should be converted. That would be "P" and "7". How does that become 20535 ?
 
The first two characters as Jesper suggests are not both ascii characters that are decimal values. what is the reasoning behind converting a string that contains alpha & numbers this does not make sense to most people.
If you mean the first characters (right to left i.e. 51) then this would be easy by using ACI on the last word of the array.
 

Similar Topics

HI, I'm currently also trying to get an Allen Bradley SLC500 fixed. Our technician is trying to replace all the Takamisawa JY25H-K-505 relays. So...
Replies
2
Views
1,729
I have 2 identical systems that have the AB SLC500 Basic card in them. I system stopped working and the issue was traced back to the card...
Replies
15
Views
3,004
I have two output cards sitting next to each other in a rack: 1746-OW16 1746-OW16 (Octal) output 13 in the first card triggers a solenoid. When...
Replies
2
Views
2,187
I propose to replace an old pc with the latest HMI from Schneider running Vijeo designer. Firstly, am I correct in thinking that I can use RS500...
Replies
4
Views
3,019
Good Morning, I have been given the task of writing a program for work to count a number of bottles in a moving machine and compare it to a...
Replies
4
Views
1,553
Back
Top Bottom