Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: jwbaker3 on April 26, 2013, 02:49:21 PM
-
I need to read the barcode on bottles on the production line, decide if it is name brand or private lable. (we could also use a vision system but the bottles already have a barcode on them and the system cost should be less) If name brand we need to know what the product is. Then if it is namebrand product 1 send 24 vdc to input 1 on a leibinger lj3 printer to print job 1, if it is namebrand product 2 send 24vdc to input 2 on the printer to print job 2, same for namebrand 3 to input 3 and if private label 24 vdc to input 4 to print job 4. I know the Do-More will interface with a barcode reader (I dont know which ones), but how (can?) the plc lookup the bardcode to know which product it is? There are a lot of barcodes and they may change (new products) and will require updating. What is the best way to do this? The product will be made in batches, they are trying to take the human from happening when a batch change accures and the wrong thing is printed on the bottle. I have done a lot of PLC work but never with a barcode reader or a lookup table.
Thanks,
JW
-
What is "a lot of bar codes"?
What are the bar codes? (numbers only, or alphanumeric)
How fast is it?
Are you checking each bottle, or only the batch?
-
I am waiting for the database with the barcodes. I think they are numbers only. We will look at each bottle, but there is a gap between products..so maybe I need to read the first in the batch and some during the run to make sure. The bottles are passing the barcode reader at about 60 to 80 per minute max.
Thanks,
JW
-
You can get the data into the PLC in a couple of ways: Scanning the codes and use an HMI to tell the PLC what category the code is, or you could use something like a .php script that interfaces with a database.
Numeric only barcodes should be easy and fast to search, Strings can take a little longer.
Communicating with a scanner should be pretty easy, but make sure you spec a scanner fast enough to do what you need (comms as well as scans per second).
-
Thank you for the reply plcnut. I should have the barcode list by the end of the week. If the list is not too long could I just do the matching in the PLC? I am not sure how to use the HMI for this, but I am hoping the list manageable.
Thanks,
JW
-
Hmmm...
I'm seeing a binary string search task example coming on. The 'more' that Do-more was designed to do! ;)
-
I got the list of UPC codes they are 10 digit (Some 11 some 5 but they are outside of the range I need to look at) numbers only. There are 450 total but I think we will only see about 300 on the line we are working on. I want to look at the barcode and if it is within range 1 turn on output 1, if it is within range 2 turn on output 2, if within range 3 turn on output 3, if not 1 2 or 3 turn on output 4. The first 5 numbers for ranges 1,2 and 3 are all the same. Any suggestions on the best way to do this?
Thanks,
JW
-
Sounds simple,
STREAMIN
STR2INT
Compares with < > to SET bits.
-
I got the list of UPC codes they are 10 digit (Some 11 some 5 but they are outside of the range I need to look at) numbers only. There are 450 total but I think we will only see about 300 on the line we are working on. I want to look at the barcode and if it is within range 1 turn on output 1, if it is within range 2 turn on output 2, if within range 3 turn on output 3, if not 1 2 or 3 turn on output 4. The first 5 numbers for ranges 1,2 and 3 are all the same. Any suggestions on the best way to do this?
I agree with 'nut...except for one possible caveat. The range of a 32 bit integer is -2147483648 to 2147483647, or for our purposes, 0 to 2147483647. If the first 5 digits are less than or equal to 21474xxxxx, then yes STREAMIN to read data, STR2INT to convert, and a handful of relational contacts to do the compares and set bits.
If the first 5 are outside that range, then you will need to do some string processing to lop off the first 5 characters and first compare them to your 1, 2, and 3 ranges first 5, and then if they match do a STR2INT on the last 5 digits and do the compares.
If there are different lengths of codes, which it sound like there is, you will first have to normalize the input string to a known fixed length before doing the other work.
Conceptually it might end up being something like this (in psuedocode):
InputStr = StreamIn()
if(InputStr.Length > 10)
Group = 4
else
NormalizedStr = FmtString(InputStr, 10, right)
Left5Digits = StrSub(NormalizedStr, 5, left)
if(Left5Digits != Group123Prefix)
Group = 4
else
Right5Digits = StrSub(NormalizedStr, 5, right)
BarCodeValue = Str2Int(Right5Digits)
if(BarCodeValue >= Group1Start && BarCodeValue <= Group1End)
Group = 1
else if(BarCodeValue >= Group2Start && BarCodeValue <= Group2End)
Group = 2
else if(BarCodeValue >= Group3Start && BarCodeValue <= Group3End)
Group = 3
else
Group = 4