Instruction Manual of DELIXI PLC
Instruction Manual of DELIXI PLC
Instruction Manual of DELIXI PLC
Notes
1. The instructions in this chapter perform bit logic operations on the corresponding bit
registers.
Numbering
Register type Description Range
system
■ FGs_16MR/FGs_16MT
Input bit-register of PLC, some of them correspond to
0~77
X actual input contacts, and the rest are similar to Octal
■ Else
internal bit registers.
0~177
■ FGs_16MR/FGs_16MT
Output bit-register of PLC, some of them correspond
0~77
Y to actual output contacts, and the rest are similar to Octal
■ Else
internal bit registers.
0~177
Table 1.1. 1
1
LD/AND/OR
Instruction introduction
1. This instruction is NO (normally open) contact operation start instruction, and the
specific bit register is set as an input contact. When value of the bit register is 1,
contact closes; When the value of the bit register is 0, contact opens.
3. In instruction table, input contacts can also be connected through AND (NO contact
(refer to example).
Setting data
Table 1.2. 1
Example
Instruction table:
Network 000
LD X000 //add normal open coil X000, coil will be closed when X000 is ON
OR X002 //add normal open coil X002 to make parallel connection with X000
AND X001 //add normal open coil X001 to make series connection with X000
OUT Y000 //add Y000 as output contact
Ladder diagram:
2
Figure 1.2. 1
3
LDIM/ANDIM/ORIM
Instruction introduction
and the specific bit register is set as an input contact. When value of the bit register is
1, contact closes immediately; When the value of the bit register is 0, contact opens
immediately, and the specified bit does not depend on the scan cycle to update, it will
be updated immediately.
3. In instruction table, input contacts can also be connected through ANDIM (immediate
Setting data
Table 1.3. 1
Example
Instruction table:
Network 000
LDIM X000 //add immediate normally open coil X000
ORIM X002 //add immediate normally open coil X002 to make parallel connection with X000
ANDIM X001 //add immediate normally open coil X001 to make series connection with X000
OUT Y000 //add Y000 as output contact
4
Ladder diagram:
Figure 1.3. 1
LDI/ANDI/ORI
Instruction introduction
1. This instruction is NC (normally close) contact operation start instruction, and the
specific bit register is set as an input contact.When the value of the bit register is 1,
contact opens; When the value of the bit register is 0, the contact closes.
3. In the instruction table, input contacts can also be connected through ANDI (NC
contact series connection instruction) and ORI (NC contact parallel connection instruction)
(refer to example).
Setting data
Table 1.4. 1
5
Example
Instruction table:
Network 000
LDI X000 //add normally close coil X000
ORI X002 //add normally close coil X002 to make parallel connection with X000
ANDI X001 //add normally close coil X001 to make series connection with X000
OUT Y000 //add Y000 as output contact
Ladder diagram:
Figure 1.4. 1
LDIIM/ANDIIM/ORIIM
Instruction introduction
and the specific bit register is set as an input contact. When the value of the bit
register is 1, contact opens immediately; When the value of the bit register is 0,
contact closes immediately. The specified bit does not depend on the scan cycle to
Setting data
Table 1.5. 1
Example
Instruction table:
Network 000
LDIIM X000 //add immediate normally close coil X000
ORIIM X002 //add immediate normally close coil X002 to make parallel connection with X000
ANDIIM X001 //add immediate normally close coil X001 to make series connection with X000
OUT Y000 //add Y000 as output contact
Ladder diagram:
Figure 1.5. 1
7
LDP/ANDP/ORP
Instruction introduction
1. This instruction is a rising edge pulse operation start instruction, and the specific bit
register is set as an input contact. Contact closes for a scan period only at rising edge
3. In the instruction table, input contacts can also be connected through ANDP (rising
edge pulse series connection instruction) and ORP (rising edge pulse parallel
Setting data
Table 1.6. 1
Example
Instruction table:
Network 000
LD X000 //add normal open coil X000, coil will be closed when X000 is ON
OR X002 //add normal open coil X002 to make parallel connection with X000
ANDP X001 //add rising edge pulse coil X001 to make series connection with X000
SET Y000 K1 //set Y000
Ladder diagram:
8
Figure 1.6. 1
LDF/ANDF/ORF
Instruction introduction
1. This instruction is falling edge pulse operation start instruction, and the specific bit
register is set as an input contact. Contact closes for a scan period only at the falling
3. In the instruction table, input contacts can also be connected through ANDF (falling
edge pulse series connection instruction) and ORF (falling edge pulse parallel
Setting data
(s) Bit register used as falling edge pulse input contact X/Y/M/T/C/S - bool
Table 1.7. 1
Example
Instruction table:
9
Network 000
LD X000 //add normal open coil X000, coil will be closed when X000 is ON
OR X002 //add normal open coil X002 to make parallel connection with X000
ANDP X001 //add falling edge pulse coil X001 to make series connection with X000
SET Y000 K1 //set Y000
Ladder diagram:
Figure 1.7. 1
MEP
Instruction introduction
1. When the operation result before the MEP instruction is a rising edge (OFF→ON), the
instruction will become ON (conduction state); otherwise, the instruction will become
Example
Instruction table:
Network 000
LD X000 //add normal open coil X000, coil will be closed when X000 is ON
10
OR X002 //add normal open coil X002 to make parallel connection with X000
MEP //turn ON at rising edge of ahead operation result
SET Y000 K1 //set Y000
Ladder diagram:
Figure 1.8. 1
MEF
Instruction introduction
1. When the operation result before the MEP instruction is a falling edge (ON → OFF),
the instruction will become ON (conduction state); otherwise, the instruction will
Example
Instruction table:
Network 000
LD X000 //add normal open coil X000, coil will be closed when X000 is ON
11
OR X002 //add normal open coil X002 to make parallel connection with X000
MEF //turn ON at falling edge of ahead operation result
SET Y000 K1 //set Y000
Ladder diagram:
Figure 1.9. 1
INV
Instruction introduction
Example
Instruction table:
Network 000
LD M000 //add normal open coil M000
INV //invert the operation result
OUT Y001 //turn ON when M000 is OFF, turn OFF when M000 is ON
Ladder diagram:
12
Figure 1.10. 1
OUT
Instruction introduction
Setting data
Table 1.11. 1
Example
Instruction table:
Network 000
LD X000 //add normal open coil X000
OUT Y000 //turn ON when X000 is ON, turn OFF when X000 is OFF
Ladder diagram:
13
Figure 1.11. 1
Attention
Do not add two or more OUT instructions of same bit-register in the ladder diagram,
otherwise the output may be prohibited.The auxiliary relay M can be used to solve this
problem
Figure 1.11. 2
OUTIM
Instruction introduction
1. This instruction will immediately output the result of the operation to the specified
register. When the instruction is executed, the specified bit does not depend on the scan
cycle to update
14
Setting data
Table 1.12. 1
Example
Instruction table:
Network 000
LD X000 //add normal open coil X000
OUTIM Y000 //turn ON immediately when X000 is ON, turn OFF immediately when X000 is OFF
Ladder diagram:
Figure 1.12. 1
SET
Instruction introduction
1. This instruction sets the specified bit register and the following bit (set to 1). Set (N)
operands starting from the specified address bit (BIT), and the maximum number of
15
Setting data
(L) Numbers of set operation K/H depends on case 32-bit unsigned integer
Table 1.13. 1
Example
Instruction table:
Network 000
LD X000 //add normal open coil X000
SET Y000 K16 //set bits from Y000 to Y015
Ladder diagram:
Figure 1.13 1
SETIM
Instruction introduction
1. The instruction will immediately set the specified bit register and the following bit (set
to 1). Immediately set (N) operands starting from the specified address bit (BIT), and
16
the maximum number of points is set according to the operand type. Set immediately
Setting data
(L) Numbers of set operation K/H depends on case 32-bit unsigned integer
Table 1.14. 1
Example
Instruction table:
Network 000
Ladder diagram:
Figure 1.14. 1
RST
Instruction introduction
1. This instruction resets (to 0) bits of specified bit-register and the following bits.Reset
17
(N) operands starting from the specified address bit (BIT). The maximum number of
Setting data
(L) Numbers of reset operation K/H depends on case 32-bit unsigned integer
Table 1.15. 1
Example
Instruction table:
Network 000
Ladder diagram:
Figure 1.15. 1
18
RSTIM
Instruction introduction
1. This instruction immediately reset (to 0) bits of specified bit-register and the following
bits, Set immediately dose not relying on the PLC scan cycle to update.
Setting data
(L) Numbers of reset operation K/H depends on case 32-bit unsigned integer
Table 1.16. 1
Example
Instruction table:
Network 000
LD X000 //add normal open coil X000
RSTIM Y000 K16 //reset bits from Y000 to Y015 immediately
Ladder diagram:
Figure 1.16. 1
19
ALT
Instruction introduction
When the specified operand changes from OFF to ON, the instruction makes the specified
operand alternate between 1 (ON) and 0 (OFF). The specified bit-register will reverse (ON
<-> OFF) at each scan period of PLC. When this instruction is disabled, the reversing will
stop.
Setting data
Table 1.17. 1
Example
Instruction table:
Network 000
LD X000 //add normal open coil X000
ALT Y000 //Y0 will reverse at each period time of PLC when X000 is ON
Ladder diagram:
Figure 1.17. 1
20
ALTP
Instruction introduction
When the specified operand changes from OFF to ON, the instruction makes the specified
Setting data
Table 1.18. 1
Example
Instruction table:
Network 000
LD X000 //add normal open coil X000
ALTP Y000 //Y0 will reverse once at rising edge of X000.
Ladder diagram:
Figure 1.18. 1
21
22
Compare Instructions
Notes
1. Instructions in this chapter do compare operations to the values of data with different
types.
2. The data has 3 types: WORD, DWORD and FLOAT. Details refer to Table 2.1.1.
Table 2.1. 1
3. There are several types of registers or inputs that can be used for comparison, refer
to Table 2.1.2.
Register/input Numbering
Description Range
type system
K Decimal constant, can be an integer or a decimal. - -
H Hexadecimal code, used to fill the bytes of register. - -
Table 2.1. 2
23
LDW=/LDD=/LDF=
Instruction introduction
1. These instructions are EQ (equal to) comparison contact instructions that compare
2. When the first value is equal to the second, the contact closes, otherwise the contact
opens.
4. In instruction table, input contacts can also be connected through AW=/AD=/AF= (EQ
Setting data
LDW=
Table 2.2. 1
LDD=
Table 2.2. 2
LDF=
24
Table 2.2. 3
Example
Instruction table:
Network 000
LDW= D0 D1 //make EQ comparison between D0 and D1
ORW= D4 H0123 //make EQ comparison between D4 and H0123, parallel connect the result
AW= D2 D3 //make EQ comparison between D2 and D3, series connect the result
LDD= D6 D8 //make EQ comparison between D6(DWORD) and D8(DWORD)
ORD= D14 K888 //make EQ comparison between D14(DWORD) and K888, parallel connect the
result
AD= D10V0 D12Z0 //make EQ comparison between D10V0 (D0 with address offset of V0) and
D12Z0 (D12 with address offset of Z0), series connect the result
LDF= D18 D20 //make EQ comparison between D18(FLOAT) and D20(FLOAT)
ORF= D26 K1.234567 //make EQ comparison between D26(FLOAT) and K1.234567, series
connect the result
AF= D22 D24 //make EQ comparison between D22(FLOAT) and D24(FLOAT), parallel connect
the result
ORB //parallel connect
ORB //parallel connect
OUT Y000 //output result to Y000
Ladder diagram:
Figure 2.2. 1
25
LDW<>/LDD<>/LDF<>
Instruction introduction
1. These instructions are NE (not equal to) comparison contact instructions that
2. When the first value is unequal to the second, the contact closes, otherwise the
contact opens.
(refer to example).
Setting data
LDW<>
Table 2.3. 1
LDD<>
Table 2.3. 2
LDF<>
26
Inputs/outputs Description Operand Range Data type
Table 2.3. 3
Example
Instruction table:
Network 000
LDW<> D0 D1 //make NE comparison between D0 and D1
ORW<> D4 D5 //make NE comparison between D4 and D5, parallel connect the result
AW<> D2 D3 //make NE comparison between D2 and D3, series connect the result
LDD<> D6 D8 //make NE comparison between D6(DWORD) and D8(DWORD)
ORD<> D14 D16 //make NE comparison between D14(DWORD) and D16(DWORD), parallel
connect the result
AD<> D10 D12 //make NE comparison between D10 and D12, series connect the result
LDF<> D18 D20 //make NE comparison between D18(FLOAT) and D20(FLOAT)
ORF<> D26 D28 //make NE comparison between D26(FLOAT) and D28(FLOAT), series connect
the result
AF<> D22 D24 //make NE comparison between D22(FLOAT) and D24(FLOAT), parallel connect
the result
ORB //parallel connect
ORB //parallel connect
OUT Y000 //output result to Y000
Ladder diagram:
Figure 2.3. 1
27
LDW>=/LDD>=/LDF>=
Instruction introduction
1. These instructions are GE (greater than or equal to) comparison contact instructions
2. When the first value is greater than or equal to the second, the contact closes,
Setting data
LDW>=
Table 2.4. 1
LDD>=
Table 2.4. 2
LDF>=
28
Table 2.4. 3
Example
Instruction table:
Network 000
Ladder diagram:
Figure 2.4. 1
29
LDW<=/LDD<=/LDF<=
Instruction introduction
1. These instructions are LE (less than or equal to) comparison contact instructions that
2. When the first value is less than or equal to the second, the contact closes, otherwise
Setting data
LDW<=
Table 2.5. 1
LDD<=
Table 2.5. 2
LDF<=
30
(s2) Second value to compare K/D/CV32 ±1.17549e-38F~±3.40282e+38F float
Table 2.5. 3
Example
Instruction table:
Network 000
LDW<= D0 D1 //make LE comparison between D0 and D1
ORW<= D4 D5 //make LE comparison between D4 and D5, parallel connect the result
AW<= D2 D3 //make LE comparison between D2 and D3, series connect the result
LDD<= D6 D8 //make LE comparison between D6(DWORD) and D8(DWORD)
ORD<= D14 D16 //make LE comparison between D14(DWORD) and D16(DWORD), parallel connect
the result
AD<= D10 D12 //make LE comparison between D10 and D12, series connect the result
LDF<= D18 D20 //make LE comparison between D18(FLOAT) and D20(FLOAT)
ORF<= D26 D28 //make LE comparison between D26(FLOAT) and D28(FLOAT), series connect
the result
AF<= D22 D24 //make LE comparison between D22(FLOAT) and D24(FLOAT), parallel connect
the result
ORB //parallel connect
ORB //parallel connect
OUT Y000 //output result to Y000
Ladder diagram:
31
Figure 2.5. 1
LDW>/LDD>/LDF>
Instruction introduction
2. When the first value is greater than the second, the contact closes, otherwise the
contact opens.
4. In instruction table, input contacts can also be connected through AW>/AD>/AF> (GT
Setting data
LDW>
Table 2.6. 1
LDD>
Table 2.6. 2
LDF>
Table 2.6. 3
Example
Instruction table:
Network 000
LDW> D0 D1 //make GT comparison between D0 and D1
ORW> D4 D5 //make GT comparison between D4 and D5, parallel connect the result
AW> D2 D3 //make GT comparison between D2 and D3, series connect the result
LDD> D6 D8 //make GT comparison between D6(DWORD) and D8(DWORD)
ORD> D14 D16 //make GT comparison between D14(DWORD) and D16(DWORD), parallel
connect the result
AD> D10 D12 //make GT comparison between D10 and D12, series connect the result
LDF> D18 D20 //make GT comparison between D18(FLOAT) and D20(FLOAT)
ORF> D26 D28 //make GT comparison between D26(FLOAT) and D28(FLOAT), series
connect the result
AF> D22 D24 //make GT comparison between D22(FLOAT) and D24(FLOAT), parallel connect
the result
ORB //parallel connect
ORB //parallel connect
OUT Y000 //output result to Y000
33
Ladder diagram:
Figure 2.6. 1
LDW</LDD</LDF<
Instruction introduction
1. These instructions are LT (less than) comparison contact instructions that compare
2. When the first value is less than the second, the contact closes, otherwise the contact
opens.
4. In instruction table, input contacts can also be connected through AW</AD</AF< (LT
34
Setting data
LDW<
Table 2.7. 1
LDD<
Table 2.7. 2
LDF<
Table 2.7. 3
Example
Instruction table:
Network 000
LDW< D0 D1 //make LT comparison between D0 and D1
ORW< D4 D5 //make LT comparison between D4 and D5, parallel connect the result
AW< D2 D3 //make LT comparison between D2 and D3, series connect the result
LDD< D6 D8 //make LT comparison between D6(DWORD) and D8(DWORD)
ORD< D14 D16 //make LT comparison between D14(DWORD) and D16(DWORD), parallel connect
the result
AD< D10 D12 //make LT comparison between D10 and D12, series connect the result
LDF< D18 D20 //make LT comparison between D18(FLOAT) and D20(FLOAT)
ORF< D26 D28 //make LT comparison between D26(FLOAT) and D28(FLOAT), series
connect the result
AF< D22 D24 //make LT comparison between D22(FLOAT) and D24(FLOAT), parallel connect
the result
35
ORB //parallel connect
ORB //parallel connect
OUT Y000 //output result to Y000
Ladder diagram:
Figure 2.7. 1
CMP/CMPD/CMPF
Instruction introduction
bit-registers. CMP is for WORD type value, CMPD is for DWORD type value, CMPF
2. When the first input value is greater than the second, the first of output bit-registers is
set to 1; When the first input value is equal to the second, the second of output
bit-registers is set to 1; When the first input value is less than the second, the third of
36
Setting data
CMP
Table 2.8. 1
CMPD
Table 2.8. 2
CMPF
Table 2.8. 3
37
Example
Instruction table:
Network 000
LD M0
CMP D0 D1 M100 //compare D0 and D1
POP
LD M100 //if D0>D1, set M100 to ON
OUT M1000
POP
LD M101 //if D0=D1, set M101 to ON
OUT M1001
POP
LD M102 //if D0<D1, set M102 to ON
OUT M1002
POP
Ladder diagram:
Figure 2.8. 1
ZCP/ZCPD/ZCPF
Instruction introduction
interval consists of 2 limit values, and output the result to 3 continuous bit-registers.
38
ZCP is for WORD type value, ZCPD is for DWORD type value, ZCPF is for FLOAT
type value.
2. When comparison value is less than the lower-limit value, the first output bit-registers
is set to 1; When comparison value is between the lower-limit value and upper-limit
value (no greater than lower-limit value and no less than upper-limit value), the
second output bit-registers is set to 1; When comparison value is greater than the
Setting data
ZCP
Table 2.9. 1
CMPD
Table 2.9. 2
39
CMPF
Table 2.9. 3
Example
Instruction table:
Network 000
LD M0
ZCP K100 K200 D0 Y000 //When D0<K100, Y000 is ON;
When K100<=D0<=K200, Y001 is ON;
When D0>K200, Y002 is ON
Ladder diagram:
Figure 2.9. 1
Conversion Instructions
Notes
40
Figure 3.1. 1
2. BCD code is binary-coded decimal code, it converts each decimal digit of the number
Figure 3.1. 2
3. Conversion error may occur, and there are system special function registers record
these errors:
M8168 record if operation makes overflow, when DWORD data is too big to be
converted to WORD, this bit-register will be set to ON, indicates invalid BCD code
conversion.
M8169 record if BIN to BCD conversion is valid,if the BCD code is over 0x9999, this
41
WTOD
Instruction introduction
This instruction converts WORD data to DWORD data, and stores converted data in
specified D-registers.
Setting data
Table 3.2. 1
Example
Instruction table:
Network 000
LD X000
WTOD D0 D1 //Convert WORD data in D0 to DWORD and store result in D1D2
Ladder diagram:
Figure 3.2. 1
42
DTOW
Instruction introduction
1. This instruction converts DWORD data to WORD data, and stores converted data in
specified D-registers.
2. If the DWORD data is too big to convert, the overflow flag bit-register M8169 will be
Setting data
Table 3.3. 1
Example
Instruction table:
Network 000
LD X000
WTOD D0 D2 //Convert DWORD data in D0D1 to WORD and store result in D2
Ladder diagram:
43
Figure 3.3. 1
44
DTOF
Instruction introduction
This instruction converts DWORD data to FLOAT data, and stores converted data in
specified D-registers.
Setting data
Table 3.4. 1
Example
Instruction table:
Network 000
LD X000
DTOF D0 D2 //Convert DWORD data in D0D1 to FLOAT and store result in D2D3
Ladder diagram:
Figure 3.4. 1
45
BIN/BIND
Instruction introduction
1. These instructions convert BCD data to BIN data, and stores converted data in
specified D-registers (details of BCD and BIN refer to notes). BIN instruction is for
16-bit data, BIND instruction is for 32-bit data. The valid range of IN is 0 to 9999 BCD.
2. When the conversion is invalid, the system special function bit-register M8168 will be
set to ON.
Setting data
BIN
Table 3.5. 1
BIND
Table 3.5. 2
46
Example
Instruction table:
Network 000
LD X000
BIN H0234 D0 //Convert BCD code 234 to BIN code and store result in D0
Ladder diagram:
Figure 3.5. 1
BCD/BCDD
Instruction introduction
1. These instructions convert BIN data to BCD data, and stores converted data in
specified D-registers (details of BCD and BIN refer to notes). BCD instruction is for
16-bit data, BCDD instruction is for 32-bit data.An error occurs when the BCD code
2. When the conversion is invalid, the system special function bit-register M8168 will be
set to ON.
Setting data
BCD
47
(OUT) D-register to store converted BCD D/CV/TV/AO/V/Z 0x0000~0x9999 16-bit BCD
data code
Table 3.6. 1
BCDD
Table 3.6. 2
Example
Instruction table:
Network 000
LD X000
BCD D0 D1 //Convert BIN code in D0 to BCD code and store result in D1
Ladder diagram:
Figure 3.6. 1
ROUND
Instruction introduction
This instruction rounds FLOAT data to DWORD data, and stores converted data in
specified D-registers. If the decimal part of the FLOAT date is less than 0.5, FLOAT data
48
is rounded off; otherwise it is rounded up.
Setting data
Table 3.7. 1
Example
Instruction table:
Network 000
LD X000
ROUND K4.56 D0 //round up K4.56 to K5 and store result in D0D1
Ladder diagram:
Figure 3.7. 1
TRUNC
Instruction introduction
This instruction truncates decimal part of FLOAT data, convert it to DWORD data, and
49
Setting data
Table 3.8. 1
Example
Instruction table:
Network 000
LD X000
TRUNC K4.56 D0 //truncate K4.56 to K4 and store result in D0D1
Ladder diagram:
Figure 3.8. 1
Notes
Instructions in this chapter perform bit logic operations on WORD (16-bit) or DWORD
(32-bit) data. The logic operations include invert operation (INV), and operation (AND), or
50
operation (OR), exclusive-or operation (XOR), and complementary operation (NEG). INV
and NEG operate on a single code, details refer to Table 4.1.1; AND, OR, and XOR
Example
Operator Description
Input Output
Invert each bit of the code and add the result with 1 to get
NEG 0xFFFF 0x0001
complement which is negative form of the source code.
Table 4.1. 1
Example
Operator Description
Input1 Input2 Output
0 0 0
Add each corresponding bit of the two codes and output the result. 0 1 0
AND
(If at least one of two bits is 0, operation result is 0, otherwise result is 1) 1 0 0
1 1 1
0 0 0
Do or operation on each corresponding bit of two codes and output result. (If 0 1 1
OR
at least one of two bits is 1, operation result is 1, otherwise result is 0.) 1 0 1
1 1 1
0 0 0
Perform exclusive-or operation on each corresponding bit of the two codes
0 1 1
XOR and output the result.
1 0 1
(If two bits are different, operation result is 1, otherwise result is 0)
1 1 0
Table 4.1. 2
INVW/INVD
Instruction introduction
The instruction performs the inversion operation on the input and stores the result in the
specified register.
51
INVW is for WORD data, INVD is for DWORD data. Details of invert operation refer to
Setting data
INVW
Table 4.2. 1
INVD
Table 4.2. 2
Example
Instruction table:
Network 000
LD X000
INVW D0 D1 //do invert operation on code in D0 and store result in D1
52
Ladder diagram:
Figure 4.2. 1
ANDW/ANDD
Instruction introduction
These instructions perform and operation on input codes, and store the result in a
specified register. ANDW is for WORD data, ANDD is for DWORD data. Details of and
Setting data
ANDW
Table 4.3. 1
ANDD
Table 4.3. 2
53
Example
Instruction table:
Network 000
LD X000
ANDW D0 D1 D2 //do and operation on codes in D0 and D2, and store result in D1
54
Ladder diagram:
Figure 4.3. 1
ORW/ORD
Instruction introduction
These instructions perform or operation on input codes, and store the result in a specified
register.
ORW is for WORD data, ORD is for DWORD data. Details of or operation refer to notes of
this chapter.
Setting data
ORW
Table 4.4. 1
ORD
55
(IN2) Second code to do or operation K/H/D 0x00000000~0xFFFFFFFF 32-bit code
Table 4.4. 2
Example
Instruction table:
Network 000
LD X000
ANDW D0 D1 D2 //do and operation on codes in D0 and D1, and store result in D2
56
Ladder diagram:
Figure 4.4. 1
XORW/XORD
Instruction introduction
These instructions perform exclusive-or operation on input codes, and store the result in a
specified register. XORW is for WORD data, XORD is for DWORD data. Details of
Setting data
XORW
Table 4.5. 1
XORD
57
Table 4.5. 2
Example
Instruction table:
Network 000
LD X000
XORW D0 D1 D2 //do and operation on codes in D0 and D1, and store result in D2
58
Ladder diagram:
Figure 4.5. 1
NEGW/NEGD
Instruction introduction
These instructions perform complementary operation on input codes, and store the result
NEGW is for WORD data, NEGD is for DWORD data. Details of complementary operation
Setting data
NEGW
Table 4.6. 1
NEGD
59
(IN2) Second code to do complementary K/H/D 0x00000000~0xFFFFFFFF 32-bit code
operation
Table 4.6. 2
Example
Instruction table:
Network 000
LD X000
NEGW D0 D1 //do complementary operation on code in D0 and store result in D1
60
Ladder diagram:
Figure 4.6. 1
Transfer Instructions
Notes
Instructions in this chapter transfer data with a certain length to specified registers. The
byte 8 bits -
word 16 bits, length of WORD data MOV, MVBLK, FMOV, XCH
double-word 32 bits, length of DWORD and FLOAT data. MOVD/MOVF, MVDBLK, FMOVD, XCHD/XCHF
Table 5.1. 1
MOV/MOVD/MOVF
Instruction introduction
These instructions copy data from source registers and store it in destination registers.
MOV is for WORD data, MOVD is for DWORD data, MOVF is for FLOAT data.
61
Setting data
MOV
Table 5.2. 1
62
MOVD
Table 5.2. 2
MOVF
Table 5.2. 3
Example
Instruction table:
Network 000
LD X000
MOV D0 D1 //copy WORD data from D0 and store in D1
Ladder diagram:
Figure 5.2. 1
MVBLK/MVDBLK
Instruction introduction
These instructions copy word/double-word data of specified length from source registers
63
and store it in destination registers.
Setting data
MVBLK
Table 5.3. 1
MVDBLK
Table 5.3. 2
Example
Instruction table:
Network 000
LD X000
MVBLK D0 D5 K10 //copy data of D0-D9 and store in D5-D14
Ladder diagram:
64
Figure 5.3. 1
FMOV/FMOVD
Instruction introduction
These instructions copy word/double-word data from source registers and store it in
multiple continuous destination registers. FMOV is for word, FMOVD is for double-word.
Setting data
MVBLK
Table 5.4. 1
MVDBLK
Table 5.4. 2
65
Example
Instruction table:
Network 000
LD X000
FMOV K100 D5 K5 //copy K100 and store in D5-D9
Ladder diagram:
Figure 5.4. 1
SMOV
Instruction introduction
1. This instruction is digit move instruction, it distributes and composes data in units of
nibble (4 bits).
2. This instruction converts binary code in source register (S) and destination register (D)
to BCD code (0x0000 to 0x9999), (N2) length nibbles starting from the (N1)th nibble
are transferred to the destination register (D) starting from the (N3)th nibble,
66
An error occurs when the BCD code value exceeds 9999.
Setting data
Inputs/outputs Description Operand Range Data type
(N1) Head nibble position to be moved K/H 1~4 16-bit unsigned integer
(N3) Head digit position of movement K/H 1~4 16-bit unsigned integer
destination
Table 5.5. 1
Example
Instruction table:
Network 000
LDP M1
MOV K4321 D1 //write 4321 in D1
MOV K8888 D2 //write 8888 in D2
POP
LD M1
SMOV D1 K4 K2 D2 K3 //When M1 is ON, D2 is stored with 8438
Ladder diagram:
67
Figure 5.5. 1
XCH/XCHD/XCHF
Instruction introduction
XCH is for WORD data, XCHD is for DWORD data, XCHF is for FLOAT data.
68
Setting data
XCH
Table 5.6. 1
XCHD
Table 5.6. 2
XCHF
Table 5.6. 3
Example
Instruction table:
Network 000
LDP M7
XCH D5 D6 //Exchange data of D5 and D6
Ladder diagram:
69
Figure 5.6. 1
Notes
radication, sine, cosine, tangent, logarithm, exponent, power, absolute value, arcsine,
2. There are system special function bit-registers that record calculation errors.
M8170: When calculation result is minus or calculation input is illegal minus, this bit is
ON.
70
ADDF
Instruction introduction
1. This instruction adds one float type input (augend) with another (addend) and stores the
When M8170 is on, the result is negative. When M8171 is 0, there is no result
Setting data
Table 6.2. 1
Example
Instruction table:
Network 000
LD X000
ADDF D0 D2 D4 //D0D1+D2D3=D4D5
71
Ladder diagram:
Figure 6.2. 1
SUBF
Instruction introduction
1. This instruction subtracts one float type input (minuend) with another (subtrahend)
When M8170 is on, the result is negative. When M8171 is 0, there is no result
Setting data
Table 6.3. 1
Example
Instruction table:
72
Network 000
LD X000
SUBF D0 D2 D4 //D0D1-D2D3=D4D5
Ladder diagram:
Figure 6.3. 1
MULF
Instruction introduction
1. This instruction multiplies one float type input (multiplicand) with another (multiplier)
When M8170 is on, the result is negative. When M8171 is 0, there is no result
73
Setting data
Table 6.4. 1
Example
Instruction table:
Network 000
LD X000
MULF D0 D2 D4 //D0D1×D2D3=D4D5
Ladder diagram:
Figure 6.4. 1
DIVF
Instruction introduction
1. This instruction divides one float type input (dividend) with another (divisor) and
74
2. This instruction may set M8170, M8171 and M8172 to ON.
When M8170 is on, the result is negative. When M8171 is 0, there is no result.
Setting data
Table 6.5. 1
Example
Instruction table:
Network 000
LD X000
DIVF D0 D2 D4 //D0D1÷D2D3=D4D5
Ladder diagram:
Figure 6.5. 1
75
SQRT
Instruction introduction
1. This instruction takes the square root of the float type input (radicand) and stores the
Setting data
Table 6.6. 1
Example
Instruction table:
Network 000
LD X000
SQRT K256 D0 //SQRT(256) = D0D1 = 16
Ladder diagram:
Figure 6.6. 1
76
SIN
Instruction introduction
1. This instruction calculates the sine of the float type input (angle) and stores result in
specified register. The unit of input is degree, user can also use DEG instruction to
When M8170 is on, the result is negative. When M8171 is 0, there is no result.
Setting data
Table 6.7. 1
Example
Instruction table:
Network 000
LD X000
SIN K30 D0 //SIN(30°) = D0D1 = 0.5
77
Ladder diagram:
Figure 6.7. 1
COS
Instruction introduction
1. This instruction calculates the cosine of the float type input (angle) and stores result
in specified register. The unit of input is degree, user can also use DEG instruction to
When M8170 is on, the result is negative. When M8171 is 0, there is no result.
Setting data
Table 6.8. 1
Example
Instruction table:
Network 000
78
LD X000
COS K60 D0 //COS(60°) = D0D1 = 0.5
Ladder diagram:
Figure 6.8. 1
TAN
Instruction introduction
1. This instruction calculates the tangent of the float type input (angle) and stores result
in a specified register. The unit of input is a degree, user can also use DEG
instruction to convert the radian input into angle input. To convert the input angle from
3.1415926).
When M8169 is on, the result is overflow. When M8170 is on, the result is negative.
79
Setting data
Table 6.9. 1
Example
Instruction table:
Network 000
LD X000
TAN K45 D0 //TAN(45°) = D0D1 = 1
Ladder diagram:
Figure 6.9. 1
LN
Instruction introduction
80
approximately equal to 2.71828) of the float type input and stores result in the
specified register.
2. To promote any real number to the power of another real number, including fractional
exponents: Combine the "natural exponent" instruction with the "natural logarithm"
instruction. For example, to raise X to the power of Y, enter the following command:
EXP (Y * LN (X)).
Setting data
Table 6.10. 1
81
Example
Instruction table:
Network 000
LD X000
LN D0 D2 //LN(D0D1) = D2D3
Ladder diagram:
Figure 6.10. 1
EXP
Instruction introduction
Instruction to calculate e to the power of IN, and place the result in OUT.
EXP(IN) = OUT
82
To promote any real number to the power of another real number, including fractional
exponents: Combine the "natural exponent" instruction with the "natural logarithm"
instruction. For example, to raise X to the power of Y, enter the following command:
EXP (Y * LN (X)).
Setting data
Table 6.11. 1
83
Example
Instruction table:
Network 000
LD X000
EXP K3 D2 //EXP(3) = D2D3 = e^3
Ladder diagram:
Figure 6.11. 1
LOG
Instruction introduction
1. This instruction calculates common logarithm (base is 10) of the float type input and
Setting data
84
(IN) Input antilogarithm. K/D/AI/AO ±1.17549e-38F~±3.40282e+38F float
Table 6.12. 1
Example
Instruction table:
Network 000
LD X000
LOG K1000 D4 //LOG(K1000) = D4D5 = 3
Ladder diagram:
Figure 6.12. 1
POW
Instruction introduction
1. This instruction calculates one float type input (exponent) to the power of another one
2. Use the floating-point value of the register (B) as the base, and the floating-point
value of the register (E) as the exponent, and transfer the result to the register (P).
85
3. This instruction may set M8171 to ON.
Setting data
Table 6.13. 1
Example
Instruction table:
Network 000
LD X000
POW K1000 D4 //LOG(K1000) = D4D5 = 3
Ladder diagram:
Figure 6.13. 1
86
ABSF
Instruction introduction
This instruction calculates absolute value of the float type input and stores result in
specified register. According to the positive and negative of the input, the original value is
output when the input is positive, and the opposite value is output when the input is
negative.
Setting data
Table 6.14. 1
Example
Instruction table:
Network 000
LD M100
LOG D0 D10 //ABS(D0D1) = D10D11
Ladder diagram:
87
Figure 6.14. 1
RAD/DEG
Instruction introduction
Setting data
RAD
Table 6.15. 1
MVDBLK
Table 6.15. 2
88
Example
Instruction table:
Network 000
LD X000
RAD D0 D2 //convert degree in D0D1 to radian in D2D3
POP
LD X001
RAD D0 D2 // convert radian in D0D1 to degree in D2D3
POP
Ladder diagram:
Figure 6.15. 1
Notes
2. There are system special function bit-registers that record calculation errors.
M8170: When calculation result is minus or calculation input is illegal minus, this
bit-register is ON.
89
M8171: When calculation result is 0, this bit-register is ON.
ADD/ADDD
Instruction introduction
1. These instructions add one integer type input (augend) with another (addend) and
store the sum in the specified register. ADD is for 16-bit signed integer, ADDD is for
Setting data
ADD
Table 7.2. 1
ADDD
90
(OUT) Register stores the sum D/CV - 32-bit signed integer
Table 7.2. 2
91
Example
Instruction table:
Network 000
LD X000
ADD D0 D1 D2 //D0+D1=D2
Ladder diagram:
Figure 7.2. 1
SUB/SUBD
Instruction introduction
1. These instructions subtract one integer type input (minuend) with another (subtrahend)
and Store the difference in specified register. SUB is for 16-bit signed integer, SUBD is for
Setting data
SUB
92
(IN2) Subtrahend of subtraction. K/H/D/TV/CV/AI/AO/V/Z -32768~32767 16-bit signed integer
Table 7.3. 1
SUBD
Table 7.3. 2
Example
Instruction table:
Network 000
LD X000
SUB D0 D1 D2 //D0-D1=D2
Ladder diagram:
Figure 7.3. 1
MUL/MULW/MULD
Instruction introduction
1. These instructions multiply one integer type input (multiplicand) with another
93
(multiplier) and store product in specified register.
2. MUL is for 16-bit signed integer inputs and 16-bit signed integer output;
3. MULW is for 16-bit signed integer inputs and 32-bit signed integer output;
4. MULD is for 32-bit integer inputs and 32-bit signed integer output.
Setting data
MUL
Table 7.4. 1
MULW
Table 7.4. 2
MULD
94
disables instruction.
Table 7.4. 3
Example
Instruction table:
Network 000
LD X000
MUL D0 D1 D2 //D0×D1=D2D3
Ladder diagram:
Figure 7.4. 1
DIV/DIVW/DIVD
Instruction introduction
1. These instructions divide one integer type input (dividend) with another (divisor) and
95
2. DIV is for 16-bit signed integer inputs and 16-bit signed integer output;
3. DIVW is for 16-bit signed integer inputs and 32-bit signed integer output;
4. DIVD is for 32-bit integer inputs and 32-bit signed integer output.
Setting data
DIV
Table 7.5. 1
DIVW
Table 7.5. 2
DIVD
96
quotient.
Table 7.5. 3
Example
Instruction table:
Network 000
LD X000
DIV D0 D1 D2 //D0÷D1=D2D3
Ladder diagram:
Figure 7.5. 1
INC/INCD
Instruction introduction
the integer by one, and stores the result in the specified register.
2. INC is for 16-bit signed integer, INCD is for 32-bit signed integer.
Setting data
INC
97
Inputs/outputs Description Operand Range Data type
Table 7.6. 1
INCD
Table 7.6. 2
Example
Instruction table:
Network 000
LD X000
INC D0 D1 //D0 = D0 + 1
Ladder diagram:
Figure 7.6. 1
98
DEC/DECD
Instruction introduction
1. The instruction performs a decreasing operation on the integer type input, the integer
2. INC is for 16-bit signed integer, INCD is for 32-bit signed integer.
Setting data
DEC
Table 7.7. 1
DECD
Table 7.7. 2
Example
Instruction table:
99
Network 000
LD X000
DEC D0 D1 //D0 = D0 - 1
Ladder diagram:
Figure 7.7. 1
FACT
Instruction introduction
1. This instruction calculates factorial of integer type input and stores result in a
specified register.
Setting data
Table 7.8. 1
Example
Instruction table:
100
Network 000
LD X000
FACT K4 D0 //D0D1 = 4! = 24
Ladder diagram:
Figure 7.8. 1
ABS/ABSD
Instruction introduction
The instruction calculates the absolute value of the integer type input and stores the result
in the specified register. The instruction (ABS) inputs a given 16-bit integer (IN) and
According to the positive and negative of the input, the original value is output when the
input is positive, and the opposite value is output when the input is negative.
ABS is for 16-bit signed integer input, ABSD is for 32-bit signed integer input.
Setting data
ABS
Table 7.7. 3
ABSD
Table 7.7. 4
Example
Instruction table:
Network 000
LD M100
ABS D0 D10 //ABS(D0D1) = D10D11
Ladder diagram:
Figure 7.9. 1
102
Timer Instructions
Notes
1. Instructions in this chapter record time counting in corresponding timer and set
2. There are 3 kinds of timers, they differ from resolution. Resolution is the
minimum time interval that count of timer increases. Table 8.1.1 shows the
details.
Table 8.1. 1
The 1ms timer is refreshed by the system every 1ms, which has nothing to do with
the scan cycle and program processing. It uses the interrupt refresh method. Therefore,
when the scan cycle is bigger than 1ms, it may be refreshed multiple times in one cycle.
The current value (TV register) and (T register) may not be the same in a scan period;
The 10ms timer is automatically refreshed by the system at the beginning of each
scan period. Because it is refreshed only once every scan period, the timer bit (Tx) and
103
the current value (TVx) are always consistent in a scan period ;
The 100ms timer is refreshed when the timer instruction is executed. Therefore, if
the 100ms timer is activated, if the timer instruction is not executed every scan cycle or
the timer instruction is executed multiple times within a scan cycle, it will Causes timing
inaccuracy. The 100ms timer is only used in programs where the timer instruction is
TON
Instruction introduction
1. This instruction is on-delay timer instruction. When instruction is enabled, timer starts
to time. The timer flag-bit will be set to ON when timer count meets target time; When
instruction is disabled, timer count will be cleared and timer flag-bit will be set to OFF.
104
Figure 8.2. 1
2. User can use this instruction for single target time counting.
Setting data
Table 8.2. 1
Example
Instruction table:
Network 000
LD X000
TON TV10 D0 //when timer count of TV10 meet target time D0, T10 is set to ON
Network 000
LD T10
OUT Y000
105
Ladder diagram:
Figure 8.2. 2
TONR
Instruction introduction
1. This instruction is on-delay memory timer instruction. When instruction is enabled, the
timer starts (continues) to time. The timer flag-bit will be set to ON when timer count
meets the target time; When instruction is disabled, timer count and time flag-bit will
Figure 8.3. 1
2. User can use this instruction for multiple target time counting.
106
Setting data
Table 8.3. 1
Example
Instruction table:
Network 000
LDI Y000
TONR TV251 K100 //when timer count of TV251 meet target time K100, T251 is set to ON
Network 000
LD T251
OUT Y000 //when Y000 is ON, timer instruction is disabled.
Ladder diagram:
Figure 8.3. 2
TOF
Instruction introduction
1. This instruction is off-delay timer instruction. When instruction is disabled, the timer
starts (continues) to time. The timer flag-bit will be set to OFF when timer count meets
the target time; When instruction is enabled, timer count will be cleared and timer
107
flag-bit will be set to ON. Details refer to Figure 8.4.1.
Figure 8.4. 1
2. User can use this instruction for single target time counting.
Setting data
Table 8.4. 1
108
Example
Instruction table:
Network 000
LDI Y000
TONR TV251 K100 //when timer count of TV251 meet target time K100, T251 is set to ON
Network 000
LD T251
OUT Y000 //when Y000 is ON, timer instruction is disabled.
Ladder diagram:
Figure 8.4. 2
Counter Instructions
Notes
There are 3 types of counters, and their data bits and applicable occasions are
different.
Table 9.1. 1
109
High-speed counter is applied for high-speed pulse counting.
2. It is recommended to add only one type timer instruction of one timer in a program.
CTU
Instruction introduction
1. This instruction counts upward (count increases) at each rising-edge of input. When
the count meet set target number, corresponding flag-bit will be set to ON.When the
Setting data
Table 9.2. 1
Example
Instruction table:
110
Network 000
LD X000
CTU CV0 D0 //counter counts upward, when counter count of CV0 meet target number D0, C0 is
set to ON
Network 000
LD C0
OUT Y000
Ladder diagram:
Figure 9.2. 1
111
CTD
Instruction introduction
When the count meet set target number, corresponding flag-bit will be set to ON. The
Setting data
Table 9.3. 1
Example
Instruction table:
Network 000
LD X000
CTD CV0 D0 //counter counts downward, when counter count of CV0 meet target number D0, C0
is set to ON
Network 000
112
LD C0
OUT Y000
Ladder diagram:
Figure 9.3. 1
CTUD
Instruction introduction
counting direction depends on comparison between target number and current counts,
when target number is greater than current counts, counter counts upward; When target
number is less than current counts, counter counts downward; When the count reaches
the set target number, the corresponding flag bit will be set to ON.
Setting data
113
-32768~32767 16-bit signed integer
■ C200~C255 ■ C200~C255
-2147483648~2147483647 32-bit signed integer
Table 9.4. 1
Example
Instruction table:
Network 000
LD X000
CTUD CV0 D0 //compare target number and current counts, and counter counts upward or
downward, when counter count of CV0 meet target number D0, C0 is set to
ON
Network 000
LD C0
OUT Y000
Ladder diagram:
Figure 9.4. 1
114
Program Control Instructions
Notes
2. Program of PLC project can be divided into 3 types: main program, subroutine
program, and function block. The main program is the entrance of execution,
user can use program control instructions to call it and back to main program;
programming language, user can also call it in a program like other instructions.
3. S register is system state bit-register, it marks state of system and takes effects in
FOR~NEXT
Instruction introduction
1. FOR instruction must be used together with NEXT instruction in pairs. When FOR is
enabled, program segments between FOR and NEXT are loop program that will be
executed for specified loop number, then continue after NEXT. When FOR is
115
2. Loop number can be modified when the program is running. Once program reenters
Setting data
Table 10.2. 1
Example
Instruction table:
Network 000
LDP X000
FOR K10 //loop numbers is set with 10
Network 000
LD X001
INC D0 D0 //D0 increase in each cycle
Network 000
NEXT //end of loop
Ladder diagram:
116
Figure 10.2. 1
CJ~LBL
Instruction introduction
enabled, the program will jump to designated LBL label; When CJ is disabled,
2. CJ instruction and its corresponding LBL label must be in the same program (main
program or subroutine program). It cannot jump from main program to the subroutine
Setting data
CJ
Table 10.3. 1
LBL
Table 10.3. 2
117
Example
Instruction table:
Network 000
LD X000
CJ K0 //if X000 is ON, jump to LBL K0
Network 000
LD X001
ADD D0 D1 D2 //if X000 is OFF, D2=D0+D1 when X001 is ON
Network 000
LBL K0 //set label number with K0
Ladder diagram:
Figure 10.3. 1
CALL
Instruction introduction
1. When this instruction is enabled, program execution will jump to start of the set
subroutine program; When this instruction is disabled, it will skip this instruction and
2. The user should create a subroutine program at first, and user can also add this
diagram interface.
118
3. The maximum number of nested calls is 8.
Setting data
Table 10.4. 1
Example
Instruction table:
Network 000
LD X000
CALL Sub1 //call subroutine program “Sub1”
Ladder diagram:
Figure 10.4. 1
CALLM
Instruction introduction
1. When this instruction is enabled, program will call specified function block; When this
instruction is disabled, this instruction will be skipped and continue the following
program.
119
2. This instruction should be triggered by an edge signal.
When using the CALL instruction to call a function block, it is necessary to properly handle
the judgment of the entry and exit of the call to prevent timing or logic errors from causing
4. When using the CALLM instruction to call a function block, it is necessary to properly
handle the judgment of the entry and exit of the call to prevent timing or logic errors from
Setting data
Table 10.5. 1
Example
1. Sort function
Function block:
120
}
Instruction table:
LDP M0 //call function Data_Init once when M0 is ON, D[0]=0x4321, D[1]=0x4320, D[2]=0x4323,
D[3]=0x4322,D[4]=0x4325,D[5]=0x4324,D[6]=0x4327
MOV K7 D100 //set data length D100 with 7
CALLM Data_Init D0 D100 //call Data_Init, data=D0, size=D100
POP
LDP M1 //call function Data_Sort when M1 is ON, D[0]=0x4320 , D[1]=0x4321 , D[2]=0x4322 ,
D[3]=0x4323, D[4]=0x4324,D[5]=0x4325,D[6]=0x4327
CALLM Data_Sort D0 D100 //call Data_Sort, data=D0, size=D100
POP
LDW< D1 D2
AW< D2 D3
AW< D3 D4
AW< D4 D5
AW< D5 D6
OUT Y000 //if D1<D2<D3<D4<D5<D6,Y000 is ON
POP
121
Ladder diagram:
Figure 10.5. 1
Function block:
Instruction table:
LDP M0
MOV K10 D100 //set length of data D100 with 10
122
CALLM StandardDeviation D0 D100 D200 // call function StandardDeviation, in=D0,
size=D100, out=D200
Ladder diagram:
Figure 10.5. 2
STL/STLE/ST
Instruction introduction
1. This command is a state command, STL start state, STLE end state, ST switches on
state. In addition, using the RST instruction to reset the corresponding S-bit register
2. When using RST to switch off a state ladder, all output (output contact, timer, counter,
3. STL must be used together STLE, and state ladder between STL and STLE can’t be
nested.
4. Setting the corresponding S bit-register by using SET instruction can also switch on
step ladder. The difference is, when using SET, the set S bit-register will be reset
automatically in the next scan period; When use ST, the set S-bit-register will hold
ON.
5. Both SET and ST are state transition instructions, but the difference between the two
(1) When the SET instruction is used when the state transition condition is established,
123
the next state to be transitioned is set to ON. During the state transition, the two states will
be turned on at the same time only in one scan cycle. The current STL segment The state
(2) When the ST instruction is used when the state transition condition is established, the
next state to be transitioned is set to ON, but the state in the current STL segment will not
be reset OFF. The ST instruction is generally when the program needs to run multiple
In production practice, process selection or branch selection is required for work with
multiple processes, that is, a control flow may be transferred to one of multiple possible
control flows, but multiple branches are not allowed to execute at the same time; which
branch to enter , Depends on which of the transition conditions before the control flow is
true.
Setting data
STL
Table 10.6. 1
ST
Table 10.6. 2
124
Both SET and ST are state transition instructions, but the difference between the two state
(1) When the SET instruction is used when the state transition condition is established,
the next state to be transitioned is set to ON. During the state transition, the two states will
be turned on at the same time only in one scan cycle. The current STL segment The state
(2) When the ST instruction is used when the state transition condition is established, the
next state to be transitioned is set to ON, but the state in the current STL segment will not
be reset OFF. The ST instruction is generally when the program needs to run multiple
Example
In this example, user can select one or both of two step ladder branches to execute,
with multiple processes, that is, a control flow may be transferred to one of multiple
possible control flows, but multiple branches are not allowed to execute at the same
time; which branch to enter , Depends on which of the transition conditions before the
125
Figure 10.6. 1
Instruction table:
Network 000
LD X000
SET S0 K1 //go to S0 step ladder when X000 is ON
POP
Network 001
STL S0 //start of S0 step ladder
LD M8151
OUT Y000
POP
LD X000
SET S1 K1 //go to S1 step ladder when X000 is ON
POP
LD X003
SET S3 K1 //go to S3 step ladder when X003 is ON
POP
STLE //end of S0 step ladder
Network 002
STL S1 //start of S1 step ladder
LD M8151
OUT Y001
POP
LD X001
SET S2 K1 //go to S2 step ladder when X001 is ON
POP
STLE //end of S1 step ladder
Network 003
STL S2 //start of S2 step ladder
LD M8151
OUT Y002
POP
LD X002
SET S5 K1 //go to S5 step ladder when X002 is ON
POP
STLE //end of S2 step ladder
Network 004
STL S3 //start of S3 step ladder
LD M8151
OUT Y003
126
POP
LD X004
SET S4 K1 //go to S4 step ladder when X004 is ON
POP
STLE //end of S3 step ladder
Network 005
STL S4 //start of S4 step ladder
LD M8151
OUT Y004
POP
LD X005
SET S5 K1 //go to S5 step ladder when X005 is ON
POP
STLE //end of S4 step ladder
Network 006
STL S5 //start of S5 step ladder
LD M8151
OUT Y005
POP
LD X006
SET S6 K1 //go to S6 step ladder when X006 is ON
POP
STLE //end of S5 step ladder
127
Ladder diagram:
Figure 10.6. 2
128
2. Parallel branches
In this example, two step ladder branches are parallel, both are executed. Figure
Figure 10.6. 3
Instruction table:
Network 000
LD X000
SET S0 K1 //go to S0 step ladder when X000 is ON
POP
Network 001
STL S0 //start of S0 step ladder
LD M8151
OUT Y000
POP
LD X000
SET S1 K1 //go to S1 step ladder when X000 is ON
SET S3 K1 //go to S3 step ladder when X003 is ON
POP
STLE //end of S0 step ladder
Network 002
STL S1 //start of S1 step ladder
LD M8151
OUT Y001
POP
LD X001
SET S2 K1 //go to S2 step ladder when X001 is ON
POP
STLE //end of S1 step ladder
Network 003
STL S2 //start of S2 step ladder
LD M8151
OUT Y002
POP
STLE //end of S2 step ladder
Network 004
129
STL S3 //start of S3 step ladder
LD M8151
OUT Y003
POP
LD X002
SET S4 K1 //go to S4 step ladder when X002 is ON
POP
STLE //end of S3 step ladder
Network 005
STL S4 //start of S4 step ladder
LD M8151
OUT Y004
POP
STLE //end of S4 step ladder
Network 006
LD S2
AND S4
AND X003
SET S5 K1 //go to S5 step ladder when X003 is ON
RST S2 K1 //S2 need to be reset manually
RST S4 K1 //S4 need to be reset manually
POP
Network 007
STL S5 //start of S5 step ladder
LD M8151
OUT Y005
POP
LD X004
SET S6 K1 //go to S6 step ladder when X004 is ON
POP
STLE //end of S5 step ladder
Ladder diagram:
130
Figure 10.6. 4
131
RET
Instruction introduction
1. This instruction is used in subroutine program, and not allowed to be used in the main
program.
2. When this instruction is enabled, the subroutine program will not execute next
program after this instruction, but back to main program, and continue execution at
Setting data
Table 10.7. 1
Example
1. Main program
Instruction table:
Network 000
LD X000
CALL SUB1 //call subroutine program “SUB1”
Network 001
LD X001
ADD D0 D1 D2 //D2=D0+D1 when X001 is ON
Ladder diagram:
132
Figure 10.7. 1
2. Subroutine program
Instruction table:
Network 000
LD X001
RET //back to main program when X001 is ON
Network 001
LD X002
SUB D0 D1 D2 //D2=D0-D1 when X001 is OFF and X002 is ON
Ladder diagram:
Figure 10.7. 2
BREAK
Instruction introduction
When this instruction is enabled, if it is in a loop part (FOR to NEXT), it will jump out from
this loop and continue the program after NEXT; If it is in a step ladder (STL to STLE), it will
133
jump out from this step ladder and continue the program after STLE. If it is in both a loop
part and a step ladder, it will jump out from the loop part.
Setting data
Table 10.8. 1
Example
1. FOR to NEXT
Instruction table:
Network 000
LD X000
FOR K100 //start of loop, loop for 100 times
Network 001
LD X001
INC D0 D0 //D0 increases in each loop
Network 002
LD X002
BREAK //jump out from loop when X002 is ON
Network 003
NEXT //end of loop
Ladder diagram:
134
Figure 10.8. 1
2. STL to STLE
Instruction table:
Network 000
STL S0 //start of step ladder
Network 001
LD X000
BREAK //jump out from step ladder when X000 is ON
Network 002
LD X001
OUT Y0 //continue this instruction if not jump out
Network 003
STLE //end of step ladder
Ladder diagram:
Figure 10.8. 2
135
IST
Instruction introduction
1. This instruction automatically controls the initial state and special registers in a step
ladder program.
2. The 8 continuous bit-registers to control the step ladder program is started with input
bit-register (IN). And these bit-registers take effect at their rising-edge, in order their
effects are: switch to manual mode (IN), switch to zero-return mode (IN+1), switch to
mode (IN+4), zero-return starts (IN+5), start (IN+6), and stop (IN+7).
details refer to Table 10.9.1. Don’t use these registers as usual registers in the
program.
136
single-cycle mode, and automatic mode).
Table 10.9. 1
The details on special registers and initial state (S0 to S2) which are automatically
controlled by the IST instruction is as shown in the equivalent ladder programs below, and
the head of control bit-registers is set with M20 (only for reference, cannot be
programmed).
a) D8048
D8048 is related to the current running mode of the step ladder program (include
manual mode, origin returning mode, single-step mode, single-cycle mode, and
automatic mode). Its initial value is 0, and transforms at the rising-edge of specified
bit-registers. Single-step mode, single-cycle mode, and automatic mode are all under
one same state, so they are all classified into automatic modes, and these 3 modes
Figure 10.9. 1
b) M8020
137
When M8020 is ON, the transfer of every state is disabled.
c) M8021
M8021 turns on only under automatic modes, when the step ladder program starts
(rising-edge of IN+5), it turns ON; When the step ladder program stops (rising-edge of
IN+5), it turns OFF; when the mode is switched to manual mode or zero-return mode,
Figure 10.9. 2
d) M8022
start operation under zero-return mode. Equivalent ladder program refers to Figure
10.9.3.
Figure 10.9. 3
e) M8023
M8023 only turns ON under manual mode when zero return is complete. Equivalent
138
Figure 10.9. 4
f) M8024
M8024 is flag-bit of zero-return, it detects if the machine returns to the zero points
g) M8025
When the mode is switched among manual mode, zero-return mode and an
automatic mode, all outputs (Y-registers) and operation state relays (S-registers) are
reset if the machine is not located at the zero point. If M8025 has been set to ON in
h) M8026
When either of state relays (S-registers) is ON, M8026 turns ON. When neither of
139
state relays (S-registers) is ON, M8026 turns OFF.
i) M8027
When M8027 is ON, it stores in D8040 to D8047 sequentially from a small number to
a big number of the step relay which operates in the step ladder.
S0, S1, and S2 respectively are initial state relays of manual mode, zero-return mode,
and automatic mode. When one mode is selected, the corresponding initial start relay
will be set, and the others will be reset, meanwhile all the output Y-registers will be
immediately reset, user can also set M8025 to ON to cancel the reset of Y-registers.
Figure 10.9. 5
Setting data
(IN) Head of bit-registers to control the step ladder program X/M 0/1 bool
Table 10.9. 2
140
Attention
1. Use this instruction at beginning of the main program, and enable it with M8151
Example
There is a task to separate balls with two kinds of weight, the mechanism and working
process is designed as Figure 10.9.6 and Figure 10.9.7. The mechanical arm moves up
by output Y000, moves down by output Y001, moves right by output Y002, moves left by
output Y003; input X000 distinguishes the weight of balls (ON for heavy ones and OFF for
light ones), input X001 is the left limit of horizontal moving, X002 is the right limit of heavy
balls carry moving, X003 is the right limit of light balls carry moving, X004 is the upper limit
of vertical moving, X005 is the lower limit of vertical moving. The working process is:
141
Figure 10.9. 6 Figure 10.9. 7
The main program sets the zero-return condition M8024, enable IST instruction, and calls
subroutine program of three kinds of modes (manual mode, zero-returning mode, and
automatic mode).
Figure 10.9. 8
Manual mode program provides input to control the output manually. The state number of
142
Figure 10.9. 9
Zero-return mode program move the mechanical arm to zero point by set M25. The state
143
Figure 10.9. 10
Single-step mode, single-cycle mode, and automatic mode share one subroutine program,
In single-step mode, the process of program runs state by state, and the state won’t
In single-cycle mode, the process of program runs a whole cycle, and won’t continue next
Figure 10.9.11 shows the start of automatic modes program (S2->S20); Figure 10.9.12
144
shows branch program of carrying heavy balls (S30->S31->S32); Figure 10.9.13 shows
branch program of carrying light balls (S40->S41->S42); Figure 10.9.14 shows program of
Figure 10.9. 11
Figure 10.9. 12
145
Figure 10.9. 13
146
Figure 10.9. 14
ISTNEXT
Instruction introduction
1. The instruction ISTNEXT can be used in IST single-step mode or single-cycle mode.
Using this instruction in single-step mode, you can continue to the next state without
triggering the start bit. In the single cycle mode, the next cycle can be continued.
2. M8020 will be reset when this instruction is enabled so that it can transition to the
next state.
147
Setting data
Table 10.10. 1
Example
Refer to automatic mode part of example in IST, Figure 10.10.1 shows the case of which
ISTNEXT is applied.
Figure 10.10. 1
148
WDT
Instruction introduction
2. User can start using watchdog function and set the target value of watchdog timer in
setting as shown in Figure 10.11.1. Watchdog will be reset in each scan period
automatically, and can also be reset manual by this instruction. If the time of the
watchdog timer exceeds target time, PLC will stop running and report error code 11 in
D8176.
4.
Figure 10.11. 1
Setting data
Table 10.11. 1
149
Example
Instruction table:
Network 000
LD M0
WDT //reset watchdog timer at rising-edge of M0
POP
Ladder diagram:
Figure 10.11. 2
Shifting Instructions
Notes
bit-registers.
2. There are system special function registers that record status of shifting result:
M8166: When the last bit of shifting operation is 1, this bit-register is ON.
150
SHL/SHLD
Instruction introduction
1. The instruction shift the value of the input register by (N) bits to the left, and loads the
result into the specified register, details refer to Figure 11.2.1. SHL is for WORD data,
Figure 11.2. 1
151
Setting data
SHL
Table 11.2. 1
SHLD
Table 11.2. 2
Example
Instruction table:
Network 000
LD X000
SHL D0 K1 D1 //shift D0 leftward by 1-bit and store result in D1
Ladder diagram:
152
Figure 11.2. 2
SHR/SHRD
Instruction introduction
1. The instruction shift the value of the input register by (N) bits to the right, and loads
the result into the specified register, details refer to Figure 11.3.1. SHR is for WORD
Figure 11.3. 1
Setting data
SHR
153
(D) Destination register to D/TV/CV/AO/V/Z - 16-bit code
store the result
Table 11.3. 1
SHLD
Table 11.3. 2
Example
Instruction table:
Network 000
LD X000
SHR D0 K1 D1 //shift D0 leftward by 1-bit and store result in D1
Ladder diagram:
Figure 11.3. 2
154
ROL/ROLD
Instruction introduction
1. The instruction circulating the value of the input register by (N) bits to the left, and
outputs the result to the word register, details refer to Figure 11.4.1. ROL is for
Figure 11.4. 1
Setting data
ROL
Table 11.4. 1
ROLD
155
disables instruction.
Table 11.4. 2
Example
Instruction table:
Network 000
LD X000
ROL D0 K1 D1 //rotate D0 leftward by 1-bit and store result in D1
Ladder diagram:
Figure 11.4. 2
ROR/RORD
Instruction introduction
1. The instruction circulating the value of the input register by (N) bits to the right, and
outputs the result to the word register, details refer to Figure 11.5.1. ROR is for
156
2. When using a type with signed data, the sign bit is also shifted.
Figure 11.5. 1
Setting data
ROR
Table 11.5. 1
RORD
Table 11.5. 2
157
Example
Instruction table:
Network 000
LD X000
ROR D0 K1 D1 //rotate D0 rightward by 1-bit and store result in D1
158
Ladder diagram:
Figure 11.5. 2
SHLB
Instruction introduction
1. This instruction shifts (N1) bit length continuous bit-registers (D) leftward by (N2) bits
and fill the empty bits with continuous source bit-registers (S), details refer to Figure
11.6.1.
Eg:
[SRC.] [DST.] n1 n2
SHLB Y0 M0 K8 K2
159
(5) Y1, Y0 → M1, M0
Figure 11.6. 1
160
Setting data
Table 11.6. 1
Example
Instruction table:
Network 000
LD X000
SHLB M0 Y0 K16 K1 //shift Y0~Y15 1 bit leftward, and fill Y0 with M0
Ladder diagram:
Figure 11.6. 2
SHRB
Instruction introduction
1. The instruction shifts the operand (S) right (N2) into the operand (D) of length (N1).
N2≤N1≤the maximum length of the operand (D), where the operand (S) specifies the
lowest bit of its (N2) bit, and the operation starts from the lowest bit of the (N2) bit
161
specified by the operand (S) Number (D), details refer to Figure 11.7.1.
Eg:
[SRC.] [DST.] n1 n2
SHRB Y0 M0 K8 K2
162
Order execution process:
(1)M1,M0 → remove
(2)M3,M2 → M1,M0
(3)M5,M4 → M3,M2
(4)M7,M6 → M5,M4
(5)Y1,Y0 → M7,M6
Figure 11.7. 1
Setting data
Table 11.7. 1
Example
Instruction table:
163
Network 000
LD X000
SHRB M0 Y0 K16 K1 //shift Y0~Y15 1 bit rightward, and fill Y0 with M0
Ladder diagram:
Figure 11.7. 2
Interrupt Instructions
Notes
1. The interrupt is a function for CPU of PLC to handle special cases such as an error,
alarm. The interrupt can be triggered by some interrupt factors, users can link these
interrupt factors with the interrupt programs (subroutine program) so that the
corresponding interrupt program will be executed when the interrupt factor occurs.
2. Interrupt has priority, when two interrupts with different priorities are triggered
simultaneously, the interrupt with higher priority will be handled first. If higher priority
interrupt is triggered when lower priority interrupt is being handled, the handling of
lower priority interrupt will pause until handling of higher priority interrupt completes.
3. Table 12.1.1 shows the interrupt vector table of external interrupts. edge change
interrupts and timer interrupts have lower priority than else. Do not trigger the external
interrupt too frequently, otherwise some interrupts may not be handled correctly.
164
4.
Interrupt timer 0 reach target time (target time can be set by system special
K6
function register D8173, the range is 1~32767ms, the resolution is 1ms)
Interrupt timer 1 reach target time (target time can be set by system special
K7
function register D8174, the range is 1~32767ms, the resolution is 1ms)
165
K38 edge change of X004 input
Table 12.1. 1
ATCH
Instruction introduction
This instruction attaches the interrupt factors with the subroutine program. The
corresponding subroutine program will execute when the interrupt factor occurs if interrupt
is allowed.
Setting data
Table 12.2. 1
Example
Instruction table:
Network 000
LDP M0
ATCH INTR_0 K0 //attach interrupt factor K0 with subroutine program INTR_0
EI //enable the interrupt
166
Network 001
LDP M1
DTCH K0 //detach interrupt factor K0 from its attached interrupt program
Network 002
LDP M2
DI //disable the interrupt
Ladder diagram:
Figure 12.2. 1
DTCH
Instruction introduction
1. This instruction detaches interrupt factor from its attached interrupt program.
Disassociate the interrupt event number (EVNT) and disable the interrupt event.
2. When DTCH is executed, counting of interrupt timer 0 and interrupt timer 1 will be
reset, the corresponding target number in D8713 and D8174 will also be reset.
Setting data
167
to detach integer
Table 12.3. 1
Example
EI
Instruction introduction
1. The instruction will globally enable all associated interrupt events. To execute the
2. When entering RUN mode, the initial state is that interrupts are prohibited. In RUN
mode, you can execute an interrupt enable instruction (EI) to allow all interrupts.
Executing the Disable Interrupt Instruction (DI) can disable the interrupt process;
Setting data
Table 12.4. 1
168
Example
DI
Instruction introduction
This instruction disables the execution of the interrupt program until the EI instruction is
enabled.
When entering RUN mode, the initial state is that interrupts are prohibited. In RUN mode,
you can execute an interrupt enable instruction (EI) to allow all interrupts. Executing the
Disable Interrupt Instruction (DI) can disable the interrupt process; however, the active
Setting data
Table 12.5. 1
Example
169
Real-time Clock Instructions
Notes
1. Instructions in this chapter do read, write, and compare operations on clock data, and
2. RTC data of PLC consists of 8 parts: year, month, day, hour, minute, second, reserve
part, and week. The RTC data of PLC is stored in BCD format.
3. User can set the format of clock data in “other option” of PLC settings, refer to Figure
13.1.1. Format of clock data can be selected with BCD code or BIN code (BIN and
BCD refer to notes of conversion instructions). RTC data of PLC itself is formatted
Figure 13.1. 1
4. Table 13.1.1 shows the details of read clock data. (For data register that stores the
Friday, 6 is Saturday)
Number of Range
Description
data-register BCD BIN
170
3 Hour 0x0000~0x0023 0~23
6 Reserved - -
Table 13.1. 1
TRD
Instruction introduction
This instruction reads RTC data of PLC and store it in specified 8 continuous D-registers
Setting data
Table 13.2. 1
Example
Instruction table:
Network 000
LD X000
TRD D0 //read RTC data of PLC and store in D0~D7
Ladder diagram:
171
Figure 13.2. 1
TWR
Instruction introduction
1. This instruction writes RTC data into PLC from specified 8 continuous D-registers
Setting data
Table 13.3. 1
Example
Instruction table:
Network 000
LD X000
TWR D0 //write RTC data into PLC from D0~D7
172
Ladder diagram:
Figure 13.3. 1
TRDS
Instruction introduction
1. This instruction reads RTC data of PLC, calculates how many seconds pass since
(double-word).
Setting data
Table 13.4. 1
Example
Instruction table:
173
Network 000
LD X000
TDRS D0 //write passed seconds into D0D1
Ladder diagram:
Figure 13.4. 1
TWRS
Instruction introduction
1. According to the number of seconds pass since 2000/1/1 00:00:00 stored in specified
D-register, this instruction calculates the clock data and writes it into PLC.
Setting data
(T) D register stores the number of seconds D 0~ 4294967295 32-bit unsigned integer
Table 13.5. 1
174
Example
Instruction table:
Network 000
LD X000
TDRS D0 //write passed seconds into D0D1
Ladder diagram:
Figure 13.5. 1
TSEC
Instruction introduction
This instruction reads clock data in specified 8 continuous D-registers, calculates how
many seconds pass since 2000/1/1 00:00:00, and stores the number of seconds in
Setting data
Table 13.6. 1
Instruction table:
175
Network 000
LD X000
TSEC D0 D10 //transform data in D0~D7 into number of seconds and store in
D10
Ladder diagram:
Figure 13.6. 1
RSEC
Instruction introduction
This instruction reads the number of seconds in specified D-register, calculates clock data
that pass the specified seconds after 2000/1/1 00:00:00, and stores the clock data in
Setting data
Table 13.7. 1
176
Example
Instruction table:
Network 000
LD X000
RSEC D10 D0 //transform seconds in D10 into clock data and store in
D0~D7
Ladder diagram:
Figure 13.7. 1
TCMP
Instruction introduction
This instruction reads RTC data of PLC, compares it with clock data stored in specified 8
continuous D-registers, and the output result to specified bit-registers. If input time is
earlier than RTC of PLC, the first of the output bit-registers is ON; If input time is same to
RTC of PLC, the second of output bit-registers is ON; If input time is later than RTC of
Setting data
177
(OUT) Head of bit-registers output the comparison result. Y/M/S 0/1 bool
Table 13.8. 1
Example
Instruction table:
Network 000
LD X000
TCMP D0 Y0 //compare time in D0~D7 with RTC of PLC and output
result to Y0~Y2
Ladder diagram:
Figure 13.8. 1
TZCP
Instruction introduction
1. This instruction reads RTC data of PLC, compares it with time frame consists of start
clock and end clock, and output result to specified bit-registers. If RTC of PLC is
before the time frame, the first of the output bit-registers is ON; If RTC of PLC is
within the time frame, the second of output bit-registers is ON; If RTC of PLC is after
178
2. End clock must be later than the start clock. For example, a time frame like [2020/1/1
179
Setting data
(OUT) Head of bit-registers output the comparison result. Y/M/S 0/1 bool
Table 13.9. 1
Example
Instruction table:
Network 000
LD X000
TCMP D0 D10 Y0 //compare RTC with time frame in D0~D7 and
D10~D17, output result to Y0~Y2
Ladder diagram:
Figure 13.9. 1
WKCMP
Instruction introduction
1. This instruction compares RTC with specified clock data regardless of year, month,
180
and day.
2. This instruction reads RTC data of PLC (without year, month, and day), compares it
with time and week data stored in specified 5 continuous D-registers (last 5 words of
the whole clock data), and output result to specified bit-registers. If input time and
week is earlier than RTC of PLC, the first output bit-registers is ON; If input time and
week is same to RTC of PLC, the second output bit-registers is ON; If input time and
week is later than RTC of PLC, the third output bit-registers is ON.
181
Setting data
Table 13.10. 1
Example
Instruction table:
Network 000
LD X000
WKCMP D0 Y0 //compare time and week in D0~D4 with RTC of PLC and output
result to Y0~Y2
Ladder diagram:
Figure 13.10. 1
WKZCP
Instruction introduction
1. This instruction compares RTC with a specified time frame regardless of year, month,
and day.
182
2. This instruction reads RTC data of PLC (without year, month, and day), compares it
with time frame consist of start clock (without year, month, and day) and end clock
(without year, month, and day), and output result to specified bit-registers. If RTC of
PLC is before the time frame, the first output bit-registers is ON; If RTC of PLC is
within the time frame, the second output bit-registers is ON; If RTC of PLC is after the
3. The input start clock and end clock (without year, month, and day) are both stored in
5 continuous D-registers, users can also read from the fourth register of clock data
registers.
4. End clock of the time frame must be later than the start clock of time frame. For
example, the time frame like [23:59:59 Saturday, 00:00:00 Sunday] is illegal.
Setting data
(E) Head of D registers store end clock (without year, month, and day) D - -
of time frame.
(OUT) Head of bit-registers output the comparison result. Y/M/S 0/1 bool
Table 13.11. 1
Example
Instruction table:
183
Network 000
LD X000
WKCMP D0 D10 Y0 // compare RTC with time frame in D0~D4 and D10~D14 (without year,
month, and day), output result to Y0~Y2
Ladder diagram:
Figure 13.11. 1
CKCMP
Instruction introduction
1. This instruction compares RTC with specified time data only include hour, minute,
and second.
2. This instruction reads RTC data of PLC, compares it with time data stored in specified
3 continuous D-registers (the fourth to sixth words of the whole clock data), and
output result to specified bit-registers. If input time is earlier than RTC of PLC, the first
output bit-registers is ON; If input time is the same to RTC of PLC, the second output
bit-registers is ON; If input time is later than RTC of PLC, the third output bit-registers
is ON.
Setting data
(OUT) Head of bit-registers output the comparison result. Y/M/S 0/1 bool
184
Table 13.12. 1
Example
Instruction table:
Network 000
LD X000
CKCMP D0 Y0 //compare time in D0~D2 with RTC of PLC and output result to
Y0~Y2
Ladder diagram:
Figure 13.12. 1
CKZCP
Instruction introduction
1. This instruction compares RTC with specified time frame only include hour, minute,
and second.
2. This instruction reads RTC data of PLC (only include hour, minute, and second),
compares it with a time frame consist of start time (only include hour, minute, and
second) and end time (only include hour, minute, and second), and output result to a
specified bit-registers. If RTC of PLC is before the time frame, the first output
185
bit-registers is ON; If RTC of PLC is within the time frame, the second output
bit-registers is ON; If RTC of PLC is after the time frame, the third output bit-registers
is ON.
3. The input start time and end time are both stored in 3 continuous D-registers, users
can also read from the fourth to sixth registers of clock data registers.
4. End time of a time frame must be later than the start time of time frame. For example,
Setting data
(OUT) Head of bit-registers output the comparison result. Y/M/S 0/1 bool
Table 13.13. 1
Example
Instruction table:
Network 000
LD X000
CKZCP D0 D10 Y0 // compare RTC with time frame in D0~D2 and
D10~D12 (only include hour, minute, and second), output result to Y0~Y2
Ladder diagram:
186
Figure 13.13. 1
Communication Instructions
Notes
Samkoon PLC supports Modbus communication protocol that can be applied for serial
ports like RS232, RS485, and USB, the Modbus support at most 127 slave stations. User
can set communication parameters in PLC parameter settings as shown in Figure 14.1.1.
Figure 14.1. 1
When using Modbus communication, firstly users needs to create Modbus table before
use communication instructions. Shown as Figure 14.1.2 and Figure 14.1.3, the user can
enter Modbus table form project explorer, and edit the table with an operation bar.
187
Figure 14.1. 2
Figure 14.1. 3
Modbus table support function codes 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x0f and 0x10, their function and support register types refer to Table 14.1.1. By setting
slave register, slave length, and master register in Modbus table, data of specified length
can be read from slave registers and store in the master register, or be copied from the
188
master registers and write into the slave registers. The address of slave register is marked
with offset number, Table 14.1.2 shows the offset number of different types of registers.
Table 14.1. 1
Register type Range Data type Read function code Write function code offset number
X 0~127 bit 0x0x/0x02 0x05 0
Table 14.1. 2
189
EX, EY, EAI, EAO are registers of extension module. For CV32 type register, each 2
continuous offset numbers make a 32-bit data, for example: offset number 61024 is low
MBUS
Instruction introduction
1. This instruction is used for the master station to communicate with the slave station
2. Firstly, user need to set communication parameters of serial port before using this
Station number: number of master station or slave station, the devices in same
Baud rate: frequency of data signal, the unit is baud (length of a single character,
always be 1 byte) per second, can be set with 1200, 2400, 4800, 9600, 19200,
38400, 57600, or 115200. The baud rate of master and slave must be same.
Stop bit: length of stop signal, marks the end of one data frame.
Check bit: bit that locates after data bit, can be set with none, even, or odds. If
none, there is no check bit; If even, check bit is 1 if there are even number of
190
high-level signals in data bit; If odds, check bit is 1 if there are odds number of
Timeout and retransmission times: if slave doesn’t return message for the set
timeout, master will resend data, reset timeout, and wait for return message from
slave. If reach the set retransmission times, master will report error code 0x10 in
specified data-register.
status and error of Modbus communication. Table 14.2.1 shows the information code
and corresponding meaning. This instruction also assigns a D register to store the
command is executed, user can also write it to control which command to execute.
Figure 14.2. 1
Code Description
191
0x06 Slave station is busy
0x18 Received information frame error (length error, CRC check error)
Table 14.2. 1
192
Setting data
Table 14.2. 2
Attention
1. Setting of timeout should be adjusted by baud rate, if the baud rate is low, the slow
data transmission may need longer timeout. Additionally, if the data size to transmit is
2. When a serial is used for Modbus communication, it can’t be used for other purpose
3. If one slave of Modbus communication is disconnected, master will still call on it, and
this will cause lag on communication. For quicker response, user can set shorter
Example
This example uses 3 Modbus tables, and a single table is for a single slave station.
Communication will loop among 3 slave stations, and user can also select which slave
193
Modbus table:
Figure 14.2. 2
Instruction table:
Network 000
LDP M8183
MPS
AW= D1234 K1
AW= D5001 K2
MOV K2 D1234 //go to slave 2 when communication of slave 1 is completed
MOV K0 D5003 //initiate command ID of slave 2
MRD
AW= D1234 K2
AW= D5003 K2
MOV K3 D1234 //go to slave 3 when communication of slave 2 is completed
MOV K0 D5005 //initiate command ID of slave 3
MRD
AW= D1234 K3
AW= D5005 K2
MOV K3 D1234 //go to slave 1 when communication of slave 3 is completed
MOV K0 D5001 //initiate command ID of slave 1
MPP
RST M8183 K1
POP
LD M6000
MPS
AW= D1234 K1
MBUS K1 Slave 1 D5000 D5001 //enable Modbus communication if slave 1
MRD
AW= D1234 K1
MBUS K1 Slave 2 D5002 D5003 //enable Modbus communication if slave 2
MRD
AW= D1234 K1
MBUS K1 Slave 3 D5004 D5005 //enable Modbus communication if slave 3
POP
194
Ladder diagram:
Figure 14.2. 3
SEND
Instruction introduction
D-registers (ADDR) with specified length (LEN) to specified serial port (COM).
2. There are system special function registers that record transmission status of
3. There is an extra parameter differs from Modbus communication: Buffer bit. When
buffer bit is selected with 8, transmission only reads low byte of D-registers; When
buffer is selected with 16, transmission reads and writes high byte and low byte of
195
D-registers. User can set this parameter in communication parameters setting.
Register Description
Table 14.3. 1
Setting data
Table 14.3. 2
Attention
2. When a serial is used for free port communication, it can’t be used for other purpose
4. Free port communication is half-duplex, so that the SEND instruction and REV
Example
1. Example 1
196
Instruction table:
Network 000
LDP M0
SEND K1 D0 K21 //select COM1, head register is D0, data length is 21;
//if the buffer is 8-bit, all low byte in D0~D20, 21-byte in whole,
will be sent
//if the buffer is 16-bit, all data in D0~D10 and low byte of D11,
21-byte in whole, will be sent
//SEND is trigger by rising-edge here, if it is enabled by normal
close coil, SEND will execute during each scan period
Ladder diagram:
Figure 14.3. 1
2. Example 2
Instruction table:
Network 000
LD M0
MPS
MVBLK D2000 D1 D0 //move data block of D0 length from D2000 to D1
MPP
ANDI M8180 //disable SEND when transmission is completed
MEP
SEND K1 D1 D0 //send date to COM0 when M0 is ON
Network 001
LD M8180
REV K0 D1001 D1000 //enable REV after transmission is completed
Network 001
LDF M8178 //close under a falling-edge when reception is completed
MOV D1000 D3000 //move data length from D1000 to D3000
MVBLK D1001 D3001 D1000 //move data block of D1000 length from D1001 to D3001
RST M8180 K1 //reset M8180 when transmission is completed
Ladder diagram:
197
Figure 14.3. 2
REV
Instruction introduction
1. This instruction is applied to free port communication, it receives data from specified
serial port (COM), write data into specified D-registers (ADDR), and write data length
2. There are system special function registers that record reception status of
3. There is an extra parameter differs from Modbus communication: Buffer bit. When
buffer bit is selected with 8, reception only writes low byte of D-registers; When buffer
is selected with 16, reception writes high byte and low byte of D-registers. User can
Register Description
198
M8183 Turns ON when reception of serial port COM1 is completed.
Table 14.4. 1
Setting data
Table 14.4. 2
Attention
2. When a serial is used for free port communication, it can’t be used for other purpose
4. Free port communication is half-duplex, so that the SEND instruction and REV
Example
1. Example 1
Instruction table:
Network 000
LDP M0
REV K1 D0 D1000 //select COM1, head register is D0, data length is D1000;
Assume that COM1 receives data: 0x10 0x11 0x12 0x13
0x14
199
//if the buffer is 8-bit, D1000=5, D0=0x0010, D1=0x0011,
D2=0x0012, D3=0x0013, D4=0x0014
//if the buffer is 8-bit, D1000=5, D0=0x1110, D1=0x1312,
D2=0x0014
Ladder diagram:
Figure 14.4. 1
2. Example 2
Instruction table:
Network 000
LD M0
REV K0 D1 D0 //receive date from COM0 when M0 is ON and store data in D1
Network 001
LDP M8182
SEND K0 D1001 D1000 //enable SEND after reception is completed
RST M8182 K1 //reset M8182 automatically
Network 001
LDF M8178 //close under a falling-edge when reception is completed
MVBLK D1 D2000 D0 //move stored receive data to D2000
Ladder diagram:
Figure 14.4. 2
200
CRC
Instruction introduction
1. This instruction calculates specified CRC mode (MODE) check sequence of data with
2. Unit of data length is byte, the data must be stored in D-registers. What should be
noted is, the high byte of data register is at right, the low byte of data register is at left.
4. Generated check sequence is also called redundancy check bit, it will be stored
closely after the origin data, these 2 parts constitute CRC code (Cyclic redundancy
check code).
CRC-12 K1 2 bytes
CRC-8 K2 1 byte
CRC-CCITT K3 2 bytes
CRC-32 K4 4 bytes
CRC-32C K5 4 bytes
Table 14.5. 1
Setting data
201
(LEN) Length of origin data. K/D - 16-bit unsigned integer
(MODE) CRC mode to generate check code. D 0~5 16-bit unsigned integer
Table 14.5. 2
Example
Instruction table:
Network 000
LD M0
MOV H3412 D0
MOV H7856 D1
CRC D0 K4 K0 //select CRC-16 mode, data length is 4 bytes, calculate CRC check code
of 0x12345678 and store result 0x107B in D2
Ladder diagram:
Figure 14.5. 1
CRCCHECK
Instruction introduction
1. This instruction checks CRC code under specified CRC mode (MODE) and output
result to specified bit-register (RES), the origin data with specified length (LEN) starts
2. The CRC code must be stored in D-registers. What should be noted is, the high byte
202
3. Modes of CRC refer to Table 14.5.1.
4. Output bit is ON when check passed, is OFF when check not passed.
Setting data
Table 14.6. 1
Example
Instruction table:
Network 000
LD M0
MOV H3412 D0
MOV H7856 D1
MOV H107B D1
CRCCHECK D0 K6 K0 M1 //origin data is 0x12345678, redundancy check bit is
0x7B10, check is passed
Ladder diagram:
Figure 14.6. 1
203
Pulse Instructions
Notes
outputting is 500kHz. Relay type PLC does not support high-speed pulse.
2. high-speed pulse output can be only counted with high-speed counter but not inner
3. In light load situation, the duration of transistor on OFF state will be longer. When less
response time is needed in this situation, it is better to add load resistance or enlarge
load current.
are readable and writable, when be written with new value, the counting will continue
5. The time high-speed pulse is outputting, value in pulse cumulative counting registers
is discrete and varying. When users need to compare the value, use less than or
6. When an output point is used for high-speed pulse output, it can’t be used as a
204
7. If frequency of pulse output is more than 200k, it’s better to add pull-up resistor in
8. There are special function system registers that store information of instruction
running. User can modify some writable registers of them to control. For all pulse
instructions, there are registers that record pulse direction, pulse count, pulse count
overflow, and pulse outputting status, details refer to Table 15.1.1; For multistage
pulse instructions (PLSR, POLYLINE, e.g.), there are registers that record current
segment number and error segment number, details refer to Table 15.1.2; For
interpolation instructions (POLYLINE, LINE, ARC, e.g.), there are registers that
Pulse
Pulse direction Counter overflow Pulse outputting Pulse Output
accumulation
register flag register status register port
counter
32-bit signed
Data type bool bool bool -
integer
205
Show pulse Show if
Show if Record how
direction of corresponding
corresponding many pulses that Corresponding
corresponding output port is
Description counter is corresponding pulse output
output port, 1 for outputting pulse, 1
overflow, 1 for output port port
positive, 0 for for outputting, 0 for
overflow, 0 for not outputs
negative not
M_8102 (r) M_8118 (r) M_8134 (r) D_8140 (r/w) Y000
Table 15.1. 1
Platform
Error segment Current segment Pulse Output
outputting status
number register number register port
register
16-bit unsigned 16-bit unsigned
Data type - Data type bool
integer integer
Show if
Show which corresponding
Show which segment of path Corresponding platform is
Description
Description segment of path that current pulse output outputting, 1 for
that error occurs motion point port outputting, 0 for
locates in not.
D_8108 (r) D_8124 (r) Y000 M_8144 (1st) (r)
D_8109 (r) D_8125 (r) Y001 M_8145 (2nd)
D_8110 (r) D_8126 (r) Y002 (r)
Register
D_8111 (r) D_8127 (r) Y003 M_8146 (3rd) (r)
D_8112 (r) D_8128 (r) Y004 M_8147 (4th) (r)
Register
D_8113 (r) D_8129 (r) Y005 M_8148 (5th) (r)
D_8114 (r) D_8130 (r) Y006
Table 15.1. 3
D_8115 (r) D_8131 (r) Y007
Table 15.1. 2
206
PLSF
Instruction introduction
1. PLSF instruction outputs pulse with variable frequency, and there is no transition
2. When the instruction is enabled, pulse will start outputting with set frequency, and the
frequency can be adjusted during running, pulsing stops till instruction is disabled.
3. This instruction does not include pulsing direction port output, if there is need for
direction output, user can define any output port as direction port. Shown as Figure
Figure 15.2. 1
Setting data
207
Hz. 0~200000 integer
■ FGm
0~500000
Table 15.2. 1
208
Attention
1. Pulse frequency parameter of PLSF is 32-bit integer, which occupies two D registers.
2. This instruction outputs pulse without direction, so that the pulse accumulation
Example
Instruction table:
Network 000
LDP M8151 //enable when PLC run, must be triggered with rising-edge to avoid repeating assignment
MOVD K400 D0 //original frequency
Network 001
LDP M1
MOVD K900 D0 //variable frequency stored in D0D1
Network 002
LDP M2
MOVD K650 D0 //variable frequency stored in D0D1
Network 003
LDP M3
MOVD K500 D0 // variable frequency stored in D0D1
Network 004
LD M0
PLSF D0 Y000 //when M0 is ON, Y0 outputs pulse with frequency stored in D0D1 and stop till M0
is OFF, frequency transforms following with value in D0D1 transforms.
Ladder diagram:
209
Figure 15.2. 2
PWM
Instruction introduction
1. This instruction outputs pulse with variable frequency and variable duty ratio, and
2. When the instruction is enabled, pulse will start outputting with set frequency and duty
cycle, the frequency and duty cycle can be adjusted during running, pulsing stops till
instruction is disabled.
Setting data
210
(DC) Duty cycle of pulse, ratio that K/H/D 0~100 8-bit unsigned
signal width occupy in a pulse integer
cycle.
Table 15.3. 1
Attention
1. Pulse frequency parameter of PWM is 32-bit integer, which occupies two D registers.
2. This instruction outputs pulse without direction, so that the pulse accumulation
3. Frequency distortion will occur when pulse in high-speed, it’s better not to set pulse
frequency too high when there is need for precise pulse width control.
Example
Instruction table:
Network 000
LD M0
PWM D0 D2 Y000 //When M0 is ON, Y0 outputs pulse with frequency stored in D0D1,
and duty cycle stored in D2D3
Ladder diagram:
Figure 15.3. 1
PWMS
211
Instruction introduction
1. This instruction outputs pulse with variable pulse period and variable pulse width.
2. When the instruction is enabled, pulse will start outputting with set pulse period and
pulse width, the pulse period and pulse width can be adjusted with immediate effect
3. Time unit of this instruction can be selected with millisecond and microsecond. As
wave form distortion may occur when pulse in high-speed, system will automatically
limit pulse width when microsecond time unit is selected, for example, when pulse
width is set 1us, system will adjust it to 2us to keep the wave form.
4. This instruction provides M8062 register to transform level output sequence, this
register decide outputting effective level or noneffective level at first in a pulse cycle.
When M8062 is ON, effective level at first, when M8062 is OFF, noneffective level at
first. What should be noted is, M8062 should be set before PWMS is enable,
Setting data
(P) Period of pulse, the unit is millisecond or K/H/D ● millisecond 16-bit unsigned
microsecond. 2~65535 integer
● microsecond
5~65535
(DP) width of pulse, the unit is millisecond or K/H/D 0~65535 16-bit unsigned
microsecond integer
212
(OUT) Port that outputs the pulse. Y - bool
Table 15.4. 1
Attention
1. Pulse cycle parameter and pulse width parameter of PWMS is 16-bit integer, which
2. This instruction outputs pulse without direction, so that the pulse accumulation
3. Frequency distortion will occur when pulse in high-speed, it’s better not to set pulse
frequency too high when there is need for precise pulse width control.
Example
Instruction table:
Network 000
LD M0
PWMS K0 D0 D1 Y000 //When M0 is ON, Y0 outputs pulse with pulse cycle (ms)
stored in D0, and pulse width (ms) stored in D1
Ladder diagram:
Figure 15.4. 1
213
PLSY
Instruction introduction
2. When the instruction is enabled, pulse will start outputting with set frequency, and the
frequency can be adjusted during running, pulsing stops till instruction is disabled.
When pulse outputting count reach target pulse number, the pulse will stop.
3. This instruction does not include pulsing direction port output, if there is need for
direction output, user can define any output port as direction port. (Refer to
introduction of PLSF)
Setting data
Table 15.5. 1
Attention
1. Frequency parameter and target pulse number of PLSY are both 32-bit integer, which
Example
Instruction table:
Network 000
LDP M8151 //enable when PLC run, must be triggered with rising-edge to avoid repeating assignment
MOVD K400 D0 //original frequency
Network 001
LDP M1
MOVD K900 D0 //variable frequency stored in D0D1
Network 002
LDP M2
MOVD K650 D0 //variable frequency stored in D0D1
Network 003
LDP M3
MOVD K500 D0 //variable frequency stored in D0D1
Network 004
LD M0
PLSY D0 D2 Y000 //when M0 is ON, Y0 outputs pulse with frequency stored in D0D1 and
stop till value in D2D3 reaches target pulse number, frequency
transforms
Network 005
LDF M8134
RST M0 K1 //when pulse stop, reset M0 to disable PLSF
215
Ladder diagram:
Figure 15.5. 1
Sequence chart:
Figure 15.5. 2
PLSR/PLSA/EPLSR
Instruction introduction
1. PLSR, PLSA and EPLSR are all multistage pulse outputting instructions, they output
pulse with set frequency and target pulse number, and the parameters can be
216
adjusted dynamically. Target pulse number of PLSR is set relatively, target pulse of
segments separately.
2. When PLSR/PLSA/EPLSR is enabled, pulse will start outputting with set frequency,
and transfer to next segment when meet target pulse number, the transition will be
stored in a piece of D-register area start from first address Dn, Figure 15.6.1 shows
3. When target pulse number of one segment is set -1, pulse outputting will be fixed in
the segment till corresponding PLSNEXT instruction is enabled. When frequency and
target pulse number of one segment are set 0, the segment will be end segment,
4. For one single segment of whole, set start frequency of the segment as Fs (Hz), set
end frequency of the segment as FE (Hz), set sum of acceleration and deceleration
time as T (s), set pulse count of this segment as N. And these parameters should
(FS+Fe) T ≤ 2N
5. For PLSR, direction outputting is decided by sign of frequency or target pulse number
in first segment (if one of them is negative, the direction outputting is negative), and it
target pulse number in each segment, and it will change automatically. For EPLSR,
direction outputting will also change automatically according to actual pulse count.
217
6. M8068 is pulse direction outputting polarity register, when it is ON, all pulse direction
outputting will reverse. M8069 is curve type register, when it is ON, pulse outputting
7. Frequency parameter and target pulse number parameters stored in D-register can
running one.
Setting data
PLSR/PLSA and EPLSR create a piece of D-registers area to store segments parameters.
Shown as Figure 15.6.1, for PLSR/PLSA, each four D-registers store parameters of one
segment; For EPLSE, each six D-registers store parameters of one segment.
Figure 15.6. 1
PLSR/PLSA
218
Inputs/outputs Description Operand Range Data type
Table 15.6. 1
EPLAR
Table 15.6. 2
Attention
two D registers.
2. This instruction outputs pulse with direction, so that the pulse accumulation counter
3. Pulse outputting stops at segment with 0 frequency and 0 target pulse number, notice
4. Pulse accumulation counters only count when pulse instruction is abled, the count will
219
Example
Instruction table:
Network 000
LDP M8151
MOVD K100000 D0 //set pulse frequency of 1st segment to D0D1
MOVD K200000 D2 //set target pulse number of 1st segment to D2D3
MOVD K200000 D4 //set pulse frequency of 2nd segment to D4D5
MOVD K300000 D6 //set pulse frequency of 1st segment to D6D7
FMOVD K0 D8 K2 //end segment, set 0 to D8-D10
Network 001
LD M0
PLSR D0 K100 Y000 Y004 //PLSR start running when M0 is ON
Ladder diagram:
Figure 15.6. 2
Find PLSR instruction in project explorer through click path: Project -> instruction ->
Pulse -> PLSR, right click PLSR, and user can set function name and block of
function. Create this function and there will be a CALLM instruction block in ladder
Figure 15.6. 3
Double click the CALLM instruction block, user can fill value in the table to set
parameters. The Frequency chart briefly shows how the frequency transform (refer to
Figure 15.6. 5
Figure 15.6.6
Instruction table:
Network 000
221
LD M8151
CALLM SetDPLSRParams D0 //set parameters by function
MOVD K100 D100 //set acceleration/deceleration time
Network 001
LD M0
PLSRD0 D100 Y000 Y004 //PLSR start running when M0 is ON
Network 002
LDF M8134 //pulse outputting is over
RST M0 K1 //reset M0
Ladder diagram:
Figure 15.6.7
PLSNEXT
Instruction introduction
This instruction switches current segment of multistage pulse outputting to next segment.
When instruction is enabled and the pulse outputting is in stable frequency, the pulse
Setting data
Table 15.7. 1
222
Attention
1. This instruction takes no effect when pulse is accelerating or decelerating. When next
segment is end segment and pulse is in stable frequency, enabling this instruction will
3. This instruction must be enabled with edge trigger, otherwise the pulse will be in a
mess.
Example
Instruction table:
Network 000
LD M8151
MOVD K100000 D0 //set frequency of 1st segment
MOVD HFFFFFFFF D2 //set target pulse number of 1st segment to maximum, wait for PLSNEXT
MOVD K200000 D4 //set frequency of 2nd segment
MOVD K9999999 D6 // set target pulse number of 2nd segment
FMOVD K0 D8 K2 //end segment
MOVD K100 D100 //set acceleration/deceleration time
Network 001
LD M0
PLSR D0 D100 Y000 Y010 //PLSR start running when M0 is ON
Network 002
LDF M8134 //pulse outputting is over
RST M0 K1 //reset M0
Network 003
LDP X000 //use rising-edge of X000 to trigger
PLSNEXT Y000 //switch pulse of Y000
Ladder diagram:
223
Figure 15.7. 1
PLSSTOP
Instruction introduction
When this instruction is enabled, corresponding pulse output port will pulse stop
outputting as selected stop mode. If stop mode is immediate stop, the pulse outputting will
stop immediately without deceleration time; If stop mode is slowing down to stop, the
Setting data
224
(MODE) Stop mode of pulse outputting, 0 for Immediate stop, 1 K 0~1 8-bit unsigned
for slowing down to stop integer
(TIME) Deceleration time of slowing down to stop. K/H/D 0~65535 16-bit unsigned
integer
Table 15.8. 1
Attention
Example
Instruction table:
Network 000
LDP M11 //trigger with rising-edge of M11
PLSSTOP Y000 K1 K100 //pulse outputting of Y0 stops in 100ms
Ladder diagram:
Figure 15.8. 1
DRVI/DRVA
Instruction introduction
1. DRVI/DRVA outputs pulse with set frequency, set target pulse number, set
acceleration time and deceleration time, DRVI is set with relative target pulse number
225
and DRVA is set with absolute target pulse number. When the instruction is enabled,
pulse starts to accelerate to set frequency in set acceleration time, and decelerates to
0 in set deceleration time and reach set target pulse number. When the instruction is
2. These instructions can be controlled by special function register M8068, when M8068
3. This instruction can be set curve mode by special function register M8069, when
M8069 is ON, the frequency curve is S-shape type, when it is OFF, the frequency
Setting data
Table 15.9. 1
Attention
This instruction outputs pulse with direction, so that the pulse accumulation counter
226
(D8140-D8158) can count in both directions.
Example
Instruction table:
Network 000
LDP M8151
MOVD K100000 D0 //target pulse number stores in D0D1
MOVD K50000 D2 //pulse frequency stores in D2D3
MOV K100 D4 //acceleration time stores in D4
MOV K200 D5 //deceleration time stores in D5
Network 001
LD M0
DRVI D0 D2 D4 D5 Y1 Y6 //pulse starts outputting when M0 is ON
Ladder diagram:
Figure 15.9. 1
POLYLINEF/POLYLINEI
Instruction introduction
float), correspondingly they use pls (pulse count) and mm (millimeter) as units.
2. These instructions output pulse to control motion, of which path is combined by lines
and arcs. Pulse frequency transits smoothly through joints when two path segments
227
are joined collinearly or tangentially, otherwise pulse decelerates or accelerates near
the joints. the configuration of lines and arcs refers to introduction of LINEI/LINEF and
ARCI/ARCF instructions.
3. POLYLINE parameters can be mapped to D-registers for dynamic control, user can
parameters in D-registers while motion running is allowable, so that the velocity can
D-registers", there is no need to input any parameters value in the instruction, the
motion path will totally be decided by the assigned data sequence in D-registers.
Figure 15.10. 1
ARCI/ARCF, and BLOCK, e.g.), platform system must be set at first. The polyline system
creates a platform with 2 axes, and all interpolations are based on this platform.
228
Brief introduction
1. The click path of polyform system setting is: Main menu -> Pulse -> Pulse
platform.
2. There are 5 platform systems to select, they take effect after enabled.
3. there are two kinds of unit to select: mm (millimeter) and pls (pls count).
error-prone, and easy to convert. The unit selection only affects setting of the
4. Overrun processing is used together with limit of X/Y axis. System will alarm
when motion of next segment is going to break the limit, if “Ignored” is selected,
overrun will be ignored; If “Slowing down and stop” is selected, motion will stop in
5. Pulse output port must be set with high-speed pulse output port (refer to first of
pulse instruction notes), direction output port can be set with any Y port. And all
pulse output ports and direction output ports of enabled platform system must
not be repeated.
6. Pulse equivalent means distance that actuator motions per single pulse. In actual
Pulse equivalent is core parameter that link set coordinate to actual measure, it
must be accurate.
229
according to actual situation. When motion breaks the boundary, system will
this parameter in coarse tuning, but in fine tuning. This parameter is not suitable
to be set too big, it is better to adjust mechanical structure when clearance is big.
Attention
1. Pulse equivalent of X-axis and Y-axis should be set equal as far as possible, if
not, the system unit should choose pls (pulse count) to avoid conversion
troubles.
2. When pulse equivalent of X-axis and Y-axis is set different, all calculation of
pulse count unit without relation to specified axis (such as calculation of velocity)
3. All pulse output ports and direction output ports of enabled platform system must
not be repeated.
230
Operation introduction
Figure 15.10. 2
1. First, the platform system must be selected and enabled (refer to platform system
2. User can choose mm (millimeter) or pls (pulse count) as parameter unit, respectively
231
correspond to POLYLINEF and POLYLINEI instruction. POLYLINEF is more
recommendable, as the millimeter unit is more realistic, less error-prone, and easy to
convert.
delete, and move operations are selectable. (Configuration of lines and arcs refers to
4. Position and velocity parameters can be input with K or D type data. In the situation
velocity parameter is input with D type data, changing the value of relative D-register
can also change velocity in real time. Additionally, velocity would not change
should be noted that, when using MOV type instruction to assign the D-registers for
path parameters, the selection of MOVD and MOVF is decided by the POLYLINE
parameters of which unit is pulse count, so that the value must be assigned by MOVD.
the value must be assigned by MOVF. And the unit of acceleration and deceleration
5. "Mapping to D-registers" mode means, in the time instruction is enabled, all the set
specific order. the mapping rule refers to Figure 15.10.3, also the mapped D-registers
address will show before the input box once user select this mode. What should be
232
noted is, the execution of segments interpolation is prospective. The segment after
the one in execution will be processed and not permitted to be modified. Modification
prospective mistake will appear, lead to confusion and even running error. This
Figure 15.10. 3
6. When "Only mapping to D registers" mode is selected, path will only be controlled by
values in mapped D-registers, and values input in the instruction takes no effect in
this mode. The mapping rule refers to Figure 15.10. 4. Different from "Mapping to
D-registers" mode, there is a block of D-registers that save global velocity parameters.
If the velocity mode control bit of segments in other parameters is set with 1, the
with red in the figure), otherwise it will be controlled by global velocity parameters.
233
Figure 15.10. 4
7. In "Only mapping to D registers" mode, using MOV type instructions to assign value
templates "OnlyDMappingI" and "OnlyDMappingF" are designed for this work. Users
can import and use the function blocks refer to Figure 15.10.5 and Figure 15.10.6,
function details refer to the annotation in it (the function files locate in “PlaneSys”
234
Figure 15.10. 5 Figure 15.10. 6
Attention
1. This instruction outputs pulse with direction, so that the pulse accumulation counter
2. Acceleration and deceleration time will take no effect if the value is set too small.
3. When pulse equivalents of X and Y axes are set different in platform system, by
default the real velocity will be calculated with pulse equivalent of X axis.
4. M8134 register can only show if Y0 output point is outputting. If there is need to get
running state of platform system, use M8144 register that show ON when any axis of
235
Example
Use this instruction to paint graph as Figure 15.10.7, interpolation velocity of line is
Figure 15.10. 7
Ladder diagram:
Figure 15.10. 8
Add lines and arcs in sequence, and set position parameters of them. For speed, line
is set with D-type data and assigned value with MOVD/MOVF according to instruction
2. Mapping to D-registers
236
Add lines and arcs in sequence, set first address of mapping D-registers, and set
Import function block OnlyDMappingF and set as following code. Additionally, trigger
ParaAddr = AddEndF(ParaAddr);
LINEF/LINEI
Instruction introduction
1. LINEI/LINEF instructions differs for the parameter types (integer and float),
2. These instructions complete straight-line path from current point to end point in
3. relations of line path length (L), velocity (V), acceleration time (Tac) and deceleration
time (Tde) should meet condition below (value of these parameters will be adjusted
237
0.5 × (Tac + Tde) ×V ≤ L
If the parameters were set too unreasonable to adjust automatically, instruction may
stop outputting pulse when error was checked. Users can modify parameters
Operation introduction
1. First, the polyline number must be selected and enabled (refer to platform system
2. User can choose mm (millimeter) or pls (pulse count) as parameter unit, respectively
correspond to LINEF and LINEI instruction. LINEF are more recommendable, as the
3. End-point X and end-point Y are the coordinates of final position of line path, these
parameters can be input with K or D type data. The selection of MOVD and MOVF to
(LINEI/LINEF) type.
4. When relative coordinate mode is selected, the coordinate of end point is based on
offset from current point. When absolute coordinate mode is selected, the coordinate
of end point is based on offset from origin point. These 2 modes refer to Figure
15.11.1.
238
Figure 15.11. 1
5. Acceleration and deceleration time parameters can be set with K or D type data. If set
with D type data, during initialization instruction will read value from D registers as
are 16-bits integer, must be assigned with MOV instruction. Limited by interpolation
period (4ms) of algorithm, frequency hopping will be too sharp to make acceleration
and deceleration effective if time was set too small. The acceleration and
Figure 15.11. 2
239
6. Speed parameter means resultant velocity of X-axis and Y-axis, this parameter can
be set with K or D type data. If set with K type data, the speed of line path will be
non-adjustable; if set with D type data, the speed can be adjusted by the value in
corresponding D register. Also, the selection of MOVD and MOVF to assign value of
equivalents of X and Y axis are set different, system will calculate speed with pulse
speed parameters are set illegal, system will adjust these parameters to make them
legal. The adjustment refers to Figure 15.11.2 (blue line means normal case, green
Attention
1. This instruction outputs pulse with direction, so that the pulse accumulation counter
3. When unit is set with pls, the unit of speed is pls/s. If pulse equivalent of X-axis and
Y-axis are set different, by default the resultant velocity is calculated on base of
4. Special function register M8134 to M8153 only shows if corresponding pulse output
port is outputting, if there is need to detect if interpolation is running, user should use
240
Example
Paint a line from current point to end-point, when interpolation starts, M500 is set, when
interpolation is over, M500 is reset. Platform system set Y0 port as X-axis pulse outputting
Ladder diagram:
Figure 15.11. 3
ARCF/ARCI
Instruction introduction
1. ARCI/ARCF instructions differs for the parameter types (integer and float),
2. These instructions complete arc path from current point to end point in specified
platform system.
3. relations of line path length (L), velocity (V), acceleration time (Tac) and deceleration
time (Tde) should meet condition below (value of these parameters will be adjusted
0.5 ×(Tac+Tde)×V ≤ L
241
If the parameters were set too unreasonable to adjust automatically, instruction may
stop outputting pulse when error was checked. Users can modify parameters
4. In 2-point arc painting mode, it should be noted when setting parameters, length from
end point to current point must be less than arc radius, otherwise system will regard
5. In 3-point arc painting mode, it should be noted when setting parameters, end point,
6. In center arc painting mode, it should be noted when setting parameters, center point
must be at middle perpendicular of link line between end point and current point.
7. The path of arc interpolation is composed with micro line path, there will be chord
error between actual path and theoretic path (refer to Figure 15.12.1). When the arc
radius parameter is small and interpolation speed parameter is big, even if the
parameters is legal, chord error still can’t be ignored. The relations of chord error,
interpolation speed and arc radius refer to Figure 15.12.2, chord error will be
prominent in high speed and short radius. System will lower the speed to avoid big
chord error, also there should not be arc with too small radius in actual use.
242
Figure 15.12. 1 Figure 15.12. 2
Operation introduction
1. First, the polyline number must be selected and enabled (refer to platform system
2. User can choose mm (millimeter) or pls (pulse count) as parameter unit, respectively
correspond to LINEF and LINEI instruction. LINEF are more recommendable, as the
3. End-point X and end-point Y are the coordinates of final position of arc path, these
parameters can be input with K or D type data. The selection of MOVD and MOVF to
(LINEI/LINEF) type.
4. When relative coordinate mode is selected, the coordinate of end point is based on
offset from current point. When absolute coordinate mode is selected, the coordinate
of end point is based on offset from origin point. These 2 modes refer to Figure
1.11.1.
243
5. Acceleration and deceleration time parameters can be set with K or D type data. If set
with D type data, during initialization instruction will read value from D registers as
are 16-bits integer, must be assigned with MOV instruction. Limited by interpolation
period (4ms) of algorithm, frequency hopping will be too sharp to make acceleration
and deceleration effective if time was set too small. The acceleration and
6. Speed parameter means resultant velocity of X-axis and Y-axis, this parameter can
be set with K or D type data. If set with K type data, the speed of line path will be
non-adjustable; if set with D type data, the speed can be adjusted by the value in
corresponding D register. Also, the selection of MOVD and MOVF to assign value of
equivalents of X and Y axis are set different, system will calculate speed with pulse
speed parameters are set illegal, system will adjust these parameters to make them
7. Arc painting modes include 2-points mode, 3-points mode and center mode, these
modes use different parameters. In 2-points mode, refer to Figure 15.12.3, the user
need to confirm which path to go between the current point and end point decided by
turning direction (clockwise or anti-clockwise) and arc length (minor or major arc). In
3-points mode, refer to Figure 15.12.4, the user only needs to confirm a mid-point
244
between current point and end point. In center mode, refer to Figure 15.12.5, users
Attention
1. In 2-points arc painting mode,the length from end point to the current point must be
2. In 3-points arc painting mode, end point, mid-point and current point must not be
collinear.
3. In center arc painting mode, the center must be at the middle perpendicular of the link
Example
Paint an anticlockwise minor arc form current point to end-point with 100mm radius, when
interpolation starts, M500 is set, when interpolation is over, M500 is reset. Platform
system set Y0 port as X-axis pulse outputting port, set Y1 as Y-axis pulse output port.
245
Ladder diagram:
Figure 15.12. 6
BLOCK
Instruction introduction
1. This instruction controls pulse to paint the imported graph in a specified platform
system.
2. For the present, this instruction only supports the imported graph from AutoCAD that
combined with line and arc, additionally it only supports DXF file format.
Operation introduction
1. First, using AutoCAD software to paint the graph with line and arc only, and what
should be noted is, user should confirm the size of platform system to avoid the
246
painted the graph crossing the border of the platform system. imported graphs are all
painted with the absolute coordinate, so the origin point of the platform system need
to overlap with the origin point of world coordinates in AutoCAD, set size unit to the
millimeter, and check if all the segments are necessary to paint in the graph, and it is
3. Import graph from click path: main menu -> pulse -> import graph. Refer to Figure
15.13.1.
4. After completion of import, choose the platform system in which the graph located
5. Add a BLOCK instruction in the ladder graph, choose which graph to paint, and set
flag-bit. During the drawing process, some graph can’t be completed with one stroke,
transition lines are needed among these graph parts. Those transition lines need not
paint are called imaginary lines (dotted lines), those lines need to paint are called real
lines (solid lines). Flag-bit is used to distinguish between real lines and imaginary
247
Attention
1. Acceleration and deceleration time will take no effect if the value is set too small.
2. During the painting process, the speed parameter will be adjusted automatically if it is
illegal, the speed will slow down according to the shapes of the graph path.
3. Size of the imported graph file is not permitted to be too big. otherwise graph is not
able to be downloaded.
Example
Painting graph as Figure 15.13.2, import file Luffy.dxf as Figure 15.13.1 shows, set flag-bit
as Y6, set and enable platform system, set velocity with D0, set acceleration time with
Figure 15.13. 1
248
Figure 15.13. 2
Figure 15.13. 3
PAUSE
Instruction introduction
2. This instruction takes effects during painting process of POLYLINE and BLOCK.
pulse outputting of corresponding platform system will stop when PAUSE is enabled,
and continue when PAUSE is disabled, PAUSE dose not influence paths of graph
painting.
249
Operation introduction
2. Set a platform system of PAUSE instruction in accord with the platform system in
PASUE instruction when the pause of painting is needed, then painting will slow
down and stop, the deceleration time is in accord with deceleration time set in
painting is needed.
Attention
1. Pause may not always respond immediately, PAUSE will not start during
when the interpolation instruction is enabled, the graph painting will restart from the
3. After a pause, the interpolation instruction will still occupy the pulse and direction
ports. The stop state after the pause is unable and not permitted to be removed.
250
Example
Ladder diagram:
Figure 15.14 1
ZRNR
Instruction introduction
This instruction controls workbench to return to zero from any position. When this
instruction is enabled, according to the default zero returning direction and mode,the
pulse will be generated and stop beside a particular range until meets zero signal. When
Setting data
Table 15.15. 1
Parameter introduction
1. Crawl speed and returning speed parameters can be inputted with 32-bit K/D/H(hex)
type value. When both speed parameters are set with a minus value, the default zero
returning direction will be changed, additionally the zero-signal position will also be
changed.
2. Pulsing port and pulsing direction assign which port to output pulse and pulse
direction.
3. Zero signal, positive/negative limit signal and Z-phase signal input ports should be
inputted with ports that connect to the corresponding sensor (signal input port can be
inputted with X port or M register), among them, positive/negative limit signal and
4. Polarity of zero signal and positive/negative limit signal should be decided by actual
5. In most cases (start position being beyond zero signal area), default zero returning
direction decides the motion direction of the workbench from the start position to zero.
6. There are 2 kinds of zero returning modes, near-point signal mode and zero
positive-edge mode, zero returning path and position of 2 modes are different (refer
7. Together, zero returning mode and default zero returning direction decide the final
252
zero position (on which side of the zero signal area).
Attention
1. After using this instruction to complete zero returning action, pulse accumulation
counters of corresponding output ports will be reset automatically as the origin point.
2. Filtering mode of sensors connected to X input ports should be set OFF, or there will
3. When the signals of pulsing ports are high level, the direction of workbench motion
otherwise, the direction is negative direction, the corresponding limit is the negative
limit.
(to make sure the outputs of pulsing direction are influenced by other instructions).
5. If the default zero returning direction is selected positive, in most cases (start position
being beyond zero signal area) the pulsing direction starts with high level, the
negative, it's opposite. Users can select the appropriate default zero returning
direction according to the actual case (such as in which area start position located
6. User should affirm the final zero position before using. Refer to Figure 15.15.1, it
shows the final zero position on near-point signal mode. Final zero position will locate
253
in side of zero signal area near positive limit if the default zero returning direction is
positive, or near the negative limit if the default zero returning direction is negative.
Figure 15.15 1
7. Positive/negative limit signal and Z-phase signal are optional, if neither of 2 limit
signals is selected, zero returning from any position can’t be realized(the following
zero returning paths that relate to unselected limit signals will not be realized, others
paths that unrelated to unselected limit signals can be realized still). User can select
Z-phase signal as need (Z-phase pulsing of servo can be connected to PLC. What
should be noted is the signal must be in 24V level, please transform it if not,
8. If workbench stops when entering positive/negative limit area during zero returning,
and the error message shows "Zero signal lost", please check if the sensor of zero
signal works normally. After troubleshooting, zero returning still can work by enabling
instruction. If workbench stops during zero returning and the error message shows
"Acceleration and deceleration distance is too long", this indicates the workbench
reach and even overstep the limit signal area, please check position of workbench
9. If workbench can’t decelerate to crawl speed in the zero signal area, please widen
zero signal area appropriately or lower acceleration and deceleration time to make
workbench to decelerate to 0.
12. returning error can be influenced by the following 3 factors: Final motion speed when
meeting zero position (if the speed is lower, the error is smaller; Scan period of PLC
(if the scan period is shorter, the error is smaller). Motion inertia of workbench (if the
On the case of negative default zero returning direction, the following schematic plots
show how workbench motion during zero returning in 2 modes (In the plots, the circle
within number means point during zero returning path,the red arrow means accelerated
motion, the green arrow means uniform motion, the blue arrow means decelerated
motion).
1. Start position locates between the positive limit signal area and zero signal area.
Figure 15.15 2
255
③→④: Workbench enters zero signal area and decelerates to crawl speed.
Figure 15.15 3
⑥:Workbench stops at the side of the zero signal area, if Z-phase is selected,
Figure 15.15 4
③→④: Workbench enters zero signal area and decelerates to crawl speed.
⑤→⑥: Workbench stops at the side of the zero signal area, if Z-phase is selected,
256
workbench stops at the Z-phase signal.
⑦:
Figure 15.15 5
⑥:Workbench stops at the side of the zero signal area, if Z-phase is selected,
Figure 15.15 6
257
Figure 15.15 7
③: Workbench stops at the side of the zero signal area, if Z-phase is selected,
4. Start position locates between zero signal area and negative limit signal area.
Figure 15.15 8
⑧→⑨: Workbench enters zero signal area and decelerates to crawl speed in a
negative direction.
⑩: Workbench stops at the side of the zero signal area, if Z-phase is selected,
Figure 15.15 9
⑥→⑦: Workbench enters zero signal area and decelerates to crawl speed.
Figure 15.15 10
⑤→⑥: Workbench enters zero signal area and decelerates to crawl speed in
negative direction.
259
⑦: Workbench stops at side of zero signal area, if Z-phase is selected, workbench
Figure 15.15 11
③→④: Workbench enters zero signal area and decelerates to crawl speed in a
positive direction.
JOG
Instruction introduction
1. This instruction can generate jog pulse with direction by setting frequency and
2. This instruction can judge the sign of frequency automatically, and adjust the pulsing
direction of Y output points. for example, when the frequency is 100kHz the pulsing
260
direction is positive, when the frequency is -100kHz the pulsing is negative, there is
T-shape and S-shape position control, it is S-shape when the control bit located in
Setting data
Table 15.16. 1
Attention
This instruction outputs pulse with direction, so that the pulse accumulation counter
Example
Instruction table:
Network 000
LD M0
JOG K100000 K100 Y0 Y4 //JOG start outputting pulse when M0 is ON
261
Ladder diagram:
Figure 15.16. 1
FOLLOW
Instruction introduction
This is a pulse sending instruction. The pulse sending frequency is determined according
to the speed of the change of the following value. The number of pulses sent is
Operation introduction
1. At first, refer to the ladder diagram of an example, set the first address of following
2. Value in address D0 (32-byte value) is the target value that pulse follows, in this
example the target value is in CV235. What should be noted is that, if the value
changes too fast, the corresponding frequency may be beyond the limit. Additionally,
the following is only decided by the change of target value, the original value before
When the performance parameter is big, the motion will follow the target strictly with a
262
short delay, the follow will be stiff. When the performance parameter is small, follow
will be slow and not so strict, but more flexible, more suitable to response shock. if
there is no need for such strict follow, it is recommended to set this parameter to 50.
2 coefficients can be set from 1 to 100. The result after multiplication and division is
used as pulsing quantity, and the result will be treated as extremum if beyond the
extremum.
Setting data
Table 1.17. 2
Attention
1. This instruction outputs pulse with direction, so that the pulse accumulation counter
263
(D8140-D8158) can count in both directions.
2. Target value should not change sharply during the following, otherwise frequency of
Example
Instruction table:
Network 000
LD M8151
EHCNT CV235 K2 K0 K9999999 //enable counter when running
Network 001
LD M0
MOVD CV235 D0 //set instruction to follow the counter CV235
MOV K20 D2 //set performance parameter
MOV K0 D3 //set feedforward compensation ratio parameter
MOV K1 D4 //set multiplication coefficient
MOV K1 D5 //set division coefficient
FOLLOW D0 Y000 Y012 //FOLLOW starts when M0 is ON
Ladder diagram:
Figure 15.17. 1
264
ECAM
Instruction introduction
In the material cutting industry, traditional methods mostly use stopping shear and
stopping cut, these methods are inefficient and may not meet the requirements of the
material molding process. In the packaging and printing industries that need real-time
Refer to Figure 15.18.1 that shows how mechanical CAM works, the component that
drives the rotation of CAM is the input-axis, the component that pushed by CAM is
output-axis, this corresponding relation is decided by the profile of CAM, which can be
actual processing, not all parts of CAM profile play a key role, only some points and
segments of CAM profile work in processing, by using these points and segments,
combined with appropriate mathematical models, function relation between the position of
the main shaft and driven shaft can be build. On base of the function relation, position of
the output-axis can be calculated with position of input-axis, so that PLC can output pulse
to control output-axis to move to the corresponding position as CAM profile does, this is
265
Figure 15.18. 1
Compared with mechanical CAM, electronic CAM is more flexible, more convenient to
modify the profile, and cheaper to maintain. For the present ECAM instruction has 3
modes: flying saw mode, flying shear mode and universal CAM mode. Among them, flying
saw mode and flying shear mode are 2 specific application scenarios of universal CAM,
mainly apply to profile cutting, fixed-length paper cutting and other fields. For these 3
additionally, user can preview and adjust the motion curve of CAM.
flying saw mode of EACM instruction controls driven cutting machine motion to follow
input-axis. The cutting machine cuts material by using a synchronous area in motion, then
slow down to 0 and back to the origin point rapidly, waiting for the next following motion.
This kind of cutting motion can keep the input-axis ongoing and improve efficiency.
As shown in Figure 15.18.2, modules of flying saw consist of feed drive of input-axis,
position feedback of input-axis, linear following of the output-axis and cutting module.
Usually, the servo or transducer constitutes feed drive of the input-axis, encoder
266
constitutes position feedback of input-axis that feedback current position and velocity of
input-axis. Servo with lead screw constitutes linear following of output-axis that drives the
motion of the cutting module. The cutting module is mainly driven by hydraulic pressure,
pressure system or servo drive. Compared with implanting flying saw programs into the
servo systems, using PLC to realize this program will be easier to modify. ECAM
instruction makes the control of flying saw more convenient and efficient.
Figure 15.18. 2
Main driving part is driven by a servo or transducer, it drives the press roller to feed.
Position and velocity of input-axis are feedback by encoder that connects with PLC input.
Servo of the flying saw gets pulse signals output from PLC set by flying saw function, and
drive the cutting module to position located on output-axis correspond to the CAM curve,
then cutting module cuts according to marks on synchronous area. Origin is used for reset
of the cutting module, near the limit and the far limit is used for limitation protection.
flying saw need to configure cutting length, and generate flying saw curve automatically
according to curve parameters, mechanical parameters and so on. The curve consists of
267
Figure 15.18. 3
In the figure, the horizontal axis means the position of input-axis, vertical axis means the
position of the output-axis. material length equal to the sum of distance that input-axis
velocity of input-axis in stable running) multiplies by cutting time (need to be more than
What should be noted is, acceleration and deceleration will be more stable if the
accelerating area and decelerating area are longer. When material length is fixed, longer
accelerating area and the decelerating area will result in a shorter synchronous area, and
Same as flying saw, flying shear keep the output-axis and input-axis synchronous when
cutting to make cutting ongoing and efficient. What is different is the motion mode of the
output-axis, for flying saw it is transitional motion, for flying shear it is rotational motion.
As shown in Figure 15.18.4, module of flying shear consists of the feed drive of input-axis,
position feedback of input-axis and cutting wheel. Usually the cutting wheel is driven by a
servo.
268
Figure 15.18. 4
As shown in Figure 15.18.5, motion area of flying shear is divided into 3 parts:
accelerating area, synchronous area, and decelerating area. As the rolling motion is a
Figure 15.18. 5
To generate flying shear curve, user need to configure cutting length, angle of
accelerating area, angle of synchronous area, number of cutters and so on. the curve
Figure 15.18. 6
269
In the Figure, horizontal axis means position of input-axis, vertical axis means angle
position of output-axis.
Flying saw and flying shear is a common application of CAM. For more wise and flexible
use, there is general CAM that can generate a motion curve by key-joints.
Shown as Figure 15.18.7, user can set any target key-joints (consist of X/Y coordinates
Figure 15.18. 7
Setting data
Parameters of ECAM can be divided into 2 parts, one part is general parameters, and
another part is parameters in different modes. ECAM will not run if parameters are set
illegal, and the error code register D8176 will show corresponding error code 46. Possible
P.S.
INT32 means 32-bit signed integer, UINT32 means 32-bit unsigned integer, FP32
means 32-bit floating-point number, INT16 means 16-bit signed integer, UINT16
270
means 16-bit unsigned integer, bool means flag bit.
Figure 15.18. 8
Figure 15.18.8 shows the interface of parameter configuration, Table 15.18.1 shows brief
divided into 3 types: running status parameter, following factor, and compensation factor.
Parameter type Parameter name Data type Operand Default Range Unit
Pulse output Y
Pulse related
Pulse direction Y
INT32 W/R
(Readable
Measured phase position of
when running, D pls
input-axis
General Running status writable when
271
System reserved INT32 W/R D
Table 15.18. 1
Pulse output:
Pulse direction:
Register that the record phase position of the input-axis, can be set with D or CV
register.
Counting direction:
decremental
Clutch flag-bit:
Flag-bit that control clutch, can be set with X or M register (support X port of IO
expansion board, not support X port of extended module, additionally the X port
restart from the phase position where ECAM disable; If not, running will restart from
the origin.
272
Measured phase position of input-axis:
Phase position that input-axis locates in one cycle, recount at begin of the new cycle.
For flying saw/shear, phase position means feedback pulse count of the
corresponding encoder during one order length cut; For general CAM, phase position
Phase position that output-axis locates in one cycle, recount at begin of the new cycle.
For flying saw and general CAM, phase position may be the same in a different
areas(segment), it should work with current segment number; For flying shear, phase
position means feedback pulse count of the corresponding encoder during one order
length cut.
Phase position of the output-axis that input-axis corresponds to in the CAM curve, it is
System reserved:
Synchronization flag-bit:
Flag-bit that shows if output-axis is in synchronization area, 1 means in, 0 means not.
Binding flag-bit:
Flag-bit that controls and shows if the output-axis is binding with input-output-axis, 1
Multiplication coefficient:
Division coefficient:
Parameter that adjusts stiffness of following, bigger the parameter is, closer the
fixed-mark mode.
Figure 15.18. 9
Figure 15.18.9 shows the interface of flying saw parameter configuration, Table 15.18.2
Parameter type Parameter name Data type Operand Default Range Unit
274
Input-axis pulse count pre cycle UINT32 W D/K >0 pls
parameter Output-axis pulse count pre cycle UINT32 W D/K >0 pls
Fixed-mark setting
Table 15.18. 2
Fixed-mark setting:
Flag-bit of color-mark:
Input of mark detection signal (support X port of IO expansion board, not support X
In fixed-mark mode, after one color-mark is detected,the system will not detect next
until the output-axis run a distance combined with order cutting length and protection
distance.
275
Order cutting length:
In fixed-length mode, order cutting length is the actual cutting length; In fixed-mark
Figure 15.18. 10
Figure 15.18.10 shows the interface of flying shear parameter configuration, Table
Parameter type Parameter name Data type Operand Default Range Unit
Mechanical Input-axis pulse count pre cycle UINT32 W D/K >0 pls
Flying shear parameter parameter Input-axis motion length per cycle FP32 W D/K >0 mm
276
Output-axis motion length per cycle FP32 W D/K >0 mm
Fixed-mark setting
Table 15.18. 3
Figure 15.18. 11
Figure 15.18.11 shows the interface of general CAM parameter configuration, Table
Parameter type Parameter name Data type Operand Default Range Unit
Unit
General CAM Pulse equivalent of output-axis FP32 W D/K 0.01 >0 mm/pls
segment type
277
Control mode
Else
Start address of control registers
Table 15.18. 4
Unit:
Unit of key joint coordinate, can be set with mm (millimeter) or pls (pulse count).
Ranged of output-axis:
Input-axis coordinate:
Output-axis coordinate:
Input-axis coordinate:
Target slope:
Segment type:
Control mode:
When control mode is selected, user can set the start address of mapped D-registers.
278
Curve preview area
Figure 15.18. 12
As shown in Figure 15.18.12, the X-axis means the displacement of input-axis, the Y-axis
in their curve, means displacement, velocity, acceleration of output-axis in order. User can
input parameters and drag the joint in the preview area to adjust the curve. The curve
Annotation
Fixed-mark mode
The motion cycle starts from origin when the color mark is detected (flag-bit of color-mark
is ON). If distance between 2 color-marks is longer than order cutting length, the actual
cutting length will be the distance between marks; If distance between color-marks is
equal to order cutting length, the actual cutting length will be ordered cutting distance; If
the distance between color marks is shorter than order cutting distance, the detection of
second color-mark will take no effect, but take effect until the distance between next mark
and start mark is longer than order cutting distance, in this case, there may be one or
279
Rationality of parameter setting
All the parameter setting must not be beyond data range, also they should meet specific
For flying saw, we define length of input-axis accelerating area as A1, length of input-axis
synchronous area as S, length of input-axis decelerating area as D1, order cutting length
as L1, distance of output-axis accelerating area as A2, output-axis limit length as L2, and
Figure 15.18.1):
A1+S+D1 < L1
A2+S < L2
α + β <(360。/K)
deceleration, it is opposite; During uniform motion, the error stays stable. The
Cause: because of feature of ECAM, the error comes from delay caused by operation
process.
Solution: the program will give an appropriate algorithm delay time T, along with the
velocity of input-axis F, the compensation Δ equals to T*F can be calculated. Add the
compensation to the position of input-axis that measured each time, so that the error
can be compensated. What should be noted is, the meaning of input-axis velocity
input-axis displacement. the error will increase with the input-axis motion. The
Cause: there are differences between actual mechanical structure and theoretical
model. For example, advance length L during a round of rolling wheel equals to the
Solution: As the error is proportional to whole motion distance, we can get the
each round to compensate error. What should be noted is, in fixed-length mode the
factor is very closed to 1; In fixed-mark mode, the factor is 1 by default, and can be
the input-axis, it comes from phase bias in the first cut. The error symptom refers to
Figure 15.18.15.
Figure 15.18. 15
compensate for the error. Refer to Figure 15.18.16, if the compensation factor is the
deviation in the first cut, if it is plus the cut will be advanced, if it is minus the cut will
be lagging.
283
Figure 15.18. 16
The parameters of general ECAM should meet some specific rules, and may be adjusted
coordinate of the current segment must be bigger than the input-axis coordinate last
segment.
2. If Y coordinate of two adjacent key joints is the same, the slope of them will be
adjusted to 0 automatically.
3. If the curve type of the current segment is a straight line, the slope and output-axis
4. If the curve type of the current segment is a straight line and curve type of the last
segment is splines, the slope of the last segment will be adjusted to be the same with
284
Clutch
Flag-bit of the clutch can be set as X or M register. When the flag-bit of the clutch is set,
binding between the input-axis and output-axis will break without disabling instruction, in
this way the motion of output-axis can be controlled by other pulsing instructions. When
the flag-bit of clutch is reset, running will continue from the binding break phase (if
What should be noted is, when the clutch is set, if not especially necessary, it is
recommended to keep the input-axis motionless during clutch is ON, otherwise the
material length of the first cut after resetting clutch will have a corresponding offset. If
output-axis is being controlled by other pulsing instruction, resetting the flag-bit must be
after disabling the instruction, otherwise the binding between input-axis and output-axis
will not recover, if output-axis position gets deviation from clutch ON to clutch OFF, there
will be the deviation of whole output-axis travel, for flying saw it may cause overrun. If
will restart running from the origin, and this may also cause deviation of whole output-axis
travel.
If there is a need to record the running position when instruction is disabled, the user can
distribute these registers into the retentive zone, so that ECAM can restart running from
the position recorded in these registers automatically but not the origin. Users can also
285
reset these registers in the ladder diagram to restart ECAM from the origin without
remembering the input-axis phase. Additionally, these registers are read-only when
ECAM instruction enabled, readable and writable when ECAM instruction disabled, so the
reset operation can only take effect when ECAM instruction disabled.
Application
1. Check if PLC pulsing port is well worked, the servo is well worked, and ensure correct
wiring.
2. Configure the pulsing port, and address of target value. Confirm target value of
needed to remember current phase of input and output axis, if needed the running
status parameters should be set into the retentive zone, so that ECAM instruction can
restart from the last position where it stops after power off.
3. Configure mechanical parameters of ECAM, such as the pulsing number and forward
4. Select fixed-mark mode of fixed-length mode according to the actual case, and set
Flying saw
286
On the premise that parameter setting is rational, the purpose of parameter
setting is making cutting module accelerating stable, and more space for a
synchronous area to complete cutting. Figure 15.18.17 shows the flying saw
parameters.
Figure 15.18. 17
input-axis and position of output-axis in origin as L, and L=| A1-A2|. With L, the
cutting point can be certain (it is highly recommended to set A1 more than A2 , or
energy-efficient).
the detection point, the marked point will be the cutting point. User can also set
some offset on mark to offset the cutting point according to the actual case.
287
Flying shear
synchronous area to complete cutting. Figure 15.18.18 shows the flying shear
parameters.
Figure 15.18. 18
a) A=Mθ/ (360。/ i)
c) L = A + S1
can ensure the material being long enough to meet the first cut.
If fixed-mark mode is selected, mark detection point is always set in cutting point.
User can also set some offset on mark to offset the cutting point according to the
actual case.
5. Set appropriate following factor according to actual case and need, the details refer to
FOLLOW instruction.
6. Write manual program to drive input/output axis motion, and to reset output axis to
origin.
7. Do a test run after the setting is completed, observe the speed synchronization in the
synchronous area. If the synchronization error is small, trial cut can start, if the
8. After trial cutting, the cutting length might differ from the set length, the error may be
caused by mechanical parameter inconsistent with the real situation. User can
measure the running length during rounds of certain numbers, calculate and reset the
mechanical parameters.
Attention
1. Parameter modification does not take effect during instruction running, but after
2. If parameters are set unreasonable, after enabling, the instruction will not run, but
289
report an error. Users needs to check and modify these parameters and restart the
instruction.
3. User can use the flag of synchronous area to trigger the cutting, and use the
6. Do not clear or modify the target value register when instruction is running, otherwise
it is most likely to cause overrun error because of abrupt change of input-axis target
value.
7. Color-mark detection will not take effect when the clutch is ON. Before the clutch
being OFF, all the instructions that drive the output-axis must be disabled.
8. If there is a need to restart the CAM curve and remembering input-axis phase is set,
the user can disable ECAM instruction, clear all the running status parameters and
restart it.
EDRVI/EDRVA
Instruction introduction
1. These instructions outputs pulse with adjustable frequency and target pulse number.
290
For EDRVI, adjusting of frequency and target pulse number is relative; For EDRVA,
2. When the instruction is enabled, it will accelerate to set the frequency in set
acceleration time, decelerate to 0 in set deceleration time, and reach the set target
pulse number in the outputting process. When the instruction is disabled, pulse
outputting will stop instantly. If user modifies frequency and target pulse number
during outputting, the output will adjust to the modified value with
acceleration/deceleration.
4. This instruction can be controlled by special function register M8068, when M8068 is
5. This instruction can be set curve mode by special function register M8069, when
M8069 is ON, the frequency curve is S-shape type, when it is OFF, the frequency
6. When target pulse number is set 0x7FFFFFFF, the pulse will keep outputting in
positive direction; When target pulse number is set 0x8000000, pulse will keep
outputting in a negative direction. If instruction starts with these 2 kinds of target pulse
number setting, adjusting of target pulse number during outputting will take no effect.
7. When the frequency is set to 0 during outputting, pulse outputting will stop instantly
without deceleration, and continue to output with acceleration when the frequency is
291
Operation introduction
1. Set frequency, target pulse number, acceleration time, and deceleration time, then
enable the instruction. If do no adjusting, this instruction works like EDRV. If adjust
in next period when detecting the change of parameters system will recalculate the
frequency curve, additionally adjusting of target pulse number may cause a reversal
of the motor, details will be introduced in later parts. Adjusting takes effects as long as
the instruction is enabled, despite pulse outputting being over. Additionally, adjusting
outputting still reaches the target pulse number as case without adjusting.
Figure 15.19. 1
292
Figure 15.19. 2
3. Adjusting of target pulse number is used for position adjusting. As shown in Figure
target position with adjusting target pulse number, and P2 is after P1. System will
adjust frequency to reach the new adjusted target pulse number, Figure 15.19.4
shows 3 kinds of case (black line means adjusting during stable frequency, red line
means adjusting during deceleration, blue line means adjusting after pulse outputting
is over).
Figure 15.19. 3
Figure 15.19. 4
293
Figure 15.19.5 and Figure 15.19.6 shows case that P2 is before P1.
Figure 15.19. 5
Figure 15.19. 6
294
Setting data
Table 15.19. 1
Attention
This instruction outputs pulse with direction, so that the pulse accumulation counter
Notes
1) High-speed count instructions are designed to count high-speed pulse, and there are
specific CV registers (CV235 to CV255) are used for high-speed pulse count.
295
Single-phase counting counts the pulse of one port in one direction (positive or
negative).
Double-phase counter counts the pulse of two ports in two directions (positive
Figure 16.1. 1
AB-phase counting counts pulse of A phase and B phase of the motor, and there
are 2 modes for AB-phase count: single frequency multiplication mode and
Figure 16.1. 2
296
Figure 16.1. 3
HCNT
Instruction introduction
1. This instruction supports most 4 pulse input ports, so that FGm series don’t support
this instruction. For series that only support 2 high-speed pulse ports
counting.
297
2. High speed counters are assigned with specific counting mode in this instruction,
details refer to Table 16.2.1 (in the Table, U means counting upward, N means
CV235 U
CV236 U
Single-phase
CV237 U
CV238 U
CV246 U D
Double-phase
CV248 U D
CV251 A B
AB-phase
CV252 A B
Table 16.2. 1
M8051 and M8052, they control the counting mode of CV251 and CV252. When the
Setting data
Table 16.2. 2
298
Attention
recommended to add the shielding lines which on the input line, and connect
2. When one high-speed counter is used, the input port it occupies can’t be used for
3. AB-phase counting mode needs to be set before instruction running, modify during
299
Example
1. Single-phase counting
Instruction table:
Network 000
LD M0
HCNT CV235 K1000 //when M0 is ON, CV235 begin to count pulse of X0 input, when pulse
count reach 1000, C235 will be set
Network 001
LD C235
OUT Y000 //when pulse count reach 1000, Y0 will be ON
Network 002
LDP M1
RST C235 K1 //when M1 is ON, reset C235 and CV235
Ladder diagram:
Figure 16.1. 4
2. Double-phase counting
Instruction table:
Network 000
LD M0
HCNT CV246 K1000 //when M0 is ON, CV246 begin to count pulse of X0 input in positive
direction, and X1 in negative direction, when pulse count reach 1000, C246 will
be set
Network 001
LD C246
OUT Y000 //when pulse count reach 1000, Y0 will be ON
Network 002
LDP M1
RST C246 K1 //when M1 is ON, reset C246 and CV246
300
Ladder diagram:
Figure 16.1. 5
3. AB-phase counting
Instruction table:
Network 001
LDP M8150
SET M8051 //set counting mode to single frequency multiplication mode when PLC run
Network 001
LD M0
HCNT CV251 K1000 //when M0 is ON, CV251 begin to count pulse of X0(A-phase) and
X1(B-phase) input, when pulse count reach 1000, C251 will be set
Network 002
LD C251
OUT Y000 //when pulse count reach 1000, Y0 will be ON
Network 003
LDP M1
RST C251 K1 //when M1 is ON, reset C251 and CV251
Ladder diagram:
Figure 16.1. 6
301
EHCNT
Instruction introduction
Single-phase counting: use one input port, and can only count in a positive
direction.
Double-phase counting: use two input ports, one is count in an upward direction
AB-phase counting: use two input ports, one for A phase and another for B
Pulse and direction counting: use two input ports, one is pulse input and another
is pulse direction input. When pulse direction input is ON, counting counts in a
3. There are 2 kinds of triggering mode for start and reset counter:
Self-triggering: when this mode is selected, counter will start counting once it is
enabled, and reset count and counting flag-bit when the count number reaches
External triggering: this mode has two sets of input ports to choose (X25/X26 and
X27/X32). When X25/X26 is chosen, the user can use X25 to start the counter
and use X26 to reset the counter; When X27/X32 is chosen, user can use X27 to
302
4. This instruction supports most 12 input ports (X0 to X7 and X10 to X13). Shown as
Table 16.3.1, in 4 kinds of counting mode, correspondences between input ports and
CV235 U
CV236 U
CV237 U
CV238 U
CV239 U
CV240 U
Single-phase
CV241 U
CV242 U
CV243 U
CV244 U
CV245 U
CV246 U
CV235 U D
CV237 U D
CV239 U D
Double-phase
CV241 U D
CV243 U D
CV245 U D
CV235 A B
CV237 A B
AB-phase
CV239 A B
CV241 A B
303
CV243 A B
CV245 A B
CV235 PLS DIR
Table 16.3. 1
Setting data
Attention
recommended to add shielding lines on the input line, and connect the shielding line
to ground.
2. When one high-speed counter is used, the input port it occupies can’t be used for
3. Response when counter counts to target number are immediate, it is unaffected from
304
scan period.
HSCS
Instruction introduction
3. This instruction is used together with HCNT, it only takes effects when HCNT on the
skipped, the following ones won’t be triggered only if the user reset the counter.
5. Interruption event will be handled once it is triggered, nothing to do with scan period
of PLC.
305
Setting data
Figure 16.4. 1
1. Counter:
Can be set with a single-phase counter (CV235 to CV238) and AB-phase counter
2. Triggering mode:
Can be set with single mode or cycle mode. In single mode, when the last interruption
again only if user reset the counter; In cycle mode, when the last interruption is
triggered, counter will reset automatically and restart counting with cycle count adding
3. Cycle count:
D-register that records how many cycles that interruptions are triggered.
4. Counting mode:
Can be set with absolute mode or relative mode. In absolute mode, target number
306
means actual number of pulse outputting; In relative mode, target number means
difference value of actual pulse number from last target to the current.
5. Target number:
Can be set with K type data or D type data, user can add, move, modify, and remove
6. Interruption:
Can be set with 4 ways: setting coil, resetting coil, subroutine, and null. For setting
coil, the user can fill “#(SET Yn)” or “#(SET Mn)” to set corresponding Y and M
registers; For resetting coil, user can fill “#(RST Yn)” or “#(RST Mn)” to reset
corresponding Y and M registers; For subroutine, user can fill name of corresponding
subroutine to call it; For null, there is no need to fill, system will do nothing when
7. Table length:
Attention
incremental, target number of double-phase counting must be different from last one.
4. Interval between two adjacent target numbers is recommended to set more than 50,
307
otherwise the interruption may not be triggered normally.
5. set or reset coil of interruption can be set with a coil of the extend module.
Example
Instruction table:
Network 000
LD M0
HCNT CV251 K999999 //enable counter when M0 is ON
HSCS CV251 K999999 K3 //enable HSCS when M0 is ON
Network 001
LDP M1
RST C251 K1 //reset counter when M1 is ON, so that interruption can be triggered from start
Ladder diagram:
Figure 16.4. 2
String Instructions
Notes
Instructions in this chapter do inter-conversion between number and string. The type of
number can be word, double word, and float, the string can only be ASCII encoded (not
support Unicode). Table 17.1.1 shows the commonly used ASCII encoding.
Table 17.1.1 1
I_S
Instruction introduction
1. This instruction converts WORD type data (IN) into an 8-byte string (OUT) with a
309
2. Only the bottom nibble (half-byte) of the format mask takes effects, the head bit (c) of
the nibble decides if the output string is separated with point (“.”) or comma (“,”),
bottom 3-bit (nnn) of the nibble decides the length of the number after the point or
Figure 17.2. 1
Setting data
Table 17.2. 1
Example
Instruction table:
310
Network 000
LDP X000
I_S K12345 H8 D10 //K12345 is converted to “12345” and store in D10~D13 (use
point, 0 numbers after point)
Ladder diagram:
Figure 17.2. 2
DI_S
Instruction introduction
1. This instruction converts DWORD type data (IN) into a 12-byte string (OUT) with a
2. Only the bottom nibble (half-byte) of the format mask takes effects, the head bit (c) of
the nibble decides if the output string is separated with point (“.”) or comma (“,”),
bottom 3-bit (nnn) of the nibble decides the length of the number after the point or
311
Figure 17.3. 1
Setting data
Table 17.3. 1
312
Example
Instruction table:
Network 000
LDP X000
DI_S D0 HA D10 //D0 is converted to string and stored in D10~D15 (use point, 2
numbers after point)
Ladder diagram:
Figure 17.3. 2
R_S
Instruction introduction
1. This instruction rounds float type data (IN) and converts it into specified length string
2. Only low byte of format mask takes effects, head 4-bit (ssss) of the byte decides the
length of the output string, 5th bit (c) of the byte decides if the output string is
separated with point (“.”) or comma (“,”), bottom 3-bit of the nibble decides the length
of a number after the point or comma (maximum is 7). Details refer to Figure 17.3.1.
313
Figure 17.4. 1
314
Setting data
Table 17.3. 2
Example
Instruction table:
Network 000
LDP X000
R_S K3.141593 HFA D10 //K3.141593 is converted to “ 3.14” and stored in
D10~D17 (15 length string, use point, 2 numbers after
point)
Ladder diagram:
Figure 17.4. 2
315
S_I
Instruction introduction
1. This instruction converts string into 16-bit signed integer (WORD) when it is enabled.
2. This instruction converts from (IDX)th character of the string, the start character must
be number character (“0” to “9”), “+”, “-”, or any numbers of space; The conversion
ends at a character which is not number character (“0” to “9”) or one of following
characters: “+”, “-”, “,” and “.”. Figure 17.5.1 shows examples of conversion and illegal
input.
3. If the number after conversion is too great or too less compared with a 16-bit signed
integer, there will be overflow and underflow, M8169 will turn ON.
4. If the input string is invalid to convert to an integer, there will be no output, and M8169
will also turn ON. Figure 17.5.1 shows some examples of conversion and illegal input.
Figure 17.5. 1
Setting data
316
(EN) Input that enables or disables 0/1 bool
instruction.
Table 17.5. 1
Example
Instruction table:
Network 000
LDP X000
S_I D0 K1 D100 //convert string in D0 and follow from index 1, and store integer result
in D100
Ladder diagram:
Figure 17.5. 2
S_DI
Instruction introduction
1. This instruction converts string into 32-bit signed integer (DWORD) when it is
enabled.
2. This instruction converts from (IDX)th character of the string, the start character must
be number character (“0” to “9”), “+”, “-”, or any numbers of space; The conversion
317
ends at a character which is not number character (“0” to “9”) or is one of following
characters: “+”, “-”, “,” and “.”. Figure 17.5.1 shows examples of conversion and illegal
input.
3. If the number after conversion is too great or too less compared with a 32-bit signed
integer, there will be overflow and underflow, M8169 will turn ON.
4. If the input string is invalid to convert to an integer, there will be no output, and M8169
will also turn ON. Figure 17.5.1 shows some examples of conversion and illegal input.
Figure 17.6. 1
Setting data
Table 17.6. 1
318
Example
Instruction table:
Network 000
LDP X000
S_DI D0 K1 D100 //convert string in D0 and follow from index 1, and store integer result
in D100D101
Ladder diagram:
Figure 17.6. 2
S_R
Instruction introduction
2. This instruction converts from (IDX)th character of the string, the start character must
be number character (“0” to “9”), “+”, “-”, or any numbers of space; The conversion
ends at a character which is not number character (“0” to “9”) or is one of following
characters: “+”, “-”, “,” and “.”. Figure 17.5.1 shows examples of conversion and illegal
input.
3. Conversion to float will not cause overflow or underflow, but if the significant digits of
the conversion number are more than 7, the result will be rounded.
319
4. If the input string is invalid to convert to a float, there will be no output, and M8169 will
also turn ON. Figure 17.5.1 shows some examples of conversion and illegal input.
Figure 17.7. 1
Setting data
Table 17.7. 1
Example
Instruction table:
Network 000
LDP X000
S_R D0 K1 D100 //convert string in D0 and follow from index 1, and store float result in
D100D101
Ladder diagram:
320
Figure 17.7. 2
EPID
PID control is a kind of closed-loop control, according to error ( e(t) ) between measured
value ( y(t) ) of control target and set target value ( r(t) ), use proportional ( Kp ), integral
( Ki ), differential ( Kd ) coefficient to process the error and use it as input of control target
Figure 18.1. 1
The mathematical relations of r(t), e(t), u(t), and y(t) refer to following formula:
While in actual case, there is minimum interval time for the sampling (T), so that the
321
formula can be written as:
Integral time Ti and differential time Td can also be transformed into integral coefficient Kp
Instruction introduction
1. This instruction does PID control to output according to the measured value and
target value. It supports switching value output and analog quantity output, and can
2. User can adjust the PID parameters manually, and can also use self-tuning to set the
initial PID parameters. The self-tuning uses a critical oscillations method, and it is
recommended to adjust the output of device (measured value) close to the target
3. This instruction has three modes to select and user can switch them during running.
322
Setting data
offset type
0 Sampling cycle dword R/W Time interval to sample the error, unit is ms (millisecond). For switching value
mode, it is 1000ms by default; For analog quantity mode, it is 0 by default and must
be assigned by user.
2 Proportional float R/W Kp (proportional coefficient) of PID control, takes no effect when is set 0.
coefficient
4 Integral time float R/W Ti (Integral time) of PID control, of which unit is ms, takes no effect when is set 0.
6 Integral float R
coefficient
Ki (Integral coefficient) of PID control, .
8 Differential time float R/W Td (differential time) of PID control, of which unit is ms, takes no effect when is set
0.。
10 Differential float R
coefficient
Kd (Differential coefficient) of PID control, .
12 Dead band range float R/W When error between target value and measured value is less than dead band
14 Output high limit float R/W High limit of the output, for switching value mode, it is limit of duty ratio; For analog
16 Output low limit float R/W Low limit of the output, for switching value mode, it is limit of duty ratio; For analog
18 PID configuration hex R/W Configuration for PID control processing, details refer to following introduction.
20 PID calculated dword R Only for switching value mode, store close time during a sampling cycle, of which
22 PID valid range float R/W When error between target value and measured value is exceeds PID valid range,
PID will output high/low limit according to sign of error and action direction.
24 Error code hex R Error code record legality of parameters setting when instruction is enabled, details
25 PID mode word R/W Data register records and switched the PID processing mode, value 0 for routine
control mode, value 1 for manual control mode, value 2 for fuzzy self-adjusting
control mode, else value for pausing control (output remains same).
26 Fuzzy word R/W Data register records and switches the status of fuzzy self-adjusting control, value 1
self-adjusting for in self-adjusting status, else value for not in self-adjusting status.
status
34 Self-tuning status word R/W Data register records and switches the status of self-tuning, value 0 for self-tuning
completed, value 1 for self-tuning processing, value 2 for self-tuning failed. User
36 Self-tuning dword R/W Timeout for self-tuning, if time of self-tuning exceed timeout, the self-tuning will fail.
timeout
323
Table 18.1. 1
In EPID instruction guide, user can set head D-register to map parameters to D-registers,
so that parameters could be monitored and adjusted during running, the mapping rule of
parameters refers to Table 18.1.1. Parameters will be initialized by setting in guide, user
can also initialize these parameters by transfer instructions. The following introduces
1. Sampling cycle
Sampling cycle ( T ) is time interval that system samples the measured value and
target value, its unit is ms (millisecond). Additionally, it is also the cycle of switching
output.
The sampling cycle must be longer than the scan period of PLC.
2. Proportional coefficient
Proportional coefficient ( Kp ) scales the error to control the device, when it is big, the
response of control will be quick, but there will be overshoot and fluctuation in device
output; When it is small, the device output will be stable, but the response will be
slow.
3. Integral time
Integral time ( Ti ) divides the accumulated error from start to current, when it is
bigger, integral takes stronger effect; When it is smaller, integral takes a weaker
324
effect.
4. Integral coefficient
5. Differential time
Differential time ( Td ) multiplies the error difference from current one to last one,
when it is bigger, differential takes stronger effect; When differential takes weaker
effect.
6. Differential coefficient
Integral coefficient (≠ Kd ) scales the gradient (rate of change) of error to follow the
Figure 18.1. 2
325
7. Dead band range
Refer to Figure 18.1.2, when error between the target value and the measured value
is less than dead band range, PID control is ineffective, the output value will
unchanged still the error is out of the dead band. The function of the dead band is to
avoid unnecessary calculation during a stable state (error is small and stable).
Refer to Figure 18.1.2, this parameter limits the highest value of output, it must be
greater than output low limit. Under switching value mode, output limit must be no
Refer to Figure 18.1.2, this parameter limits the lowest value of output, it must be less
than the output high limit. Under switching value mode, output low limit must be
nonnegative.
Proper output high limit and the low limit can shorten time cost of self-tuning. If the
high limit is too high and low limit is too low, self-tuning will cause bigger and longer
output fluctuation, so that it will cost more time; If the high limit is too low and low limit
is too high, measured value may not reach the target value and the self-tuning will
fail.
326
Bit 15:4 3 2:1 0
Table 18.1. 2
This data-register records and controls the following configuration of PID control:
Dir: action direction of the target device, should be set by an actual case. When
this bit is ON, the action direction is forward, the error is equal to the measured
value minus target value, the PID output should increase/decrease when
measured value increases/decreases; When this bit is OFF, the action direction
is backward, the error is equal to target value minus measured value, the PID
TYPE: control type of PID, value 00 for PID, value 01 for PI, value 10 for P. PID
is applicable to the actual case with large lag, such as temperature control; PI is
the applicable actual case with quick response, such as pressure control and
flow control.
SD: this bit enables or disables automatic detection of stable state, value 0 for
is used for fuzzy self-adjusting control, when it is enabled, system will enter
This value is only readable and if only valid under switching value mode. It records
327
the calculated output ( u(t) ) of PID control, it’s also the close duration of switching
Refer to Figure 18.1.2, when the error between the target value and the measured
value is within the dead band range, the PID control will be valid; Otherwise PID
control will be invalid, in this case, if the action direction is forward, output will jump to
high/low limit when an error is plus/minus; If the action direction is backward, output
Bit 15:3 2 1 0
Value Reserved SC HL ST
Table 18.1. 3
When parameters are set illegal, PID won’t calculate and output will maintain the
SC: when the sampling cycle ( T ) is set illegal/legal, this bit turns ON/OFF.
HL: when the output high limit is set illegal/legal, this bit turns ON/OFF.
ST: when PID valid range is set illegal/legal, this bit turns ON/OFF.
User can switch PID modes by setting different values in this data-register: value 0 for
328
routine control mode, value 1 for manual control mode, value 2 for fuzzy
Routine control mode: under this model, PID control will running with user set
PID parameters, user can also modify self-tuning status to enable self-tuning.
Manual control mode: under this model, PID control will running as output that
set by users. When this mode is switched to routine control mode or fuzzy
Fuzzy self-adjusting mode: under this mode, PID control will detect if the error is
stable. If error is stable, PID control will enter the self-adjusting mode and adjust
Stopping control: output will maintain the same when control is stopped.
This data register records if control enters self-adjusting status under fuzzy
self-adjusting mode, value 1 for in self-adjusting status, else value for not.
Control will enter self-adjusting mode automatically when error is stable, and adjust
PID parameters ( Kp , Ki, Kd ) automatically, user can also set the value with 1 to
force control to enter self-adjusting mode, but this operation will cost more time to
stabilize the error and even fail if enter the mode when the error is not stable.
This data register record and control status of self-tuning, value 0 for self-tuning
329
completed, value 1 for self-tuning processing, value 2 for self-tuning failed, else value
Self-tuning is used to set initial PID parameters when PID control starts. When
self-tuning is enabled, the output will jump between high limit and low limit alternately
It is recommended to adjust the output to make measured value being close to the
target value under manual control mode, so that the self-tuning will be quick and the
This data register set timeout of self-tuning, the timeout of self-tuning is no less than
60 minutes. if time cost of self-tuning exceeds the timeout, self-tuning status will be
self-tuning failed.
Appendix
System special function registers are D-registers (data registers) and M-registers (bit
D8048 Current mode of IST (0: none, 1: manual mode, 2: zero-return mode, 3: R
330
single-step mode, 4: single-cycle mode, 5: automatic mode).
D8074 Check bit mode of COM0, range from 0 to 2, corresponding to NONE, EVEN, R
and ODD.
D8075 Check bit mode of COM0, range from 0 to 2, corresponding to NONE, EVEN, R
and ODD.
D8092 Y000 pulse port acceleration/deceleration time of multistage pulse output. R/W
D8093 Y001 pulse port acceleration/deceleration time of multistage pulse output. R/W
D8094 Y002 pulse port acceleration/deceleration time of multistage pulse output. R/W
D8095 Y003 pulse port acceleration/deceleration time of multistage pulse output. R/W
D8108 Y000 pulse port error segment number (For multistage pulse output) R
D8109 Y001 pulse port error segment number (For multistage pulse output). R
D8110 Y002 pulse port error segment number (For multistage pulse output). R
D8111 Y003 pulse port error segment number (For multistage pulse output). R
D8124 Y000 pulse port current segment number (For multistage pulse output). R
D8125 Y001 pulse port current segment number (For multistage pulse output). R
D8126 Y002 pulse port current segment number (For multistage pulse output). R
D8127 Y003 pulse port current segment number (For multistage pulse output). R
331
D8176 error code R/W
0x00: no error
0x09: real-time clock error
0x0A: watchdog timer timeout
0x0C: serial port communication timeout
0x0D: USB port communication timeout
0x0E: XML region data exception,
0x0F: configuration region data exception
0x10: HashCode region data exception
0x11: Modbus table data exception
0x12: PLSTABLE table data exception
0x13 PLSBLOCK region data exception
0x17: segments number of multistage pulse output out of range
0x18: first segment frequency of multistage pulse lower than default start
frequency
0x19: frequency lower than low limit
0x1A: target number of single-stage pulse lower than low limit.
0x1B: acceleration/deceleration time of single-stage pulse lower than low limit
0x1C: parameters don’t meet legal condition of acceleration/deceleration
0x1D: last segment of multistage pulse doesn’t meet legal condition of
acceleration/deceleration
0x1E: FPGA loads firmware timeout
0x1F: EPCS4 ID check error
0x20: EPCS4 erases data error
0x21: EPCS4 update firmware timeout
0x22: EPCS4 update data package error
0x23: EPCS4 response check error
0x24: interpolation parameters error
0x25: interpolation prospective error
0x26: interpolation velocity error (be 0 or too big)
0x27: end-point coordinates error (movement can’t be 0)
0x28: arc interpolation radius error
0x29: be about to cross the border
0x2A: interpolation parameters don’t meet legal condition of
acceleration/deceleration
0x2B: chord error too big
0x2C: exceed maximum of pulse frequency
0x2D: ECAM data error
0x2E: ECAM parameters error
0x34: low extension module version, new function not applicable
0x35: low PLC version, new function not applicable
0x36: extension module communication error
0x37: extension module retransmission timeout
0x38: extension module type query error
332
0x39: extension module parameters passing error
0x3A: Ethernet port module configuration error
0x3B: CAD graph import to FLASH handshake error
0x3F: HCNT parameter setting unreasonable
0x40: CADflash read/write error
0x41: CADflash download data package error
0x42: graph data read error
0x43: spline interpolation error
0x44: zero signal of zero-return disabled
0x45: displacement of acceleration/deceleration too long
0x46: high-speed counter ports conflict
0x48: ECAM FIFO cross border
0x49: platform-system pulse output port error
0x4A: TBL segments jump error
0x4B: pulse peak flirting judgement timeout
0x4C: ZRNR frequency missing
0x7A: stack overflow error
0x7B: access inner registers out of range
D8194(D8195) Y000 pulse port basal frequency (5Hz~ Y000 maximum frequency) R/W
D8196(D8197) Y001 pulse port basal frequency (5Hz~ Y001 maximum frequency) R/W
D8198(D8199) Y002 pulse port basal frequency (5Hz~ Y002 maximum frequency) R/W
D8200(D8201) Y003 pulse port basal frequency (5Hz~ Y000 maximum frequency) R/W
D8202(D8203) Pulse port basal frequency of pulse port Y004~Y007 and Y010~Y011 (5Hz~ R/W
~D8212(D8213) Y000 maximum frequency)
D8222(D8223) Pulse port maximum frequency of pulse port Y004~Y007 and Y010~Y011. R/W
~D8232(D8233)
D8234 Y0 port deceleration time under FOLLOW limit position mode (address R/W
increases with 6 for Y1~Y5)
D8236(D8237) Y0 port FOLLOW positive limit position (address increases with 6 for Y1~Y5) R/W
D8238(D8239) Y0 port FOLLOW negative limit position (address increases with 6 for Y1~Y5) R/W
D8294 Y0 port deceleration time under platform-system limit position mode (address R/W
increases with 6 for Y1~Y5)
M-registers (bit-registers)
333
M8037 High-speed counter CV237 counting direction. R
M8050 High-speed counter CV250 frequency multiplication (0: single frequency R/W
multiplication, 1: quadruple frequency multiplication)
M8051 High-speed counter CV251 frequency multiplication (0: single frequency R/W
multiplication, 1: quadruple frequency multiplication)
M8052 High-speed counter CV252 frequency multiplication (0: single frequency R/W
multiplication, 1: quadruple frequency multiplication)
M8053 High-speed counter CV253 frequency multiplication (0: single frequency R/W
multiplication, 1: quadruple frequency multiplication)
M8054 High-speed counter CV254 frequency multiplication (0: single frequency R/W
multiplication, 1: quadruple frequency multiplication)
M8055 High-speed counter CV255 frequency multiplication (0: single frequency R/W
multiplication, 1: quadruple frequency multiplication)
M8062 PWMS high low-level mode (0: high after low, 1: high before low). R/W
M8064 COM2 is transmitting data. R
M8065 COM2 is receiving data. R
M8068 Global polarity of all pulse outputting ports (pulse direction reversals when it is R/W
1).
M8069 Frequency curve type of acceleration/deceleration (0: T-shape type, 1: S-shape R/W
type).
M8070 If to ignore the pulse output error of Y0 port, set 0 by default (0: ignore and R/W
continue outputting pulse, 1: stop outputting pulse).
M8071 If to ignore the pulse output error of Y1 port, set 0 by default (0: ignore and R/W
continue outputting pulse, 1: stop outputting pulse).
M8072 If to ignore the pulse output error of Y2 port, set 0 by default (0: ignore and R/W
continue outputting pulse, 1: stop outputting pulse).
334
M8073 If to ignore the pulse output error of Y3 port, set 0 by default (0: ignore and R/W
continue outputting pulse, 1: stop outputting pulse).
M8162 Clear all data out of retentive zone (0: NONE, 1: CLEAR). R/W
M8163 Clear all data in retentive zone (0: NONE, 1: CLEAR). R/W
335
M8174 PLC in error status (0: OK, 1: ERROR). R
M8193 Local polarity of pulse outputting port Y1 (pulse direction reversals when it is 1). R/W
M8194 Local polarity of pulse outputting port Y2 (pulse direction reversals when it is 1). R/W
M8195 Local polarity of pulse outputting port Y3 (pulse direction reversals when it is 1). R/W
M8202 Stop mode of EDRVI/EDRVA (0: instantly stop, 1: slower to stop). R/W
M8203 Stop mode of FOLLOW in limit position (0: instantly stop, 1: slower to stop). R/W
M8204 Stop mode of FOLLOW under limit signal (0: instantly stop, 1: slower to stop). R/W
M8205 Y0 port positive limit signal. R/W
M8225 If to maintain direction when pulse outputting stop (0: not maintain, 1: maintain). R/W
M8234 PLSY Y0 port pulse outputting completed. R
336