3 Pump Floating Master

maxp2025

Member
Join Date
Nov 2023
Location
Michigan
Posts
3
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 goes that if the more button is pressed then the pump that has been turned off for the longest kicks on. The same goes for the less button the pump that has been turned on for the longest will be turned off once the less button is pressed. I am just looking for the best and most efficent way to get this done.

Thanks
 
Post what you have so far.

Have you summarized the inputs?

Have you summarized the outputs?

Have you thought about what internal variables the program will need to maintain e.g. the accumulated run time of each motor?

Have you thought about the algorithms will you need? e.g.

  • determining the stopped motor with the least amount of run time
  • determining the started motor with the greatest amount of run time
  • Do you want to execute those algorithms only when a start or stop button is pressed,
  • or do you want to maintain that information continuously i.e. on every scan cycle, so the program always knows the next pump to start and the next pump to stop?
  • whichever approach you choose, how will you represent that information in program memory?
The inputs, the outputs, and the internal variables provide a model of the process; all you have to do ;) is come up with logic that interacts with that model.

There are probably several ways to skin this cat. The best way to doing something like this is to

  1. think of an approach
  2. construct the data model for that approach (inputs, outputs, persistent internal variables like assumulated runtime).
  3. figure out how to hold those model data in the available data types (integers, arrays, booleans, structures, etc.).
  4. try to code the approach
  5. see what is easy about that approach
  6. see what is difficult about coding that approach
  7. see what the edge cases are that make that approach hard to implement
  8. use 5, 6, and 6 to inform a new approach, either a variation on the current approach or a completely new approach, i.e. return to step one
Do not expect the first approach to work, instead expect to refactor at least a few times to get a clean, understandable, working approach.
 
For extra credit the OP could perform an analysis to see if the approach outlined in the assignment did a better job of equalizing runtime than the alternative approach of having the 'more' button turn on the pump with the least run time.
 
I just realized I misread the original post. What it said is

  • when turning off one pump, you turn off the one that has been on the longest;
  • when turning on one pump, you turn on the one that has been off the longest.
The interesting thing there is that you don't have to keep track of the run time of the pump, you only need to keep track of the order in which pumps were turned off and were turned on.

I suggest you look into FIFOs as the data model.
 
DrBitBoy,

Inputs and Outputs:
More and Less are my two inputs. The three motors are my outputs.

For the run time of the motors I have them attached to RTO's with their bool bits motor_run.

Now for determining the motors with least and most amount of run time I was planning on putting each motor onto an RTO and using the RTO.acc to determine which motor would kick on. Although I could force a pattern into the program by initially forcing the Pump one to kick on when more is pressed first.

Yes, the program has memory to know which pump is on and which pump should be next.
 
Most cycling programs like this go by the accumulated runtime of each pump, as both above answers reflect.


Your question is worded a little differently - it seems you want to control the pumps based on the OFF time since the last time it ran regardless of the pumps runtime hours.


Could you be interpreting the assignment wrong, or is this a really weird assignment that will never have a real world application?
 
Now for determining the motors with least and most amount of run time I was planning on putting each motor onto an RTO and using the RTO.acc to determine which motor would kick on.


that is how you are storing the run times.


how do you choose between the three motors?

is there another set of RTOs keeping track of the off-times? Or are the order of off-times simply the reverse of the order of run times?
 
" I am just looking for the best and most efficent way to get this done."

If I were you, I'd ignore the drbitboy. He's normally not the brightest nor anywhere near any efficiency mode that you are looking for. I meant, take a look at his sig, it's a big mess, really. 🍻
 
@maxp2025: so which is it?

is the run time RTO reset to 0 each time its pump starts?

or does run time from previous run periods continue to accumulate?


Using a RTO with a DINT accumulator will only go up to 596 hours of runtime before rolling over to a negative value.


A pump in use could easily reach thousands of runtime hours. I worked on a compressor control that the 4 air compressors were all showing about 17,000 hours and they were nowhere near the end of their life.



If the assignment is for runtime then it's best to have the RTO trigger a ADD to a DINT to know hours of runtime.
 
" I am just looking for the best and most efficent way to get this done."

If I were you, I'd ignore the drbitboy. He's normally not the brightest nor anywhere near any efficiency mode that you are looking for. I meant, take a look at his sig, it's a big mess, really. 🍻

heh.
 
I am just looking for the best and most efficient way to get this done.
Best and most efficient do not always pull in the same direction.

For the "pump that has been most recently turned on/off the longest," efficient is two rungs and ten instructions, or a bit more to debounce the input buttons.

For the "pump that has the most/least accumulated run time over all past on/off cycles," efficient is three rungs and about forty instructions, including input debounce. There may be a more efficient way with SQO.

Best is another metric cf. here.

If you want to learn, you could pursue both i.e. write two programs: one playing code golf; one coded so simply and clearly that comments are all but unnecessary.

But @L33er is right: you should ignore me.
 
Last edited:
I would do it in long unsigned integer mins, that would be probably 8 years before going negative, even though accumulation of fractions of minutes missed on each motor is not going to be that much between them on average, only in total runtime.
 
I would do it in long unsigned integer mins, that would be probably 8 years before going negative, even though accumulation of fractions of minutes missed on each motor is not going to be that much between them on average, only in total runtime.

But if he used a RTO that added 1 to the value and then RES itself it wouldn't lose 1 second.

For me what I do is have a 6 second timer and use the .DN to add 0.1 minutes to runtime for all motors and pumps that are running at that scan. I have ran this method along with a precise RTO and over a year it was only off a couple of minutes
 
I think you need to read my post, I was stating that if they wanted a total runtime over probably the lifetime of the motor then minutes would be fine, no need to worry about seconds the average pump losing even a minute every changeover as they would all do it then it would probably average out between pump recorded run times. Probably more accurate to use the on-board RTC so a change on every minute would almost certainly be as accurate although the pump stopping at say 15:39:59 would lose 59 seconds but on the other hand if it was 115:39:01 then only loose a second, I used to use a 1 second clock then every 60 seconds add one to the minute & do the same for hours etc.so inreality the actual runtime will be 3 variables, hours minutes & seconds the hours var was a double unsigned integer this gave years of actulal runtime probably more than the life of the plant or a persons life. Forget timers just use RTC clock pulses.
Although the OP's post indicated the only interest is 1 Button for which pump has been on the longest so turn it off , 2nd button in which pump has run the least will be turned off, does not really make sense, if pump 1 is running & pump 2 has been off for the longest, then this will start pump 2 same as pump 3, then a second button will turn off the pump that has been on for the longest & turn it off.
Well this does not make sense first how many pumps are running in the first place ?, if you turn off the pump that has the most run time does that leave 2 pumps running ?, then if all 3 pumps are running & you press the more button does this turn off that pump leaving 2 pumps running ? how many pumps should be running 1, 2, 3 in normal operation ?.
 

Similar Topics

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
82
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
132
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,077
So I very much new to doing ladder coding I have a pump with a Stop float switch that stops the pump when a sump is low. I want my manual run mode...
Replies
13
Views
1,391
Hi everyone, I am a newbie and I have trouble in the control sequence. I have a system with 4 pumps. The required: Ex: Push a button to start in...
Replies
21
Views
2,763
Back
Top Bottom