Write a PLC Program for Selector Machine using Structured Text

In this post, we will see a PLC program for writing a selector machine logic using structured text language.

Write a PLC Program for Selector Machine

Let us understand the case scenario first. There are four tanks supplying ingredients to a common mixture tank. According to the recipe made by the operator, the selected ingredients will be fed to the common tank for a set time. If any of the tank levels are low, the process will not run and halt at the corresponding stage.

The operator will manually fill the tank and wait for the level to become normal. If the collection tank level becomes high, then the process will abort or reset; this is because the recipe is designed properly, and filling the tank fully means there is some abnormality in the recipe or process.

After the recipe time is completed successfully, the cycle will reset and wait for the next start operation from the user. Pressing the start button starts the process, pressing the stop button pauses the process, and pressing the reset button resets the process.

According to our requirements, these are the following PLC IOs:

  1. Digital inputs – start push button, stop push button, and reset push button.
  2. Digital outputs – tank-1 discharge valve, tank-2 discharge valve, tank-3 discharge valve, and tank-4 discharge valve.
  3. Analog inputs – tank-1 level, tank-2 level, tank-3 level, tank-4 level, and common tank level.

Structured Text Language

Let us now see the logic for this process. Refer to the below image. First, we will create a logic for starting, stopping, and resetting the logic. We will use two main bits in the logic – cycle running and cycle started.

Cycle running can be started or paused anytime, but the cycle started is a latched bit. It latches once the cycle starts and resets only on reset condition. If the start button is pressed, then we set both these bits.

If the stop button is pressed or if the cycle is not started, then we reset the cycle running bit. If the reset button is pressed, then we reset the cycle started bit.

PLC Program for Selector Machine using Structured Text

Next, we use the batch cycle counter for the process timer. We use a set value of 10 seconds. If the cycle is running, then the counter increments every second. If the cycle is not started, then the counter remains in reset condition. And when the counter is done, then we reset the cycle started a bit.

Now, we will write the logic for the step counter. We use three-step setpoints, which will be written by a recipe in HMI. If the current batch timer value is less than setpoint-1 and the cycle is started, then we are in step number 1.

If the current batch timer value is greater than setpoint-1 and less than setpoint-2 and the cycle is started, then we are in step number 2. If the current batch timer value is greater than setpoint-2 and less than setpoint-3 and the cycle is started, then we are in step number-3. If the cycle is not started, then we are in step number 0.

Next, we need to turn on the valves according to the recipe. The recipe will change its set values according to the current step number. So, we create a case statement of four values.

  • If tank number 1 is selected, then we turn on valve 1 and turn off the remaining valves.
  • If tank number 2 is selected, then we turn on valve-2 and turn off the remaining valves.
  • If tank number 3 is selected, then we turn on valve 3 and turn off the remaining valves.
  • If tank number 4 is selected, then we turn on valve 4 and turn off the remaining valves.

Now, we will write the logic for pausing and aborting the logic. If any of the tank levels is less than 100 liters, then we reset the cycle running bit.

If the common tank level is more than 500 liters, then we reset the cycle started a bit.

If the cycle is not running, then all the valves will remain off.

In this way, we saw how to write a PLC program for a selector machine using structured text.

Read Next:

Don't Miss Our Updates
Be the first to get exclusive content straight to your email.
We promise not to spam you. You can unsubscribe at any time.
Invalid email address

Leave a Comment

Share via
Follow us and never miss an update!