Convert String or compare string

Rcochran@ee

Member
Join Date
Sep 2013
Location
Cleveland,TN
Posts
22
I have a string value in Logix 5000 it is fg500-34900 i want to either drop the first 2 letters and then compare numbers to a know to see if match is there a simple where i have to do this 15 different numbers like above to get which tells me what program to start based on the above model no.
 
There is a ControlLogix instruction called "STOD", which extracts a DINT from a String. There is a similar instruction called "STOR" which extracts a REAL number from a String.

If you ran STOD on that string, the result would be 500, because the STOD instruction ignores any non-numeric characters before it finds numeric characters, then stops when it encounters more non-numeric characters.

To extract both 500 and 34900 from the string, you would first have to split up the string based on character position, or using the FIND instruction to find the dash character.

Once you have those numeric values, the logic to compare them to a table or array should be easier.
 
The plain old EQU (Equal) comparison instruction in ControlLogix accepts strings for both Source A and Source B. You would not have to drop the first two letters, if all your 15 strings have the extra letters.

EQU in ControlLogix.jpg
 
Last edited:
Ok thanks i was trying equal and did not have it pointed to the right part in the Udt. I was kinda panicking since i had to have this done today at noon to give to customer. thanks for all your help(y)
 

Similar Topics

Hi I need to convert a DINT with HEX value e.g A0F15663 to a string with the same value 'A0F15663'. Any tips of good instructions to use ...
Replies
11
Views
3,381
First post here, hopefully not breaking any rules. I am working with a Redlion G3 HMI (yes, I know). I have a series of string tags that I am...
Replies
17
Views
4,020
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,049
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,270
I'm trying to display a Allen Bradley Controller Serial Number that's in HEX to String for my SCADA to display. Any ideas?
Replies
3
Views
2,840
Back
Top Bottom