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,195
Any one give solution for this fault. We are using AB Gaurd logix controller(5573s), resent days we are facing major fault in controller...
Replies
1
Views
89
Hi how's it going. Was just wondering if someone could help me out. Recently one of the guys over on the LinuxCNC forums put me onto getting an...
Replies
15
Views
356
Hello, Does anyone have one of these cables and willing to open the case so I can see the cable connections inside? 2707-NC5 I have sourced the...
Replies
3
Views
105
Currently trying to find: micrologix ethernet interface 1761-NET-ENI AIC to micrologix 761-CBL-AM00 Ser C cable These are used for micrologix...
Replies
3
Views
141
Back
Top Bottom