Auto Populate Fields with a Barcode Scanner

Kev@B&W

Member
Join Date
Aug 2022
Location
Worthing
Posts
3
Hello Everyone.

I am working on a project where I need to scan in 2 Barcodes to populate 2 different tags. A glue Batch and a product serial number. Once I have scanned in the data for the glue batch, I would like the input to jump to the serial number field to populate that tag.
Currently if scanning multiple times the data, is just overwritten unless I manually click the next tag.
Hope this makes sense.

Equipment I am using is a Redlion HMI CR3000 - 10000 using crimson 3.1 and the barcode scanner is a Proster with a USB connection directly into the HMI. I've not used a barcode scanner before.

This is my first post, so be gentle... lol

Thanks for your help
 
Last edited:
Perhaps give us some idea of the two different codes, i.e. length ? using this it may be possible to determine if the bar code is a batch number or what ever, did a similar thing many years ago, however, this was directly into the PLC, basically, the first barcode was the product code & the next was something else (cannot remember what lost a few braincells since then), I do remember the product code was always 10 chars the other was longer so simple to check the length in the PLC.
 
I believe the serial number barcode will be 10 characters long (numerical) and the glue batch barcode will be no more than 20 characters (alpha-numeric).
 
Never used the later Redlion, believe they used to be paradigm or something like that, their "C" programs are very good, did some logging on one many years ago, it should be possible to grab the data, check the length or perhaps some other parameter to decide what the type of barcode has been read. there are others here that perhaps have experience with Redlion & bar code reading.
Here is a link to a manual for bar code reading it may help you out, you might want to add some extra code then move the string from the com variable to some variables to some variables in the PLC.
https://www.redlion.net/sites/defau...ller - Barcode Scanner Support TNOI40._1.pdf
 
Last edited:
If I'm understanding correctly, have a data entry field that the barcode scanner always inputs into.
Then run some logic interrogating the scanned data to determine which barcode has been scanned.
So any serial number barcodes (10 characters) will always go to the S/N tag and any glue batch barcodes (20 characters) will always go to the Glue tag.

Will give it a go, not done much with the programming syntax in crimson before. So may be back for some pointers, if I get stuck.
 
I don't know much about RedLion, but usually TextBox(?) controls (tags) can have event handlers (callbacks) assigned to certain events, so when that event happens on a widget, the callback is called.

For example, if the serial number is always ten characters, then if you scan that first, there might be a event that triggers as each character is added; in Windows there is a TextChanged event (cf. here). If that or a similar event exists, it could be used to check if the serial number length is 10, and if it is, switch the input focus to the glue batch control.

If you have to scan the glue batch barcode first, then perhaps the scanner appends a carriage return to the batch string, and the event handler, as each character is added, can check if the last character added was a carriage return, and if it is, then switch the input focus to the serial number control.

Again, I don't know RedLion, but this is how most of these types of applications work. If RedLion/Crimson expose those interfaces, then you may be in high cotton.
 
Last edited:
So any serial number barcodes (10 characters) will always go to the S/N tag and any glue batch barcodes (20 characters) will always go to the Glue tag.


Looking at the PDF @parky posted, this sounds like a much better approach than my event/callback suggestion. You are limited to whatever interfaces RedLion exposes.
 
I believe when a barcode is read it can run a program, in that program you could for example, check the number of chars in the tag that is populated by the read or some special characters if there are any & then depending on the result populate the two string tags that can be used in your logic.
This way if the operator reads the barcode twice then it only populates the barcode tag, then when the batch bar code is read it only populates the batch tag.
Operators will often read two or three times (especially if the response is a bit slow).
The C syntax in RL is probably a simplified type of C so limited on it's functionality but is quite good as I remember.
Alternatively, run the program on a timed basis i.e. every second, then when the data arrives, check it's length or perhaps a "END" char like "CR" (or "LF") then copy the data to the relevant tags & clear the read tag.
 
Had a quick look at the manual, If your knowledge of "C" is limited, then you could use the "PLC" logic to do what you need to determine where the data is populated, not looked into it fully, but once you have your Barcode working i.e. the data comming into a string tag, then in a program that runs every say 100ms you can test the tag for the relevant information regardless if it be by length, chars or control chars. The Redlion can be programmed in the IEC language for example, let's say we have 3 string tags, Barcode_Read, Serial_Number & Batch_Number.
Barcode_Read is the tag assigned to the coms (all reads come into this), every time the operator scans a barcode this tag is populated, in the program that is called every x ms check the Barcode_Read tag (i.e. length or chars etc.) if it matches the serial number type of read then copy it to the Serial_Number tag else copy it to the Batch_Number tag, all this could be done in IEC program type. Obviously there may be a need to do some error checking if the data needs to be accurate for example length, checksum etc. perhaps display an alarm if the data is not valid.
 
Read the docs a little more, there seems to be no info on running a program on time, there must be some sort of event scheduling but cannot see it, however, have looked a little closer & you define the com port to read a barcode scanner, there is an entry to run a program (lets say Program1) on Update field put in program1, when data is recieved, this calls the program block, here is a simple bit of code based on the string length.

// This program block is called in the barcode coms i.e. on update event

cstring input = PortInput (3, 0, 13, 500, 0); //Define the port
if (input != "") // If not equal to null, then update the barcode tag
BarCode_Read = input;

Size = Len(BarCode_Read); //Get the length of the data

if (Size > 10) // If it's greater than 10 it must be batch code
{
Batch_Code = BarCode_Read; // So update the Batch code
BarCode_Read = ""; // Clear the read tag
}

else // If not then it must be the Serial number
{
Serial_Number = BarCode_Read;
BarCode_Read = "";
}
 
Do you have any insight into the 2 different barcodes?
If, for example, the SN is coded as a Code39 and the GlueCode is Code128, you can use the different symbiology identifiers to direct what your code does w/ it.

Now, you might need a slightly more advanced barcode scanner(since I couldn't find a programming manual for the scanner you listed) and/or some ability to direct that the barcodes be different types.
 
As myself & others have pointed out, how you determine which is which will depend on the format of the string some examples are:
Perhaps the data contains start, end, checksum or other information then it will need stripping or could make displaying it messy, may contain other information that is unique to that type of code i.e. is it the serial number or batch code, or simply the number of chars recieved.
Many older readers just send the code as an ASCII string with termination chars, in this case length or content is probably the only way of detecting the two codes.
 
Many barcode scanners can be configured to auto-append a carriage return or tab character to the end of a scan.

And since the input from many barcode scanners appears as standard keyboard input, adding a tab character after a scan (and setting the tab order of your input fields) might be an easy option to auto-increment to the next input field.
 
Last edited:

Similar Topics

I noticed in Rockwell AOIs, they add a BOOL Output parameter at the end of the "Parameters" list of each AOI that carries the same name as the...
Replies
1
Views
81
Hello everyone, I'm new here. First of all I just want to say that you guys are very knowledgeable and reading your posts on here has saved my...
Replies
4
Views
176
Hello, I m having a problem with wago 750-862 plc. The plc won't start automatically in run mode after a power reboot. I've also tried the...
Replies
4
Views
359
I have 32 masters in a linear topology network chain. I would prefer to use AL1xxx series from IFM. They do support device level ring if that...
Replies
15
Views
1,031
Hello all, I am looking for a way to have a user get logged out after an X amount of time because to default so that user privilages are no...
Replies
4
Views
597
Back
Top Bottom