Eee3420 lecture04 rev2011

51
1 Week © Vocational Training Council, Hong Kong. │ Lecture 4 │ Advanced PLC Programming EEC3420 Industrial Control Department of Electrical Engineering

Transcript of Eee3420 lecture04 rev2011

Page 1: Eee3420 lecture04 rev2011

1Week © Vocational Training Council, Hong Kong.

│ Lecture 4 │

Advanced PLC Programming

EEC3420 Industrial ControlDepartment of Electrical Engineering

Page 2: Eee3420 lecture04 rev2011

2© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Learning Objectives Understand the structure of Mitsubishi FX series PLC Understand the advanced programming techniques of

PLC

Page 3: Eee3420 lecture04 rev2011

3© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Advanced PLC Programming

nowadays PLCs have many features normally found in larger controllers like

floating-point mathematics, the ability to process 32-bit data words and a wide range of fully-configurable communications

options advanced PLC programming is often machine specific

Page 4: Eee3420 lecture04 rev2011

4© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Mitsubishi PLC FX series model part number of Mitsubishi PLC FX series

Page 5: Eee3420 lecture04 rev2011

5© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Hardware Details for Mitsubishi PLC Inputs

Device Mnemonic: X Purpose: Representation of physical inputs to the

PLC. Available forms: NO and NC contacts only. Devices numbered in: Octal, i.e. X0 to X7, X10 to

X17, etc.

Page 6: Eee3420 lecture04 rev2011

6© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Hardware Details for Mitsubishi PLC Outputs

Device Mnemonic: Y Purpose: Representation of physical outputs from

the PLC. Available forms: NO and NC contacts and output

coils. Devices numbered in: Octal, i.e. Y0 toY7, Y10 to

Y17, etc

Page 7: Eee3420 lecture04 rev2011

7© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Hardware Details for Mitsubishi PLC Auxiliary Relays

Device Mnemonic: M Purpose: Internal programmable controller status flags. Available forms: NO and NC contacts and output coils. Devices numbered in: Decimal, i.e. M0 to M9, M10 to M19,

etc. Further uses: General stable state auxiliary relays (GAR) Battery backed/latched auxiliary relays (BBR) Special diagnostic auxiliary relays

Page 8: Eee3420 lecture04 rev2011

8© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Hardware Details for Mitsubishi PLC Other Relays

General Stable State Auxiliary Relays Battery Backed/Latched Auxiliary Relays Special diagnostic auxiliary relays State Relays Pointers Interrupt Pointers

Page 9: Eee3420 lecture04 rev2011

9© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Hardware Details for Mitsubishi PLC Data

Constant K Input Interrupt s Timer Interrupts Counter Interrupts Constant H Data Registers

Page 10: Eee3420 lecture04 rev2011

10© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Hardware Details for Mitsubishi PLC Data

General Use Registers File Registers Index Registers

Refer to the programmer’s manual for the use of these registers

Page 11: Eee3420 lecture04 rev2011

11© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Special Instructions of Mitsubishi PLC Applied Instructions are the ‘specialist’ instructions of

the FX family of PLC’s, format is shown below.

Page 12: Eee3420 lecture04 rev2011

12© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Representation of the operands

Bit devices, individual and grouped Word devices Interpreting word data

Page 13: Eee3420 lecture04 rev2011

13© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Bit Devices Devices such as X, Y, M and S are bit devices Bit devices can be grouped together to form bigger

representations of data, 8 consecutive bit devices are referred to as a byte

16 consecutive bit devices are referred to as a word 32 consecutive bit devices are a double word

Page 14: Eee3420 lecture04 rev2011

14© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Grouped Bit Devices the form KnP is used to denote a group of devices P represents the head address of the bit devices to be

used the Kn portion of the statement identifies the range of

devices enclosed each “n” digit actual represents 4 bit devices “n” can be a number from the range 0 to 8

Page 15: Eee3420 lecture04 rev2011

15© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Word Devices Word devices such as T, C, D, V and Z can store data

about a particular event or action within the PLC these devices are 16 bit registers pairs of consecutive data registers or combined V and

Z registers may form 32-bit devices PLC’s can read the word data as: A pure bit pattern; A

decimal number; A hexadecimal number;or as a BCD (Binary Coded Decimal) number

Page 16: Eee3420 lecture04 rev2011

16© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Signed binary representation Signed binary representation of a group of 16 devices

Page 17: Eee3420 lecture04 rev2011

17© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Hexadecimal Representation Hexadecimal representation of a group of 16 devices

Page 18: Eee3420 lecture04 rev2011

18© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

BCD Representation BCD (Binary Coded Decimal) representation of a group of 16

devices

Page 19: Eee3420 lecture04 rev2011

19© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Scientific Notation• Scientific Notation use two devices to store information

about a number• one device contains a data string of the actual

characters in the number (called the mantissa)• while the second device contains information about the

number of decimal places used in the number (called the exponent)

• Scientific Notation limits are;• 9999 x 1035 ~ 9999 x 10-41

• -9999x 1035 ~ -9999 x 10-41

Page 20: Eee3420 lecture04 rev2011

20© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Scientific Notation• Scientific Notation can be obtained by using the BCD,

or EBCD in FX2N, instruction (FNC 18 or FNC 118) with the float flag M8023 set ON

• In this situation floating point format numbers are converted by the BCD instruction into Scientific Notation

• The mantissa and exponent are stored in consecutive data registers

Page 21: Eee3420 lecture04 rev2011

21© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Scientific NotationScientific format cannot be used directly in calculations, but it does provide an ideal method of displaying the data on a monitoring interface

Page 22: Eee3420 lecture04 rev2011

22© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Floating Point Format• extends the abilities and ranges provided by Scientific

Notation with the ability to represent fractional portions of whole numbers

• a greater degree of accuracy • Decimal data can be converted in to floating point by

using the FLT, float instruction (FNC 49) • When this same instruction is used with the float flag

M8023 set ON, floating point numbers can be converted back to decimal

Page 23: Eee3420 lecture04 rev2011

23© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Floating Point Format• occupy two consecutive data registers (or 32 bits) • cannot be directly monitored, as they are stored in a

special format recommended by the I.E.E.E (Institute of Electrical and Electronic Engineers)

• have both mantissa and exponents

Page 24: Eee3420 lecture04 rev2011

24© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Program Flow-Functions 00 to 09 • CJ - Conditional jump FNC 00• CALL - Call Subroutine FNC 01 • SRET - Subroutine Return FNC 02 • IRET - Interrupt Return FNC 03 • EI - Enable Interrupt FNC 04 • DI - Disable Interrupt FNC 05• FEND - First End FNC 06 • WDT - Watchdog Timer FNC 07 • FOR - Start of a For/Next Loop FNC 08 • NEXT - End a For/Next Loop FNC 09

Page 25: Eee3420 lecture04 rev2011

25© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Move And Compare - Functions 10 to 19• CMP - Compare FNC 10 • ZCP - Zone Compare FNC 11• MOV - Move FNC 12 • SMOV - Shift Move FNC 13• CML - Compliment FNC 14 • BMOV - Block Move FNC 15 • FMOV - Fill Move FNC 16• XCH - Exchange FNC 17 • BCD - Binary Coded Decimal FNC 18 • BIN - Binary FNC 19

Page 26: Eee3420 lecture04 rev2011

26© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Arithmetic And Logical Operations -Functions 20 to 29

• ADD - Addition FNC 20 • SUB - Subtraction FNC 21 • MUL - Multiplication FNC 22 • DIV - Division FNC 23 • INC - Increment FNC 24 • DEC - Decrement FNC 25 • WAND - Word AND FNC 26 • WOR - Word OR FNC 27 • WXOR - Word Exclusive OR FNC 28 • NEG - Negation FNC 29

Page 27: Eee3420 lecture04 rev2011

27© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Rotation And Shift - Functions 30 to 39• ROR - Rotation Right FNC 30 • ROL - Rotation Left FNC 31 • RCR - Rotation Right with Carry FNC 32 • RCL - Rotation Left with Carry FNC 33 • SFTR - (Bit) Shift Right FNC 34 • SFTL - (Bit) Shift Left FNC 35 • WSFR - Word Shift Right FNC 36 • WSFL - Word Shift Left FNC 37 • SFWR - Shift Register Write FNC 38 • SFRD - Shift Register Read FNC 39

Page 28: Eee3420 lecture04 rev2011

28© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Data Operation - Functions 40 to 49• ZRST - Zone Reset FNC 40 • DECO - Decode FNC 41 • ENCO - Encode FNC 42 • SUM - The Sum Of Active Bits FNC 43 • BON - Check Specified Bit Status FNC 44 • MEAN - Mean FNC 45 • ANS - (Timed) Annunciator Set FNC 46 • ANR - Annunciator Reset FNC 47 • SQR - Square Root FNC 48 • FLT - Float, (Floating Point) FNC 49

Page 29: Eee3420 lecture04 rev2011

29© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

High Speed Processing - Functions 50 to 59

• REF - Refresh FNC 50 • REFF - Refresh and filter adjust FNC 51 • MTR - Input matrix FNC 52 • HSCS - High speed counter set FNC 53 • HSCR - High speed counter reset FNC 54 • HSZ - High speed counter• zone compare FNC 55 • SPD - Speed detect FNC 56 • PLSY - Pulse Y output FNC 57 • PWM - Pulse width modulation FNC 58 • PLSR - Ramp Pulse output FNC 59

Page 30: Eee3420 lecture04 rev2011

30© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Handy Instructions - Functions 60 to 69• IST - Initial State FNC 60• SER - Search FNC 61 • ABSD - Absolute Drum FNC 62 • INCD - Incremental Drum FNC 63 • TTMR - Teaching Timer FNC 64 • STMR - Special Timer - Definable FNC 65• ALT - Alternate State FNC 66 • RAMP - Ramp - Variable Value FNC 67 • ROTC - Rotary Table Control FNC 68 • SORT - Sort Data FNC 69

Page 31: Eee3420 lecture04 rev2011

31© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

External FX I/O Devices - Functions 70 to 79• TKY - Ten Key Input FNC 70 • HKY - Hexadecimal Input FNC 71 • DSW - Digital Switch (Thumbwheel input) FNC 72 • SEGD - Seven Segment Decoder FNC 73 • SEGL - Seven Segment with Latch FNC 74 • ARWS - Arrow Switch FNC 75 • ASC - ASCII Code FNC 76

Page 32: Eee3420 lecture04 rev2011

32© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

External FX I/O Devices - Functions 70 to 79• ASC - ASCII Code FNC 76 • PR- ‘Print’ To A Display FNC 77 • FROM - Read From A Special• Function Block FNC 78 • TO - Write To A Special Function Block FNC 79

Page 33: Eee3420 lecture04 rev2011

33© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

External FX Serial Devices - Functions 80 to 89• RS - RS Communications FNC 80 • PRUN - FX2-40AP Parallel Run FNC 81 • ASCI - Hexadecimal to ASCII FNC 82 • HEX - ASCII to Hexadecimal FNC 83 • CCD - Check Code FNC 84 • VRRD - FX-8AV Volume Read FNC 85 • VRSD - FX-8AV Volume Scale FNC 86• - Not Available FNC 87• PID - PID Control Loop FNC 88 • - Not Available FNC 89

Page 34: Eee3420 lecture04 rev2011

34© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Floating Point 1 & 2 - Functions 110 to 129

• ECMP - Float Compare FNC 110 • EZCP - Float Zone Compare FNC 111 • - Not Available FNC 112 to 117• EBCD - Float to Scientific FNC 118 • EBIN - Scientific to Float FNC 119

Page 35: Eee3420 lecture04 rev2011

35© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Floating Point 1 & 2 - Functions 110 to 129

Floating Point 2• EADD - Float Add FNC 120 • ESUB - Float Subtract FNC 121 • EMUL - Float Multiplication FNC 122 • EDIV - Float Division FNC 123 • - Not Available FNC 124 to 126• ESQR - Float Square Root FNC 127 • - Not Available FNC 128• INT - Float to Integer FNC 129

Page 36: Eee3420 lecture04 rev2011

36© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Trigonometry - FNC 130 to FNC 139• SIN - Sine FNC 130 • COS - Cosine FNC 131 • TAN - Tangent FNC 132 • - Not Available FNC 133 to 139

Page 37: Eee3420 lecture04 rev2011

37© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Data Operations 2 - FNC 140 to FNC 149

• - Not Available FNC 140 to 146• SWAP - Float to Scientific FNC 147 • - Not Available FNC 148 to 149

Page 38: Eee3420 lecture04 rev2011

38© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Positioning Control - FNC 150 to FNC 159• - Not Available FNC 150 to 154• ABS - Absolute current value read FNC 155 • ZRN - Zero return FNC 156 • PLSV - Pulse V FNC 157 • DRVI - Drive to increment FNC 158 • DRVA - Drive to absolute FNC 159

Page 39: Eee3420 lecture04 rev2011

39© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Real Time Clock Control - FNC 160 to FNC 169

• TCMP - Time Compare FNC 160 • TZCP - Time Zone Compare FNC 161 • TADD - Time Add FNC 162 • TSUB - Time Subtract FNC 163• - Not Available FNC 164 to 165• TRD - Read RTC data FNC 166 • TWR - Set RTC data FNC 167 • - Not Available FNC 168• HOUR - Hour meter FNC 169

Page 40: Eee3420 lecture04 rev2011

40© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Gray Codes - FNC 170 to FNC 179

• GRY - Decimal to Gray Code FNC 170 • GBIN - Gray Code to Decimal FNC 171 • - Not Available FNC 172 to 175• RD3A - Read FX0N-3A FNC 176 • WR3A - Write to FX0N-3A FNC 177

Page 41: Eee3420 lecture04 rev2011

41© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Additional Functions - FNC 180 to FNC 189

• EXTR - External ROM Function FNC 180

Page 42: Eee3420 lecture04 rev2011

42© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Inline Comparisons - FNC 220 to FNC 249

• LD - LoaD compare FNC 224 to 230 • AND - AND compare FNC 232 to 238 • OR - OR compare FNC 240 to 246

Page 43: Eee3420 lecture04 rev2011

43© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Applications of the Special Instructions

• Alternating ON/OFF States

Page 44: Eee3420 lecture04 rev2011

44© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Applications of the Special InstructionsMultiple-LED flasher • the LED group of 0,

2, 4 & 6 and LED group 1, 3, 5 & 7 will lit alternatively every second.

• the operand K2Y0 means two groups of 4-bits starting from Y0, that is, Y0 ~ Y7

• H55 = 0101 0101 B, HAA = 1010 1010 B

Page 45: Eee3420 lecture04 rev2011

45© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Applications of the Special Instructions

Using Battery Backed Devices• The status of the latched devices (in this example FX M coils M600

and M601) is retained during the power down. • Once the power is restored the battery backed M coils latch

themselves in again, i.e. the load M600 is used to drive M600

Page 46: Eee3420 lecture04 rev2011

46© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Applications of the Special InstructionsIndexing Through Multiple Display Data Values

Page 47: Eee3420 lecture04 rev2011

47© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Applications of the Special InstructionsIndexing Through Multiple Display Data Values• The contents of 10 counters are displayed in a

sequential operation. • The paging action occurs every time the input X11 is

received. • What actually happens is that the index register Z is

continually incremented until it equals 9. • When this happens the comparison instruction drives

M1 ON which in turn resets the current value of Z to 0 (zero).

Page 48: Eee3420 lecture04 rev2011

48© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Applications of the Special InstructionsReading And Manipulating Thumbwheel Data

• BIN instructions read in the data values• the first value, the single digit stored in D1, is combined with the

second data value D2 (containing 2 digits)• by the SMOV instruction, the contents of D1 is written to the third

digit of the contents of D2, the result is then stored back into D2

Page 49: Eee3420 lecture04 rev2011

49© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Applications of the Special InstructionsMeasuring a High Speed Pulse

Input – a 1 ms timer pulse measurement

• utilizes two interrupt routines to capture a pulse width and measure it with a 1ms timer

• the 1 ms timer T246 is driven when interrupt I001 is activated.

• when the input to X1 is removed the current value of the timer T246 is moved to data register D0 by interrupt program I100

• the operation complete flag M0 is then set ON, X10 acts as an enable/disable flag

Page 50: Eee3420 lecture04 rev2011

50© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Summary of Advanced PLC Programming

․ PLC systems offer sophisticated instructions to manipulate data of various kinds and perform complicated program logic flow

․ For advanced PLC programming, it is often machine specific.

․ Applied Instructions are the ‘specialist’ instructions of the FX family of PLC’s, they allow the user to perform complex data manipulations, mathematical operations while still being very easy to program and monitor.

Page 51: Eee3420 lecture04 rev2011

51© Vocational Training Council, Hong Kong.

EEE3420 Industrial Control

Week

Advanced PLC Programming

End of Lecture 4

RevisionMitsubishi PLC FX series programming manual