Nickyv6363

Cognex and Compact logix

10 posts in this topic

Hi,
I need help finding the length of a string.  I am using an In-sight 9000 series camera with a compact logix 5380 and communicating over ethernet. Unfortunately, the string length is not provided in the AOP, and the barcode length will constantly change. I told to use the FSC instruction, but I cannot get it to work.

Thanks 

Share this post


Link to post
Share on other sites

Compact Logix String Variables consist of two parts.

String.LEN and String.Data  

Are you saying String.LEN is a zero or an 82 and does not match the length of the data?

Share this post


Link to post
Share on other sites

Bob,

No, the camera only provides the string, not the length of the string.  

Share this post


Link to post
Share on other sites

I just rechecked the Cognex site and the 9000 uses the same AOP that the 5000 I worked with uses and the string length is part of what is sent.

Can you post what you're seeing when online with the processor?

Share this post


Link to post
Share on other sites

Sure, i attached two pictures.  the second one is the all the inputs from the AOP, and you can see it does not have a length

Pic1.PNG

Pic2.PNG

Share this post


Link to post
Share on other sites

What is the data type of the InspectionResults tag?

Share this post


Link to post
Share on other sites

Is it a SINT array? In other words, does it say "SINT[x]" in the datatype? What's the value of the "x"?

The Logix 5k STRING datatype is actually a compound datatype consisting of a .LEN element (DINT) and a .DAT element which is a SINT[82] array.

If Cognex isn't giving you the length automatically, you can find it pretty easily with a loop that looks for the first element of the SINT array that has a value of zero. Or use the FSC. I threw this together real quick, so you'll want to do some limit/error checks to avoid overflows and such.
FSC.JPG.165859e27c97b175d51c92a2f594b501
After a single false-to-true rung condition, the .POS member of the Control tag used in the FSC contains the index of the first zero element of the array, which is also the length of the string. The element before that (element [7]) is the last character of the string. To work with it in the PLC, you can COP the SINT array into the .DAT element of a string tag and then update the .LEN element if the string tag with the .POS member of the FSC control tag.

Share this post


Link to post
Share on other sites
2 hours ago, Nickyv6363 said:

Sure, i attached two pictures.  the second one is the all the inputs from the AOP, and you can see it does not have a length

Pic1.PNG

Pic2.PNG

So which element of the status data array is the string you are interested in?

You mentioned in your original post that the "barcode length will vary"  but you don't show the data structure that brings the barcode over.

The status array just shows you what the camera is doing not what data it might have available to send.

Share this post


Link to post
Share on other sites

In the first picture is, camera.inspectionresults, is what I am focusing on. The status does not mention inspection length, nor does camera.inspectionresults. After Talking to Cognex, this is a known issue with the series 9000 AOP, but they helped me get the length using spreadsheet. I would still like to use the FSC function that Joe mentioned in the post above to find a length of a string when it's not provided just in case, I might need it in the future.  Thanks for the help!!!

pic3.PNG

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now