Cognex barcode data comparison in PLC


SUB Print.ST16[30].Data[1] COGNEX:I.Result[0] diff
EQU diff 48 SUB Print.ST16[30].Data[2] COGNEX:I.Result[1] diff
EQU diff 48 SUB Print.ST16[31].Data[1] COGNEX:I.Result[2] diff
EQU diff 48 SUB Print.ST16[31].Data[2] COGNEX:I.Result[3] diff
EQU diff 48 OTE BarcodeMatches



In Logix, that could all be on one rung.

Caveats/Assumptions


  • diff is a SINT tag
  • BarcodeMatches is a Boolean, with a value of True if the barcode matches the Print.ST16[30]+Print.ST16[31] pair.
  • Print.ST16 is an array of strings
    • So Print.ST16[030] is not 10
      • but is '10' i.e.
        • a string
        • Print.ST16[30].LEN is 2
        • Print.ST16[30].DATA[1] is 49 (SINT) and '1' (ASCII character)
        • Print.ST16[30].DATA[2] is 48 (SINT) and '0' (ASCII character)
  • COGNEX:I.Result is an array of SINTs, with integer values 0 though 9, and not ASCII characters, where the SINT value 1 represents the ASCII character '1' (SINT 49)
 
Last edited:
COGNEX:I.ResultData[0] = 1
COGNEX:I.ResultData[1] = 0
COGNEX:I.ResultData[2] = 2
COGNEX:I.ResultData[3] = 5

Cognex Camera Results are sent to the PLC as ASCII values. 4 compares of the .DATA[n] in series to an OTE will show if all are true.

EQU COGNEX:I.ResultData[0] Print.ST16[30].DATA[0] EQU COGNEX:I.ResultData[1] Print.ST16[30].DATA[1] EQU COGNEX:I.ResultData[2] Print.ST16[31].DATA[0] EQU COGNEX:I.ResultData[3] Print.ST16[31].DATA[1] OTE Strings_Equal
 
COGNEX:I.ResultData[0] = 1
COGNEX:I.ResultData[1] = 0
COGNEX:I.ResultData[2] = 2
COGNEX:I.ResultData[3] = 5

Cognex Camera Results are sent to the PLC as ASCII values. 4 compares of the .DATA[n] in series to an OTE will show if all are true.

EQU COGNEX:I.ResultData[0] Print.ST16[30].DATA[0] EQU COGNEX:I.ResultData[1] Print.ST16[30].DATA[1] EQU COGNEX:I.ResultData[2] Print.ST16[31].DATA[0] EQU COGNEX:I.ResultData[3] Print.ST16[31].DATA[1] OTE Strings_Equal


+1!


So you mean, not what you wrote above, but actually this:
COGNEX:I.ResultData[0] = '1'
COGNEX:I.ResultData[1] = '0'
COGNEX:I.ResultData[2] = '2'
COGNEX:I.ResultData[3] = '5'
That was not at all clear in the OP, which is why I posted my caveats and assumptions.
 
Last edited:
yes, that's correct. I just did copy/paste from his post. All Cognex camera's write ascii values to the Camera:I.ResultsData tags.
 
yes, that's correct. I just did copy/paste from his post. All Cognex camera's write ascii values to the Camera:I.ResultsData tags.

This is certainly not true for *all* Cognex cameras (eg Insight 2000), but looking at the DataMan® Industrial Protocol Manual suggests it holds true for all their barcode scanners (ie all relevant to this thread).

If that's the case it does indeed drastically simplify things as you note, but OPs original post certainly seemed to suggest otherwise. We work with what we are told.
 
It is 0 based. OP could COPy their strings to second tags to get the results they are looking for. Something like
Code:
COP COGNEX:I.ResultsData[0] MonthString.DATA[0] 2
and
Code:
COP COGNEX:I.ResultsData[2] DateString.DATA[0] 2
would give them the strings 10 and 25 to compare against if that was the route they decided to take.
 
for that matter they could COPy or CONCAT both sources to 4-character strings:

COP COGNEX:I.ResultsData[0] BarcodeYYMM.DATA[0] 4
MOV 4 BarcodeYYMM.LEN
CONCAT Print.ST16[30] Print.ST16[30] TodayYYMM
EQU BarcodeYYMM TodayYYMM OTE Strings_Equal


Which could again all be on one line, but I think @cwal51's solution is the best.
 
COGNEX:I.ResultData[0] = 1
COGNEX:I.ResultData[1] = 0
COGNEX:I.ResultData[2] = 2
COGNEX:I.ResultData[3] = 5

Cognex Camera Results are sent to the PLC as ASCII values. 4 compares of the .DATA[n] in series to an OTE will show if all are true.

EQU COGNEX:I.ResultData[0] Print.ST16[30].DATA[0] EQU COGNEX:I.ResultData[1] Print.ST16[30].DATA[1] EQU COGNEX:I.ResultData[2] Print.ST16[31].DATA[0] EQU COGNEX:I.ResultData[3] Print.ST16[31].DATA[1] OTE Strings_Equal

This is the simplest explanation of what i was needing and it works perfectly.

Thanks everyone for your input!
 
This is certainly not true for *all* Cognex cameras (eg Insight 2000), but looking at the DataMan® Industrial Protocol Manual suggests it holds true for all their barcode scanners (ie all relevant to this thread).

If that's the case it does indeed drastically simplify things as you note, but OPs original post certainly seemed to suggest otherwise. We work with what we are told.

Plvice, Your correct. Bad wording on my part. I should have stated:

Cognex camera's will write ascii values to the Camera:I.ResultsData tags when set to SINT.

To be truthful I had to check one of my programs to verify because of the wording and responses. It was kind of likeo_O I don't remember having to do that.
 
Plvice, Your correct. Bad wording on my part. I should have stated:

Cognex camera's will write ascii values to the Camera:I.ResultsData tags when set to SINT.
Fair enough. I've never used a Cognex in a situation where transferring ASCII data (or a anything else in a SINT format) would actually be beneficial, so it's not a possibility I would have though of. I don't deal with barcodes.
 
I recently set up a Cognex barcode reader to take in a barcode, and compare it to a number set up in the system for use in sorting packages.

I'm not sure where you are having a problem? I didn't have to concatenante anything.

say I brought my data in from the cognex, and the string array the data goes into is already good as it is.

don't pull from asciistring.DATA[0], asciistring.DATA[1], asciistring.DATA[2]

just use a CPS instruction

CPS
(Source) - asciistring
(Dest) - String_To_Compare


it's already concatenated.
 

Similar Topics

We are trying to get rid of triggering and just have the scanner always trigger. The only part I am having trouble figuring out is how to use the...
Replies
3
Views
2,504
Struggling!! I have a Dataman 100 Cognex barcode camera with Cognex I/O board. I have established comunication with the camera and the I/O board...
Replies
7
Views
4,462
We finally replaced our Cognex Checker with an IV-3 and I'm wondering if can replace the s/w in the monitor with anything else. I haven't been...
Replies
0
Views
103
Thank you for any and all responses/help. I have an RSLogix 5000 v20 and a Cognex In-Sight v5.9 spreadsheet (8502P). I can not figure out how to...
Replies
0
Views
133
Which signals do I have to use to get data from camera. For example camera detects a defect and sends signal to controller. Power cable: CCB-PWRIO-05
Replies
1
Views
218
Back
Top Bottom