Accumulating number of starts and runtime hours, both daily and total

defcon.klaxon

Lifetime Supporting Member
Join Date
Feb 2015
Location
Far NorCal
Posts
616
In a system I'm working on, remote well pump sites report to a central controller. Amongst other signals, the remote well pumps report the daily number of pump starts (and daily runtime hours). These values reset each night at midnight. What I'd like to do is display the daily number of starts and runtime hours on my HMI, as well as show an accumulated value for the life of the pump as well.

I'm thinking there has to be a simple way to program a function that would show the daily value, the accumulated value, and have them both increment simultaneously when the pump is running. The problem I'm facing is that of course with ladder logic, the purpose is to run over and over again, so I can't just add the values because they would accumulate every time the program ran through the ladder. So I'm thinking maybe I store the values in other variables, but the exact method is something I'm finding a bit challenging. I was wondering if someone had a suggestion for implementing this.

The functionality I'm thinking of similar to Excel being able to display a value in a cell that is based on the values of other cells, and that display cell just contains an equation. That's basically what I'm trying to do. The resetting value is creating another level of complexity, I think.

Anyway, if anyone has suggestion on how this might be implemented with logic, I'd love to see them. I can write this program either in ladder logic with function blocks, or in structured text a la IEC 61131-3. Thanks!
 
Well first we need to know what PLC you are using. That will help us get you in the right direction.

I was working on somthing simular to this in that I am doing Daily, Monthly and Yearly totals of a flow meter.

I would start out with a Accumulator of hours and one for starts. Every time a pump starts add one to the START_ACCUM register. When a pump starts you can start a timer and move the value into the HOURS_ACCUM register. When the pump is off reset the timer and stop moving the value.

For the Daily values you can move the value of START_ACCUM and HOURS_ACCUM into a register. Say HOURS_DAY_START and STARTS_DAY_START at midnight or what ever time you need. Then you can subtract that value from START_ACCUM and HOURS_ACCUM and place it into another register say START_DAILY and HOURS_DAILY. You may want to do an array of 31 days and move the value of each day into a new array element. What I did was to use a 32 element array and move the daily data into the element that corresponded to the day of the month. So if the day is 5 I moved that data into HOURS_DAILY[5]. I didn't use the 0 element. I just figured using the day of the month was much easier.

Hope this gets you moving.
 
Last edited:
Hi Bullzi,

Thanks for the response.

The PLC I'm working with is an ICLinks Lassen.

As far as the details, I already have daily hours and number of starts coming in from the remote sites so I don't need to create the accumulators per say, as they already exist at the remote site. Thus all I need to do is take that piped in value and increment a total count (for hours and number of starts). In theory that makes it easier, but it's also a bit of a unique approach.

The other thing I could do is just create my own accumulators from the "pump is running" feedback, that may be easier just from the perspective of creating timers and accumulating values...it may be more wise than I originally thought.
 
You could show the run time for the day. Look at total accumulated you had yesterday and add those up for total accumulated.
Look at runtime for the day, when it goes to 0, add the last recorded daily runtime to your accumulator. And start over.
 
I think boneless's idea is a good one. Just look at the current values each scan, if they're not zero then copy the current values into a "value last scan" register. If they ARE zero, then add the "value last scan" register to your total.

The only thing you'd have to do is make sure you only add them on once, the first time the values go to zero. I'm not sure of the exact terminology for your PLC but look up positive edge or negative edge triggers.
 
Hi Bullzi,

Thanks for the response.

The PLC I'm working with is an ICLinks Lassen.

As far as the details, I already have daily hours and number of starts coming in from the remote sites so I don't need to create the accumulators per say, as they already exist at the remote site. Thus all I need to do is take that piped in value and increment a total count (for hours and number of starts). In theory that makes it easier, but it's also a bit of a unique approach.

The other thing I could do is just create my own accumulators from the "pump is running" feedback, that may be easier just from the perspective of creating timers and accumulating values...it may be more wise than I originally thought.





You can try this, new values are added to your accum when values change at remote site. Take care of negative value, if remote site's old accum is bigger than new value (accumulator overruns and starts from zero on remote site)

rem_accum_new is your remote site accumulator value which you have allready. New value is updated every plc sacn, if remote accum value changes, then new value have value one plc scan.
You can count this then directly to your own accumulator.


|------------------------------------------|
-----------| new_value := rem_accum_new-rem_accum_old |
|------------------------------------------|


|------------------------------------------|
-----------| rem_accum_old:=rem_accum_new |
|------------------------------------------|

|-----------------| |-------------------------|
---new_value<0 |-------| new_value:=0 |
|-----------------| |-------------------------|

|---------------------------|
--------------------------| acc:=acc+new_value |
|---------------------------|



 
or



|----------------------------| day_changed
---|rem_accum_new<rem_accum_old |-----------------------( )
|----------------------------|


day _changed |---------------| |----------------------------|
---|/|--------|rem_accum_new>0|---| accum_day := rem_accum_new |
|---------------| |----------------------------|




|------------------------------|
-------------------------------|rem_accum_old:= rem_accum_new |
|------------------------------|



day_changed |------------------------------|
-----|P|------------------|accum_yesterday := accum_day| |
| |------------------------------|
|
| |------------------------------|
|-------|accum_day :=0 |
|------------------------------|




p.s You maybe want check day changing with this way. (If you have connection error at midnight, this should work even after your connection start working (remote site accumalator have goed to zero and counted allready from zero...)

Or you can do midnight savings on your PLC, but then probably different PLC's have different times and accumulator values ;)
 
For runtime:
Base a one shot off of a valid real time clock, say the seconds register.
Then every scan, if the one shot is active, and if a pump is running, increase the "Seconds Run" register for that pump (add one).

For starts, just use a one shot based on the run command to increment a "Starts" register.
 
Hey thanks everyone for your responses, they were most helpful.

Using structured text, I was able to get what I wanted from the following code (in case anyone is interested):

Code:
IF HTS_RT = 0.0 THEN
    HTS_RT_BUFFER := 0.0;
ELSIF HTS_RT > 0.0 AND HTS_RT > HTS_RT_BUFFER THEN
    HTS_RT_TOTAL := HTS_RT_TOTAL + HTS_RT - HTS_RT_BUFFER;
    HTS_RT_BUFFER := HTS_RT;
END_IF;

Basically the present hours value is put into a buffer, and total hours is itself plus the daily runtime, minus the previous runtime value. Then when daily resets to zero, the buffer resets to zero. This allows the total hours to simultaneously increment with the daily hours. It turned out to be pretty simple, but it took awhile to figure it out before I could write the code.
 

Similar Topics

Hi all, Can anyone tell me why the MinDuractionACC isn't accumulating in the example below? Is it just a visual bug? I've tried in multiple...
Replies
4
Views
1,194
I AM Using a AB micro1500 PLC and the PTO instruction. I need a program or technique to keep a running total of all pulses produced from the PTO...
Replies
0
Views
1,076
Hello everyone, so I added some inputs and 2 TON timers to an existing program that I knew was working just fine before I added these. I verified...
Replies
3
Views
2,304
Hey guys, we have a big trouble with our drives; In our application we have often to disable the drive and hold it on brake; The problem is after...
Replies
2
Views
1,630
I'm having a hard time wrapping my head around this today. Very likely due to being sick and not thinking straight, plus my inexperience with...
Replies
18
Views
8,313
Back
Top Bottom