plc programming_plc_programozÁs_alapok_angol.pptx

57
7- 1 03/15/2022 ©T.C. Chang Chapter 7. PROGRAMMABLE LOGIC CONTROLLER Dr. T.C. Chang School of Industrial Engineering Purdue University

Upload: bodijozsef

Post on 02-Oct-2015

14 views

Category:

Documents


2 download

TRANSCRIPT

Chapter 7. PROGRAMMABLE LOGIC CONTROOLER

Chapter 7. PROGRAMMABLELOGIC CONTROLLERDr. T.C. ChangSchool of Industrial EngineeringPurdue University7- #10/11/2013T.C. Chang1FUNCTIONS OF CONTROLLERS1) on-off control,2) sequential control, 3) feedback control, and 4) motion control. 7- #10/11/2013T.C. Chang2CONTROL DEVICES1) mechanical control - cam, governor, etc.,2) pneumatic control - compressed air, valves,etc.3) electromechanical control - switches, relays, a timer, counters, etc,4) electronics control - similar to electromechanical control, except uses electronic switches.5) computer control.7- #10/11/2013T.C. Chang3PROGRAMMABLE LOGIC CONTROLLERInvented in 1968 as a substitute for hardwired relay panels."A digitally operating electronic apparatus which uses a programmable memory for the internal storage of instructions by implementing specific functions such as logic sequencing, timing, counting, and arithmetic to control, through digital or analog input/output modules, various types of machines or processes. The digital computer which is used to perform the functions of a programmable controller is considered to be within this scope. Excluded are drum and other similar mechanical sequencing controllers."National Electrical Manufacturing Association (NEMA)7- #10/11/2013T.C. Chang4VENDORSMODICOM - GOULDALLEN-BRADLEYGESQUARE-Detc.7- #10/11/2013T.C. Chang5PLC CPUSystemUser LadderDiagramWorking memoryregistersInputFlagOutputInput ModuleOutputModule7- #10/11/2013T.C. Chang6An Large Size PLC

The main module measures 19 x 20 x 14.5. have upto 10,000 I/O points supports all functions expansion slots to accommodate PC and other communication devices.

7- #10/11/2013T.C. ChangA Small Size PLC

Measures 4.72x 3.15 x 1.57. 32 I/O pointsStandard RS 232 serial communication port

7- #10/11/2013T.C. ChangSWITCHESDPSTSPDTNon-lockingLockingNormally OpenNormally ClosedMultiple ThrowP1P2Multiple PoleBreak-before-makeMake-before-break7- #10/11/2013T.C. Chang9TERMSThrow - number of statesPole - number of connecting moving parts (number of individual circuits).

SPDTDPSTA serial switch box (A-B box) hastwo 25 pin serial ports to switch from.InputOutputABKnobHow is this switch classified?7- #10/11/2013T.C. Chang10TYPES OF SWITCHESSelector switchesPushbutton switchesPhotoelectric switchesLimit SwitchesProximity switchesLevel switchesThumbwheel switchesSlide switches

RATING:

24 Volts AC/DC48 Volts AC/DC120 Volts AC/DC230 Volts AC/DCTTL level (Transistor-to-transistor 5V)Isolated Input7- #10/11/2013T.C. Chang11RELAYSA switch whose operation is activated by an electromagnet is called a "relay" contactcoilinputRelay coilR1R1Output contact7- #10/11/2013T.C. Chang12COUNTERDigital counters output in the form of a relay contact when a preassigned count value is reached.

57- #10/11/2013T.C. Chang13TIMERA timer consists of an internal clock, a count value register, and an accumulator. It is used for or some timing purpose.

Time 5 seconds.

7- #10/11/2013T.C. Chang14AN EXAMPLE OF RELAY LOGIC

For a process control, it is desired to have the process start (by turning on a motor) five seconds after a part touched a limit switch. The process is terminated automatically when the finished part touches a second limit switch. An emergency switch will stop the process any time when it is pushed.

7- #10/11/2013T.C. Chang15PLC ARCHITECTUREProgrammable controllers replace most of the relay panel wiring by software programming.

A typical PLC7- #10/11/2013T.C. Chang16PLC COMPONENTS1. ProcessorMicroprocessor based, may allow arithmetic operations, logic operators, block memory moves, computer interface, local area network, functions, etc.

2. MemoryMeasured in words.ROM (Read Only Memory), RAM (Random Access Memory), PROM (Programmable Read Only Memory), EEPROM (Electric Erasable Programmable ROM), EPROM (Erasable Programmable Read Only Memory),EAPROM (Electronically Alterable Programmable Read Only Memory), andBubble Memory. 7- #10/11/2013T.C. Chang17PLC COMPONENTS3. I/OModular plug-in peripheryAC voltage input and output, DC voltage input and output, Low level analog input, High level analog input and output, Special purpose modules, e.g., high speed timers, Stepping motor controllers, etc. PID, Motion4. Power supply AC power5. Peripheral hand-held programmer (HHP)CRT programmeroperator consoleprintersimulatorEPROM loadergraphics processornetwork communication interfacemodular PC

7- #10/11/2013T.C. Chang18Discrete I/OAC Voltage I/ODC Voltage I/Onumerical input and outputspecial-purpose modules, for example, high-speed timers, and stepping motor controllers7- #10/11/2013T.C. ChangAnalog I/OAnalog inputs:Flow sensorsHumidity sensorsPotentiometersPressure sensorsTemperature sensors

Analog outputs:Analog metersAnalog valves and actuatorsDC and AC motor drives7- #10/11/2013T.C. ChangSome Special I/OThermocouple input Low level analog signal, filtered, amplified, and digitized before sending to the processor through I/O bus.Fast input 50 to 100 microsecond pulse signal detection.ASCII I/OCommunicates with ASCII devices.Stepper motor outputProvide directly control of a stepper motor.Servo interfaceControl DC servo motor for point-to-point control and axis positioning. PID control The Proportional Integral Derivative is used for closed loop process control. Network module7- #10/11/2013T.C. ChangA Hand Held Programmer

7- #10/11/2013T.C. ChangLADDER DIAGRAMA ladder diagram (also called contact symbology) is a means of graphically representing the logic required in a relay logic system.

RailRung7- #10/11/2013T.C. Chang23PLC WIRING DIAGRAMExternalswitchesStored program0102202020110102031112CPLCInputOutputAB7- #10/11/2013T.C. Chang24Input Connections

AC DC TTL7- #10/11/2013T.C. ChangOutput Connections

AC DC TTL7- #10/11/2013T.C. ChangSCANA PLC resolves the logic of a ladder diagram (program) rung by rung, from the top to the bottom. Usually, all the outputs are updated based on the status of the internal registers. Then the input states are checked and the corresponding input registers are updated. Only after the I/Os have been resolved, is the program then executed. This process is run in a endless cycle. The time it takes to finish one cycle is called the scan time. In some controllers the idle state is eliminated. In this case, the scan time varies depends on the program length.beginInputOutputResolvelogicIdleScan cycle7- #10/11/2013T.C. Chang27PLC ProgrammingLadder Diagram - most commonStructure Text Programming (ST)Functional Block Programming (FB)Instruction List (IL)Sequential Function Chart (SFC)7- #10/11/2013T.C. ChangPLC Ladder DiagramINSTRUCTIONS1) Relay,2) Timer and counter,3) Program control,4) Arithmetic,5) Data manipulation,6) Data transfer, and7) Others, such as sequencers. 7- #10/11/2013T.C. Chang29LOGIC STATESON : TRUE, contact closure, energize, etc. OFF: FALSE, contact open , de-energize, etc.(In the notes we use the symbol "~" to represent negation. AND and OR are logic operators. )Do not confuse the internal relay and program with the externalswitch and relay. Internal symbols are used for programming.External devices provide actual interface.7- #10/11/2013T.C. Chang30AND and OR LOGICPB1R1PB2R2R1 = PB1.AND.PB2 R2 = PB2.AND.~PB4PB3PB4PB1R1PB2R1 = PB1 .OR. PB2ANDOR7- #10/11/2013T.C. Chang31COMBINED AND & ORR1 = PB1 .OR. (PB2 .AND. PB3) PB1R1PB2pb37- #10/11/2013T.C. Chang32RELAYA Relay consists of two parts, the coil and the contact(s). Contacts:

a. Normally open-| |-b. Normally closed-|/|-c. Positive transition sensing -|P|-d. Negative transition sensing-|N|-

Coil: a. Coil-( )-b. negative coil-(/)-c. Set Coil-(S)-d. Reset Coil-(R)-( )7- #10/11/2013T.C. Chang33Relay (continue)Coil: e. Retentive memory Coil-(M)-f. Set retentive memory Coil-(SM)-g. Reset retentive memory Coil -(RM)-h. Positive Transition-sensing Coil-(P)-h. Negative Transition-sensing Coil-(N)-

(set coil latches the state, reset coil deenergize the set coil. retentive coil retain the state after power failure.)7- #10/11/2013T.C. ChangTIMERS AND COUNTERSTimers:

a. Retentive on delay-(RTO)- b. Retentive off delay-(RTF)- c. Reset-(RST)-

Counter:

a. Counter up-(CTU)- b. Counter down-(CTD)- c. Counter reset-(CTR)- RTO counting stop counting resume

RTF stop counting stopTrue False TrueInputRTO reach PR value, output ONRTF reach PR value, output OFFPR value in 0.1 second7- #10/11/2013T.C. Chang35SEQUENCERSequencers are used with machines or processes involving repeating operating cycles which can be segmented into steps. Output Step A B C Dwell time 1 ON OFF OFF 5 sec. 2 ON ON OFF 10 sec. 3 OFF OFF ON 3 sec. 4 OFF ON OFF 9 sec. 7- #10/11/2013T.C. Chang36A-B PLCI/O points are numbered, they correspond to the I/O slot on the PLC.

For A-B controller used in our labI/O uses 1-32Internal relays use 033 - 098Internal timers/counters/sequencers use 901-932Status 951-982

7- #10/11/2013T.C. Chang37PROGRAMMING EXAMPLE 1

iddescriptionstateexplanation MSImicroswitch 1part arrive R1output to bar code reader 1scan the part C1 input from bar code reader1right part R2output robot1loading cycle R3output robot1unloading cycle C2 input from robot1robot busy R4output to stopper1 stopper up C3 input from machine1machine busy C4 input from machine1task complete 7- #10/11/2013T.C. Chang38SOLUTION

Rung 1. If part arrives and no part is stopped, trigger the bar code reader. Rung 2. If it is a right part, activate the stopper. Rung 3. If the stopper is up, the machine is not busy and the robot is not busy, load the part onto the machine. Rung 4. If the task is completed and the robot is not busy, unload the machine. 7- #10/11/2013T.C. Chang39Structured Text Programminga high level language used to express the behavior of functions, function blocks and programsIn IEC 1131-3 standard, it has a syntax very similar to PASCALstrongly typed languageFunctions:assignmentsexpressionsstatementsoperatorsfunction callsflow control7- #10/11/2013T.C. Chang40Data Types SINTshort integer1 byteINTinteger2 bytesDINTdouble integer4 bytesLINTlong integer8 bytesUSINTunsigned short integer1 byteUINT unsigned integer2 bytesUDINTunsigned double integer4 bytesULINTunsigned long integer8 bytesREALreal4 bytesLREALlong real8 bytes

TIMEtime durationDATEcalendar dateTODtime of dayDTdate and time of daySTRINGcharacter strings

BOOLboolean1 bitBYTEbyte1 byteWORD16 bit bit string16 bitsDWORD32 bit bit string32 bitsLWORD64 bit bit string64 bits7- #10/11/2013T.C. Chang41Derived Data TypesTYPE (* user defined data types, this is a comment*)pressure : REAL;temp : REAL;part_count:INT;END_TYPE;

Structure:

TYPE data_packet:STRUCTinput:BOOL;t:TIME;out:BOOL;count:INT;END_STRUCT;END_TYPE;7- #10/11/2013T.C. Chang42Variable DeclarationsVARI,j,k: INT;v: REAL;END_VAR

Local variable:Use VAR, VAR_INPUT, VAR_OUTPUT, VAR_IN_OUT, VAR_GLOBAL, VAR_EXTERNAL for different variable types.7- #10/11/2013T.C. Chang43Operators and Expressions( )parenthesized expressionfunction( )function**exponentiation-negationNOTBoolean complement+ - * /math operatorsMODmodulus operation< > =comparison operators=equalnot equalAND, &Boolean ANDXORBoolean XORORBoolean ORY := X+1.0;

y := a AND b;

v := (v1 + v2 + v3)/3

output := (light = open) OR (door = shut);

7- #10/11/2013T.C. ChangCondition StatementsIF a > 100 THENredlight := on;ELSEIF a > 50 THENyellowlight := on;ELSEgreenlight := on;END_IF;

CASE dial_setting OF1 :x := 10;2 :x := 15;3 :x := 18;4,5:x := 20; (* 4 or 5 *)ELSEx := 30;END_CASE

7- #10/11/2013T.C. ChangIteration StatementsFOR I:= 0 to 100 BY 1 DOlight[I] := ON;END_FOR

I := 0;WHILE I < 100 DOI := I + 1;light[I] := on;END_WHILEI := 0;REPEATI := I + 1;light[I] := on;UNTIL I > 100;END_REPEAT

7- #10/11/2013T.C. ChangFunctionsFUNCTION add_num: REALVAR_INPUTI,J: REALEND_VARadd_num := I + J;END_FUNCTION

Call a function:x:= add_num(1.2, 5.6);Built-in Functions:ABS, SQRT, LN, LOG, EXP, SIN, COS, TAN, ASIn, ACOS, ATAN, ADD, MUL, SUB, DIV, MOD, EXPT, MOVE), logic functions (AND, OR, XOR, NOT), bit string functions (SHL, SHR shift bit string left and right , ROR, ROL rotate bit string), etc.7- #10/11/2013T.C. ChangProgramsPROGRAM example7.1VAR_INPUTMSI: BOOL;C1:BOOL;C2: BOOL;C3:BOOL;C4:BOOL;END_VARVAR_OUTPUTR1:BOOL : FALSE;R2:BOOL : FALSE;R3:BOOL : FALSE;R4: BOOL : FALSE;END_VAR

R1 := MS1 AND (NOT R4);R2 := R4 AND (NOT C3) AND (NOT C2);R3 := C4 AND (NOT C3);R4 := C1;END_PROGRAM

7- #10/11/2013T.C. ChangFunctional Block ProgrammingFunctional block (FB) is a well packaged element of software that can be re-used in different parts of an application or even in different projects. Functional blocks are the basic building blocks of a control system and can have algorithms written in any of the IEC languages.7- #10/11/2013T.C. ChangAn Up Counter Function Block

The algorithm in Structured Text:

FUNCTION BLOCK CTUVAR_INPUTCU : BOOL;R : BOOL;PV : INT;END_VARVAR_OUTPUTQ : BOOL;CV : INT;END_VARIF R THENCV := 0;ELSEIF CUAND (CV < PV) THENCV := CV + 1;END_IF;Q := (CV >= PV);END_FUNCTION_BLOCK

CU : input to be counted R : resetPV : preset valueQ : contact outputCV : counter value.

7- #10/11/2013T.C. ChangA PID Control Function Block

block diagram

control algorithmSPset pointPVsensor feedbackKPproportional error gainTRintegral gainTDderivative gainAUTOcalculateXOUToutput to processXOmanual output adjustmentcycletime between execution7- #10/11/2013T.C. ChangInstruction List ProgrammingA low level language which has a structure similar to an assembly language. Since it is simple, it is easy to learn and ideally for small hand-held programming devices. Each line of code can be divided into four fields: label, operator, operand, and comment.

e.g.

LD MS1STR1loopANDNC37- #10/11/2013T.C. ChangOperatorsOperator Modifiers DescriptionLDNload operand into registerSTNstore register value into operandSset operand trueRreset operand falseANDN, (Boolean AND&N, (Boolean ANDORN, (Boolean ORXORN, (Boolean XORADD(additionSUB(subtractionMUL(multiplicationDIV(divisionGT(greater thanGE(greater than and equal toEQ(equalNE(not equalLE(less than and equal toLT(less thanJMPC, Njump to labelCALC, Ncall function blockRETC, Nreturn from function or function block)execute last deferred operatorModifier N means negate. ( defers the operator. C is a condition modifier, the operation is executed if the register value is true.7- #10/11/2013T.C. ChangInstruction List for Example 1PROGRAM example7.1VAR_INPUTMSI: BOOL;C1:BOOL;C2: BOOL;C3:BOOL;C4:BOOL;END_VARVAR_OUTPUTR1:BOOL : FALSE;R2:BOOL : FALSE;R3:BOOL : FALSE;R4: BOOL : FALSE;END_VAR

LDMS1ANDN R4STR1LDR4ANDNC3ANDNC2STR2LDC4ANDNC3STR3LDC1STR4

END_PROGRAM

7- #10/11/2013T.C. ChangSequential Function Chart(SFC)A graphics language used for depicting sequential behavior. The IEC standard grew out of the French standard Grafcet which in turn is based on Petri-net. A SFC is depicted as a series of steps shown as rectangular boxes connected by vertical lines. Each step represent a state of the system being controlled. The horizontal bar indicates a condition. It can be a switch state, a timer, etc. A condition statement is associated with each condition bar. Each step can also have a set of actions. Action qualifier causes the action to behave in certain ways. The indicator variable is optional. It is for annotation purposes.7- #10/11/2013T.C. ChangSFC

Action Qualifiers:Nnon-stored, executes while the step is activeRresets a store actionSsets an action activeLtime limited action, terminates after a given periodDtime delayed action.Pa pulse action, executes once in a stepSDstored and time delayedDStime delayed and storedSLstored and time limited

7- #10/11/2013T.C. ChangSFC for Example 1

7- #10/11/2013T.C. Chang

Allen-Bradley PLC-3

Allen-Bradley MicroLogix 1000

An Allen-Bradley hand-held programmer for MicroLogix 1000