Pump Stroke Counter

During my test I logger over 1450 "strokes" based on 17 strokes per minute. I ended up with a calculted 16.997168 strokes per minute, with the calculation being update per stroke.

Here's a Logix 5k version:
 
What's the 3510 as the preset for the StrokeInputTmr?

Since I didn't have an input handy for the test, I set it up off of a free running timer. Replace "StrokeInputTmr" with the actual input of your stroke signal. The timer would be deleted, and your stroke input would replace "StrokeInputTmr".

You would also want to condition "StrokeTmr" with the pump running bit.
Reset "StrokeTmr" and "StrokeCntr" from time to time to keep them from having overflow issues, and make sure that "StrokeCntr" is greater than zero to keep from having Divide by zero problems. The same applies to "StrokePeriodx1000" as well.

And if your PLC is like mine, you will have a very slight error introduce because of scan overhead.
 
Why not provide an "most recent" SPM value and a "shift" SPM value? there's really no way to provide the kind of accuracy your customer is looking for.
 
Okay, thanks. Was the scan overhead the reason for using 3510 for the preset?

Yup. :) I had forgotten that I had done that. :oops:

60/17 should have been 3529.

But you get the idea, each time you get a new stroke in, use a oneshot to execute the math.

And you won't be using that part of it anyway. It was just there to simulate strokes.
 
Last edited:
I have tested rootboy's first suggestion and it works great. just make sure to reset your seconds and ticks count after each calculation at 5 strokes.
 
I have tested rootboy's first suggestion and it works great. just make sure to reset your seconds and ticks count after each calculation at 5 strokes.


Thanks! But I'm curious, why reset it? I had my sample running for 1500+ strokes without any problem (on a Rockwell Logix5000 PLC).

You shouldn't have a problem unless you are limited by the size of your variable.
 
Thanks! But I'm curious, why reset it? I had my sample running for 1500+ strokes without any problem (on a Rockwell Logix5000 PLC).

You shouldn't have a problem unless you are limited by the size of your variable.

Basically I get the first stroke then start the one second timer. I also start counting up to the 5th stroke. So naturally this first stroke is number 1. once I get the 5th stroke I basically do I one shot pulse that adds the number of seconds with the fractional value of the one second time that has elapsed. I then do the math to get seconds per stroke then divide 60 by this. Once I do this I start over.

I have another simple network that adds the total strokes. I just reset the counter to start counting up to 5 again as well as the number of seconds it takes to do so.

The customer has tested this with their customer and everyone is happy.
 
Oh, I see. But why use a 1 second timer? (unless you have to) I don't know anything about the Siemens PLC, but I would think that you could create a bigger timer.

All you are interested in with the timer is the accumulated time, so the larger the timer preset, the better off you will be.

My timer was set to nearly a million seconds, so I was in no danger of timing out the timer any time soon. :)

The timer preset I chose was completely arbitrary since the number of strokes that occurred during a given period would give you the correct STM value.

And it has the effect of being self averaging since over time any deviation in the stroke rate will get figured out (instantly) with the math.
 
Oh, I see. But why use a 1 second timer? (unless you have to) I don't know anything about the Siemens PLC, but I would think that you could create a bigger timer.

All you are interested in with the timer is the accumulated time, so the larger the timer preset, the better off you will be.

My timer was set to nearly a million seconds, so I was in no danger of timing out the timer any time soon. :)

The timer preset I chose was completely arbitrary since the number of strokes that occurred during a given period would give you the correct STM value.

And it has the effect of being self averaging since over time any deviation in the stroke rate will get figured out (instantly) with the math.

In Siemens anything larger than a 1 second timer doesnt give you the time elapsed in milliseconds. I chose the one second timer so that I could get the fractional value.

If anyone knows how to get milliseconds a different way that would be good to know.
 
In Siemens anything larger than a 1 second timer doesnt give you the time elapsed in milliseconds.

Ohhh... Ugghhhh... I see.

Well, what comes to mind is a counter that toggles on/off every other scan. Let that run for a minute and see how many counts you collect. Use that as the timebase.

I would think that it would be fairly repeatable...
 
I think it was already mentioned, but simply calculate seconds (or hundredths, or thousandths) per cycle and convert it to cycles per minute with a single divide instruction with a floating point destination.

I use an unconditional timer for this, and capture the accumulated value and reset on the rising edge of each cycle completion.

You get cycles per minute after each and every cycle. You don't have to wait.

This simple method might display a value that is out of whack only when the cycle is interrupted. If you don't want to see those values, use a minimum run time to condition the DIV instruction (don't update it for the first x seconds after returning to "auto" mode). Or, you can average the last two or three samples to smooth normal variances and clip the peaks during interruptions.
 

Similar Topics

Hi everyone, I wonder if some one can help with code to have one short pulse on out put for every piston stroke on piston pump. I have input from...
Replies
1
Views
2,290
Hi, I would like to assemble a simulator/practice booster pump system that uses PID to maintain steady water pressure under various outlet demands...
Replies
0
Views
86
I've gotten to the learning curve where I can program a call for pump to come on at set point but I'm not sure how to turn the same pump off when...
Replies
1
Views
140
Hey Guys, I was looking for a little help on a school project. I was asked to program three pumps with two inputs, more and less. The project...
Replies
23
Views
2,525
My department has been tasked with writing the program for a 4 pump lift station that alternates all four pumps (one lead, one lag, two on...
Replies
4
Views
1,080
Back
Top Bottom