Jump to content

comparing multiple inputs scanned one after the after

Recommended Posts

I'm working on a scanning project that scans barcodes of 2 parts during assembly to compare them. I'm using 1 scanner connected to the serial port. I need the operator to scan the  first  barcode, then he should be prompted to scan second barcode, then compare the 2 strings. I need help on how to prompt to second scanning after handling and saving the first input. Should I just fill the buffer with 000 then put a rung to receive data through the port again? 

Link to comment
Share on other sites

  • MVP 2023

You can scan barcode by Protocol FB.  Scanned barcode is replaced by another one in buffer if you try to scan another barcode.


There is several options in this process:

1) Barcode 1 = Barcode 2. User can scan barcode 1 (or barcode 2) two times and it is wrong solution.

2) Barcode 1 not equal Barcode 2 but these two barcodes is an assembly unit - you can scan it and find a row in DTI where another one barcode is present.

3) Use two barcode scanner with different positions (stationary) connected to different com ports. Parts scanned if it fit correctly.

4) Barcode 1 + Barcode2 = constant. Scan barcode1 add to SUM tag, scan barcode 2 add to SUM tag and compare with CORRECT SUM tag. Reset SUM.

5) Generate different  sound for different barcode (zebra motorola  barcode scanner has this option embedded into firmware).


I  implemented  barcode scanner for wire harness checking device.

The main problem - user scan barcode - check wire harness ---OK.  Then user scan barcode for another one  but did not check another wire. The first OK wire harness is checked many times.

In system log all wire is checked but it is not correct.

After all  we used hardware for marking good wire harness and if marking is present - user cannot check one wire  many times.

This problem is the main in your system. User can scan correct part many times and use wrong one in assembly. 



Link to comment
Share on other sites

  • 2 weeks later...

I'm already using 2 scanners connected to 2 different Serial COM ports. but currently they only scan once with both scanners and then I compare the 2 barcodes. But  I also want to scan 2 other parts with the same scanners and also compare them. So my question is, can I just copy and paste the rungs I'm already using to treat additional barcodes? Will it automatically prompt the cursor to take in other barcodes after each scan? What if I want to move to the next barcodes only when the ones just scanned are good? 

I'm attaching my code to show what I'm talking about.

UniStream_070_Message_Composer_Two Barcode Readers.ulpr

Link to comment
Share on other sites

  • MVP 2023

Your COM Rx blocks are on the rail and therefore always live and looking for data from the associated port.  Do not just copy and paste them, as if there are two COM Rx blocks looking at the same port at the same time they will crash into each other.

Instead, create a sequence that looks at the port, and when data comes in move it to another string variable you can use for comparison like you are doing in rung 2 (all the time).  

8 hours ago, Bertrand Irakoze said:

What if I want to move to the next barcodes only when the ones just scanned are good? 

This is what your sequence will do.  You'll have to make your program decide.

If you can be very specific about what rules you want to follow and in what order we can help.

Joe T.  

  • Like 1
Link to comment
Share on other sites

Thanks for that Joe! you put it very well. It makes sense now.  As long as my COM Rx blocks are live, every new data I get I can copy it to another string variable. Can I use the same buffer tags to write data to from the ports they are looking at. Since I reset them after each successful comparison. But let me be specific about my rules. 

First scan, In one port, I I look at the string for its last digit, if it is L (for Left), that's good. Same thing for the other port, on the first scan, I look for R( for Right) as the last digit of the string. Only when that's good, I take in another string on the subsequent scan.

For these new strings, I do the same and look for the last characters ( L and R), but also compare the first part of the string that comprises of numbers. If they match then I'm good to go. I already got the code working for this second set of comparisons. I wanted to add another sequence for the new scan.


Bertrand Irakoze 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...