More Related Content
Similar to Eee3420 lecture04 rev2011
Similar to Eee3420 lecture04 rev2011 (20)
Eee3420 lecture04 rev2011
- 1. EEC3420 Industrial Control
Department of Electrical Engineering
│ Lecture 4 │
Advanced PLC Programming
© Vocational Training Council, Hong Kong. Week 1
- 2. EEE3420 Industrial Control
© Vocational Training Council, Hong Kong. Week
2
Learning Objectives
Understand the structure of Mitsubishi FX series PLC
Understand the advanced programming techniques of
PLC
- 3. EEE3420 Industrial Control
© Vocational Training Council, Hong Kong. Week
3
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
- 4. EEE3420 Industrial Control
© Vocational Training Council, Hong Kong. Week
4
Mitsubishi PLC FX series
model part number of Mitsubishi PLC FX series
- 5. EEE3420 Industrial Control
Hardware Details for Mitsubishi PLC
© Vocational Training Council, Hong Kong. Week
5
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.
- 6. EEE3420 Industrial Control
Hardware Details for Mitsubishi PLC
© Vocational Training Council, Hong Kong. Week
6
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
- 7. EEE3420 Industrial Control
Hardware Details for Mitsubishi PLC
© Vocational Training Council, Hong Kong. Week
7
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
- 8. EEE3420 Industrial Control
Hardware Details for Mitsubishi PLC
© Vocational Training Council, Hong Kong. Week
8
Other Relays
General Stable State Auxiliary Relays
Battery Backed/Latched Auxiliary Relays
Special diagnostic auxiliary relays
State Relays
Pointers
Interrupt Pointers
- 9. EEE3420 Industrial Control
Hardware Details for Mitsubishi PLC
© Vocational Training Council, Hong Kong. Week
9
Data
Constant K
Input Interrupt s
Timer Interrupts
Counter Interrupts
Constant H
Data Registers
- 10. EEE3420 Industrial Control
Hardware Details for Mitsubishi PLC
© Vocational Training Council, Hong Kong. Week
10
Data
General Use Registers
File Registers
Index Registers
Refer to the programmer’s manual for the use of these
registers
- 11. EEE3420 Industrial Control
Special Instructions of Mitsubishi PLC
Applied Instructions are the ‘specialist’ instructions of
the FX family of PLC’s, format is shown below.
© Vocational Training Council, Hong Kong. Week
11
- 12. EEE3420 Industrial Control
© Vocational Training Council, Hong Kong. Week
12
Representation of the operands
Bit devices, individual and grouped
Word devices
Interpreting word data
- 13. EEE3420 Industrial Control
© Vocational Training Council, Hong Kong. Week
13
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
- 14. EEE3420 Industrial Control
© Vocational Training Council, Hong Kong. Week
14
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
- 15. EEE3420 Industrial Control
© Vocational Training Council, Hong Kong. Week
15
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
- 16. EEE3420 Industrial Control
© Vocational Training Council, Hong Kong. Week
16
Signed binary representation
Signed binary representation of a group of 16 devices
- 17. EEE3420 Industrial Control
© Vocational Training Council, Hong Kong. Week
17
Hexadecimal Representation
Hexadecimal representation of a group of 16 devices
- 18. EEE3420 Industrial Control
© Vocational Training Council, Hong Kong. Week
18
BCD Representation
BCD (Binary Coded Decimal) representation of a group of 16
devices
- 19. EEE3420 Industrial Control
© Vocational Training Council, Hong Kong. Week
19
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
- 20. EEE3420 Industrial Control
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
© Vocational Training Council, Hong Kong. Week
20
data registers
- 21. EEE3420 Industrial Control
Scientific Notation
Scientific format cannot be used directly in
calculations, but it does provide an ideal method of
displaying the data on a monitoring interface
© Vocational Training Council, Hong Kong. Week
21
- 22. EEE3420 Industrial Control
© Vocational Training Council, Hong Kong. Week
22
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
- 23. EEE3420 Industrial Control
© Vocational Training Council, Hong Kong. Week
23
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
- 24. EEE3420 Industrial Control
Program Flow-Functions 00 to 09
© Vocational Training Council, Hong Kong. Week
24
• 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
- 25. EEE3420 Industrial Control
Move And Compare - Functions 10 to 19
© Vocational Training Council, Hong Kong. Week
25
• 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
- 26. EEE3420 Industrial Control
Arithmetic And Logical Operations -
Functions 20 to 29
© Vocational Training Council, Hong Kong. Week
26
• 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
- 27. EEE3420 Industrial Control
Rotation And Shift - Functions 30 to 39
© Vocational Training Council, Hong Kong. Week
27
• 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
- 28. EEE3420 Industrial Control
Data Operation - Functions 40 to 49
© Vocational Training Council, Hong Kong. Week
28
• 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
- 29. EEE3420 Industrial Control
High Speed Processing - Functions 50 to
59
© Vocational Training Council, Hong Kong. Week
29
• 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
- 30. EEE3420 Industrial Control
Handy Instructions - Functions 60 to 69
© Vocational Training Council, Hong Kong. Week
30
• 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
- 31. EEE3420 Industrial Control
External FX I/O Devices - Functions 70 to
79
© Vocational Training Council, Hong Kong. Week
31
• 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
- 32. EEE3420 Industrial Control
External FX I/O Devices - Functions 70 to
79
© Vocational Training Council, Hong Kong. Week
32
• 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
- 33. EEE3420 Industrial Control
External FX Serial Devices - Functions 80
to 89
© Vocational Training Council, Hong Kong. Week
33
• 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
- 34. EEE3420 Industrial Control
Floating Point 1 & 2 - Functions 110 to
129
© Vocational Training Council, Hong Kong. Week
34
• 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
- 35. EEE3420 Industrial Control
Floating Point 1 & 2 - Functions 110 to
129
© Vocational Training Council, Hong Kong. Week
35
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
- 36. EEE3420 Industrial Control
Trigonometry - FNC 130 to FNC 139
© Vocational Training Council, Hong Kong. Week
36
• SIN - Sine FNC 130
• COS - Cosine FNC 131
• TAN - Tangent FNC 132
• - Not Available FNC 133 to 139
- 37. EEE3420 Industrial Control
Data Operations 2 - FNC 140 to FNC 149
© Vocational Training Council, Hong Kong. Week
37
• - Not Available FNC 140 to 146
• SWAP - Float to Scientific FNC 147
• - Not Available FNC 148 to 149
- 38. EEE3420 Industrial Control
Positioning Control - FNC 150 to FNC 159
© Vocational Training Council, Hong Kong. Week
38
• - 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
- 39. EEE3420 Industrial Control
Real Time Clock Control - FNC 160 to
FNC 169
© Vocational Training Council, Hong Kong. Week
39
• 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
- 40. EEE3420 Industrial Control
Gray Codes - FNC 170 to FNC 179
© Vocational Training Council, Hong Kong. Week
40
• 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
- 41. EEE3420 Industrial Control
Additional Functions - FNC 180 to FNC
189
• EXTR - External ROM Function FNC 180
© Vocational Training Council, Hong Kong. Week
41
- 42. EEE3420 Industrial Control
Inline Comparisons - FNC 220 to FNC 249
© Vocational Training Council, Hong Kong. Week
42
• LD - LoaD compare FNC 224 to 230
• AND - AND compare FNC 232 to 238
• OR - OR compare FNC 240 to 246
- 43. EEE3420 Industrial Control
Applications of the Special Instructions
© Vocational Training Council, Hong Kong. Week
43
• Alternating ON/OFF States
- 44. EEE3420 Industrial Control
Applications of the Special Instructions
© Vocational Training Council, Hong Kong. Week
44
Multiple-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
- 45. EEE3420 Industrial Control
Applications of the Special Instructions
© Vocational Training Council, Hong Kong. Week
45
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
- 46. EEE3420 Industrial Control
Applications of the Special Instructions
Indexing Through Multiple Display Data Values
© Vocational Training Council, Hong Kong. Week
46
- 47. EEE3420 Industrial Control
Applications of the Special Instructions
Indexing Through Multiple Display Data Values
• The contents of 10 counters are displayed in a
© Vocational Training Council, Hong Kong. Week
47
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).
- 48. EEE3420 Industrial Control
Applications of the Special Instructions
Reading And Manipulating Thumbwheel Data
• BIN instructions read in the data values
• the first value, the single digit stored in D1, is combined with the
© Vocational Training Council, Hong Kong. Week
48
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
- 49. EEE3420 Industrial Control
Applications of the Special Instructions
Measuring 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
© Vocational Training Council, Hong Kong. Week
49
- 50. EEE3420 Industrial Control
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
© Vocational Training Council, Hong Kong. Week
50
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.
- 51. EEE3420 Industrial Control
© Vocational Training Council, Hong Kong. Week
51
Advanced PLC Programming
End of Lecture 4
Revision
Mitsubishi PLC FX series programming manual