Người sử dụng có thể lập trình để thực hiện một loạt trình tự các sự kiện. Các sự kiện này được kích hoạt bởi tác nhân kích thích (ngõ vào) tác động vào PLC hoặc qua các hoạt động có trễ như thời gian định thì hay các sự kiện được đếm. PLC dùng để thay thế các mạch relay (rơ le) trong thực tế. PLC hoạt động theo phương thức quét các trạng thái trên đầu ra và đầu vào. Khi có sự thay đổi ở đầu vào thì đầu ra sẽ thay đổi theo. Ngôn ngữ lập trình của PLC có thể là Ladder hay State Logic. Hiện nay có nhiều hãng sản xuất ra PLC như INVT, AllenBradley,Omron, Honeywell...
Trang 13.1 Basic Instructions and Step Ladder Instructions
ES includes ES/EX/SS; SA includes SA/SX/SC; EH includes EH2/SV/EH3/SV2
For EH series MPU, the execution speed in the brackets ( ) refers to the execution speed of designated operand
M1536 ~ M4095
Basic Instructions
Execution speed (us) Instruction
Code
STEP
LD Loading in A contact X, Y, M, S, T, C 3.8 3.8 0.24 (0.56) 1~3
LDI Loading in B contact X, Y, M, S, T, C 3.88 3.88 0.24 (0.56) 1~3
AND Series connection- A contact X, Y, M, S, T, C 2.32 2.32 0.24 (0.56) 1~3
ANI Series connection- B contact X, Y, M, S, T, C 2.4 2.4 0.24 (0.56) 1~3
OR Parallel connection- A contact X, Y, M, S, T, C 2.32 2.32 0.24 (0.56) 1~3
ORI Parallel connection- B contact X, Y, M, S, T, C 2.4 2.4 0.24 (0.56) 1~3
ANB Series connection- loop blocks N/A 1.76 1.76 0.24 1~3
ORB Parallel connection- loop blocks N/A 1.76 1.76 0.24 1~3
MPS Store the current result of the internal
MRD Reads the current result of the
MPP Pops (recalls and removes) the
Output instructions
Execution speed (us) Instruction
Code
STEP
RST Clear the contacts or the registers Y, M, S, T, C, D, E, F 7.8 7.8 0.24 (0.56) 3
Timers, Counters
Execution speed (us) API Instruction
STEP
97 CNT 16-bit counter C-K or C-D (16 bits) 9.7 9.7 12.8 4
97 DCNT 32-bit counter C-K or C-D (32 bits) 10.3 10.3 14.3 6
Trang 2 Main control instructions
Execution speed (us) Instruction
Code
STEP
Instructions for detecting the contacts of rising-/falling-edge
Execution speed (us)
API Instruction
90 LDP Rising-edge detection operation X, Y, M, S, T, C 5.1 5.1 0.56 (0.88) 3
91 LDF Falling-edge detection operation X, Y, M, S, T, C 5.1 5.1 0.56 (0.88) 3
92 ANDP Rising-edge series connection X, Y, M, S, T, C 4.9 4.9 0.56 (0.88) 3
93 ANDF Falling-edge series connection X, Y, M, S, T, C 4.9 4.9 0.56 (0.88) 3
94 ORP Rising-edge parallel connection X, Y, M, S, T, C 4.9 4.9 0.56 (0.88) 3
95 ORF Falling-edge parallel connection X, Y, M, S, T, C 4.9 4.9 0.56 (0.88) 3
Rising-/falling-edge output instructions
Execution speed (us)
API Instruction
End instruction
Execution speed (us)
Instruction
Other instructions
Execution speed (us)
API Instruction
Trang 3 Step ladder instructions
Execution speed (us) Instruction
Code
STEP STL Step transition ladder start instruction S 11.6 10.6 0.56 1 RET Step transition ladder return instruction N/A 7.04 6.04 0.24 1 Note 1: ES includes ES/EX/SS; SA includes SA/SX/SC; EH includes EH/EH2/SV
Note 2: For EH series MPU, the execution speed in the brackets ( ) refers to the execution speed of designated
operand M1536 ~ M4095
3.2 Explanations on Basic Instructions
LD Loading in A contact 1
Controllers
ES EX SS SA SX SC EH2 SV EH3 SV2
X0 ~ X377 Y0 ~ Y377 M0 ~ M4095 S0 ~ S1023 T0 ~ T255 C0 ~ C255 D0 ~ D9999
Operand
Explanations:
The LD instruction is used on the A contact that has its start from the left BUS or the A contact that is the start of a
contact circuit The functions are to save the present contents and store the acquired contact status into the
accumulative register
Program Example:
Ladder diagram: Instruction code: Operation:
LD X0 Loading in contact A of X0 AND X1 Connecting to contact A of X1 in series
X0 X1
Y1
OUT Y1 Driving Y1 coil Note: DVP-EH3 series PLCs whose version is 1.40 and DVP-SV2 series PLCs whose version is 1.20 support the
operands X, Y, M, and S These operands can be qualified by E or F, e.g LD X0E1
LDI Loading in B contact 1
Controllers
ES EX SS SA SX SC EH2 SV EH3 SV2
X0 ~ X377 Y0 ~ Y377 M0 ~ M4095 S0 ~ S1023 T0 ~ T255 C0 ~ C255 D0 ~ D9999
Operand
Explanations:
The LDI instruction is used on the B contact that has its start from the left BUS or the B contact that is the start of a
contact circuit The functions are to save the present contents and store the acquired contact status into the
accumulative register
Trang 4Program Example:
Ladder diagram: Instruction code: Operation:
LDI X0 Loading in contact B of X0 AND X1 Connecting to contact A of X1 in series
X0 X1
Y1
OUT Y1 Driving Y1 coil Note: DVP-EH3 series PLCs whose version is 1.40 and DVP-SV2 series PLCs whose version is 1.20 support the operands X, Y, M, and S These operands can be qualified by E or F, e.g LDI X0E1
AND Series connection- A contact 1
Controllers
ES EX SS SA SX SC EH2 SV EH3 SV2
X0 ~ X377 Y0 ~ Y377 M0 ~ M4095 S0 ~ S1023 T0 ~ T255 C0 ~ C255 D0 ~ D9999
Operand
Explanations:
The AND instruction is used in the series connection of A contact The functions are to read out the status of present d series connection contacts and perform the “AND” operation with the logical operation result obtained The final result will be store in the accumulative register
Program Example:
Ladder diagram: Instruction code: Operation:
LDI X1 Loading in contact B of X1
AND X0 Connecting to contact A of X0 in series
X0
X1
Y1
OUT Y1 Driving Y1 coil Note: DVP-EH3 series PLCs whose version is 1.40 and DVP-SV2 series PLCs whose version is 1.20 support the operands X, Y, M, and S These operands can be qualified by E or F, e.g AND X0E1
ANI Series connection- B contact 1
Controllers
ES EX SS SA SX SC EH2 SV EH3 SV2
X0 ~ X377 Y0 ~ Y377 M0 ~ M4095 S0 ~ S1023 T0 ~ T255 C0 ~ C255 D0 ~ D9999
Operand
Explanations:
The ANI instruction is used in the series connection of B contact The functions are to read out the status of present designated series connection contacts and perform the “AND” operation with the logical operation result obtained The final result will be store in the accumulative register
Trang 5Program Example:
Ladder diagram: Instruction code: Operation:
LD X1 Loading in contact A of X1
ANI X0 Connecting to contact B of X0 in series
X0
X1
Y1
OUT Y1 Driving Y1 coil Note: DVP-EH3 series PLCs whose version is 1.40 and DVP-SV2 series PLCs whose version is 1.20 support the operands X, Y, M, and S These operands can be qualified by E or F, e.g ANI X0E1
OR Parallel connection- A contact 1
Controllers
ES EX SS SA SX SC EH2 SV EH3 SV2
X0 ~ X377 Y0 ~ Y377 M0 ~ M4095 S0 ~ S1023 T0 ~ T255 C0 ~ C255 D0 ~ D9999
Operand
Explanations:
The OR instruction is used in the parallel connection of A contact The functions are to read out the status of present designated parallel connection contacts and perform the “OR” operation with the logical operation result obtained The final result will be store in the accumulative register
Program Example:
Ladder diagram: Instruction code: Operation:
LD X0 Loading in contact A of X0
OR X1 Connecting to contact A of X1 in parallel
X0
X1
Y1
OUT Y1 Driving Y1 coil
Note: DVP-EH3 series PLCs whose version is 1.40 and DVP-SV2 series PLCs whose version is 1.20 support the operands X, Y, M, and S These operands can be qualified by E or F, e.g OR X1E1
ORI Parallel connection- B contact 1
Controllers
ES EX SS SA SX SC EH2 SV EH3 SV2
X0 ~ X377 Y0 ~ Y377 M0 ~ M4095 S0 ~ S1023 T0 ~ T255 C0 ~ C255 D0 ~ D9999
Operand
Explanations:
The OR instruction is used in the parallel connection of B contact The functions are to read out the status of present designated parallel connection contacts and perform the “OR” operation with the logical operation result obtained The final result will be store in the accumulative register
Trang 6Program Example:
Ladder diagram: Instruction code: Operation:
LD X0 Loading in contact A of X0
ORI X1 Connecting to contact B of X1 in parallel
X0
X1
Y1
OUT Y1 Driving Y1 coil
Note: DVP-EH3 series PLCs whose version is 1.40 and DVP-SV2 series PLCs whose version is 1.20 support the operands X, Y, M, and S These operands can be qualified by E or F, e.g ORI X1E1
ANB Series connection- loop blocks 1
Controllers
ES EX SS SA SX SC EH2 SV EH3 SV2
Explanations:
To perform the “AND” operation of the preserved logic results and content in the accumulative register
Program Example:
Ladder diagram: Instruction code: Operation:
LD X0 Loading in contact A of X0
ORI X2 Connecting to contact B of X2 in parallel
LDI X1 Loading in contact B of X1
OR X3 Connecting to contact A of X3 in parallel
ANB Connecting circuit block in series
X0
X2
Y1 X1
X3
ANB
Block A Block B
OUT Y1 Driving Y1 coil
ORB Parallel connection- loop
Controllers
ES EX SS SA SX SC EH2 SV EH3 SV2
Explanations:
To perform the “OR” operation of the preserved logic results and content in the accumulative register
Program Example:
Ladder diagram: Instruction code: Operation:
LD X0 Loading in contact A of X0 ANI X1 Connecting to contact B of X1 in series LDI X2 Loading in contact B of X2
AND X3 Connecting to contact A of X3 in series
ORB Connecting circuit block in parallel
X0
X2
Y1 X1
X3
ORB Block A
Block B
OUT Y1 Driving Y1 coil
Trang 7Mnemonic Function Program steps
MPS Store the current result of
the internal PLC operations 1
Controllers
ES EX SS SA SX SC EH2 SV EH3 SV2
Explanations:
To save the content in the accumulative register into the operational result (the pointer of operational result will plus 1)
MRD Reads the current result of
the internal PLC operations 1
Controllers
ES EX SS SA SX SC EH2 SV EH3 SV2
Explanations:
To read the operational result and store it into the accumulative register (the pointer of operational result stays intact)
MPP Pops (recalls and removes)
the currently stored result 1
Controllers
ES EX SS SA SX SC EH2 SV EH3 SV2
Explanations:
To retrieve the previous preserved logical operation result and store it into the accumulative register (the pointer of operational result will minus 1).
Program Example:
Ladder diagram: Instruction code: Operation:
LD X0 Loading in contact A of X0
MPS Saving into stack AND X1 Connecting to contact A of X1 in series OUT Y1 Driving Y1 coil
AND X2 Connecting to contact A of X2 in series OUT M0 Driving M0 coil
MPP Reading from stack and pop pointer OUT Y2 Driving Y2 coil
X0
Y1 X1
M0 X2
Y2 END MPP
MRD
MPS
Trang 8Mnemonic Function Program steps
Controllers
ES EX SS SA SX SC EH2 SV EH3 SV2
X0 ~ X377 Y0 ~ Y377 M0 ~ M4095 S0 ~ S1023 T0 ~ T255 C0 ~ C255 D0 ~ D9999
Operand
Explanations:
1 To output the logical operation result before OUT instruction into a designated device
2 Actions of coil contact:
OUT instruction
Contact Operational result
Coil
A contact (normally open) B contact (normally closed)
Program Example:
Ladder diagram: Instruction code: Operation:
LDI X0 Loading in contact B of X0 AND X1 Connecting to contact A of X1 in series
X0 X1
Y1
OUT Y1 Driving Y1 coil Note: DVP-EH3 series PLCs whose version is 1.40 and DVP-SV2 series PLCs whose version is 1.20 support the operands Y, M, and S These operands can be qualified by E or F, e.g OUT Y1E2
Controllers
ES EX SS SA SX SC EH2 SV EH3 SV2
X0 ~ X377 Y0 ~ Y377 M0 ~ M4095 S0 ~ S1023 T0 ~ T255 C0 ~ C255 D0 ~ D9999
Operand
Explanations:
When the SET instruction is driven, its designated device will be “On” and keep being On both when SET instruction
is still being driven or not driven Use RST instruction to set “Off” the device
Program Example:
Ladder diagram: Instruction code: Operation:
LD X0 Loading in contact A of X0 ANI Y0 Connecting to contact B of Y0 in series X0 Y0
Y1 SET
SET Y1 Y1 latched (On) Note: DVP-EH3 series PLCs whose version is 1.40 and DVP-SV2 series PLCs whose version is 1.20 support the operands Y, M, and S These operands can be qualified by E or F, e.g SET Y1E2
Trang 9Mnemonic Function Program steps
RST Clear the contacts or
Controllers
ES EX SS SA SX SC EH2 SV EH3 SV2
X0 ~ X377 Y0 ~ Y377 M0 ~
M4095 S0 ~ S1023 T0 ~ T255 C0 ~ C255
D0 ~ D9999
E0 ~ E7 F0 ~ F7
Operand
Explanations:
1 When the RST instruction is driven, the actions of the designated devices are:
Y, M, S, Coil and contact will be set to “Off”
T, C Present values of the timer or counter will be set to “0”, and the coil and contact will be set to
“Off”
D, E, F The content will be set to “0”
2 If RST instruction is not being executed, the status of the designated device will stay intact
Program Example:
Ladder diagram: Instruction code: Operation:
LD X0 Loading in contact A of X0
X0
Y5
Note: DVP-EH3 series PLCs whose version is 1.40 and DVP-SV2 series PLCs whose version is 1.20 support the operands Y, M, and S These operands can be qualified by E or F, e.g RST Y5E2
Controllers
ES EX SS SA SX SC EH2 SV EH3 SV2
T-K T0 ~ T255, K0 ~ K32,767
Operand
T-D T0 ~ T255, D0 ~ D9999
Explanations:
When TMR instruction is executed, the designated coil of the timer will be On and the timer will start to time When the set value in the timer is reached (present ≥ set value), the contact will be:
NO (Normally Open) contact Open collector
NC (Normally Closed) contact Close collector
Program Example:
Ladder diagram: Instruction code: Operation:
LD X0 Loading in contact A of X0 T5 timer
X0
T5
TMR T5 K1000 Set value in timer T5 as K1,000
Remarks:
See the specification of each model for the range of operand T
Trang 10Mnemonic Function Program steps
ATMR 16-bit contact type
Controllers
ES EX SS SA SX SC EH2 SV EH3 SV2
T-K T0 ~ T255,K0 ~ K32,767
Operand
T-D T0 ~ T255, D0 ~ D11999
Explanations:
1 The instruction ATMR corresponds to the combination of AND and TMR If the contact preceding ATMR is ON, the timer specified will begin to count When the count value is greater than or equal to the setting value, the AND contact is ON If the contact preceding ATMR is not ON, ATMR will automatically clear the count value
Program Example:
Ladder diagram: Instruction code: Operation:
LD X0 Loading in contact A of X0
ATMR T5 K100 The setting value of T5 is K100
X0
T5 ATMR K1000 Y0
OUT Y0 When the count value is greater than or equal
to the setting value, Y0 is ON
Remarks:
1 Please refer to specifications for the model used for more information about the timers which can be used
2 EH3 series PLCs whose version is 1.40 and SV2 series PLCs whose version is 1.20 support ATMR
Controllers
ES EX SS SA SX SC EH2 SV EH3 SV2
C-K C0 ~ C199, K0~K32,767
Operand
C-D C0 ~ C199, D0 ~ D9999
Explanations:
3 When the CNT instruction goes from Off to On, the designated counter coil will be driven, and the present value
in the counter will plus 1 When the counting reaches the set value (present value = set value), the contact will be:
NO (Normally Open) contact Open collector
NC (Normally Closed) contact Close collector
4 If there are other counting pulse inputs after the counting reaches its target, the contact and present value will stay intact Use RST instruction to restart or reset the counting
Program Example:
Ladder diagram: Instruction code: Operation:
LD X0 Loading in contact A of X0
X0
C20
CNT C20 K100 Set value in counter C20 as K100