First experience with PLC - build a sample ID

Flemingtb

Member
Join Date
Sep 2011
Location
USA
Posts
9
Pretty new to PLC programming, i have a Compact Logix chassis for testing, my task is to build a sample ID in order to link process parameters to the samples being run.

The sample ID needs to be unique, the format is like Year.Mo.Day.run

For example: 180928010

What is the best way to build this ID with (4) inputs from the User?
 
Pretty new to PLC programming, i have a Compact Logix chassis for testing, my task is to build a sample ID in order to link process parameters to the samples being run.

The sample ID needs to be unique, the format is like Year.Mo.Day.run

For example: 180928010

What is the best way to build this ID with (4) inputs from the User?

Your example will not be Y3K compliant.
Make sure to use leading Zeros to keep your ID length consistent.

Use a GSV of real time clock to build the first part automatically without user input, and an incrementing counter on run completion, then no user input (or mistakes).
 
Ok so my example was a little too simple.

The ID will consist of the data (GSV is a nice solution for this), the Serial number of the product (4-digit number), the batch, the section and the run number.

so something like this:

(Date)(Product)(Batch)(Section)(Run)

I think i want to do this with INSERT sting instruction, the only way i can think i can do this is with a cascading string, which is a lot of code for such a simple thing.

String1 = Date
String2 = String1 INSERT Product
String3 = String2 INSERT Batch
String4 = String3 INSERT Section
String5 = String4 INSERT Run

Each string will need to be of a known size so START can be correctly called out.

Is this the only way?
 
I haven't worked with them myself, but some OEM equipment we have at our facility created a string for each field (date, batch, etc.) and used a series of CONCAT instructions to combine them into the final ID string.

Using a set of scratch/work strings as you show in your example is a good method as it helps with troubleshooting.
 
OK so this is actually pretty neat, i learned how to use a UDT for getting system time. I want to take it one step further. I'd like to generate a lookup table of sorts...

For example putting in the numeric number of the month (October = 10) into a sample ID that is all numbers is confusing and really doesn't help anyone in terms of identifying what the sample ID is really telling them.

Let's use the Months of the year for example.

January = A
February = B
March = C
...

How can i use the month of the year to generate or return a letter that i define? For example if the GSV instruction returns a 10 i'd like the value placed in sample ID to be a 'J'.

I appreciate all of the help thus far, thank you.
 
A Rockwell Logix platform string is really a structure with a length element followed by a data array element. You can access all these items directly programmatically. If you follow Plastic's point that you use leading zeros to make sure your sting length is always the same, the month letter designator will always be in the same data array byte location. Also, the ASCII character set already defines 2-digit hex values for every supported character. As it turns out, the letter "A" has a decimal value of 65.

Calculate the month desigantor decimal value by adding decimal 64 to the realtime clock month value. Then move this result into the string data array location containing the month designator.

Keith
 
"The ID"

Ok so my example was a little too simple.

The ID will consist of the data (GSV is a nice solution for this), the Serial number of the product (4-digit number), the batch, the section and the run number.

so something like this:

(Date)(Product)(Batch)(Section)(Run)

I think i want to do this with INSERT sting instruction, the only way i can think i can do this is with a cascading string, which is a lot of code for such a simple thing.

String1 = Date
String2 = String1 INSERT Product
String3 = String2 INSERT Batch
String4 = String3 INSERT Section
String5 = String4 INSERT Run

Each string will need to be of a known size so START can be correctly called out.

Is this the only way?


Not sure what you are going to do with the "ID".
1. Feed Strings to report history?
2. Print Human Readable Labels?

3. Print old-school bar codes?

4. Print 2-d high density data-matrix labels


….Yes CONCANTENATE is how to assemble strings
…. prepare all of the individual parts of the string, and then append them together.

My coarse point is only addressing the DATE portion of your string, as we have no knowledge of your companies product / batch / section /run data


If you want to limit the real data, or hide data from the casual consumer, and don't care about Y-3k, the smallest amount of place holders for a date code are is 4. This is how it was done years ago, when computer memory, and 1-d barcode was limited.

Example: 8J01

8 = last digit of current year

J = Oct (per you suggestion)

01 = October 01




You can also pull this off with Julian day-of-year
Today would be 8274 where
8 = Last digit of current year
274 = 274 day of this year


But all of the above is just a bad way to sort real data over time.

I suggest this format for your date code

YYYYMMDD


This will always net a larger number as time goes on, and sorts very well in text and numerical databases.


Today is 20181001
Tomorrow 20181002
Yesterday 20180930
 
If this is a real application, and you really want to make sure that your numbers are unique, I would go ahead and register with GS1 for a company barcode prefix (if you don't already have one). Then add whatever qualifying information after that for your product runs, but in full barcode format.
 

Similar Topics

@ All: what is your best guess on a potential range in increase in efficiency in % (i.e. saved programming hours, greater output, etc.) when...
Replies
5
Views
349
Hey guys, has anyone worked with any type of Keyence PLC and could share their experience with it? Vendor showed me camera footage reply of a work...
Replies
7
Views
1,164
Here is my recent experience using the Zebra AOI for printing from the PLC. Please do not ask me for my PLC or template files as they are the...
Replies
11
Views
12,305
Hi everyone, I have started work on a couple of jobs that I think a Click PLC would be perfect for. The problem is I have zero experience with...
Replies
23
Views
6,034
Hi Everyone, I'm working on a PLC-5 program offline that I've modified several files on - adding rungs or branches to rungs. No data table...
Replies
0
Views
2,613
Back
Top Bottom