PLC5 String Compare

Kabir

Member
Join Date
Mar 2004
Posts
107
I am doing a design of an RSVIEW HMI where I would have data stored in string format meaning that could mean the startup of a particular set of equipment. Hence Id like to send this data to the plants main control PLC (AB PLC5/40) then have the PLC perform the desired action(s).



My problem is I would like the PLC to compare the String stored in say ST9:0 to a known string say "Silo_210" as part of rungs logic. Can this be done without storing all my known strings in files like can I directly compare ST9:0 to "Silo_210". I know it may work if I were to store "Silo_210" in ST9:1 then compare ST9:0 to ST9:1 but I would rather do it directly...

 
Kabir,

No, I do not think you can compare a string of characters directly using the ASR command, without first storing it into a ST memory location. You can convert the numbers in a string into an integer value (using the ACI instruction), then compare the value with another value using the CMP or EQU instructions.

For HMI data, I find it best to store data as numbers, integer if possible, or floating-point if not. For example, if ST9:0 = "Silo_210", then have your program store a "1" in B19:0/0 for "Run Silo_210" or a "0" in B19:0/0 for "Don't Run Silo_210".

ASR - ASCII String Compare

Type - ASCII String
This instruction is only supported by Enhanced_PLC5s processors and the SoftLogix 5 controller.

Description
Use the ASR instruction to compare two ASCII strings. The system looks for a match in length and upper/lower case characters. If strings are identical the rung is true, otherwise the rung is false.

Entering Parameters
Source A: Specify string file element (Example - ST9:0)
Source B: Specify string file element (Example - ST9:1)

Error Checking
An invalid string length sets minor fault bit S:17/8 and the rung is false.
© 1997 Rockwell Software Inc.
 
Last edited:
If you can't store all those strings in PLC memory (ST files are memory hogs)...


You may be able to write a macro in RSView to do the comparisons for you and set the appropriate bit(s) in the PLC.

Paul
 

Similar Topics

I have recently been working on a project that involves a PLC5/40 system and a SLC5/04 networked together through DH+. I've setup a MSG...
Replies
2
Views
3,501
Hey all, I've encountered something weird today that I can't explain. I have a variable in a string file, call it ST15:18. I need to convert...
Replies
2
Views
4,248
I am using the following formula and I am getting error, Invalid Expression - too many closing parenthesis. when i copy the formula to notepad or...
Replies
4
Views
143
Preface: Kinda long, so I made section titles Intro: I just want to see if anyone here has seen anything similar. A PLC5-40 series C enhanced...
Replies
3
Views
362
Back
Top Bottom