20
1 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS ADVANCED PLC PROGRAMMING & SCADA SYSTEM DESIGN Conducted by:

Advanced plc programming & scada system design

Embed Size (px)

Citation preview

Page 1: Advanced plc programming & scada system design

1 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

ADVANCED PLC PROGRAMMING & SCADA SYSTEM DESIGN

Conducted by:

Page 2: Advanced plc programming & scada system design

2 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

MODULE-1

Introduction

A Programmable Logic Controller, PLC or Programmable Controller is a digital computer used

for automation of electromechanical processes, such as control of machinery on factory

assembly lines, amusement rides, or light fixtures. The abbreviation "PLC" and the term

"Programmable Logic Controller" are registered trademarks of the Allen-Bradley Company

(Rockwell Automation). PLCs are used in many industries and machines. Unlike general-

purpose computers, the PLC is designed for multiple inputs and output arrangements, extended

temperature ranges, immunity to electrical noise, and resistance to vibration and impact.

Programs to control machine operation are typically stored in battery-backed-up or non-volatile

memory. A PLC is an example of a hard real time system since output results must be produced

in response to input conditions within a limited time, otherwise unintended operation will

result.

History

Before the PLC, control, sequencing, and safety interlock logic for manufacturing automobiles

was mainly composed of relays, cam timers, drum sequencers, and dedicated closed-loop

controllers. Since these could number in the hundreds or even thousands, the process for

updating such facilities for the yearly model change-over was very time consuming and

expensive, as electricians needed to individually rewire relays to change the logic.

Digital computers, being general-purpose programmable devices, were soon applied to control

of industrial processes. Early computers required specialist programmers, and stringent

operating environmental control for temperature, cleanliness, and power quality. Using a

general-purpose computer for process control required protecting the computer from the plant

floor conditions. An industrial control computer would have several attributes: it would tolerate

the shop-floor environment, it would support discrete (bit-form) input and output in an easily

extensible manner, it would not require years of training to use, and it would permit its

operation to be monitored. The response time of any computer system must be fast enough to

be useful for control; the required speed varying according to the nature of the process.

In 1968 GM Hydra-Matic (the automatic transmission division of General Motors) issued a

request for proposals for an electronic replacement for hard-wired relay systems based on a

white paper written by engineer Edward R. Clark. The winning proposal came from Bedford

Associates of Bedford, Massachusetts. The first PLC, designated the 084 because it was Bedford

Associates' eighty-fourth project, was the result. Bedford Associates started a new company

dedicated to developing, manufacturing, selling, and servicing this new product: Modicon, which

stood for MOdular DIgital CONtroller. One of the people who worked on that project was Dick

Morley, who is considered to be the "father" of the PLC.The Modicon brand was sold in 1977 to

Gould Electronics, and later acquired by German Company AEG and then by French Schneider

Electric, the current owner.

Page 3: Advanced plc programming & scada system design

3 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

Programming

Early PLCs, up to the mid-1980s, were programmed using proprietary programming panels or

special-purpose programming terminals, which often had dedicated function keys representing

the various logical elements of PLC programs.Some proprietary programming terminals

displayed the elements of PLC programs as graphic symbols, but plain ASCII character

representations of contacts, coils, and wires were common. Programs were stored on cassette

tape cartridges. Facilities for printing and documentation were minimal due to lack of memory

capacity. The very oldest PLCs used non-volatile magnetic core memory.

More recently, PLCs are programmed using application software on personal computers, which

now represent the logic in graphic form instead of character symbols. The computer is

connected to the PLC through Ethernet, RS-232, RS-485 or RS-422 cabling. The programming

software allows entry and editing of the ladder-style logic. Generally the software provides

functions for debugging and troubleshooting the PLC software, for example, by highlighting

portions of the logic to show current status during operation or via simulation. The software

will upload and download the PLC program, for backup and restoration purposes. In some

models of programmable controller, the program is transferred from a personal computer to the

PLC through a programming board which writes the program into a removable chip such as an

EEPROM or EPROM.

Functionality

The functionality of the PLC has evolved over the years to include sequential relay control,

motion control, process control, distributed control systems and networking. The data handling,

storage, processing power and communication capabilities of some modern PLCs are

approximately equivalent to desktop computers. PLC-like programming combined with remote

I/O hardware, allow a general-purpose desktop computer to overlap some PLCs in certain

applications. Regarding the practicality of these desktop computer based logic controllers, it is

important to note that they have not been generally accepted in heavy industry because the

desktop computers run on less stable operating systems than do PLCs, and because the desktop

computer hardware is typically not designed to the same levels of tolerance to temperature,

humidity, vibration, and longevity as the processors used in PLCs. In addition to the hardware

limitations of desktop based logic, operating systems such as Windows do not lend themselves

to deterministic logic execution, with the result that the logic may not always respond to

changes in logic state or input status with the extreme consistency in timing as is expected from

PLCs. Still, such desktop logic applications find use in less critical situations, such as laboratory

automation and use in small facilities where the application is less demanding and critical,

because they are generally much less expensive than PLCs.

Page 4: Advanced plc programming & scada system design

4 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

The Architecture of a PLC, Function, Scan cycle and the Speed of a PLC

Main Parts of a PLC

Microprocessor RAM EPROM Base I/O Modules Power Supply Data BUS Extensions

PLC modes Basically there are two modes in a PLC.

1. Programming Mode 2. Run Mode

Monitoring mode/ Stop mode also available in some of brands.

Page 5: Advanced plc programming & scada system design

5 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

SCAN CYCLE A PLC works by continually scanning a program. We can think of this scan cycle as consisting of 3 important steps. There are typically more than 3 but we can focus on the important parts and not worry about the others. Typically the others are checking the system and updating the current internal counter and timer values.

Step 1-CHECK INPUT STATUS-First the PLC takes a look at each input to determine if it is on or off. In other words, is the sensor connected to the first input on? How about the second input? How about the third... It records this data into its memory to be used during the next step. Step 2-EXECUTE PROGRAM-Next the PLC executes your program one instruction at a time. Maybe your program said that if the first input was on then it should turn on the first output. Since it already knows which inputs are on/off from the previous step it will be able to decide whether the first output should be turned on based on the state of the first input. It will store the execution results for use later during the next step. Step 3-UPDATE OUTPUT STATUS-Finally the PLC updates the status of the outputs. It updates the outputs based on which inputs were on during the first step and the results of executing your program during the second step. Based on the example in step 2 it would now turn on the first output because the first input was on and your program said to turn on the first output when this condition is true. After the third step the PLC goes back to step one and repeats the steps continuously. One scan time is defined as the time it takes to execute the 3 steps listed above

WatchDog Timer A timer that monitors how long it takes the CPU to complete a scan. Watchdog timers output an error message if the CPU scan takes too long. Speed of a PLC Depending on,

1. Processor Speed 2. Program length and number of modules. 3. Network speed

Page 6: Advanced plc programming & scada system design

6 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

Combinational Designs for PLCs All programmable controllers have standard logic instructions – AND, OR, NOT etc. and these may be combined to create logic networks. Boolean algebra may be used as a tool to assist in the design of logic networks. E.g. Y5 = X1.X2.X3. There are three steps in combinational design method:

1. Functional Description 2. Truth Table 3. Boolean Expression

Karnaugh Maps method (Simplification of Boolean Expression) A Karnaugh map provides a pictorial method of grouping together expressions with common factors and therefore eliminating unwanted variables. The Karnaugh map can also be described as a special arrangement of a truth table.

Page 7: Advanced plc programming & scada system design

7 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

Inputs and Outputs of a PLC and their Connection Methods In smaller PLCs the inputs are normally built in and are specified when purchasing the PLC. For larger PLCs the inputs are purchased as modules, or cards, with 8 or 16 inputs of the same type on each card. For discussion purposes we will discuss all inputs as if they have been purchased as cards. The list below shows typical ranges for input voltages, and is roughly in order of popularity.

12-24 Vdc 100-120 Vac 10-60 Vdc 12-24 Vac/dc 5 Vdc (TTL) 200-240 Vac 48 Vdc 24 Vac

PLC input cards rarely supply power, this means that an external power supply is needed to

supply power for the inputs and sensors.

As with input modules, output modules rarely supply any power, but instead act as switches.

External power supplies are connected to the output card and the card will switch the power on

or off for each output. Typical output voltages are listed below, and roughly ordered by

popularity.

120 Vac

24 Vdc

12-48 Vac

12-48 Vdc

5Vdc (TTL)

230 Vac

These cards typically have 8 to 16 outputs of the same type and can be purchased with different

current ratings. A common choice when purchasing output cards is relays, transistors or triacs.

Relays are the most flexible output devices. They are capable of switching both AC and DC

outputs. But, they are slower (about 10ms switching is typical), they are bulkier, they cost more,

and they will wear out after millions of cycles. Relay outputs are often called dry contacts.

Transistors are limited to DC outputs, and Triacs are limited to AC outputs. Transistor and triac

outputs are called switched outputs.

Dry contacts - a separate relay is dedicated to each output. This allows mixed voltages (AC or DC

and voltage levels up to the maximum), as well as isolated outputs to protect other outputs and

the PLC. Response times are often greater than 10ms. This method is the least sensitive to

voltage variations and spikes.

Switched outputs - a voltage is supplied to the PLC card, and the card switches it to different

outputs using solid state circuitry (transistors, triacs, etc.) Triacs are well suited to AC devices

requiring less than 1A. Transistor outputs use NPN or PNP transistors up to 1A typically. Their

response time is well under 1ms.

Page 8: Advanced plc programming & scada system design

8 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

Selection of a Programmable Logic Controller When an engineer is embarking on any program of automation, it must be remembered

that the controller is only a tool used to perform the necessary tasks. The actual task of

implementing automation is therefore paramount, often involves many methodologies in its

system design phase. Once the specifications are established, the job of selecting a suitable

controller will then become most important as this would determine how at ease the

automation program might continue.

There is a massive range of PLC systems available today, with new additions or

replacements continually being produced with enhanced features of one types or another.

Advances in technology are quickly adopted by manufacturers in order to improve the

performance and market status of their products. However, irrespective of make, the majority

of PLC in each size range are very similar in term of their control facilities. Where significant

differences are to be found is in the programming methods and languages, together with

differing standards of manufacturer support and backup.

Considerations in choosing a suitable PLC With the vast choice of equipment now available, the engineer can usually obtain

similar systems from several original equipment manufacturers (OEM). When the specification

requires certain types of function or input/output, it is possible that one system from a single

manufacturer standing out as more superior or cost effective than the other; but normally this is

rarely the case. To determine the the most suitable PLC to be used in the automation task,

there are several basic considerations to be made:

_ Necessary input/output capacity;

_ Types of I/O required;

_ Size of memory required;

_ Speed and power required of the CPU and instruction set

_ Manufacturer's support and backup.

All these topics are to a large extent interdependent, with the memory size being

directly tied to the amount of I/O as well as program size. As the I/O and memory size rises,

this takes longer to process and requires a more powerful, faster central processor if scan times

are to remain acceptable.

Introduction to Programming Methods

1. Ladder Diagram

2. Instruction List & Statement List (STL)

3. FBD (Function Block Diagram)

4. SFC (Sequential Function Chart)

Page 9: Advanced plc programming & scada system design

9 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

Standard Contacts The Normally Open contact instructions (LD, A, and O) and Normally Closed contact instructions

(LDN, AN, ON) obtain the referenced value from the memory or from the process-image

register. The standard contact instructions obtain the referenced value from the memory (or

process-image register if the data type is I or Q). The Normally Open contact is closed (on) when

the bit is equal to 1, and the Normally Closed contact is closed (on) when the bit is equal to 0. In

FBD, inputs to both the And and Or boxes can be expanded to a maximum of 32 inputs. In STL,

the Normally Open instructions Load, AND, or OR the bit value of the address bit to the top of

the stack, and the Normally Closed instructions Load, AND, or OR the logical NOT of the bit value

to the top of the stack.

Immediate Contacts An immediate contact does not rely on the S7-224 scan cycle to update; it updates immediately. The Normally Open Immediate contact instructions (LDI, AI, and OI) and Normally Closed Immediate contact instructions (LDNI, ANI, and ONI) obtain the physical input value when the instruction is executed, but the process-image register is not updated. The Normally Open Immediate contact is closed (on) when the physical input point (bit) is 1, and the Normally Closed Immediate contact is closed (on) when the physical input point (bit) is 0. The Normally Open instructions immediately Load, AND, or OR the physical input value to the top of the stack, and the Normally Closed instructions immediately Load, AND, or OR the logical NOT of the value of the physical input point to the top of the stack.

Page 10: Advanced plc programming & scada system design

10 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

Positive and Negative Transition Instructions The Positive Transition contact instruction (EU) allows power to flow for one scan for each off-to-on transition. The Negative Transition contact instruction (ED) allows power to flow for one scan for each on-to-off transition. For the Positive Transition instruction, detection of a 0-to-1 transition in the value on the top of the stack sets the top of the stack value to 1; otherwise, it is set to 0. For a Negative Transition instruction, detection of a 1-to-0 transition in the value on the top of the stack sets the top of the stack value to 1; otherwise, it is set to 0.

NOT Instruction The Not instruction (NOT) changes the state of power flow input (that is, it changes the value on the top of the stack from 0 to 1 or from 1 to 0).

Output Instructions The Output instruction (=) writes the new value for the output bit to the process-image register. When the Output instruction is executed, the CPU turns the output bit in the process-image register on or off. For LAD and FBD, the specified bit is set equal to power flow. For STL, the value on the top of the stack is copied to the specified bit.

Page 11: Advanced plc programming & scada system design

11 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

The Output Immediate instruction (=I) writes the new value to both the physical output and the corresponding process-image register location when the instruction is executed. When the Output Immediate instruction is executed, the physical output point (Bit) is immediately set equal to power flow. For STL, the instruction immediately copies the value on the top of the stack to the specified physical output bit (STL). The “I” indicates an immediate reference; the new value is written to both the physical output and the corresponding process-image register location when the instruction is executed. This differs from the non-immediate references, which write the new value to the process-image register only.

Set Reset Bits The Set (S) and Reset (R) instructions set (turn on) or reset (turn off) the specified number of points (N), starting at the specified address (Bit). You can set or reset from 1 to 255 points. If the Reset instruction specifies either a timer bit (T) or counter bit (C), the instruction resets the timer or counter bit and clears the current value of the timer or counter.

TIMER Instruction There are four fundamental types of timers shown in below figure. An on-delay timer will wait for a set time after a line of ladder logic has been true before turning on, but it will turn off immediately. An off-delay timer will turn on immediately when a line of ladder logic is true, but it will delay before turning off. Consider the example of an old car. If you turn the key in the ignition and the car does not start immediately, that is an on-delay. If you turn the key to stop the engine but the engine doesn’t stop for a few seconds, that is an off delay. An on-delay timer can be used to allow an oven to reach temperature before starting production. An off delay timer can keep cooling fans on for a set time after the oven has been turned off.

On delay

Operands: 0-255 PT Value: VW,T,C,IW,QW,MW, ALW, constant

Page 12: Advanced plc programming & scada system design

12 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

On-Delay Timer, Retentive On-Delay Timer, Off-Delay Time

The On-Delay Timer and Retentive On-Delay Timer instructions count time when the enabling input is ON. When the current value (Txxx) is greater than or equal to the preset time (PT), the timer bit is ON. The On-Delay timer current value is cleared when the enabling input is OFF, while the current value of the Retentive On-Delay Timer is maintained when the input is OFF. You can use the Retentive On-Delay Timer to accumulate time for multiple periods of the input ON. A Reset instruction (R) is used to clear the current value of the Retentive On-Delay Timer. Both the On-Delay Timer and the Retentive On-Delay Timers continue counting after the Preset is reached, and they stop counting at the maximum value of 32767. The Off-Delay Timer is used to delay turning an output OFF for a fixed period of time after the input turns OFF. When the enabling input turns ON, the timer bit turns ON immediately, and the current value is set to 0. When the input turns OFF, the timer counts until the elapsed time reaches the preset time. When the preset is reached, the timer bit turns OFF and the current value stops counting. If the input is OFF for a time shorter than the pre-set value, the timer bit remains ON. The TOF instruction must see an ON to OFF transition to begin counting. If the TOF timer is inside an SCR region and the SCR region is inactive, then the current value is set to 0, the timer bit is turned OFF, and the current value does not count.

Page 13: Advanced plc programming & scada system design

13 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

Understanding the Timer Instructions You can use timers to implement time-based counting functions. The S7-200 instruction set provides three types of timers as shown below. Following Table shows the actions of the different timers. On-Delay Timer (TON) for timing a single interval Retentive On-Delay Timer (TONR) for accumulating a number of timed intervals Off-Delay Timer (TOF) for extending time past a false condition (in other words, such as cooling a motor after it is turned off)

Counter Instructions

Page 14: Advanced plc programming & scada system design

14 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

-The Count Up instruction counts up to the maximum value on the rising edges of the Count Up

(CU) input. When the current value (Cxxx) is greater than or equal to the Preset Value (PV), the

counter bit (Cxxx) turns on. The counter is reset when the Reset (R) input turns on.

-The Count Up/Down instruction counts up on rising edges of the Count Up (CU) input. It

counts down on the rising edges of the Count Down (CD) input. When the current value (Cxxx) is

greater than or equal to the Preset Value (PV), the counter bit (Cxxx) turns on. The counter is

reset when the Reset (R) input turns on.

-The Count Down Counter counts down from the preset value on the rising edges of the Count

Down (CD) input . When the current value is equal to zero, the counter bit (Cxxx) turns on. The

counter resets the counter bit (Cxxx) and loads the current value with the preset value (PV)

when the load input (LD) turns on. The Down Counter stops counting when it reaches zero.

Counter ranges: Cxxx=C0 through C255 In STL, the CTU Reset input is the top of the stack value,

while the Count Up input is the value loaded in the second stack location. In STL, the CTUD Reset

input is the top of the stack value, the Count Down input is the value loaded in the second stack

location, and the Count Up input is the value loaded in the third stack location. In STL, the CTD

Load input is the top of stack, and the Count Down input is the value loaded in the second stack

location.

Page 15: Advanced plc programming & scada system design

15 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

Compare Instructions

The Compare Byte instruction is used to compare two values: IN1 to IN2. Comparisons include: Equal: IN1 = IN2 Greater than or equal : IN1 >= IN2 Less than or Equal: IN1 <= IN2 Greater than: IN1 > IN2 Less than IN1 < IN2 or IN1 <> IN2. Also can use for integer, Word, double words. Ex:

Page 16: Advanced plc programming & scada system design

16 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

Math Instructions Add and Subtract:

The Add Integer and Subtract Integer instructions add or subtract two 16-bit integers and

produce a 16-bit result (OUT).

The Add Double Integer and Subtract Double Integer instructions add or subtract two 32-bit

integers, and produce a 32-bit result (OUT).

The Add Real and Subtract Real instructions add or subtract two 32-bit real numbers and

produce a 32-bit real number result (OUT).

In LAD and FBD: IN1 + IN2 = OUT IN1 - IN2 = OUT

Multiply and Divide:

Page 17: Advanced plc programming & scada system design

17 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

Increment & Decrement

The Increment Byte and Decrement Byte instructions add or subtract 1 to or from the

input byte (IN) and place the result into the variable specified by OUT. Increment and

decrement byte operations are unsigned.

The Increment Word and Decrement Word instructions add or subtract 1 to or from

the input word (IN) and place the result in OUT. Increment and decrement word

operations are signed (16#7FFF > 16#8000).

The Increment Double Word and Decrement Double Word instructions add or

subtract 1 to or from the input double word (IN) and place the result in OUT. Increment

and decrement double word operations are signed (16#7FFFFFFF > 16#80000000).

In LAD and FBD:

IN + 1 = OUT

IN - 1 = OUT

Page 18: Advanced plc programming & scada system design

18 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

Special Memory (SM) Bits Special memory bits provide a variety of status and control functions, and also serve as a means of communicating information between the CPU and your program. Special memory bits can be used as bits, bytes, words, or double words.

Page 19: Advanced plc programming & scada system design

19 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

CPU Memory Areas

Using the Memory Address to Access Data. To access a bit in a memory area, you specify the address, which includes the memory area identifier, the byte address, and the bit number. Figure 5-1 shows an example of accessing a bit (which is also called “byte.bit” addressing). In this example, the memory area and byte address (I = input, and 3 = byte 3) are followed by a period (“.”) to separate the bit address (bit 4).

You can access data in many CPU memory areas (V, I, Q, M, S, L, and SM) as bytes, words, or double words by using the byte-address format. To access a byte, word, or double word of data in the CPU memory, you must specify the address in a way similar to specifying the address for a bit. This includes an area identifier, data size designation, and the starting byte address of the byte, word, or double-word value, as shown in following figure. Data in other CPU memory areas (such as T, C, HC, and the accumulators) are accessed by using an address format that includes an area identifier and a device number.

Page 20: Advanced plc programming & scada system design

20 Advanced PLC Programming & SCADA System Design| APOGEE AUTOMATION SYSTEMS

Representation of Numbers Below image shows the range of integer values that can be represented by the different sizes of

data. Real (or floating-point) numbers are represented as 32-bit, single-precision numbers

whose format is: +1.175495E-38 to +3.402823E+38 (positive), and -1.175495E-38 to

3.402823E+38 (negative). Real number values are accessed in double-word lengths. Refer to

ANSI/IEEE 754-1985 standard for more information about real or floating-point numbers.

Addressing the Process-Image Input Register (I)

As described in Section 4.6, the CPU samples the physical input points at the beginning of each

scan cycle and writes these values to the process-image input register. You can access the

process-image input register in bits, bytes, words, or double words.

Format:

Bit I[byte address].[bit address] I0.1

Byte, Word, Double Word I[size][starting byte address] IB4

Addressing the Process-Image Output Register (Q) At the end of the scan cycle, the CPU copies the values stored in the process-image output

register to the physical output points. You can access the process-image output register in bits,

bytes, words, or double words.

Format:

Bit Q[byte address].[bit address] Q1.1

Byte, Word, Double Word Q[size][starting byte address] QB5