z-logo
open-access-imgOpen Access
Teaching Finite State Machines (FSMs) as Part of a Programmable Logic Control (PLC) Course
Author(s) -
Curtis Cohenour
Publication year - 2018
Language(s) - English
Resource type - Conference proceedings
DOI - 10.18260/1-2--28917
Subject(s) - programmable logic controller , finite state machine , programmable logic device , state (computer science) , computer science , supervisor , complex programmable logic device , control logic , simatic s5 plc , ladder logic , control engineering , embedded system , engineering , programming language , operating system , political science , law
Industrial control courses in Electrical and Computer Engineering (ECE) include programming of Programmable Logic Controllers (PLCs). Text books are available to support these courses but few provide any content on Finite State Machines (FSMs). This is unfortunate because a great deal of PLC applications in industry involve sequence logic which lends itself to the FSM. A FSM consists of a defined (finite) number of states that a system can be in, and well defined rules for how the system moves from one state to the next. The FSM can perform entry chores, exit chores, and state tasks. Inputs and calculations made within the state define the movement from state to state. The action that results from an input may depend on the current state. A PLC is a computer that solves relay logic also referred to as ladder logic. PLCs are typically connected to limit switches and solenoid valves and provide low level control functions. Supervisor computer systems may also direct the action of a PLC. The course content described in this paper offers the author’s industry tested implementation of the FSM for PLC implementation. The FSM connects the PLC input devices to the PLC output devices in a straight forward manner that makes the system easier to understand for engineers and maintenance personnel. Students learn not just how to program a PLC, but how to create ladder logic that provides a reliable and maintainable PLC solution. PLCs are ubiquitous in industry and students with experience and ability are in high demand. Motivation: Electrical Engineering (EE) and Engineering Management and Technology (ETM) students can increase their employability with Programmable Logic Controller (PLC) skills. PLC positions exist in supervision, maintenance, operations, and sales. Supervisory positons can be in maintenance or operations. These may include supervisory responsibility over processes or personnel involved production or maintenance. Maintenance positions include troubleshooting PLC systems and maintaining PLCs and Input Output (IO) devices. Operations may include using PLC controlled equipment in production. Sales may include the sale of PLC controlled equipment, or the sale of PLC processors, IO cards, and accessories. To meet these needs an undergraduate senior elective in PLCs is offered. The course has long been offered without any specific training in sequences. In the fall of 2015 the course was modified to include Finite State Machines (FSMs). With this change students are now trained to recognize the difference between combinational logic and state logic. Combinational logic is logic that is derived exclusively from current inputs and does not depend on previous inputs. State logic includes memory of previous events specifically embodied in the “states”. Additional learning outcomes for the modified course are: 1. Recognize the difference between combinational and state logic 2. Recognize a sequence 3. Create a state diagram 4. Implement an FSM in Ladder Logic 5. Create outputs from FSM states 6. Test and debug an FSM on a laboratory system These learning outcomes are assessed via assignments, exams, and laboratory exercises. Background: Ladder Logic (LL) or Ladder diagram (LD) is one of five programming languages defined in IEC 61131-3 [1]. The defining feature of IEC 61131-3 is its cyclic execution model. In addition the IEC 61499 [2] provides an event driven execution model. These standards and conversion to IEC 61499 are described in [3] [4]. Combinational logic, also known as time-independent logic, is PLC logic that depends only on the current inputs. Because the ladder logic is solved cyclically, per IEC 61131-3, combinational logic can be defined as logic that depends only on logic that is solved earlier in the cycle. If the logic depends on information from a previous cycle (memory), it is state logic. Memory from previous states could be numeric, but for the purposes of this paper, a state is defined as any coil where the value from a previous scan is used in the current scan. Our focus here is on the implementation of the FSM in LL. Alternatives exist such as the Sequential Function Chart (SFC), also contained in IEC 61131-3 [1]. The SFC is not LL and may be unfamiliar to maintenance personnel in some organization. In addition, there are sequencers and drum controllers available in some PLCs, but again these may not be suitable for some organizations. A review of undergraduate level PLC text books was conducted to determine if there were any texts that dealt with FSMs in PLCs. The closest match is found in [3], were sequential applications are addressed using latching relays in chapter 6, this is repeated using Allen-Bradley PLCs in chapter 6 of [4]. SFC programming and sequence logic using control relays is discussed in [6]. Sequential Function Chart programming is discussed in [8]. The Allen Bradley “Sequencer” instruction is discussed in [8]. There is no mention of sequences in [5]. The text used at our institution is [9]. In this text SFCs are mentioned in passing. Short sequences using control relays are covered with no overt explanation that the control relays define states, or that there is a sequence of events. FSM Implementation: PLC LL programs are often filled with state machines. Every seal in circuit is a two state FSM. What is required of the student is to recognize the difference between combinational logic, and state logic, and to perform the implementation accordingly. Combinational logic is the direct assignment of an output or internal coil based on inputs with no memory. The inputs may be connected to real world devices such as limit switches and push buttons or internal coils. The outputs may be real world outputs or internal coils. As an example assume that there are two pushbuttons and a limit switch that control a solenoid valve. There are three inputs that can be on or off for a total of eight combinations. Of the eight combinations some of these combinations turn the solenoid valve on and some turn it off. In combinational logic three binary inputs yield 8 possibilities which are assigned to the output. The previous values of the inputs or the outputs are not considered. State logic is any logic that is dependent on previous events. The most common example is a seal in circuit. Figure 1 shows a combinational circuit in Rung 1 and a two state FSM in Rung two. In rung one there are three inputs and one output. The state of the output is dependent only on the state of the three inputs. In Rung two there are only two inputs and one output. The output Y008 is used in conjunction with the two inputs X008 and X009 to determine the output. The output Y008 depends not only on the inputs but also on the previous value of the output. Y008 is a state. Figure 1Two similar motor start circuits implemented in PLC logic. Rung one (top) is combinational logic. Rung two (bottom) is a two state FSM. Note that in rung 2 the output Y008 is dependent on the previous value, or state of Y008. The motor start circuit in Rung one is preferred because if the motor quits for any reason, the seal X003 will be lost, and the motor will not restart. This is a basic safety feature of the circuit. The circuit in Rung one is also preferred because it is combinational. Rung two is a state machine with two states. The two states are on and off based on the condition of Y008. The PLC logic of Rung two might be used in a situation where an unplanned start would not create a safety or process risk, or where an auxiliary contact for the motor is unavailable. An FSM Example Consider the box fill operation, shown in Figure 2. Boxes move along the conveyor to a fill station where they stop and are filled. After the box is filled, the conveyor is started to remove the full box and bring an empty box to the fill positon. There is a level switch to detect the full condition, and a proximity to indicate that the box is in position. The system can be in auto or standby. If the system is in auto the conveyor runs until a box is detected by the proximity switch. When the box is detected the conveyor stops, the fill valve is energized and material flows from the hopper into the box. The box full condition is indicated by the level switch. When the box is full, the fill valve is closed and the conveyor starts and runs until the box is clears the proximity switch. The conveyor continues to run until an empty box is detected by the proximity. The cycle repeats as long as the system is in auto. Figure 2 A box fill operation. A state machine diagram is given in Figure 3. There are three states. The author’s practice is to number the states by tens to allow for modifications. In state 10 the conveyor is running and we are looking for an empty box as indicated by the proximity switch. In state 20 the box is filled until the level switch is made. In state 30 the conveyor runs until the proximity switch clears indicating the full box is gone. The transition from standby is made to state 30 so that if there is a box on the conveyor it is removed before the fill operation begins. Figure 3 A state diagram for a three state FSM for a box fill operation The system can be in auto or standby, and for safety includes a Normally Open (NO) contact from an external estop relay. The auto standby circuit is operated by an NO Pushbutton (PB) for auto start, and a Normally Closed (NC) PB for stop. This two state auto/standby FSM is shown in rung one of Figure 4. Note that rung one is a two state FSM and rungs two through four are a separate three state FSM. The outputs on rungs five and six are combinational logic. Coil C101 is a state because it is dependent on the previous value of C101, C102, and C103. Coil C102 is a state because it depends on the previous scan value of C102, and C103. In Rung four the new values from the current scan are available for C101, and C102, but the previous scan value for C103 is used making C103 a state. One might argue th

The content you want is available to Zendy users.

Already have an account? Click here to sign in.
Having issues? You can contact us here
Accelerating Research

Address

John Eccles House
Robert Robinson Avenue,
Oxford Science Park, Oxford
OX4 4GP, United Kingdom