Under these conditions, it is impossible to guarantee that the entire complement of any percentage will be sampled.
Here is an extreme example:
If, in a run of 100 parts, the sample requirement is 100%, the test fails if the PLC "randomly" decides to let the first part pass.
If, in a run of 100 parts, the sample requirement is 15%, the test fails if the PLC "randomly" decides not to grab a sample until well after the 85th part. If it grabs the 86th then it will also have to grab all of the remaining parts so as to meet the inspection quota.
15% means 15 per hundred.
15% means 1.5 per ten.
I don't know what your production rate is so I'm gonna assume 100 parts per day... just to give my head a break... it's hot over here today (where's that MGD?).
You would do better by grabbing x-samples-per-10.
You could have an absolute minimum of 1-per-10 and a maximum of 2? or 3?
So, you have a "random-picker" that picks a set of numbers out of the set of 1-to-10. Duplicate numbers are not allowed.
Let's assume that the samples-per-10 value is 2. If the samples-per-10 value is 2 then your "random-picker" will choose two numbers. First it "randomly" chooses one number from the set of 1-to-10. Then it chooses a second number from a set which is 1-10 WITHOUT the previously picked number (no duplicates allowed!).
Since "10" is actually a two-digit number, and since at least one sample must be taken, "0" can represent "10" without harm or confusion. So the actual range of numbers would be 0-to-9.
For any given sample-period, you will need to maintain a list of selected, randomly-chosen, numbers.
For example,
When it is time to select the random numbers, clear your list of selected, randomly-chosen, numbers. Then...
Random-Pick First Number:
"Randomly" choose one a number from the following: 0-1-2-3-4-5-6-7-8-9.
Let's say that the first pick was "8".
Add "8" to the list of randomly-chosen numbers.
Random-Pick Second Number:
"Randomly" choose a number from the following: 0-1-2-3-4-5-6-7-X-9.
Let's say that the second pick was "3".
Check to see if "3" is in the list of randomly-chosen numbers.
If it is, then do another "pick".
If it is not, then add "3" to the list.
If the number of items in the randomly-chosen list is equal to the required sample number then the picking routine is done. Otherwise, continue picking, checking and adding.
If your sample number was 3-of-10 then you would "randomly" choose a number from the following: 0-1-2-X-4-5-6-7-X-9.
Once the list of randomly-chosen numbers is completed it is time to do the samples. Every time a part is produced and a part-counter increments, check the list to see if that count is to be inspected. If so, then do so. Otherwise, wait for the next part.
Note: You could sort your list so that your process is waiting for the first part-count in the list to show up. When it shows up, the process would grab for inspection and then watch for the next part-count in the list to show up.
There could be a problem if the inspection process is at least somewhat automated. That is, if a part is occupying a controlled space while under inspection then the next part can not be inspected while the first inspection is occurring.
In that case, you lose the second random inspection or you stop the line.
Now... here comes the booger...
How does one generate a random number between 0 and 9?
Uuurrppp...! Damn it Casey... where the hell did you put the rest of my MGD! I can't think under these conditions...
(88)