A way to calculate CPM (Container Per Minute) Accurately

gappvembe

Member
Join Date
May 2007
Location
MI
Posts
81
Here's the situation, we have a machine the fill containers. No big deal. I don't think they ever run in faster than 175 CPM, normally around 145ish. The problem is, the read out of the CPM data isn't very accurate. It will fluctuate I think a good 10 CPM.

I tried doubling C5:6 from 5 to 10 and halving the rate from 12 to 6.

That seemed to make things worse. I realize now, I believe that I also need to change the Rate Timer T4:0 to double the time, since I doubled the counter (C5:6).

Before I trial and error this, does anyone know if this will improve anything? Or maybe you know a better way to go about it?

I didn't write this program, this is what came with the machine. Like usual, I just edit and change things.
Thanks in advance, I'll be checking in from time to time throughout the day.

ElmarCPM.jpg
 
You might get better accuracy if you don't use the timer as you are.

1) Reset the timer and the counter.
2) When the counter counts 10 containers, save the timer's .ACC Value somewhere, then reset timer and counter
3) Calculate the CPM using the 10 containers, and the measured timer .ACC value.
 
It will fluctuate I think a good 10 CPM.

More like it will flucatuate a good 12 CPM. Take a look at rung 2 and think about it. If you count 12 containers in 5 seconds, that's 144 CPM. Or 13 containers in 5 seconds is 156 CPM. Stick with rdrast's suggestion. And let us know what kind of accuracy you find if you try it.
 
When I worked in canning, at about 1000cpm, we used a photo eye connected to a digital/analogue converter to give us 4-20mA signal on speed.

I think E&H or P&F made them, a bit of awhile back.

Better, quicker and more accurate.
 
More like it will flucatuate a good 12 CPM. Take a look at rung 2 and think about it. If you count 12 containers in 5 seconds, that's 144 CPM. Or 13 containers in 5 seconds is 156 CPM. Stick with rdrast's suggestion. And let us know what kind of accuracy you find if you try it.
Yeah I see that now. I was just trying to remember what I saw.

What I did do was change the wrong numbers, I don't need to touch the counter, I needed to manipulate the time.
 
You might get better accuracy if you don't use the timer as you are.

1) Reset the timer and the counter.
2) When the counter counts 10 containers, save the timer's .ACC Value somewhere, then reset timer and counter
3) Calculate the CPM using the 10 containers, and the measured timer .ACC value.
Yeah this sounds more like it.
I was hung up on the counters preset, not the actual time.

I need to look up on storing numbers (ie. timers.ACC)
 
3) Calculate the CPM using the 10 containers, and the measured timer .ACC value.
A question about this method... what would be the equation?
Time is the only constant in the formula, not containers.
The Timer.ACC would vary and I would never know how far off from 1 Min I would be.
 
Try this - measure the time for 5 products, divide time into 5 minutes worth of 1/100ths of a second.

Edit - Corrected program to add reset of counter, One-shot necessary if reset of counter happens while the input is still on. - Edit

Rate.JPG
 
Last edited:
Alternate solution

Containers per minute is a RATE. I do this sort of calcualation differently.

I would have a timer (0.01 base) that runs continuously, use a preset of 30,000.

Next rung would examine the Input sensor, and one-shot the following:
MOV the Timer.acc to a storage integer (delta time ie N7:5)
RES the Timer

Next rung:
DIVIDE Sorce A 6,000 Source B (delta time N7:5) Dest= Integer (CPM)

At your maximum project RATE of 176 CPM there should be about 0.34 sec delta between leading edges of your sensor.

6,000 / 34 = 176
 
Algebra is your friend.
Units are in ()

Code:
   [U]COUNT * (Product)[/U]   *  [U]60 * (Sec)[/U]  = [U]Tot * (Product)[/U]
   Timer.ACC * (Sec)       1 * (Min)      1 *(Min)

Now, you need to get the Timer.ACC value from 1/100's of a second, to actual seconds, so put it in a float.

DIV T4:0.ACC 100.0 F8:0

Then you get (after canceling everything out and making the constants constant:

Code:
       [U]300  [/U]= Total CountPerMinute
       F8:0 

or, 

DIV 300.0 F8:0 F8:1

Reset both the timer and the counter as just after you do the calculation.
 
Algebra is your friend.
Units are in ()

Code:
   [U]COUNT * (Product)[/U]   *  [U]60 * (Sec)[/U]  = [U]Tot * (Product)[/U]
   Timer.ACC * (Sec)       1 * (Min)      1 *(Min)

Now, you need to get the Timer.ACC value from 1/100's of a second, to actual seconds, so put it in a float.

DIV T4:0.ACC 100.0 F8:0

Then you get (after canceling everything out and making the constants constant:

Code:
       [U]300  [/U]= Total CountPerMinute
       F8:0 
 
or, 
 
DIV 300.0 F8:0 F8:1

Reset both the timer and the counter as just after you do the calculation.


Any other AB platform would have the float, but the OP is using a ML1000 1761 - does not support floating point
 
Another good way is to count number of containers over a 10 second interval at the end of ten seconds shift a 6 word area & store the number of containers just counted in the start of the shift register.
add up the 6 registers & this gives you a running count.
i.e.
1st cycle word 1 = 6 word 2 = 0 word 3 = 0 etc. (6+0+0+0+0+0) = 6 per minute after 10 secs
2nd cycle word 1 = 8 word 2 = 6 word 3 = 0 etc. (8+6+0+0+0+0
= 14
(10+8+6+0+0+0) = 24
and so on
this gives you an average over one minute but gives instant results after 10 seconds
once running the parts per minute will rise until the first minute then providing it stays at speed will give in this case 60 per minute if the rate falls for 10-20 seconds the total per running minute will fall.
 
Thanks everyone.
I've had to get off this machine for a while and get some parts ordered.
I'll be back on this project again at 5AM.
We'll see how these changes turn out.
 
I use counters for counting bottles at speeds between 100 and 700 per minute.
Simply call a Function (FC) from a cyclic interupt OB set to 20mSec (10mSec for above 400 per min).

Counter code is simple.
A I 8.2
CU C 2
A "ResetC2"
R C 2
L C 2
T "CurrData21".HotBottles

Then in another FC run every minute (called from another OB) transfer the counter value to a DB and reset the counter. I collect the 1 minute speeds for 5 minutes and average them updating the speed every minute to get accuracy much better than 1 bottle per minute.
 
Last edited:
Some feedback...
I finally got to talk to the people who run the machine that this is on and they said it is working much more accurately.
I used bernie_carlton method, simply because that seemed like the easiest (in terms of size and followability) way to go about it.
I can thank you enough for your help, and speedy at that.
That's why I love coming here if I have a problem.
 

Similar Topics

Hi everyone, This is my first time posting, so please forgive any omissions or mistakes. I am attempting to control the velocity of a stepper...
Replies
18
Views
958
Good morning, I have a question. I don't know much about ST yet I would like to calculate the average number of products per hour. how do I do...
Replies
22
Views
2,942
Can someone help me with this? I'm no good at SCL - virtually everything I've done so far has been ladder logic. The return value from the...
Replies
13
Views
1,101
I want to calculate the energy consumed from instantaneous power. Can this be done using the TOT block with timebase set to Hour?
Replies
2
Views
684
Hi everyone, I have to calculate the length in millimeters of a glass that enters a transport (I don't know the speed yet) through a barrier...
Replies
15
Views
3,456
Back
Top Bottom