Transcription

STEP 2000Basics of PLCs

Table of ContentsIntroduction .2PLCs .4Number Systems.8Terminology . 14Basic Requirements.23S7-200 Micro PLCs.28Connecting External Devices.39Programming A PLC .41Discrete Inputs/Outputs .49Analog Inputs and Outputs.61Timers.64Counters . 71High-Speed Instructions .75Specialized Expansion Modules .78Review Answers.84Final Exam .851

IntroductionWelcome to another course in the STEP 2000 series, SiemensTechnical Education Program, designed to prepare ourdistributors to sell Siemens Energy & Automation productsmore effectively. This course covers Basics of PLCs and relatedproducts.Upon completion of Basics of PLCs you should be able to:2 Identify the major components of a PLC and describetheir functions Convert numbers from decimal to binary, BCD, andhexadecimal Identify typical discrete and analog inputs and outputs Read a basic ladder logic diagram and statement list Identify operational differences between different S7-200models Identify the proper manual to refer to for programming orinstallation of an S7-200 PLC Connect a simple discrete input and output to an S7-200 Select the proper expansion module for analog inputs andoutputs Describe the operation of timers and counters

This knowledge will help you better understand customerapplications. In addition, you will be better able to describeproducts to customers and determine important differencesbetween products. You should complete Basics of Electricitybefore attempting Basics of PLCs. An understanding of manyof the concepts covered in Basics of Electricity is requiredfor Basics of PLCs. In addition you may wish to completeBasics of Control Components. Devices covered in Basicsof Control Components are used with programmable logiccontrollers.If you are an employee of a Siemens Energy & Automationauthorized distributor, fill out the final exam tear-out card andmail in the card. We will mail you a certificate of completion ifyou score a passing grade. Good luck with your efforts.SIMATIC, STEP 7, STEP 7-Micro, STEP 7-Micro/WIN, PG 702,and PG 740 are registered trademarks of Siemens Energy &Automation, Inc.Other trademarks are the property of their respective owners.3

PLCsProgrammable Logic Controllers (PLCs), also referred to asprogrammable controllers, are in the computer family. They areused in commercial and industrial applications. A PLC monitorsinputs, makes decisions based on its program, and controlsoutputs to automate a process or machine. This course is meantto supply you with basic information on the functions andconfigurations of PLCs.4

Basic PLC OperationPLCs consist of input modules or points, a Central ProcessingUnit (CPU), and output modules or points. An input accepts avariety of digital or analog signals from various field devices(sensors) and converts them into a logic signal that can be usedby the CPU. The CPU makes decisions and executes controlinstructions based on program instructions in memory. Outputmodules convert control instructions from the CPU into a digitalor analog signal that can be used to control various field devices(actuators). A programming device is used to input the desiredinstructions. These instructions determine what the PLC will dofor a specific input. An operator interface device allows processinformation to be displayed and new control parameters to beentered.Pushbuttons (sensors), in this simple example, connected toPLC inputs, can be used to start and stop a motor connected toa PLC through a motor starter (actuator).5

Hard-Wired ControlPrior to PLCs, many of these control tasks were solved withcontactor or relay controls. This is often referred to as hardwired control. Circuit diagrams had to be designed, electricalcomponents specified and installed, and wiring lists created.Electricians would then wire the components necessary toperform a specific task. If an error was made the wires hadto be reconnected correctly. A change in function or systemexpansion required extensive component changes and rewiring.MOL T1MOL T2MOL T3L1460 VAC L2L3MotorOLM1CR24 VACStopStartCR2CRAdvantages of PLCsThe same, as well as more complex tasks, can be done witha PLC. Wiring between devices and relay contacts is done inthe PLC program. Hard-wiring, though still required to connectfield devices, is less intensive. Modifying the application andcorrecting errors are easier to handle. It is easier to create andchange a program in a PLC than it is to wire and rewire a circuit.Following are just a few of the advantages of PLCs: 6Smaller physical size than hard-wire solutions.Easier and faster to make changes.PLCs have integrated diagnostics and override functions.Diagnostics are centrally available.Applications can be immediately documented.Applications can be duplicated faster and less expensively.

Siemens PLCsSiemens makes several PLC product lines in the SIMATIC S7family. They are: S7-200, S7-300, and S7-400.S7-200The S7-200 is referred to as a micro PLC because of its smallsize. The S7-200 has a brick design which means that thepower supply and I/O are on-board. The S7-200 can be used onsmaller, stand-alone applications such as elevators, car washes,or mixing machines. It can also be used on more complexindustrial applications such as bottling and packaging machines.S7-300 and S7-400The S7-300 and S7-400 PLCs are used in more complexapplications that support a greater number of I/O points. BothPLCs are modular and expandable. The power supply and I/Oconsist of separate modules connected to the CPU. Choosingeither the S7-300 or S7-400 depends on the complexity ofthe task and possible future expansion. Your Siemens salesrepresentative can provide you with additional information onany of the Siemens PLCs.7

Number SystemsSince a PLC is a computer, it stores information in the form ofOn or Off conditions (1 or 0), referred to as binary digits (bits).Sometimes binary digits are used individually and sometimesthey are used to represent numerical values.Decimal SystemVarious number systems are used by PLCs. All number systemshave the same three characteristics: digits, base, weight. Thedecimal system, which is commonly used in everyday life, hasthe following characteristics:Ten digitsBaseWeightsBinary System0, 1, 2, 3, 4, 5, 6, 7, 8, 9101, 10, 100, 1000, .The binary system is used by programmable controllers. Thebinary system has the following characteristics:Two digitsBaseWeights0, 12Powers of base 2 (1, 2, 4, 8, 16, .)In the binary system 1s and 0s are arranged into columns. Eachcolumn is weighted. The first column has a binary weight of02 . This is equivalent to a decimal 1. This is referred to as theleast significant bit. The binary weight is doubled with eachsucceeding column. The next column, for example, has a weight1of 2 , which is equivalent to a decimal 2. The decimal value isdoubled in each successive column. The number in the far lefthand column is referred to as the most significant bit. In this7example, the most significant bit has a binary weight of 2 . Thisis equivalent to a decimal 128.8

Converting Binaryto DecimalThe following steps can be used to interpret a decimalnumber from a binary value.1)2)3)Search from least to most significant bit for 1s.Write down the decimal representation of each columncontaining a 1.Add the column values.In the following example, the fourth and fifth columns from theright contain a 1. The decimal value of the fourth column fromthe right is 8, and the decimal value of the fifth column fromthe right is 16. The decimal equivalent of this binary number is24. The sum of all the weighted columns that contain a 1 is thedecimal number that the PLC has stored.In the following example the fourth and sixth columns from theright contain a 1. The decimal value of the fourth column fromthe right is 8, and the decimal value of the sixth column fromthe right is 32. The decimal equivalent of this binary number is40.Bits, Bytes, and WordsEach binary piece of data is a bit. Eight bits make up one byte.Two bytes, or 16 bits, make up one word.9

Logic 0, Logic 1Programmable controllers can only understand a signal thatis On or Off (present or not present). The binary system is asystem in which there are only two numbers, 1 and 0. Binary 1indicates that a signal is present, or the switch is On. Binary 0indicates that the signal is not present, or the switch is Off.BCDBinary-Coded Decimal (BCD) are decimal numbers whereeach digit is represented by a four-bit binary number. BCD iscommonly used with input and output devices. A thumbwheelswitch is one example of an input device that uses BCD. Thebinary numbers are broken into groups of four bits, each grouprepresenting a decimal equivalent. A four-digit thumbwheelswitch, like the one shown here, would control 16 (4 x 4) PLCinputs.10

HexadecimalHexadecimal is another system used in PLCs. The hexadecimalsystem has the following characteristics:16 digitsBaseWeights0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F16Powers of base 16 (1, 16, 256, 4096 .)The ten digits of the decimal system are used for the first tendigits of the hexadecimal system. The first six letters of thealphabet are used for the remaining six digits.A 10B 11C 12D 13E 14F 15The hexadecimal system is used in PLCs because it allows thestatus of a large number of binary bits to be represented in asmall space such as on a computer screen or programmingdevice display. Each hexadecimal digit represents the exactstatus of four binary bits. To convert a decimal number to ahexadecimal number the decimal number is divided by the baseof 16. To convert decimal 28, for example, to hexadecimal:Decimal 28 divided by 16 is 1 with a remainder of 12. Twelve isequivalent to C in hexadecimal. The hexadecimal equivalent ofdecimal 28 is 1C.The decimal value of a hexadecimal number is obtained bymultiplying the individual hexadecimal digits by the base 16weight and then adding the results. In the following examplethe hexadecimal number 2B is converted to its decimalequivalent of 43.016 1116 16B 1111

Conversion of Numbers12The following chart shows a few numeric values in decimal,binary, BCD, and hexadecimal representation.

Review 11.Identify the following:2.The binary number system has a base .3.The hexadecimal number system has a base.4.Convert a decimal 10 to the following:BinaryBCDHexadecimal13

TerminologyThe language of PLCs consists of a commonly used setof terms; many of which are unique to PLCs. In order tounderstand the ideas and concepts of PLCs, an understandingof these terms is necessary.SensorA sensor is a device that converts a physical condition into anelectrical signal for use by the PLC. Sensors are connected tothe input of a PLC. A pushbutton is one example of a sensorthat is connected to the PLC input. An electrical signal is sentfrom the pushbutton to the PLC indicating the condition (open/closed) of the pushbutton contacts.ActuatorsActuators convert an electrical signal from the PLC into aphysical condition. Actuators are connected to the PLC output.A motor starter is one example of an actuator that is connectedto the PLC output. Depending on the output PLC signal themotor starter will either start or stop the motor.14

Discrete InputA discrete input, also referred to as a digital input, is an inputthat is either in an ON or OFF condition. Pushbuttons, toggleswitches, limit switches, proximity switches, and contactclosures are examples of discrete sensors which are connectedto the PLCs discrete or digital inputs. In the ON condition adiscrete input may be referred to as a logic 1 or a logic high. Inthe OFF condition a discrete input may be referred to as a logic0 or a logic low.A Normally Open (NO) pushbutton is used in the followingexample. One side of the pushbutton is connected to the firstPLC input. The other side of the pushbutton is connected to aninternal 24 VDC power supply. Many PLCs require a separatepower supply to power the inputs. In the open state, no voltageis present at the PLC input. This is the OFF condition. When thepushbutton is depressed, 24 VDC is applied to the PLC input.This is the ON condition.15

Analog InputsAn analog input is an input signal that has a continuous signal.Typical analog inputs may vary from 0 to 20 milliamps, 4 to 20milliamps, or 0 to 10 volts. In the following example, a leveltransmitter monitors the level of liquid in a tank. Depending onthe level transmitter, the signal to the PLC can either increase ordecrease as the level increases or decreases.Discrete OutputsA discrete output is an output that is either in an ON or OFFcondition. Solenoids, contactor coils, and lamps are examplesof actuator devices connected to discrete outputs. Discreteoutputs may also be referred to as digital outputs. In thefollowing example, a lamp can be turned on or off by the PLCoutput it is connected to.16

Analog OutputsAn analog output is an output signal that has a continuoussignal. The output may be as simple as a 0-10 VDC level thatdrives an analog meter. Examples of analog meter outputs arespeed, weight, and temperature. The output signal may alsobe used on more complex applications such as a current-topneumatic transducer that controls an air-operated flow-controlvalve.CPUThe central processor unit (CPU) is a microprocessor systemthat contains the system memory and is the PLC decisionmaking unit. The CPU monitors the inputs and makes decisionsbased on instructions held in the program memory. TheCPU performs relay, counting, timing, data comparison, andsequential operations.17

ProgrammingA program consists of one or more instructions that accomplisha task. Programming a PLC is simply constructing a set ofinstructions. There are several ways to look at a program suchas ladder logic, statement lists, or function block diagrams.Ladder LogicLadder logic (LAD) is one programming language usedwith PLCs. Ladder logic uses components that resembleelements used in a line diagram format to describe hard-wiredcontrol. Refer to the STEP 2000 course Basics of ControlComponents for more information on line diagrams.STEP 2000Basics ofControlComponentsLadder Logic Diagram18The left vertical line of a ladder logic diagram represents thepower or energized conductor. The output element or instructionrepresents the neutral or return path of the circuit. The rightvertical line, which represents the return path on a hard-wiredcontrol line diagram, is omitted. Ladder logic diagrams are readfrom left-to-right, top-to-bottom. Rungs are sometimes referredto as networks. A network may have several control elements,but only one output coil.

In the example program shown example I0.0, I0.1 and Q0.0represent the first instruction combination. If inputs I0.0 andI0.1 are energized, output relay Q0.0 energizes. The inputs couldbe switches, pushbuttons, or contact closures. I0.4, I0.5, andQ1.1 represent the second instruction combination. If eitherinput I0.4 or I0.5 are energized, output relay Q0.1 energizes.Statement listA statement list (STL) provides another view of a set ofinstructions. The operation, what is to be done, is shown on theleft. The operand, the item to be operated on by the operation,is shown on the right. A comparison between the statementlist shown below, and the ladder logic shown on the previouspage, reveals a similar structure. The set of instructions in thisstatement list perform the same task as the ladder diagram.Function Block DiagramsFunction 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-hand side of the rectangle and outputs are shown onthe right-hand side. The function block diagram shown belowperforms the same function as shown by the ladder diagramand statement list.19

PLC ScanThe PLC program is executed as part of a repetitive processreferred to as a scan. A PLC scan starts with the CPU readingthe status of inputs. The application program is executed usingthe status of the inputs. Once the program is completed, theCPU performs internal diagnostics and communication tasks.The scan cycle ends by updating the outputs, then starts over.The cycle time depends on the size of the program, the numberof I/Os, and the amount of communication required.SoftwareSoftware is any information in a form that a computer or PLCcan use. Software includes the instructions or programs thatdirect hardware.HardwareHardware is the actual equipment. The PLC, the programmingdevice, and the connecting cable are examples of hardware.20

Memory SizeKilo, abbreviated K, normally refers to 1000 units. When talkingabout computer or PLC memory, however, 1K means 1024. This10is because of the binary number system (2 1024). This can be1024 bits, 1024 bytes, or 1024 words, depending on memorytype.RAMRandom Access Memory (RAM) is memory where data can bedirectly accessed at any address. Data can be written to andread from RAM. RAM is used as a temporary storage area.RAM is volatile, meaning that the data stored in RAM will belost if power is lost. A battery backup is required to avoid losingdata in the event of a power loss.ROMRead Only Memory (ROM) is a type of memory that data canbe read from but not written to. This type of memory is usedto protect data or programs from accidental erasure. ROMmemory is nonvolatile. This means a user program will not losedata during a loss of electrical power. ROM is normally used tostore the programs that define the capabilities of the PLC.EPROMErasable Programmable Read Only Memory (EPROM) providessome level of security against unauthorized or unwantedchanges in a program. EPROMs are designed so that datastored in them can be read, but not easily altered. ChangingEPROM data requires a special effort. UVEPROMs (ultravioleterasable programmable read only memory) can only be erasedwith an ultraviolet light. EEPROM (electronically erasableprogrammable read only memory), can only be erasedelectronically.FirmwareFirmware is user or application specific software burned intoEPROM and delivered as part of the hardware. Firmware givesthe PLC its basic functionality.21

Putting it TogetherThe memory of the S7-200 is divided into three areas: programspace, data space, and configurable parameter space. Program space stores the ladder logic (LAD) or statementlist (STL) program instructions. This area of memory controlsthe way data space and I/O points are used. LAD or STLinstructions are written using a programming device such asa PC, then loaded into program memory of the PLC. Data space is used as a working area, and includes memorylocations for calculations, temporary storage of intermediateresults and constants. Data space includes memorylocations for devices such as timers, counters, high-speedcounters, and analog inputs and outputs. Data space