Button Press Counting, Timer Controlled Output Question

I am relatively new to ladder logic so I am having a hard time wrapping my head around this project of mine.

I have a drink dispenser that dispenses the drink as long as the button is pressed. This forces the user to manually time the release of the button to stop dispensing the drink without over or under filling the cup. This doesn't happen so well without much practice. I want to make this gorilla proof.

I would like to use an AB Pico or similar smart relay to control this. There are only two sizes of cups, small and large. I want the user to be able to press and release the button once for a small (dispense for 6 seconds) or press and release a second time for a large (another 6 seconds or 12 seconds in all), then a third press and release will shut everything off immediately if there's a problem. I only have one button and can't add another one.

In a perfect world I'd also like to be able to press and hold the button to dispense until the button is released. I know this will get into logic that can see the difference between a press and release and a press and hold, but that is beyond my knowledge at the moment.

What I'm having trouble seeing is how to make sure the two fill levels are consistently met regardless of when the second press is done. I have logic turning on the pump on the first press but if I press again at say 4 seconds, the second timer starts so the last two seconds of the first timer don't do anything. My timers aren't cumulative and I'm struggling to see how to do this.

I've thought about an up down counter. The button counts up and the timers count down and as long as the counter is greater than zero, keep the pump running. I struggle to get that logic to work right with the third press and release if the first timer has reduced the counter from 2 to 1, it's never going to be 3. I just chase myself in a circle with ideas on what to do about it.

Can I get some help on how to handle this, please?
 
Hmmmm....thinking "out loud" here. I haven't used a Pico before so I don't know exactly how to do it but I have an idea or 2 for how to use a MicroLogix 1xxx.
How about have a one-shot-falling on the button do 2 things: add 6 seconds to the timer preset and increment a counter. Or, maybe more elegant, increment the counter and then multiply the counter accumulator by 6s and put the result into the timer preset.
If the timer is done, clear the preset and reset the counter. Or, reset the counter and have the timer preset still be 6s multiplied by the counter accumulator. If the counter reaches 3, clear everything.
Also, run a timer while the button is pressed. If it exceeds "Y" value (to be determined by you), then clear the counter and timer and hold the output on until the button is released.
 
Top