0% found this document useful (0 votes)
448 views7 pages

Programming A State Machine in Ladder Logic

Uploaded by

Felipe Suzart
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
448 views7 pages

Programming A State Machine in Ladder Logic

Uploaded by

Felipe Suzart
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

12/09/2022 11:55 Programming a State Machine in Ladder Logic

Siemens PLC programming course Register for FREE!

Back to tutorials

Programming a
State Machine in
Ladder Logic
By Letácio Lins

Introduction
A state machine is an abstraction of a
machine that can be in one of a finite
number of states at any given time,
wherein in each state there are actions
and transitions. Actions are means for the
machine to interact with the system, while
transitions are certain conditions to be
achieved in order to move from one step
to another. 

A State machine is a powerful tool when it


comes to programming procedural
industrial systems. It's possible to cover
226
Shares

https://www.solisplc.com/tutorials/programming-a-state-machine-in-ladder-logic 1/7
12/09/2022 11:55 Programming a State Machine in Ladder Logic

entire machines programs with this


methodology, and even split a complex
process into several smaller and simpler
state machines. Diagnostics and
troubleshooting are also facilitated,
considering that the lack of transition and
action signals are easily noted based on
the current step status.

In this tutorial, you'll learn how to build a


state machine in Ladder Logic. We'll be
using Siemens Tia Portal and an S7-1200
PLC, but the methodology can be applied
to any PLC and software that supports
ladder logic. 

Understanding the
general template of
a state machine in
Ladder Logic

This template covers every instruction and


the general structure of a step in ladder
logic for the state machine. At first, the
network checks whether the current step
number is equal to the specific step.
Some programmers utilize boolean
memories for each step, but personally, I
like to work with an integer memory, since
it is easier to interact with multiple steps
in a single memory.

If the current step is active, then the


program proceeds to check interlocks and
conditions needed for this step's actions.
In a parallel branch, we check all the
226
Shares

https://www.solisplc.com/tutorials/programming-a-state-machine-in-ladder-logic 2/7
12/09/2022 11:55 Programming a State Machine in Ladder Logic

conditions to move to other steps from


here.Since we're utilizing an integer
memory to keep the actual step, it makes
it easy to standardize a step-by-step logic
by incrementing its value by one each
transition. Furthermore, moving any
integer value to the actual step memory is
also useful to move the state machine to
that specific step.

Next, let's put the concept into practice


and build a simple product mixer machine.

Understanding the
Mixer Machine

The mixer machine is composed of two


product valves (Valves A and B), a mixer
(Motor A), and a drain valve (Valve C). The
operation should be initiated by pressing a
Start Push-Button, which will open both
product valves until the high-level sensor
indicates the tank is full. After filling the
tank, the mixer will be on for 10 seconds,
and after that, the drain valve should be
open until the low-level sensor goes off.

Building a State
Machine Diagram

226
Shares

https://www.solisplc.com/tutorials/programming-a-state-machine-in-ladder-logic 3/7
12/09/2022 11:55 Programming a State Machine in Ladder Logic

Building the state machine diagram is


fundamental to formulating the steps and
transitions, as well as anticipating any
incoherence that may appear. The mixer
state machine should cover the initial
state, tank filling, mixing, and draining of
the mix. Every transition condition should
be the conditions needed for the machine
to progress, while the actions of each
individual step cover the outputs and logic
commands to interact with the system.

Programming a
State Machine in
Ladder Logic

Now it's time to program each step, its


actions, and transitions in ladder utilizing
the general template of a state machine.
For the initial step (Step 0), we have no
actions (the machine is in an idle state)
and only one condition, which is the start
command.

The start command leads the machine to


the filling step (Step 1), responsible to
command both product valves (actions)
to open until the high-level signal is
received from the sensor, covering a
transition to the next step (Step 2).
226
Shares

https://www.solisplc.com/tutorials/programming-a-state-machine-in-ladder-logic 4/7
12/09/2022 11:55 Programming a State Machine in Ladder Logic

For Job LOG GET


Courses Pricing Resources  Community 
Business Boards IN STARTED

Since the memory actual step value is no


longer equal to one, the valves are not
Contents open anymore(commands to open are
Related Tutorials
off) and in the new step, the mixer motor
Understanding output should be on for the estimated Beginner
the general duration. A timer of ten seconds is then
the transition condition to move the
An
template of a
Introduction to
state machine machine state from step 2 to step 3. 
Basic Ladder
in Ladder Logic
Logic Instructions in
Siemens Tia
Understanding Portal
the Mixer
Read Tutorial
Machine

Building a
The last step consists of opening the Advanced
State Machine
drain valve (action) until its transition
Diagram Commissioning
condition (low-level sensor signal goes a Servo Motor
Programming off) is achieved. This transition leads to with Siemens
a State the completion of the process and takes Sinamics
Machine in the machine back to an idle state until the Starter
Ladder Logic start button is pressed, or in other words, Read Tutorial
we move the machine to the initial step
Conclusion
(Step 0).
Intermediate
Share This Tutorial Conclusion Siemens HMI
Programming |
In this tutorial, we covered a strategy for WinCC TIA
building state machines in ladder logic, Portal SCADA
using a simple product mixer as an Development
example. This approach can be expanded
Batching
System
to program complex machines with any
Example
number of steps. This ladder logic
structure is also convenient for alarms Read Tutorial
development and interaction between
machines and other functions from the
same code, which is a topic we'll cover in
226
the next tutorial.

Shares

https://www.solisplc.com/tutorials/programming-a-state-machine-in-ladder-logic 5/7
12/09/2022 11:55 Programming a State Machine in Ladder Logic

Back to tutorials

Start Discussion 0 replies

Ready To Learn More?


Level-up your career with unlimited access to practical, in-depth technical courses taught by
industry experts. Explore our courses

Introduction to An Introduction Introduction to


the MQTT to Industrial FANUC
Protocol Ethernet Via Industrial
RSLinx Robotics
Learn More Programming
Learn More
Learn More

LEARN RESOURCES PLANS

Allen Bradley PLC Tutorials Pricing


Programming
Practice Challenges For Business
HMI Programming
226 Guides
Shares
Siemens PLC Programming
https://www.solisplc.com/tutorials/programming-a-state-machine-in-ladder-logic 6/7
12/09/2022 11:55 Programming a State Machine in Ladder Logic
Siemens PLC Programming
Forum
Variable Frequency Drives Videos
Analog Sensors & Signals Upcoming Events
Machine Vision Podcast
PLCnext Job Board
PointIO
OPC-UA

Course Catalog
Topic Suggestions

COLLABORATE COMPANY

Become an Instructor
About
Become a Content Partner Blog
Become an Affiliate Newsletter
Systems Integration Contact us
Customer Reviews

© 2022 SolisPLC. All rights reserved. Affiliate Program T&C | Privacy


Policy | Terms of Services

226
Shares

https://www.solisplc.com/tutorials/programming-a-state-machine-in-ladder-logic 7/7

You might also like