Parts Per Minute calculation

A couple of things. In post 31, you show some pseudocode that shows T2 as a TMRAF. Was this a typo or did you recently switch to a TMRF? The reason I ask is if you really were using a TMRAF and then only using the lower word of the accumulated value, as you show in rung 3 in post 31, the lower word will go to zero after 100 seconds. So, for example, if the time between pulses was 100.1 seconds, the package rate would calculate out to 600 packages per minute. This is why I asked what constituted 'really slow' from your original post.

If you are going to use the free-running timer idea do some testing to see how the plc handles subtractions and rollover. For example, if you do something like :
500 - 9950
what do you get? With any luck you will get 550. If you do then you don't need to perform any babysitting of the timer accumulated value as you get a true delta even if the timer rolls over (or is reset in your case). This also means you can get rid of all of the comparisons of TA0 you have. Just check V2020 to make sure it's non-zero and call it even.

Keith
 
A couple of things. In post 31, you show some pseudocode that shows T2 as a TMRAF. Was this a typo or did you recently switch to a TMRF? The reason I ask is if you really were using a TMRAF and then only using the lower word of the accumulated value, as you show in rung 3 in post 31, the lower word will go to zero after 100 seconds. So, for example, if the time between pulses was 100.1 seconds, the package rate would calculate out to 600 packages per minute. This is why I asked what constituted 'really slow' from your original post.

Not a typo in my first attempt at this I did use a TMRAF. I would reset it with my trigger pulse but the enable line was the always on bit.


If you are going to use the free-running timer idea do some testing to see how the plc handles subtractions and rollover. For example, if you do something like :
500 - 9950
what do you get? With any luck you will get 550. If you do then you don't need to perform any babysitting of the timer accumulated value as you get a true delta even if the timer rolls over (or is reset in your case). This also means you can get rid of all of the comparisons of TA0 you have. Just check V2020 to make sure it's non-zero and call it even.

When I do a rollover I get a speed change that I am pretty sure is not really happening. It seems the faster I run the larger the variance. Example I was just runnning at 230 and when I rolled over I saw 380 show up. When I run at 75 110 shows up right after the roll over.



Glad I set up the test though. Think I am going and try to play with it a bit more before I tear it down so if you come up with anything else to check let me know.

I want to try Bernie's code tomorrow and see what the differences are. Run what I made and what he made side by side and see what the differences are. I have done similar to what Bernie has done on AB PLCs and it appeared to work. That is the main reason I was so puzzled when it went haywire on me.

I mean I understand the scan rate is going to play into any cycle rate program unless it runs outside the Scan in a STI but I am not using an encoder so I get one pulse to work with so using an STI would be better but I would have to have an update rate somewhere around 30 seconds to get a stable result.
 
Am I missing something?

I must have because I though the OP asked to display a PPM. If a timer's (Not Done) bit causes it's parent timer to be enabled, say for 60 seconds, or whatever resolution AD allows you to use, it will time to 60 seconds and reset itself. As it is timing, count the prox pulses into a counter. Reset the counter when the timer goes done. If you need to store the counter's data before it resets, you can use whatever AD allows to do so.
 
Originally posted by Clay B.:

When I do a rollover I get a speed change that I am pretty sure is not really happening. It seems the faster I run the larger the variance. Example I was just runnning at 230 and when I rolled over I saw 380 show up. When I run at 75 110 shows up right after the roll over.

You should probably run a quick test to see how the plc handles a rollover delta, just to make sure it does what you expect. With all the conditioning you do with the timer accumlated value there should be no way you can get less than a three second delta on the first calculation after the rollover. You don't allow calculations after 9900 or before 200, which is a three second differential. The last value that V2000 should have beefore rollover must be less than 9900. After rollover this 9900 will get shifted to V2010 and V2000 must get a number greater than 200. This should result in 200 - 9900, which, if rolover is handled right, should give you 300. 6000 / 300 is 20, whch is a best case scenario. It should be less than that. I can't envision a case where it would seem to go faster at rollover, unless your limiting logic isn't working the way you think it is.

Originally posted by Clay B.:

I want to try Bernie's code tomorrow and see what the differences are. Run what I made and what he made side by side and see what the differences are. I have done similar to what Bernie has done on AB PLCs and it appeared to work. That is the main reason I was so puzzled when it went haywire on me.

This went goofy on you because you were using a TMRAF instead of a TMRF. A TMRF uses only one V-memory location for it's accumulated value. When it hits 9999 it just stays there. A TMRAF can tiime for a longer period. It uses two V-memory locations. So, assuming exactly a 10msec scan, when the lower v-memory location hits 9999, the next scan will roll the lower v-memmory location to 0 and add 1 to the upper v-memory location. As soon as you get a period longer than 100 seconds the value in the lower v-memory location isn't what you expect it to be; it is much less. Using TMRF will take care of this for you.

Keith
 
The only thing that you have not done is to inverse the answer that you have. When the machine slows down the time that it takes to complete this cycle increases, but the machine cycle speed decreases. You need to have 1/X equation. Do not divide by a zero time value as your processor may fault.
 

Similar Topics

Hi All, Could anyone give me some pointers of how to calculate the parts per min, on a simple semi auto machine, using S7 300 PLC and a...
Replies
5
Views
6,554
I have one customer that i programmed a parts per minute display. I used without much thought on my part the "number of parts per time period"...
Replies
5
Views
6,790
Does anyone have any logic for Allen Bradley for parts per minute, and rolling averages. Im trying to write logic for uptime / downtime /...
Replies
6
Views
5,333
What is the easiest way of programming a omron plc to calculate parts per hour :D .The value will be displayed on seven segment displays
Replies
14
Views
5,220
I am looking at an application where I will need to detect small hairline cracks in stamped metal parts. The sensing will need to be done in the...
Replies
10
Views
1,062
Back
Top Bottom