AB Verify String

asedely

Member
Join Date
Jan 2013
Location
Michigan
Posts
3
One of the parts that I work on is wrote on with a laser. The laser burns on a 2D Data Matrix and some human-readable text. The barcode is then read into a CompactLogix PLC with a Cognex camera. From there the data is stored and manipulated for our customer.

The data is supposed to be Hexadecimal. Unfortunately, software for the laser was updated and settings were changed from being to write in Hexadecimal to Alpha-Numerical. This means it will serialize the parts using 0...9.a...z. Thus, no longer being Hexadecimal.

What I need to do is put in a verification program in the PLC to make sure the STRING from the camera is Hexadecimal.

Is there a simple way to check the string?
 
Welcome to the Forum !

If the data in the engraved tag is alphanumeric, won't the data in the CompactLogix also be alphanumeric ?

If you're trying to check a string to be sure that it contains no ASCII characters except 0-9 and A-F, you're probably going to have to write an iterative subroutine that just checks the value range of every .Data[x] element in the string. I would personally just brute-force it, with 82 rungs (or however many characters you're looking at) with LIM statements.
 
Thanks!

Yes, the data is going to be alphanumeric in the PLC as well, once sent over from the camera.

As far as brute force goes... I am trying to make it cleaner. Perhaps, using a pre-defined string with the values I don't want and the "FSC" instruction. I just have not found a good way to implement it.
 
I still like brute force. You only have to execute it once each time the Cognex reads the string.

Attached is an example, in RSLogix 5000 v19 format.
 
Brute force may not seem so brutal if it isn't an 82 character string that you have to check.

If the maximum length of the string coming from the Cognex is less than 82, just make yourself a new STRING data-type to only allow XX characters - try it, you'll see how easy it is. Create your STRING tags using your "user-defined" STRINGXX data-type.

And then if your strings vary in their length, then your "less brutal" checking can be even less than "less brutal" if you only check as many characters as the .LEN parameter tells you.
 
Worked

I still like brute force. You only have to execute it once each time the Cognex reads the string.

Attached is an example, in RSLogix 5000 v19 format.

I used your example as a base, but modified it for use with two production parts.

Each part has a different length of Serial Number, so the "Cognex_String.LEN" is variable, based on the part selected to run. Also, at the end of the ladder is a simple check that was added to easily show if a bad Serial Number was found.

I attached the revised version for reference.


Thanks All!
 

Similar Topics

Greetings, I am currently working on a bit of code reset a work cell after a specific fault. It will be the scanning of a supervisors barcode...
Replies
5
Views
3,352
Hi! I have a string with 10 letters. I can edit the string in my HMI. Now I want my plc to get a signal if there is something written in my...
Replies
3
Views
4,200
First off, I'm a hobbyist-level programmer, and this program isn't controlling anything anything that could even remotely be considered "life...
Replies
18
Views
591
Hi, We are thinking of implementing a light to our safety system that indicates that a machine is in a ceratian more dangerous state then normal...
Replies
12
Views
2,006
Hi, I'm working on a project with an Allen-Bradley PLC, so we are using Studio5000. I have a bunch of things that communicate through ethernet/Ip...
Replies
2
Views
1,262
Back
Top Bottom