plc basics (adapted from siemens s7200 training manual)

Upload: christopher-brown

Post on 08-Apr-2018

277 views

Category:

Documents


5 download

TRANSCRIPT

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    1/115

    PLC BASICS

    PROGRAMMABLE LOGIC CONTROLLERSV.1

    J.F. MABANGLO

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    2/115

    A programmable logic controller (PLC),

    also referred to as programmablecontroller, is a type of computercommonly used in commercial andindustrial control applications.

    While the specific applications vary

    widely, all PLCs monitor inputs andother variable values, make decisionsbased on a stored program, andcontrol outputs to automate a processor machine.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    3/115

    Simple Example

    In this simple example, pushbuttons (sensors) connected to PLCinputs, are used to start and stop a motor connected to a PLC outputthrough a motor starter (actuator). No programming device or operatorinterface are shown in this simple example.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    4/115

    The basic elements of a PLC include input modules or points, a central processing unit(CPU), output modules or points, and a programming device. The type of input modules orpoints used by a PLC depend upon the types of input devices used. Some input modulesor points respond to digital inputs, also called discrete inputs, which are either on or off.

    Other modules or inputs respond to analog signals. These analog signals representmachine or process conditions as a range of voltage or current values. The primaryfunction of a PLC's input circuitry is to convert the signals provided by these variousswitches and sensors into logic signals that can be used by the CPU.

    Basic PLC Operation

    The CPU evaluates the status of inputs, outputs, and other variables as it executes a storedprogram. The CPU then sends signals to update the status of outputs.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    5/115

    Output modules convert control signals from theCPU into digital or analog values that can be used

    to control various output devices.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    6/115

    The programming device is used to enter or changethe PLC's program or to monitor or change storedvalues. Once entered, the program and associated

    variables are stored in the CPU.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    7/115

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    8/115

    Prior to PLCs, control tasks were often performed by contactors, control relays,and other electromechanical devices with intricate interconnecting wires. Thisapproach is often referred to as hard-wired control.

    Although hard-wired control solutions are capable of performing many of the sametasks as software-based solutions, they are generally more difficult to design,install, and maintain. In addition, the process of making even simple modificationsto a hard-wired control solution can be difficult because the logic of the controlsystem is determined by the interconnection of control wires and components.

    Hard-Wired Control

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    9/115

    PLCs not only are capable of performing the same tasks as hard-wired control,but are also capable of many more complex applications. In addition, the PLCprogram and electronic communication lines replace much of the interconnecting

    wires required by hard-wired control. Therefore, hard-wiring, though still requiredto connect field devices, is less intensive. This also makes correcting errors andmodifying the application easier.

    Some of the additional advantagesof PLCs are as follows:

    Smaller physical size than hard-wire solutions.Easier and faster to makechanges.

    PLCs have integrated diagnosticsand override functions.Diagnostics are centrally available.Applications can be quicklydocumented.Applications can be duplicated

    faster and less expensively.

    Advantages of PLCs

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    10/115

    Siemens SIMATIC PLCs are the foundation upon which our TotallyIntegrated Automation (TIA) concept is based. Because the needs ofend users and machine builders vary widely, SIMATIC PLCs areavailable as conventional modular controllers, embedded automationproducts, or as PC-based controllers.

    Siemens Modular PLCs

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    11/115

    Modular SIMATIC controllers are optimized for control tasks and canbe adapted to meet application requirements using plug-in modules forinput/output (I/O), special functions, and communications. LOGO!, S7-

    200, and S7-1200 micro automation products; S7-300 and S7-400modular system PLCs; C7 combination controller and panel; and ET200 distributed I/O system with local intelligence.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    12/115

    Because a PLC is a computer, it stores information in the form of on or off conditions(1 or 0), referred to as bits. Sometimes bits are used individually and sometimesthey are used to represent numerical values. Understanding how these bits can be

    used to represent numerical values requires an understanding of the binary numbersystem.

    The binary system has a base of 2 and uses only two characters, 1 and 0. Each bitis associated with a power of 2 based on its position in the number. The further tothe left, the higher the power of 2. The number in the far left-hand column is referredto as the most significant bit or MSB and the number in the far right-hand column isreferred to as the least significant bit or LSB. A 1 is placed in a position if that powerof 2 is used in the number. Otherwise, a 0 is placed in a position.

    Binary Number System

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    13/115

    While PLCs are capable of sensing and generating analogvalues, internally, programmable controllers use signals that are

    on or off. These on and off conditions correspond to the binaryvalues 1 and 0. For example, a binary 0, also called logic 0, canbe used to indicate that a switch is off, and a binary 1 (logic 1)can be used to indicate that a switch is on.

    Logic 0 and 1

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    14/115

    Developing an understanding of PLCs requires learning some basicterminology commonly used to describe these devices and related

    components. This slide and the remaining slides in this lessonprovide summary descriptions of commonly used PLC terms.

    Sensors and Actuators

    Sensors are devices that convert a physical condition into anelectrical signal for use by the PLC. Sensors are connected to theinput of a PLC. A pushbutton is one example of a sensor. Anelectrical signal is sent from the pushbutton to the PLC indicating

    the condition (open/closed) of the pushbutton contacts.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    15/115

    Actuators are devices that convert an electrical signalfrom the PLC into a physical condition. Actuators are

    connected to PLC outputs. A motor starter is oneexample of an actuator. Depending on the PLC outputsignal, the motor starter either provides current to themotor or prevents current from flowing to the motor.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    16/115

    A discrete input, also referred to as a digital input, is either on oroff. Pushbuttons, toggle switches, limit switches, proximity

    switches, and relay contacts are examples of devices which canbe connected to a PLC's discrete inputs. In the on condition, adiscrete input is represented internal to the PLC as a logic 1. Inthe off condition, a discrete input is represented as a logic 0.

    Discrete Inputs and Outputs

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    17/115

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    18/115

    An analog input is a continuous, variable signal. Typical analog inputsvary from 0 to 20 milliamps, 4 to 20 milliamps, or 0 to 10 volts. In the

    example shown here, a level transmitter monitors the level of liquid ina storage tank.

    Analog Inputs and Outputs

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    19/115

    A discrete output is anoutput that is either on oroff. Solenoids, contactorcoils, and lamps are

    examples of devices whichcan be connected todiscrete outputs. Discreteoutputs are also referred toas digital outputs.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    20/115

    An analog output is also a signal that varies continually within a range,such as 0 to 20 milliamps, 4 to 20 milliamps, or 0 to 10 volts. Forexample, the output may be as simple as a 0-10 VDC signal thatdrives an analog panel meter.

    In this example, the panel meter displays the level of fluid in the tank.Two other analog outputs, not shown here, are connected to current-to-pneumatic transducers that control air-operated flow-control valves.This allows the PLC to automatically control the flow of liquid into andout of the storage tank.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    21/115

    The central processor unit (CPU) is a microprocessor-based systemthat contains the system memory and is the PLC's decision-making

    unit.The CPU monitors the inputs, outputs, and other variables and makesdecisions based on instructions held in the program memory.

    Central Processing Unit (CPU)

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    22/115

    A program consists of instructions that accomplish specific tasks. Thedegree of complexity of the PLCs program depends upon the complexityof the application, the number and type of input and output devices, and

    the types of instructions used.

    Ladder logic (LAD) is one programming language used with PLCs.Ladder logic incorporates programming functions that are graphicallydisplayed to resemble symbols used in hard-wired control diagrams.

    Ladder Logic Programming

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    23/115

    The left vertical line of a ladder logic diagram represents the power orenergized conductor. The output coil instruction represents the neutral or

    return path of the circuit. The right vertical line, which represents the returnpath on a hard-wired control line diagram, is omitted. Ladder logicdiagrams are read from left-to-right and top-to-bottom. Rungs aresometimes referred to as networks. A network may have several controlelements, but only one output coil.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    24/115

    While ladder logic programs are still common, there are many other

    ways to program PLCs. Two other common examples are StatementList and Function Block Diagrams.

    Statement List (STL) provides another view of a set of instructions.The operation, what is to be done, is shown on the left. Theoperand, the item to be operated on by the operation, is shown on

    the right.

    Statement List and Function

    Block Diagrams

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    25/115

    Function Block Diagrams (FBD) provide another view of a set ofinstructions. Each function has a name to designate its specifictask. Functions are indicated by a rectangle. Inputs are shownon the left side of the rectangle, and outputs are shown on theright side.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    26/115

    The PLC program is executedas part of a repetitive process

    referred to as a scan.

    A typical PLC scan starts withthe CPU reading the status ofinputs. Then, the applicationprogram is executed.

    Once the program executionis completed, the CPUperforms internal diagnosticand communication tasks.Next, the status of all outputsis updated. This process isrepeated continuously as longas the PLC is in the run mode.

    The time required for ascan depends on thecapabilities of the CPU,size of the program, the

    number of I/Os, and theamount of communicationrequired.

    PLC Scan

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    27/115

    Software is the name given to computer instructions

    regardless of the programming language. Essentially,software includes the instructions or programs thatdirect hardware.

    Software, Hardware, and

    Firmware

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    28/115

    Hardware is the name given to all the physicalcomponents of a system. The PLC, the

    programming device, and the connectingcable are examples of hardware.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    29/115

    PLCs store programs and data in integrated

    circuits, often called chips. Different types ofchips are used for the various types of PLCmemory.

    Memory Types and Size

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    30/115

    Random Access Memory(RAM) is memory from whichdata can be directly

    accessed at any address.Data can be written to andread from RAM. RAM is usedas a temporary storage areaof data that may need to bequickly changed. RAM isvolatile, meaning that thedata stored in RAM will belost if power is lost. A batterybackup is required to avoidlosing data in the event of apower loss.

    Read Only Memory (ROM)stores programs and datacannot be changed after the

    memory chip has beenmanufactured. ROM isnormally used to store theprograms and data that definethe capabilities of the PLC.ROM memory is non-volatile,meaning that its contents willnot be lost if power is lost.

    Erasable Programmable Read Only Memory (EPROM) provides some level of security againstunauthorized or unwanted changes in a program. EPROMs are designed so that data stored inthem can be read, but not easily altered without special equipment. For example, UV EPROMs(ultraviolet erasable programmable read only memory) can only be erased with an ultraviolet light.EEPROM (electronically erasable programmable read only memory), can only be erasedelectronically.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    31/115

    Putting It All Together

    The user memory of an S7-200 PLC includes space for the user program as well asaddressable memory locations for storage of data. The amount of program and data spaceavailable depends on the CPU model.

    User program space stores instructions that are executed repetitively as part of the PLC scan.The user program is developed using a programming device, such as a personal computer (PC)with programming software, then loaded into the user program memory of the PLC.

    A variety of addressable memory locations are used for storage of data that is available to theuser program. Among other things, this includes memory locations associated variable data,

    discrete inputs and outputs, analog inputs and outputs, timers, counters, high-speed counters.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    32/115

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    33/115

    Throughout this coursewe will be using the S7-200 PLC for specific

    examples of PLCconcepts. The S7-200PLC is used for thispurpose because of itsease of use and wide-

    spread application.

    Basic Requirements

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    34/115

    The items shown in the accompanying illustration areneeded to create or change a S7-200 PLC program.The program is created using STEP 7-Micro/WINprogramming software, which runs on a Windows-based personal computer (Win2000, Windows XP, andhigher operating system).

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    35/115

    A special cable is needed when a

    personal computer is used as aprogramming device. Two versions ofthis cable are available. One version,called an RS-232/PPI Multi-MasterCable, connects a personalcomputer's RS-232 interface to thePLC's RS-485 connector. The otherversion, called a USB/PPI Multi-MasterCable, connects a personalcomputer's USB interface to the PLC'sRS-485 connector.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    36/115

    The S7-200 Micro PLC is the smallest member of the SIMATIC S7 family ofprogrammable controllers.

    Each S7-200 central processing unit (CPU) model also includes input and outputpoints in the same housing as the CPU.

    Inputs and outputs (I/O) are the system control points. Inputs monitor field devices,such as switches and analog sensors. Outputs control other devices, such asmotors and control valves.

    The programming port is the connection to the programming device and also

    provides a means for connecting the PLC to other devices such as display panels.

    S7-200 CPU Models

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    37/115

    There are six S7-200 CPU types: CPU 221, CPU 222, CPU 224, CPU224XP, CPU 224XPsi, and CPU 226, and two power supply configurationsfor each type.

    In the model description, the first term following the CPU type indicates thepower supply type, the second term indicates the input type, and the thirdterm indicates the output type. For example, a 222 AC/DC/Relay model ispowered from an AC source, has DC input points, and relay contact output

    points.

    S7 200 PLC F t

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    38/115

    The S7-200 family includes a range of CPUs which provide a variety offeatures to aid in designing a cost-effective automation solution. The

    accompanying table provides a summary of the major features, many of whichare covered in this course. Note that the CPU 224XPsi has 10 current sinkingdigital outputs, but its other features are the same as for the CPU 224XP.

    S7-200 PLC Features

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    39/115

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    40/115

    M d S it h d A l Adj t t

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    41/115

    Each S7-200 CPU has a mode switch with three positions, RUN, STOP, and TERM.When the mode switch is in the RUN position, the CPU is in the RUN mode andexecuting the program, unless a fault has occurred. When the mode switch is in the

    STOP position, the CPU is in the STOP mode and not executing the user program.When the mode switch is in the TERM position, the programming device can selectthe operating mode.

    An analog adjustment is available to increase or decrease values stored in specialmemory. This can allow a variable in the user program to change as the analogadjustment is changed. CPU 221 and CPU 222 models have one analogadjustment. CPU 224, CPU 224XP, CPU 224 XPsi, and CPU 226 have two analog

    adjustments.

    Mode Switch and Analog Adjustment

    O ti l C t id

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    42/115

    S7-200 CPUs support an optional memory cartridge that providesportable EEPROM storage for the user program. The cartridge can be

    used to copy a program from one S7-200 PLC to a like S7-200 PLC.Two memory cartridge sizes are available, 64k and 256k bytes.

    Two other cartridges are alsoavailable. A real-time clock with

    battery is available for use onthe CPU 221 and CPU 222.(CPU 224, CPU 224XP, CPU224XPsi, and CPU 226 have areal-time clock built in.) Thebattery provides up to 200 daysof data retention time in theevent of a power loss. Anothercartridge is available with aback-up battery only.

    Optional Cartridges

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    43/115

    S7-200 PLCs are expandable. Expansion modules

    contain additional inputs and outputs or specialfunctionality. These modules are connected to thebase unit using a ribbon connector.

    Expansion Modules

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    44/115

    The ribbon connector is protected by a coveron the base unit. Side-by-side mountingcompletely encloses and protects the ribbonconnector.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    45/115

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    46/115

    CPU 221 comes with 6 discrete inputs and 4 discrete outputs and does not acceptexpansion modules.

    CPU 222 comes with 8 discrete inputs and 6 discrete outputs and accepts up to 2expansion modules.

    CPU 224, CPU 224XP, and CPU 224XPsi come with 14 discrete inputs and 10 discreteoutputs and accept up to 7 expansion modules. Note: The digital outputs for the CPU224XPsi are current sinking.

    Most S7-200 expansion modules are designed to provide additional I/O. However, severalexpansion modules are available to support communication options, positioning, andweighing (SIWAREX MS).

    Available Expansion

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    47/115

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    48/115

    S7-200 PLCs can be mounted in one of two ways. A DIN clip

    allows installation on a standard DIN rail. The DIN clip snapsopen to allow installation and snaps closed to secure the uniton the rail. The S7-200 can also be panel mounted usinginstallation holes located behind the access covers.

    Mounting

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    49/115

    P S

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    50/115

    Depending on the CPU model, An S7-200 CPU is poweredfrom either a 24 VDC or a 120 to 240 VAC power supply. For

    example, an CPU 221 DC/DC/DC model is power from a 24VDC power supply and a CPU 222 AC/DC/Relay model ispowered from a 120 or 240 VAC power supply.

    Power Sources

    I/O Numbering

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    51/115

    S7-200 inputs and outputs are labeled at the wiring terminations and next to the statusindicators. These alphanumeric symbols identify the I/O address to which a device isconnected. This address is used by the CPU to determine which input is present andwhich output needs to be turned on or off.

    I designates a discrete input and Q designates a discrete output. The first numberidentifies the byte, the second number identifies the bit.

    Image register space for digital I/O is always reserved in increments of eight bits (onebyte). If a module does not provide a physical point for each bit of each reserved byte,

    these unused bits cannot be assigned to subsequent modules in the I/O chain.

    I/O Numbering

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    52/115

    Input devices, such asswitches, pushbuttons, andother sensors areconnected to the terminalstrip under the bottomcover of the PLC.

    Inputs and Outputs

    A i t th d f t ti i t i t l

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    53/115

    A convenient method of testing a program is to wire toggleswitches to the inputs. Input simulators with pre-wired toggleswitches are available for use with S7-200 PLCs. Switches arewired between the 24 VDC power supply (L+) and the inputs. For

    example, the switch on the far left is wired between the first input(0.0) and L+. When the switch is closed, 24 VDC is applied to theinput. When the switch is open, 0 VDC is applied to the input.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    54/115

    Output devices, such asrelays, are connected to theterminal strip under the topcover of the PLC. When

    testing a program, it is notnecessary to connect outputdevices. The LED statusindicators signal if an outputis active.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    55/115

    CPU 224, CPU 224XP, CPU 224XPsi, andCPU 226 do not have an optional fan-outconnector. Instead, their terminal strips areremovable.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    56/115

    A super capacitor, so named because of its ability to

    maintain a charge for a long period of time, protects datastored in RAM in the event of a power loss.

    The RAM memory is typically backed up on the CPU 221and CPU 222 for 50 hours and on the CPU 224, CPU224 XP, CPU 224 XPsi, and CPU 226 for 100 hours.

    Super Capacitor

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    57/115

    An optional fan-out connectorallows field wiring connections toremain fixed when removing orreplacing a CPU 221 orCPU 222. The appropriateconnector slides into either theinput, output, or expansionmodule terminals.

    Optional Connector and Terminal

    Strip

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    58/115

    The SIMATIC S7-200Programmable ControllerSystem Manual providescomplete information oninstalling and programming the

    S7-200 PLCs. This manual canbe downloaded as a PDF filefrom a link on the Siemens S7-S00 web site:

    http://www.automation.siemens.

    com/_en/s7-200/index.htm

    Reference Manual

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    59/115

    The S7-200 programming port can be used to communicatewith a variety of external devices. One such device is the

    TD200 text display unit. The TD200 displays messages readfrom the S7-200. It allows for adjustment of program variables,provides forcing ability, and permits setting of time and date. Itcan be connected to an external power supply or receivepower from the S7-200.

    TD200

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    60/115

    The programming port has a mode called freeport

    mode, which allows various intelligent sensingdevices, such a s bar code readers, to be connected.

    TD200

    Freeport Mode

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    61/115

    Freeport mode can also be used to connect a printer.

    Printer

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    62/115

    It is possible to use one programming device toaddress multiple S7-200 device on the communicationcable. A total of 31 units can be interconnected withouta repeater.

    Interconnection

    STEP 7-Micro/WIN

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    63/115

    STEP 7-Micro/WIN has three editors for use in development of programs, onefor each of the types of programming available, ladder logic (LAD), statement

    list (STL), and function block diagram (FBD). The STL editor is often preferredby experienced programmers because of the similarity of STL programs toassembly language computer programs. However, the STL editor can only beused with the SIMATIC instruction set. Both the LAD and FBD editors can beused with the either instruction set. Throughout this course, although otherinstruction types will occasionally be shown, the emphasis will be on SIMATIC

    LAD instructions.

    STEP 7-Micro/WIN is the software used with the S7-200 PLC to create a userprogram. STEP 7-Micro/WIN programs consist of a number of instructions thatmust be arranged in a logical order to obtain the desired PLC operation.

    STEP 7-Micro/WIN

    Basic Ladder Logic Symbols

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    64/115

    PLC ladder logic consists of a commonly used set of symbols that representinstructions. Understanding the basic symbols is essential to understandingPLC operation.

    One of the most confusing aspects of PLC programming for first-time users isthe relationship between the device that controls a status bit and theprogramming function that uses a status bit. Two of the most commonprogramming functions are the normally open (NO) contact and the normally

    closed (NC) contact. Symbolically, power flows through these contacts whenthey are closed. The normally open contact (NO) is closed when the input oroutput status bit controlling the contact is 1. The normally closed contact (NC)is closed when the input or output status bit controlling the contact is 0.

    Basic Ladder Logic Symbols

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    65/115

    E t i C t l El t

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    66/115

    Entering Control Elements

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    67/115

    AND Operation

    AND Operation

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    68/115

    Each rung or network on a ladderrepresents one or more logicaloperations. The accompanying

    programming examples are for an ANDoperation.

    In the ladder diagram example, twonormally open contacts are placed inseries controlling one output coil. If both

    contacts are closed, output coil Q0.0turns on and the status bit for thatoutput is a logic1.

    Note that in the statement list a newlogic operation always begins with a

    load instruction (LD). In this example,I0.1 AND I0.5 must both be a logic 1 inorder for output Q0.0 to be a logic 1.The AND function is represented by A inthe statement list. The same rules applyto the function block diagram example.

    p

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    69/115

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    70/115

    Another way to see how an AND function works is with a truth

    table. In this case, there are two inputs (I0.1 and I0.5) and oneoutput (Q0.0). The truth table shows the output condition (logic0 or logic 1) for each combination of input conditions.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    71/115

    OR Operation

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    72/115

    The accompanying programming examples are for anOR operation. In the ladder diagram example, two

    normally open contacts are in parallel. If either contactcloses or if both contacts are closed, the output coilturns on and the status bit for output Q0.0 becomes a 1.

    OR Operation

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    73/115

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    74/115

    The same logic is duplicated in the statement list andfunction block diagram examples. If either I0.1 OR I0.5 orboth are a logic 1, output Q0.0 will be a logic 1. This logic is

    also represented in the associated truth table.

    Testing a Program

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    75/115

    Once a program has been written it needs to be tested anddebugged. One way this can be done is to simulate the inputs

    from field devices with an input simulator, such as the one madefor the S7-200.

    Testing a Program

    The program is first downloaded from the programming device tothe CPU. Then, the mode switch is placed in the RUN position.Next, the simulator switches are operated while observing theoutput status indicator lamps for the desired conditions.

    Contact and Coil Status

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    76/115

    After a program has been loaded and is running in the PLC, the actual status ofladder elements can be monitored using STEP 7 Micro/WIN software.

    Contact and Coil Status

    For example, in the accompanyingillustration, the toggle switch controlsthe status bit for I2.1. As long as thetoggle switch is open, the I2.1 status

    bit is a logic 0. The I2.1 status bitcontrols the I2.1 normally opencontact. Because the I2.1 status bit isa logic 0, the normally open contactfunction is open and no power ispassed to the Q3.1 coil function. As aresult, the Q3.1 status bit remains alogic 0 and output point Q3.1 is off.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    77/115

    When the toggle switch closes, input point I2.1 turns on andI2.1 status bit changes to a logic 1. This causes normallyopen contact I2.1 to close and turn on Q3.1 coil. Note that aclosed contact and a coil that is on are shown highlighted in

    the program. When Q3.1 coil turns on, the Q3.1 status bitgoes to a logic 1 and output point Q3.1 turns on. This causesthe lamp to light.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    78/115

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    79/115

    The accompanying illustration shows the appearance of ladder

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    80/115

    The accompanying illustration shows the appearance of ladderdiagram elements with associated status bits in the on, off,forced on, and forced off conditions.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    81/115

    Sequence

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    82/115

    For the simple lamp circuit, the following is the sequence ofevents. Using its program, the CPU scans the inputs.When it finds the switch open, I0.1 receives a binary 0.This instructs Q0.0 to send a binary 0 to the output module.The lamp remains off. When the switch is closed, I0.0receives a binary 1, which instructs Q0.0 to send a binary 1to the output module. This turns the lamp on.

    q

    PLC Motor Control

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    83/115

    Initially, I0.1 status bit is a logic 1 because the normally closed (NC) StopPushbutton is closed. I0.2 status bit is a logic 1 because the normally closed(NC) overload relay (OL) contacts are closed. I0.0 status bit is a logic 0,however, because the normally open Start pushbutton has not been pressed.

    Normally open output Q0.0 is also programmed on Network 1 as a sealingcontact. With this simple network, energizing output coil Q0.0 is required toturn on the motor.

    PLC Motor Control

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    84/115

    This motor control application can also be accomplished with a PLC.In the accompanying example, a normally open Start pushbutton iswired to the first input (I0.0), a normally closed Stop pushbutton is

    wired to the second input (I0.1), and normally closed overload relaycontacts (part of the motor starter) are connected to the third input(I0.2). These inputs are used to control normally open contacts in aline of ladder logic programmed into the PLC.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    85/115

    Motor Control Program

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    86/115

    When the Start pushbutton is pressed, the CPU receives a logic 1from input I0.0. This causes the I0.0 contact to close. All three

    inputs are now a logic 1. The CPU sends a logic 1 to output Q0.0.The motor starter is energized and the motor starts.

    The output status bit for Q0.0 is now a 1. On the next scan, whennormally open contact Q0.0 is solved, the contact will close andoutput Q0.0 will stay on even if the Start pushbutton is released.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    87/115

    Adding Run and Stop Indicators

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    88/115

    The application can be easily expanded to include indicator lights forrun and stop conditions. In this example, a RUN indicator light is

    connected to output Q0.1 and a STOP indicator light is connected tooutput Q0.2.

    Adding Run and Stop Indicators

    The ladder logic for this application includes normally open Q0.0contact connected on Network 2 to output coil Q0 1 and normally

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    89/115

    contact connected on Network 2 to output coil Q0.1 and normallyclosed Q0.0 contact connected on Network 3 to output coil Q0.2.When Q0.0 is off, the normally open Q0.0 contact on Network 2 isopen and the RUN indicator off. At the same time, the normallyclosed Q0.0 contact is closed and the STOP indicator is on.

    When the Start button is pressed, the PLC starts the motor. OutputQ0.0 is now on. Normally open Q0.0 contact on Network 2 is nowclosed and the RUN indicator is on. At the same time, the normallyclosed Q0.0 contact on Network 3 is open and the STOP indicatorlight connected to output Q0.2 is off.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    90/115

    The application can be furtherexpanded by adding a limitswitch. The limit switch couldbe used in this application fora variety of functions. Forexample, the limit switch couldbe used to stop the motor orprevent the motor from beingstarted.

    Adding a Limit Switch

    In this example, the limit switch is associated with an access

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    91/115

    door to the motor or its associated equipment. The limit switch isconnected to input I0.3 and controls a normally open contact inthe program. If the access door is open, limit switch LS1 is open

    and normally open contact I0.3 is also open. This prevents themotor from starting.

    When the access door is closed, limit switch LS1 is closed andnormally open contact I0.3 is also closed. This allows the motorto start when the Start pushbutton is pressed.

    Further Expansion

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    92/115

    The PLC program can be furtherexpanded to accommodate a widevariety of commercial and industrial

    applications.

    Start/Stop pushbuttons, selectorswitches, indicator lights, and signalingcolumns can be added. Motor starterscan be added for control of additional

    motors. Over-travel limit switches canbe added along with proximity switchesfor sensing object position. Varioustypes of relays can be added to expandthe variety of devices being controlled.

    As needed, expansion modules can beadded to further increase the I/Ocapability. The applications are onlylimited by the number of I/Os andamount of memory available on thePLC.

    Analog Inputs and Outputs

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    93/115

    Many PLCs also work with analog I/O devices. Analog devices use signals that arecontinuously variable within a specified range such as 0 to 10 VDC or 4 to 20 mA.

    Analog signals are used to represent variable values such as speed, rate of flow,

    temperature, weight, level, etc. In order to process an input of this type, a PLC mustconvert the analog signal into a digital representation.

    S7-200 PLCs convert each analog voltage orcurrent value into a 12-bit digital value. Digitalvalues from analog inputs are stored in

    addressable memory for use by the userprogram. Similarly, the user program can placedigital values in addressable memory locationsfor conversion to analog values for thedesignated analog outputs.

    The only S7-200 CPU model with analog I/O

    points on board is CPU 224XP, which has 2analog inputs and 1 analog output. However,analog I/O points can be added using expansionmodules for any CPU other than CPU 221. CPU222 allows for 2 expansion modules and theremaining CPUs allow for 7 expansion modules.

    Analog Input Example

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    94/115

    Analog inputs can be used for a variety of purposes. In thisexample, a scale is connected to a load cell. A load cell is adevice that generates an electrical output proportional to theforce applied.

    The load cell in this example converts a value of weight from 0to 50 pounds into a 0 - 10 VDC analog value. The 0 - 10 VDCload cell signal is connected to an S7-200 PLC's analog input.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    95/115

    The analog value applied to the PLC can be used in various ways. Forinstance, the actual weight can be compared to a desired weight for apackage. Then, as the package is moved on a conveyor, the S7-200 PLC

    can control a gate to direct packages of varying weight.

    A package that weighs at or greater than a specified value is routed alongone conveyor path to finished goods inventory. A package that weighs lessthan a specified value is routed along another conveyor path to an inspectionstation, where it will be checked for missing contents.

    Analog Output Example

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    96/115

    Analog outputs from a PLC are often supplied directly or through signalconverters or transmitters to control valves, instruments, electronicdrives or other control devices which respond to analog signals.

    g p p

    For example, analog outputs from the PLC could be used to control theflow of fluid in a process by controlling AC drives. Rather than simplyturning the AC drives on or off, which could be accomplished by discreteoutputs, analog signals can be used to control the output of the ACdrives. This would allow the speed of the pumps to be varieddynamically in response to changes in process requirements.

    Hard-wired Timing Circuit

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    97/115

    In a PLC, timers are programming functions that keeptrack of time and allow PLC programs to provide varied

    responses depending on the elapsed time.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    98/115

    Timers in a PLC program can be compared tohard-wired timing circuits, such as the one

    represented in the accompanying control linediagram. In this example, normally open (NO)switch (S1) is used with timer (TR1).

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    99/115

    When S1 closes, TR1 begins timing. When thetimer's preset time elapses, TR1 closes its

    associated normally open TR1 contact andpilot light PL1 turns on. When S1 opens, TR1de-energizes immediately, the TR1 contactopens, and PL1 turns off.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    100/115

    This type of timer is referred to as an on-delaytimer. The term "on-delay" indicates that thetiming begins when the timer receives a signal toturn on. In this example, that happens when S1closes.

    S7-200 SIMATIC Timers

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    101/115

    The S7-200 SIMATIC LAD instruction set includes three types of timers:On-Delay Timer (TON), Retentive On-Delay Timer (TONR), and Off-

    Delay Timer (TOF).

    Timers are represented in an S7-PLC ladder logic program by boxes.

    S7 200 SIMATIC Timers

    S7-200 timers have a resolution of 1 millisecond, 10 milliseconds, or 100milliseconds. This resolution appears in the lower right corner of thetimer box. As shown in the accompanying illustration, the resolution andtype of timer that can be used depends on the timer number. Themaximum value of time shown is for a single timer. By adding programelements, greater time intervals can be timed.

    SIMATIC On-Delay Timer (TON)

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    102/115

    The previous example illustrated how a hardware on-delay timer works.The corresponding software function in the S7-200 SIMATIC LADinstruction set is the On-Delay Timer (TON).

    After the On-Delay Timer (TON) receives an enable (logic 1) at its input(IN), a predetermined amount of time (preset time - PT) passes beforethe timer bit (T-bit) turns on. The T-bit is a logic function internal to thetimer and is not shown on the symbol. The timer resets the accumulatedtime to zero when the enabling input goes to a logic 0.

    In the accompanying timer example, when input I0.3 turns on, the I0.3

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    103/115

    contact closes, and timer T37 begins timing. T37 has a time base of 100ms (0.1 seconds). The preset time (PT) value has been set to 150.Because the resolution of the timer is set to 100 ms, a preset value of

    150 is equal to 15 seconds (150 x 100 ms). Therefore, 15 seconds afterthe I0.3 contact closes, timer bit T37 becomes a logic 1, the T37 contactcloses, and output coil Q0.1 and its associated output point turn on.

    If the switch opens before 15 seconds has elapsed, the accumulatedtime resets to 0. Because this type of timer does not retain itsaccumulated time when its input (IN) goes to logic 0, it is said to be non-retentive.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    104/115

    Th i l h

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    105/115

    The accompanying example shows aRetentive On-Delay timer (TONR) with aresolution of 100 ms and preset value of

    150 (15 seconds). When input I0.3 turnson, I0.3 contact closes, and timer T5begins timing. If, for example, after 10seconds input I0.3 turns off, the timerstops. When input I0.3 turns on again,the timer begins timing at 10 seconds.

    Timer bit T5 turns on 5 seconds afterinput I0.3 closes for the second time.When timer bit T5 turns on, contact T5closes, and output Q0.1 turns on.

    The Reset (R) function, shown in network 1, is necessary to reset the accumulatedtime of the Retentive On-delay Timer (TONR) to zero. In this example, the Reset (R)function turns on and resets the timer when contact I0.2 closes. This causes the T5contact to open and output Q0.1 to turn off.

    SIMATIC Off-Delay Timer (TOF)

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    106/115

    The SIMATIC Off-Delay Timer (TOF) begins timing when input (IN) turns off. Inthe accompanying example, when contact I1.4 closes, the current value oftimer T33 is set to 0, timer bit T33 turns on immediately, closing the T33

    contact, and turning on output Q2.3.

    When contact I1.4 opens, the timer times until the preset time elapses, 200 ms

    in this example. Then, timer bit T33 turns off, contact T33 opens, and outputQ2.3 turns off.

    If the I1.4 contact had closed again before the 200 ms preset time had elapsed,the timer's current value would again be set to 0, timer bit T33 would remain on,contact T33 would remain closed, and output Q2.3 would remain on.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    107/115

    Timer Example

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    108/115

    In this example a tank is filled with twochemicals, which are then mixed together

    and drained. When the Start button at inputI0.0 is pressed, the program starts Pump 1,controlled by Q0.0. After 5 seconds, theproper amount of Chemical 1 has beenpumped, and the pump shuts off. Pump 2then runs for 3 seconds adding Chemical 2 to

    the tank. The program then starts the mixermotor, using output Q0.2, and mixes thechemicals for 60 seconds. Then the drainvalve is opened, and Pump 3, controlled byoutput Q0.4, is turned on for 8 seconds,emptying the tank.

    A manual Stop switch is provided at inputI0.1.

    Timer Example

    S7-200 SIMATIC Counters

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    109/115

    Just like mechanical counters, PLC counter instructions keeptrack of events. As it counts, a counter instruction compares an

    accumulated count value to a preset value to determine whenthe desired count has been reached. Counters can be used toinitial an operation when a count is reached or to prevent anoperation from occurring until a count has been reached.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    110/115

    The S7-200 SIMATIC LAD instruction set includesthree types of counters: Count Up Counter (CTU),Count Down Counters (CTD), and Count Up/DownCounter (CTUD).

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    111/115

    The Count Up Counter (CTU)counts up by one each time the

    count up (CU) input transitionsfrom off to on. When theaccumulated count equals thepreset value (PV) the counter bit(not shown) turns on. The

    counter continues to count untilthe accumulated count equalsthe maximum value (32767).When the reset input (R) turnson or when a Reset instruction is

    executed, the accumulatedcount resets to zero and thecounter bit turns off.

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    112/115

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    113/115

    Count Up/Down Counter (CTUD)

    Example

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    114/115

    Counters are common instructions used for counting a

    wide variety of events such as parts manufactured orpacked, items processed, machine operations, etc.For example, a counter might be used to keep track ofthe items in an inventory storage area.

    Example

    In the accompanying illustration, Count

  • 8/6/2019 PLC Basics (Adapted From Siemens S7200 Training Manual)

    115/115

    p y gUp/down Counter (CTUD) C48 is reset tozero when contact I0.2 closes. This couldbe event could be triggered automatically

    or manually to indicate that the associatedstorage location is empty.When contact I0.0 closes, the countercounts up by 1. This could be triggered bya proximity switch sensing that an item hasbeen placed in the storage location.When contact I0.1 closes, the countercounts down by 1. This could be triggeredby a proximity switch sensing that an itemhas been removed the storage location.In this example, the storage location has150 spaces. When the accumulated countreaches 150, the counter bit turns on,

    contact C48 closes, and output Q0.1 turnson. This could trigger other logic in theprogram to divert new items to anotherlocation until such time as an item is