Allen Bradley structured text string comparison

waker1der

Member
Join Date
Aug 2015
Location
Watford
Posts
3
Hi, i am trying to compare a string value in an IF statement

My string value is user defined string called Barcode_String max characters 26. This can not be changed as it is used across the plant.

I pass that barcode string in to my AOI to a parameter called inBarcodeID which is of the same data type.

i want to know if there was a no read and in this case the value would be 00000000

IF inBarcodeID = 00000000 THEN

or

IF inBarcodeID = '00000000' THEN

does not work because of mixing data types, it wont compile.

so I have tried

IF inBarcodeID.DATA[0] = 0 THEN
noRead := 1;
END_IF;

but noRead does not change, i also tried

CASE inBarcodeID.DATA[0] OF
0 : noRead := 1;
END_CASE;

but this also doesn't change, has anyone got experience with trying to do comparisons like this?
 
Last edited:
Try defining another string, and using it as a constant to compare to.

That is, make another string tag of your Short String type, and manually set it to "00000000"
 
I may be incorrect, but this is the way Rockwell have decided that string comparisons must be done. It is also the same in RS500.
The potential downside is that the source string can be modified..
 
I read that as of version 30 and the L8x controllers you can have literal strings in assignments and comparisons.

http://literature.rockwellautomation.com/idc/groups/literature/documents/rm/1756-rm003_-en-p.pdf (page 827 and 828).

Regardless of that, try to inspect the barcode tag itself you receive into the AOI. Altought is may look like as 000000000 in the tag monitor, the .DATA[0] may not contain 0 because it holds the decimal ASCII value of "0", which is 48.

Default the style is set to ASCII, but the logix program uses the DECIMAL value in the logic.

KzIHyur.png


asciifull.gif
 

Similar Topics

Hello Everyone, I had a doubt in reading expressions written in structured text in format c := a and b. Where a is a DINT and b is a constant...
Replies
2
Views
1,168
Hi, I have a ControlLogix system with 1756-IF16 analogue inputs. I can't scale the inputs at the card as there is a requirement to facilitate...
Replies
14
Views
342
Dear community, I am trying to find a tool for Allen-Bradley PLCs similar to SiVArch for Siemens PLCs to automatically generate faceplates and...
Replies
0
Views
86
Hi everyone, new to forum. Since very long time i having issue with 1734-AENT module, after some period of time its keep stuck in error (simmilar...
Replies
16
Views
513
Hello, I am new here. I am trying to find good places to sell some surplus items that I have that isnt through ebay. Does anyone have any sources...
Replies
6
Views
358
Back
Top Bottom