Ladder Logic - 'Simple' Coffee Machine - Optional: Add Milk / Add Sugar

4.8k Views Asked by At

I'm just starting to learn Ladder Logic Programming. I'm using Allen Bradley RSLogix 5000.

I've been tasked with developing a 'Simple' Coffee Machine which operates like so:

  • Toggle Push Button to Start
  • Drop Cup (for 10 seconds)
  • Feed Hot Water (for 10 seconds)
  • If required, Add Milk (for 10 seconds)
  • If required, Add Sugar (for 10 seconds)
  • Procedure Complete - Illuminate Complete Light (for 10 seconds)

I have implemented everything except the OPTIONAL add Milk & OPTIONAL add Sugar.

Options are:

  • To have a Coffee without either Milk or Sugar.
  • Or have a Coffee with Milk and Not Sugar.
  • Or have a Coffee with Sugar & Not Milk.
  • Or have a Coffee with BOTH Sugar & Milk.

I'm considering using Toggle Buttons to select / jump to a Subroutine (choosing the required ingredient make-up). But I'm wondering if there is another way to sequentially go through the procedure?

Thanks.enter image description here

3

There are 3 best solutions below

0
On

Here is how I'll do it:

Step 1. Define all Actions: - Drop Cup, - Feed Hot Water, - Add Milk - Add Sugar. For these, make a dedicated routine or AddOnInstruction. If you think is too simple and not necessary, just think that you will have to write a diagnostics for each, and maybe you are gonna reuse Drop Cup in another project. What happens if you Drop Cup, and you are out of cups, or dropping device is defective, and so on?

Step 2. Now that you have isolated these, make the graph as everything is needed, even if not.

Step 3. Create recipe format, putting parameters for Ingredients - for Add Milk, put as parameters: requiredOrNot, numberOfSeconds

Step 4. Create as many recipes as you wish. You will never modify the software based on recipe.

Step 5. Create a recipe management. This will be very useful for all your future projects. It's a one time task.

This is how I made a cocktail bar for my wedding. I gave to my friends about 20 recipes, and by the end of the day, I found about 50 in recipe list.

P.S. I know that seems too complicated for given task, but if you step away from your particular task and analyze my example, you'll realize that you can write any program without reinventing the wheel every time.

0
On

Another method would be to give a value to each step (say 1 thru 5) and keep track of the value using an integer. Then when you are in step 4 (f required, Add Sugar (for 10 seconds)) and the option is false you can "jump" this step and go directly to step 5.

pseudocode:

if currentstep == 4 AND AddSugar = true then

  • Add Sugar for 10 seconds

  • currentstep = 5

Else
- currentstep = 5

0
On

I would also recommend creating steps so that things don't happen at unexpected times. Here is how I would set it up (Note: I wrote this very quickly, buyer beware)

enter image description here enter image description here enter image description here