Chapter 7 Advanced Function List EN-1-100
Chapter 7 Advanced Function List EN-1-100
● When execution control〝EN〞=1 or changes from 0→1( P instruction),it will terminate the FOR and NEXT
program loop。
● The program within the FOR and NEXT loop will be executed N times (N is assigned by FOR instruction)
successively,but if it is necessary to terminate the execution loop less than N times,the BREAK instruction
is necessary to apply。
● The BREAK instruction must be located within the FOR and NEXT program loop。
EN RST V
70
FOR D10
17.CMP M200
EN Sa : D100 a=b
Sb : R0V a>b
a<b
M200
EN BREAK
15
EN (+1) V OVF
71
NEXT
08.MOV
EN S : V
D : D1000
Description:The loop count used to execute the FOR and NEXT program loop is assigned by register D10;the
program within the FOR and NEXT loop is designed to search the same data storing in D100 from the
register table starting at R0。If it finds,the searching loop will be terminated and then it goes to execute
the program after the NEXT instruction;If it doesn't find,the searching loop will be executed N times (N
is the content of D10) and then it goes to execute the program after the NEXT instruction。
M200 tells the status and D100 is the pointer of searching。
7-1
Arithmetical Operation Instructions
FUN 23 P FUN 23 P
48-BIT DIVISION
DIV48 DIV48
Range HR OR SR ROR DR XR
R0 R3904 R3968 R5000 D0 V、Z
Ope- ∣ ∣ ∣ ∣ ∣
rand R3839 R3967 R4167 R8071 D4095 P0~P9
Sa ○ ○ ○ ○ ○ ○
Sb ○ ○ ○ ○ ○ ○
D ○ ○ ○* ○* ○ ○
z When operation control “EN”=1 or changes from 0→1 ( P instruction), will perform the 48 bits division operation.
Dividend and divisor are each formed by three consecutive registers starting by Sa and Sb respectively. If the
result is zero, ‘D=0’ output will be set to 1. If divisor is zero then the ‘ERR’ will be set to 1 and the resultant
register will keep unchanged.
z All operands involved in this function are all 48 bits, so Sa, Sb and D are all comprised by 3 consecutive
registers.
In this example dividend formed by register R2, R1, R0 will be divided by divisor formed by register R5, R4, R3. The
quotient will store in R8, R7, and R6.
R2 R1 R0
Sa
2147483647
R5 R4 R3
÷ Sb
1234567
R8 R7 R6
1739
Quotient
7-2
Arithmetical Operation Instructions
z When operation control “EN”=1 or changes from 0→1 ( P instruction), it puts the successive N units of 16bit or
32 bit ( D instruction) registers for addition calculation to get the summation, and stores the result into the
register which is designated by D.
z When the value of N is 0 or greater than 511, the operation will not be performed.
z Communication port1~4 can be used to serve as a general purpose ASCII communication interface. If the
data error detecting method is Checksum, this instruction can be used to generate the sum value for sending
data or ot use this instruction to check if the received data is error or not.
〈Example 1〉When M1 changes from OFF→ON, following instruction will calculates the summation for 16-bit data.
24P.SUM
M1 z The left illustrates that 6 16-bit registers starting from R0
EN S : R0 is calculated for summation, and the result is stored into
N : 6 the R100 register.
D : R100
R0=0030H
R1=0031H
R2=0032H
Î R100=012FH
R3=0033H
R4=0034H
R5=0035H
24D.SUM
M1 z The left illustrates that three 32-bit registers starting
EN S : R0 from DR0, is calculated for their summation, and the
N : 3 result is stored into the DR100 register.
D : R100
R1,R0=00310030H
R3,R2=00330032H Î R101,R100=00A5009BH
R5,R4=00410039H
7-3
Arithmetical Operation Instructions
z When operation control "EN" = 1 or from 0 to 1 ( P instruction), add the N successive 16-bit or 32-bit ( D
instruction) numerical values starting from S, and then divided by N. Store this mean value (rounding off
numbers after the decimal point) in the register specified by D.
z While the N value is derived from the content of the register, if the N value is not between 2 and 256, then the
N range error "ERR" will be set to 1, and do not execute the operation.
R0 123
S
R1 9
(N=3)
R2 788 123+9+788
3
ØX0= =306 (Rouding off the remainder)
D R10 306
7-4
Arithmetical Operation Instructions
FUN 26 D P FUN 26 D P
SQUARE ROOT
SQRT SQRT
z When operation control "EN" = 1 or from 0 to 1 ( P instruction), take the square root (rounding off numbers
after the decimal point) of the data specified by the S field, and store the result into the register specified by
D.
z While the S value is derived from the content of the register, if the value is negative, then the S value error
flag "ERR" will be set to 1, and do not execute the operation.
X0 26DP.SQRT
EN S : ERR
z The instruction at left calculates the square root of the
2147483647 constant 2147483647, and stores the result in R0.
D : R 0
S K 2147483647
ØX0=
D R1 R0 46340
R1 R0
2147483647 = 46340.95
↑
rounding off
7-5
Arithmetical Operation Instructions
D : Register to be negated
D may combine with V, Z, P0~P9 to serve indirect address
application
z When operation control "EN" = 1 or from 0 to 1 ( P instruction), negate (ie. calculate 2's complement) the
value of the content of the register specified by D, and store it back in the original D register.
z If the value of the content of D is negative, then the negation operation will make it positive.
D R0 12345 )3039H
ØX0=
D R0 −12345 )CFC7H
7-6
Arithmetical Operation Instructions
z When operation control "EN" = 1 or from 0 to 1 ( P instruction), calculate the absolute value of the content of
the register specified by D, and write it back into the original D register.
D R1 R0 −12345 )CFC7H
ØX0=
D R1 R0 12345 )3039H
7-7
Arithmetical Operation Instructions
FUN 29 D P FUN 29 D P
SIGN EXTENSION
EXT EXT
z When operation control "EN" = 1 or from 0 to 1 ( P instruction), this instruction will sign extent the 16 bit
numerical value specified by D to 32-bit value and store it into the 32-bit register comprised by the two
successive words, D + 1 and D. (Both values are the same, only it was originally formated as a 16 bit
numerical value, and was then extended to be formated as a 32 bit numerical value.)
z This instruction extent the numerical value of a 16-bit register into an equivalent numerical value in a 32-bit
register (for example 33FFH converts to 000033FFH), Its main function is for numerical operations
(+,-,*,/,CMP......) which can take the 16 bit or 32 bit numerical values as operand. Before operation all the
operand should be adjusted to the same length for proper operation.
R1 B15 R0 B0
Ignore the value of R1 before
D R1 R0 1 1 0 0 1 1 1 1 1 1 0 0 0 1 1 1 -12345
extension
ØX0=
B31 R1 B16 B15 R0 B0
D R1 R0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0 0 1 1 1 -12345
Fill B15 value into B31-B16,(if B15 is 0, then B31-B16 are all 0)
7-8
Arithmetical Operation Instructions
z PID function (FUN 30) according to the current value of process variable (PV) derived from the external
analog signal and the Set Point (SP) of process performs the calculation, which base on the PID formula. The
result of calculation is the control output for the controlled process, which can feed directly to the AO module
or other output interface or leaved for further process. The usage of PID control for process if properly can
achieve a fast and smooth result of PV tracking toward SP change or immune to the disturbance of process.
n
Mn = [(D4005/Pb)×En]+ ∑ [(D4005/Pb)×Ti×Ts×En] − [(D4005/Pb)×Td×(PVn−PVn-1)/Ts] + Bias
0
D4005 : The gain constant, the default is 1000, which can be set between 1~5000.
Pb : Proportional band ( range : 2~5000, unit 0.1%. Kc (gain) =1000/ Pb )
Ti : Intergal time constant ( range : 0~9999 corresponds to 0.00~99.99 Repeats/Minute )
Td : Differential time constant ( range : 0~9999 corresponds to 0.00~99.99 Minutes )
PVn : Process value at time ”n”
PV n-1 : Process value at time ”n”
En :Error at time ”n” =set value ( SP) − process value at time ”n” (PVn)
Ts : Interval time of PID calculation ( range: 1~3000, unit : 0.01 S )
Bias : Control output offset ( range: 0~16380 )
7-9
Arithmetical Operation Instructions
● When execution control "EN"=1 or changes from 0→1(P instruction, it will start the CRC16 calculation from
the lower byte of S and by the length of N, the result of calculation will be stored into register D and D+1.
● The output indication "D=0" will be ON if the value of calculation is 0.
● It will not execute the calculation and the output indication "ERR" will be ON if the length is invalid.
● When communicating with the intelligent peripheral in binary data format, the CRC16 error detection is used
very often; the well known Modbus RTU communication protocol uses this method for error detection of
message frame.
● CRC16 is the check value of a Cyclical Redundancy Check calculation performed on the message contents.
● Perform the CRC16 calculation on the received message data and error check value, the result of the
calculation value must be 0, it means no error within this message frame.
S D
High Byte Low Byte High Byte Low Byte
R0 Don’t care Byte-0 R10 00 CRC-Hi
R1 Don’t care Byte-1 R11 00 CRC-Lo
R2 Don’t care Byte-2
R3 Don’t care Byte-3
R4 Don’t care Byte-4
R5 Don’t care Byte-5
R6 Don’t care Byte-6
R7 Don’t care Byte-7
R8 Don’t care Byte-8
R9 Don’t care Byte-9
7-10
Arithmetical Operation Instructions
● When the analog input is one of 2~10mA/ 4~20mA/1~5V/2~10V, the analog input module is the solution
to get the value of this kind of signal, but the input span of the analog input module is 0~10mA/0~5V
(Setting at 5V、Unipolar) or 0~20mA/0~10V(Setting at 10V、Unipolar), however there will exist the offset of
the raw reading value; this instruction is applied to eliminate the offset and convert the raw reading value
into the range of 0~4095(12-bit) or 0~16383(14-bit), it is more convenient for following operation.
● When execution control "EN"=1, it will execute the conversion starting from S, length by N, and then store
the results into the D registers.
● When the input〝F/T〞=0, it assigns the 12-bit analog input module; while〝F/T〞=1, it assigns the 14-bit
operation.
7 - 11
Arithmetical Operation Instructions
Example:
M0 32.ADCNV
EN P1 : 0
M1 S : R3840
F/T N : 6
D : R500
Description:When M0 is ON and M1 is OFF, it will perform 6 points of conversion starting from R3840, where
the offset of 4~20mA raw reading value will be eliminated, and the corresponding value 0~4095
will be stored into R500~R505.
S D
When M0 is ON and M1 is ON, it will perform 6 points of conversion starting from R3840, where the
offset of 4~20mA raw reading value will be eliminated, and the corresponding value 0~16383 will be
stored into R500~R505.
S D
7-12
Arithmetical Operation Instructions
Ladder symbol
Md:Operation mode,0~3
33P.LCNV
Operation control EN Md : S :Starting address of the source data
L :
HR IR ROR DR K
Range
R0 R3840 R5000 D0
Operand
∣ ∣ ∣ ∣
R3839 R3903 R8071 D3999
Md 0~3
S ○ ○ ○ ○
Ts ○ ○ ○
D ○ ○* ○
L ○ ○ ○ 1~64
● When the analog input module being used for the analog measurement, the raw reading value of
the analog input can be converted into the engineering range through this instruction for display
or for proceeding control operation.
● For process measurement calibration, making the linear conversion for the engineering process
variable, which the measurement value from the PLC's can be corrected by the value from the
standard meter's through this instruction.
● When execution control "EN"=1or from 0→1( P instruction), this instruction will perform the linear
conversion operation according to the mode selection, where S is the starting address of the
source data, Ts is the starting address of the conversion parameter table, D is the starting
address to store the converted result, and L is the quantity of conversion entry.
● There are two expressions to meet the suitable application:
Expression 1 : Two points calibration method
Fill the conversion parameter table with the low value of measurement(VML), high value of
measurement(VMH), and the corresponding low value of standard (VSL), high value of
standard(VSH); the converted result(Dn) will be generated from the source data(Sn) through the
formula shown below:
A = (VSL-VSH/VML-VMH)×10000
B = VSL-(VML×A/10000)
Dn = (Sn×A/10000)+B
7-13
Arithmetical Operation Instructions
Fill the conversion parameter table with the values of multiplier(A), divisor(B) and offset(C);
The converted result(Dn) will be generated from the source data(Sn) through the formula shown
below:
Dn =[(Sn×A)/B]+C
1. When Md = 0, the linear conversion works by expression 1, and all source data share the same
parameters VML、VMH、VSL and VSH for conversion.
2. When Md = 1, the linear conversion works by expression 1, and each source data has the independent
corresponding parameters VML、VMH、VSL、VSH for conversion; if there are N entries of source data, the
conversion parameter table should have N groups of VML、VMH、VSL、VSH for working, there are N×4 registers
in the conversion parameter table.
3. When Md = 2, the linear conversion works by expression 2, and all source data share the same
parameters A、B and C for conversion.
4. When Md = 3, the linear conversion works by expression 2, and each source data has the independent
corresponding parameters A、B、C for conversion; if there are N entries of source data, the conversion
parameter table should have N groups of A、B、C for working, there are N×3 registers in the conversion
parameter table.
7-14
Arithmetical Operation Instructions
Description : When M0 = 1, it will perform the mode 0 operation of linear conversion, where R100 is the starting
address of the source data, R1000 is the starting address of the table of the conversion parameters
VML、VMH、VSL、VSH, the quantity is 6, and R2000~R2005 will store the converted results.
Ts
R1000 282 V ML
R1001 3530 V MH
R1002 260 V SL
R1003 3650 V SH
S D
R100 282 R2000 260
R101 3530 R2001 3650
R102 1906 R2002 1955
R103 0
Ö R2003 -34
R104 5000 R2004 5184
R105 -115 R2005 -154
7-15
Arithmetical Operation Instructions
Description : When M0 = 1, it will perform the mode 1 operation of linear conversion, where R100 is the starting
address of the source data, R1000 is the starting address of the table of the conversion parameters
VML、VMH、VSL、VSH, the quantity is 3, and R2000~R2002 will store the converted results.
Ts
R1000 282 V ML_0
R1001 3530 V MH_0
R1002 260 V SL_0
R1003 3650 V SH_0
R1004 -5 2 V ML_1
R1005 1208 V MH_1
R1006 -3 8 V SL_1
R1007 1101 V SH_1
R1008 235 V ML_2
R1009 4563 V MH_2
R1010 264 V SL_2
R1011 4588 V SH_2
S D
R100 282 R2000 260
R101 1208 Ö R2001 1101
R102 2399 R2002 2426
7-16
Arithmetical Operation Instructions
Description : When M0 = 1, it will perform the mode 2 operation of linear conversion, where R100 is the starting
address of the source data, R1000 is the starting address of the table of the conversion parameters
A、B、C, the quantity is 6, and R2000~R2005 will store the converted results.
Ts
R1000 985 A
R1001 1000 B
R1002 20 C
S D
R100 1000 R2000 1005
R101 2345 R2001 2330
R102 3560 R2002 3527
R103 401
Ö R2003 415
R104 568 R2004 579
R105 2680 R2005 2660
7-17
Arithmetical Operation Instructions
Description : When M0 = 1, it will perform the mode 3 operation of linear conversion, where R100 is the starting
address of the source data, R1000 is the starting address of the table of the conversion parameters
A、B、C, the quantity is 4, and R2000~R2003 will store the converted results.
Ts
R1000 5000
R1001 16380
R1002 0
R1003 10000
R1004 16383
R1005 0
R1006 2200
R1007 16380
R1008 -20 0
R1009 1600
R1010 16383
R1011 -1 0 0
S D
R100 8192 R2000 2501
R101 16383 R2001 10000
R102 8190
Ö R2002 900
R103 0 R2003 -1 0 0
7-18
Multiple Linear Conversion
34P. MLC
Rs: Starting address of the source data
Execution
Control EN Rs : OVR Sl : Quantity of source data, 1~64
Sl : Tx : Starting address of X table
Selection X/Y Tx : Ty : Starting address of Y table
Tl : Quantity of table, 2~255
Ty :
D : Starting address to store the result
Tl :
D:
HR IR ROR DR K
Range
R0 R3840 R5000 D0
Operand
∣ ∣ ∣ ∣
R3839 R3903 R8071 D3999
Rs ○ ○ ○ ○
Sl ○ ○ ○ 1~64
Tx ○ ○ ○
Ty ○ ○* ○
Tl ○ ○ ○ 2~255
D ○ ○ ○
● When the analog input module being used for the analog measurement, the raw reading value of
the analog input can be converted into the engineering range through this instruction for display
or for proceeding control operation.
● For process measurement calibration, making the linear conversion for the engineering process
variable, which the measurement value from the PLC's can be corrected by the value from the
standard meter's through this instruction.
● When execution control "EN"=1or from 0→1( P instruction), this instruction will perform the
multiple linear conversion operation according to the selection of X/Y input; where Rs is the
starting address of the source data, Sl is the quantity of source data for conversion, Tx is the
starting address of X conversion parameter table, Ty is the starting address of Y conversion
parameter table, Tl is the quantity of X/Y table, D is the starting address to store the converted
result.
● When executing and selection X/Y=0, it will compare the source data with the entities of Tx table
to find the corresponding location in Tx table (The entities in Tx table must be in ascending
sequence), and then calculate the linear conversion according to the located section of Tx and
Ty table;
When executing and selection X/Y=1, it will compare the source data with the entities of Ty table
to find the corresponding location in Ty table (The entities in Ty table can either be in ascending
or descending sequence), and then calculate the linear conversion according to the located
section of Ty and Tx table.
● When the source data is out of all entities of table, OVR=1.
● It wouldn’t execute this instruction if illegal SI or Tl.
7-19
Multiple Linear Conversion
Expression:
﹒The entities of Tx conversion parameter table must be in ascending sequence to have correct
linear conversion; the entities of Ty conversion parameter table can either be in ascending or
descending sequence. When executing this instruction, it will search the located section by
comparing entities of the table with source data, and then calculate the linear conversion
according to the following expression:
Vy = (Vx-Tx_n) × (Ty_n+1-Ty_n/Tx_n+1-Tx_n) + Ty_n if X/Y=0
(Tx-3,Ty-3)
(Tx-2,Ty-2)
(Tx-1,Ty-1)
(Tx-0,Ty-0)
7-20
Multiple Linear Conversion
Example 1:
Y
6000,760
970
760
2000,280
530 8000,970
280
4000,530
0,0
X
2000 4000 6000 8000
7-21
Multiple Linear Conversion
Example 2:
Y
6000,760
970
760
2000,280
530 8000,970
280
4000,530
0,0
X
2000 4000 6000 8000
7-22
Multiple Linear Conversion
Example 3:
2000
0,950
-8000 8000
X
-100
-8000,-100
7-23
Multiple Linear Conversion
Example 4:
Y
16000,5000
5000
0,0 16000
3276,0
7-24
Logical Operation Instructions
FUN 35 D P FUN 35 D P
EXCLUSIVE OR
XOR XOR
z When operation control "EN" = 1 or changes from 0 to 1 ( P instruction), will perform the logical XOR
(exclusive or) operation of data Sa and Sb. The operation of this function is to compare the corresponding
bits of Sa and Sb (B0~B15 or B0~B31), and if bits at the same position have different status, then set the
corresponding bit within D as 1, otherwise as 0.
z After the operation, if all the bits in D are all 0, then set the 0 flag "D = 0" to 1.
Sa R0 1 0 1 1 1 0 1 1 0 1 1 0 1 1 0 1
Sb R1 1 1 1 0 1 1 1 0 1 0 1 0 0 1 1 0
ØX0=
D R2 0 1 0 1 0 1 0 1 1 1 0 0 1 0 1 1
7-25
Logical Operation Instructions
FUN 36 D P FUN 36 D P
EXCLUSIVE NOR
XNR XNR
● When operation control "EN" = 1 or changes from 0 to 1 ( P instruction), will perform the logical XNR
(inclusive or) operation of data Sa and Sb. The operation of this function is to compare the corresponding
bits of Sa and Sb (B0~B15 or B1~B31), and if the bit has the same value, then set the corresponding bit
within D as 1. If not then set it to 0.
● After the operation, if the bits in D are all 0, then set the 0 flag "D=0" to 1.
Sa R0 1 0 1 1 1 0 1 1 0 1 1 0 1 1 0 1
Sb R1 1 1 1 0 1 1 1 0 1 0 1 0 0 1 1 0
ØX0=
D R2 1 0 1 0 1 0 1 0 0 0 1 1 0 1 0 0
7-26
Comparison Instructions
FUN 37 D P FUN 37 D P
ZONE COMPARE
ZNCMP ZNCMP
S ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
SU ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
SL ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
z When operation control "EN" = 1 or changes from 0 to 1 ( P instruction), compares S with upper limit SU
and lower limit SL. If S is between the upper limit and the lower limit (SL≦S≦SU), then set the inside zone
flag "INZ" to 1. If the value of S is greater than the upper limit SU, then set the higher than upper limit flag
"S>U" to 1. If the value of S is smaller then the lower limit SL, then set the lower than lower limit flag "S<L"
as 1.
z The upper limit SU should be greater than the lower limit SL. If SU<SL, then the limit value error flag "ERR"
will set to 1, and this instruction will not carry out.
SU : R 1
values of R0~R2 are as shown in the diagram at bottom
S>U
SL : R 2 left, then the result can then be obtained as at the right
S<L of this diagram.
z If want to get the status of out side the zone, then OUT
ERR
NOT Y0 may be used, or an OR operation between the
two outputs S>U and S<L may be carried out, and move
the result to Y0.
S R0 200
Y0
SU R1 300 (Upper limit value) X0=
1
SL
R2 100
(Lower limit value) )
Results of execution
Before-execution
7-27
Data Movement Instructions I
FUN 40 D P FUN 40 D P
BIT READ
BITRD BITRD
z When read control "EN" = 1 or changes from 0 to 1 ( P instruction), take the Nth bit of the S data out , and
put it to the output bit "OTB".
z When read control "EN" = 0, the output “OTB” can be selected to keep at the last state ( if M1919=0 ) or
set to zero ( if M1919=1 ).
z When the operand is 16 bit, the effective range for N is 0~15. For 32 bit operand ( D instruction) it is 0~31.
N beyond this range will set the N value error flag "ERR" to 1, and do not carry out this instruction.
40P.BITRD z The instruction at left reads the 7th bit (X7) status from
X0 Y0
EN S : WX 0 OTB
WX0 (X0~X15) and output to Y0. The results are as
N : 7 ERR follows:
X15 X7 X0
S WX0 1 1 0 0 1 1 1 0 1 0 0 1 1 0 0 1
N=7────────── ØX0=
Y0 1
7-28
Data Movement Instructions I
FUN 41 D P FUN 41 D P
BIT WRITE
BITWR BITWR
z When write control "EN" = 1 or changes from 0 to 1 ( P instruction), will write the write bit (INB) into the Nth
bit of register D.
z When the operand is 16 bit, the effective range of N is 0~15. For 32 bit ( D instruction) operand it is 0~31. N
beyond this range, will set the N value error flag "ERR" to 1, and do not carry out this instruction.
41P.BITWR
X0
z The instruction at left writes the status of the write bit
EN D : R 0 ERR
X1 INB into B3 of R0. Assuming
INB N : 3 X1 = 1, the result will be as follows:
X1 1
N=3───────────── ØX0=
D R0 1
B15 B3 B0
Bits other than B3 remain unchanged
7-29
Data Movement Instructions I
FUN 42 D P FUN 42 D P
BIT MOVE
BITMV BITMV
z When move control "EN" = 1 or changes from 0 to 1 ( P instruction), will move the bit status specified by Ns
within S into the bit specified by Nd within D.
z When the operand is 16 bit, the effective range of N is 0~15. For 32 bit ( D instruction) operand the effective
range is 0~31. N beyond this range will set the N value error flag "ERR" to 1, and do not carry out this
instruction.
X0 42P.BITMV
z The instruction at left moves the status of B11 (X11)
EN S : WX 0 ERR
within S into the B7 position within D. Except bit B7,
Ns : 11
other bits within D does not change.
D : R 0
Nd : 7
X15 X11 X0
S WX0 1
Ns=11─────
ØX0=
Nd=7 ────────
D R0 1
B15 B7 B0
7-30
Data Movement Instructions I
FUN 43 D P FUN 43 D P
NIBBLE MOVE
NBMV NBMV
z When move control "EN" = 1 or has a transition from 0 to 1 ( P instruction), will move the Ns’th nibble from
within S to the nibble specified by Nd within D. (A nibble is comprised by 4 bits. Starting from the lowest bit of
the register, B0, each successive 4 bits form a nibble, so B0~B3 form nibble 0, B4~B7 form nibble 1, etc...)
z When the operand is 16 bit, the effective range of Ns or Nd is 0~3. For 32 bit ( D instruction) operand the
range is 0~7. Beyond this range, will set the N value error flag "ERR" to 1 , and do not carry out this
instruction.
B15 B0
S R0 1 1 0 1
Ns=2 ───────
ØX0=
Nd=1 ─────────
D R1 1 1 0 1
B15 B0
7-31
Data Movement Instructions I
FUN 44 D P FUN 44 D P
BYTE MOVE
BYMV BYMV
z When move control "EN" = 1 or has a transition from 0 to 1 ( P instruction), move Nsth byte within S to Ndth
byte position within D. (A byte is comprised of 8 bits. Starting from the lowest bit of the register, B0, each
successive eight bits form a byte, so B0~B7 form byte 0, B8~B15 form byte 1, etc...)
z When the operand is 16 bit, the effective range of Ns or Nd is 0~1. For 32 bit ( D instruction) operand, the
range is 0~3. Beyond this range, will set the N value error flag "ERR" to 1, and do not carry out this
instruction.
Nd : 1
B15 B0
S R1 R0 1 0 1 1 1 0 1 1
Ns=2──────────────
ØX0=
Nd=1────────────────────
D R3 R2 1 0 1 1 1 0 1 1
B31 B0
7-32
Data Movement Instructions I
FUN 45 D P FUN 45 D P
EXCHANGE
XCHG XCHG
Da : Register a to be exchanged
Db : Register b to be exchanged
z When exchange control "EN" = 1 or has a transition from 0 to 1 ( P instruction), will exchanges the contents
of register Da and register Db in 16 bits or 32 bits ( D instruction) format.
X0 45P.XCHG
z The instruction at left exchanges the contents of the
EN Da : R 0 16-bit R0 and R1 registers.
Db : R 1
B15 B0
Da R0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Db R1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
ØX0=
B15 B0
Da R0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Db R1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7-33
Data Movement Instructions I
FUN 46 P FUN 46 P
BYTE SWAP
SWAP SWAP
z When swap control "EN" = 1 or has a transition from 0 to 1 ( P instruction), swap the data of the low byte,
Byte 0 (B0~B7), and the high byte, Byte 1 (B8~B15), in the 16 bit register specified by D.
B15 B8 B7 B0
Byte 1(high) Byte 0(low)
X0 46P z The instruction at left swaps the data of the low byte
EN SWAP R 0 (B0~B7) and the high byte (B8~B15) in R0. The results
are as follows:
Byte1 Byte0
D R0 0 0 1 1 0 0 1 1 1 1 1 1 0 0 0 0
B15 B8 B7 B0
ØX0=
B15 B0
D R0 1 1 1 1 0 0 0 0 0 0 1 1 0 0 1 1
7-34
Data Movement Instructions I
FUN 47 P FUN 47 P
NIBBLE UNITE
UNIT UNIT
z When unite control "EN" = 1 or has a transition from 0 to 1 ( P instruction), take out the lowest nibbles NB0,
of N successive registers starting from S, and fill them into NB0, NB1, .....NBn-1 of D in ascending order.
Nibbles not yet filled in D (when N is odd) are filled with 0. (A nibble is comprised by 4 bits. Starting from
the lowest bit in the register, B0, each successive four bits form a nibble, so B0~B3 form nibble 0, B4~B7
form nibble 1, etc...).
z This instruction only provides WORD (16 bit) operand. Because of this, there are usually only 4 nibbles can
be involved. Therefore the effective range of N is 1~4. Beyond this range, will set the N value error flag
"ERR" to 1, and do not carry out this instruction.
X0 47P.UNIT
z The instruction at left takes out NB0 from 3 registers, R0,
EN S : R 0 ERR R1 and R2, and fills them into NB0~NB2 within WY0
N : 3 register.
D : WY 0
N=3
7-35
Data Movement Instructions I
FUN 48 P FUN 48 P
NIBBLE DISTRIBUTE
DIST DIST
z When distribution control "EN" = 1 or has a transition from 0 to 1( P instruction), will take N successive
nibbles starting from the lowest nibble NB0 within S, and distribute them in ascending order into the 0
nibbles of N registers starting from D. The nibbles other than NB0 in each of the registers within D are all set
to zero. (A nibble is comprised by 4 bits. Starting from the lowest bit in a register, B0, each successive 4 bits
form a nibble, so B0~B3 form nibble 0, B4~B7 form nibble 1, etc...)
z This instruction only provides WORD (16 bit) operand. Therefore there are usually only 4 nibbles can be
involved, so the effective value of N is 1~4. Beyond this range, will set the N value error flag "ERR" to 1, and
do not carry out this instruction.
7-36
Data Movement Instructions I
FUN49 P FUN49 P
BYTE UNITE
BUNIT BUNIT
Range HR ROR DR K
R0 R5000 D0
Ope- ∣ ∣ ∣
rand R3839 R8071 D4095
S ○ ○ ○
N ○ ○ ○ 1~256
D ○ ○* ○
● When execution control "EN"=1 or changes from 0→1 P instruction, it will perform the byte combination
starting from S, length by N, and then store the results into D registers.
● When communicating with intelligent peripheral in binary data format, this instruction may be applied to do
byte combination for following word data processing.
Example:
M2 49P.BUNIT
EN S : R 1500
N : R 999
D : R 2500
Description:When M2 changes from 0→1, it will perform the byte combination starting from R1500, the length is
assigned by R999, and then store the results into registers starting from R2500.
It is supposed R999=10, the results of combination will store into R2500~R2504.
S D
High Byte Low Byte High Byte Low Byte
R1500 Don’t care Byte-0 R2500 Byte-0 Byte-1
R1501 Don’t care Byte-1 R2501 Byte-2 Byte-3
R1502 Don’t care Byte-2 R2502 Byte-4 Byte-5
R1503 Don’t care Byte-3 R2503 Byte-6 Byte-7
R1504 Don’t care Byte-4 R2504 Byte-8 Byte-9
R1505 Don’t care Byte-5
R1506 Don’t care Byte-6
R1507 Don’t care Byte-7
R1508 Don’t care Byte-8
R1509 Don’t care Byte-9
7-37
Data Movement Instructions I
FUN50 P FUN50 P
BYTE DISTRIBUTE
BDIST BDIST
Range HR ROR DR K
R0 R5000 D0
Ope- ∣ ∣ ∣
rand R3839 R8071 D4095
S ○ ○ ○
N ○ ○ ○ 1~256
D ○ ○* ○
● When execution control "EN" =1 or changes from 0→1( P instruction), it will perform the byte distribution
starting from S, length by N, and then store the results into D registers.
● When communicating with intelligent peripheral in binary data format, this instruction may be applied to do
byte distribution for data transmission。
Example:
M2 50P.BDIST
EN S : R 1000
N : R 999
D : R 1500
Description:When M2 changes from 0→1, it will perform the byte distribution starting from R1000, the length is
assigned by R999, and then store the results into registers starting from R1500.
It is supposed R999=9, the results of distribution will store into R1500~R1508.
S D
High Byte Low Byte High Byte Low Byte
R1000 Byte-0 Byte-1 R1500 00 Byte-0
R1001 Byte-2 Byte-3 R1501 00 Byte-1
R1002 Byte-4 Byte-5 R1502 00 Byte-2
R1003 Byte-6 Byte-7 R1503 00 Byte-3
R1004 Byte-8 Don’t care R1504 00 Byte-4
R1505 00 Byte-5
R1506 00 Byte-6
R1507 00 Byte-7
R1508 00 Byte-8
7-38
Shifting/Rotating Instructions
FUN 51 D P FUN 51 D P
SHIFT LEFT
SHFL SHFL
D : Register to be shifted
z When shift control "EN" = 1 or has a transition from 0 to 1( P instruction), will shift the data of the D register
towards the left by N successive bits (in ascending order). After the lowest bit B0 has been shifted left, its
position will be replaced by shift-in bit INB, while the status of shift-out bits B15 or B31 ( D instruction) will
appear at shift-out bit "OTB".
z If the operand is 16 bit, the effective range of N is 1~16. For 32 bits ( D instruction) operand, it is 1~32.
Beyond this range, will set the N value error flag "ERR" to 1, and do not carry out this instruction.
X0
51P.SHFL Y0 z The instruction at left shifts the data in register R0
EN D : R 0 OTB towards the left by 4 successive bits. The results are
shown below.
N : 4 ERR
INB
Y0 B15 R0 B0 INB
← 0 0 1 1 0 0 1 0 1 1 1 1 0 0 0 0 ← 1
* △
ØX0=
Y0 B15 R0 B0 INB
1 0 0 1 0 1 1 1 1 0 0 0 0 1 1 1 1 1
* △ △ △ △ △
7-39
Shifting/Rotating Instructions
FUN 52 D P FUN 52 D P
SHIFT RIGHT
SHFR SHFR
D : Register to be shifted
z When shift control "EN" = 1 or has a transition from 0 to 1 ( P instruction), will shift the data of D register
towards the right by N successive bits (in descending order). After the highest bits, B15 or B31 ( D
instruction) have been shifted right, their positions will be replaced by the shift-in bit INB, while shift-out bit
B0 will appear at shift-out bit "OTB".
z If the operand is 16 bit, the effective range of N is 1~16. For 32 bits ( D instruction) operand, it is 1~32.
Beyond this range, will set the N value error flag "ERR" to 1, and do not carry out this instruction.
52P.SHFR
z The instruction at left shifts the data in R0 register
X0 Y0
towards the right by 15 successive bits. The
EN D :R 0 OTB
results are shown below.
N : 15
INB ERR
INB B15 R0 B0 Y0
0 → 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 →
△ *
ØX0=
INB B15 R0 B0 Y0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
△ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ *
7-40
Shifting/Rotating Instructions
FUN 53 D P FUN 53 D P
ROTATE LEFT
ROTL ROTL
D : Register to be rotated
z When rotate control "EN" = 1 or has a transition from 0 to 1 ( P instruction), will rotate the data of D register
towards the left by N successive bits (in ascending order, ie. in a 16-bit instruction, B0→B1, B1→B2, .... ,
B14→B15, B15→B0. In a 32-bit instruction, B0→B1, B1→B2, .... , B30→B31, B31→B0). At the same time,
the status of the rotated out bits B15 or B31 ( D instruction) will appear at rotate-out bit "OTB".
z If the operand is 16 bit, the effective range of N is 1~16. For 32 bits ( D instruction) operand, it is 1~32.
Beyond this range, will set the N value error flag "ERR" to 1, and do not carry out this instruction.
R0 B0
1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 0
*
Y0
ØX0=
B15 R0 B0
0 1 0 1 0 1 0 1 1 1 1 0 0 0 0 1
*
1 Y0
*
7-41
Shifting/Rotating Instructions
FUN 54 D P FUN 54 D P
ROTATE RIGHT
ROTR ROTR
D : Register to be rotated
z When rotate control "EN" = 1 or has a transition from 0 to 1( P instruction), will rotate the bit data of D
register towards the right by N successive bits (in descending order, ie. in a 16-bit instruction, B15→B14,
B14→B13, .... , B1→B0, B0→B15. In a 32-bit instruction, B31→B30, B30→B29, .... , B1→B0, B0→B31). At
the same time, the status of the rotated out B0 bits will appear at the rotate-out bit "OTB".
z If the operand is 16 bit, the effective range of N is 1~16. For 32 bits ( D instruction) operand, it is 1~32.
Beyond this range, will set the N value error flag "ERR" to 1, and do not carry out this instruction.
B15 R0 B0
1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 0
*
Y0
ØX0=
B15 R0 B0
1 0 1 0 1 0 1 0 1 1 1 1 0 0 0 0
*
Y0 1
*
7-42
Code Conversion Instructions
FUN55 D P FUN55 D P
BINARY-CODE TO GRAY-CODE CONVERSION
B→ G B→ G
S :Starting of source
● When operation control "EN"=1 or changes from 0→1( P instruction), it will perform the code conversion;
where S is the source (Binary code), and D is the destination (Gray code) for storing the result.
Example 1: When M0 changes from 0→1, it will perform the 16-bit code conversion
7-43
Code Conversion Instructions
FUN55 D P FUN55 D P
BINARY-CODE TO GRAY-CODE CONVERSION
B→ G B→ G
7-44
Code Conversion Instructions
FUN56 D P FUN56 D P
GRAY-CODE TO BINARY-CODE CONVERSION
G→ B G→ B
Ladder symbol
S :Starting of source
56DP.G B
D :Starting address of destination
Operation control EN S :
S , D operand can combine V 、 Z 、 P0~P9 for index
D :
addressing
● When operation control "EN"=1 or changes from 0→1 ( P instruction), it will perform the code conversion;
where S is the source (Gray code), and D is the destination (Binary code) for storing the result.
1 0 0 1 1 0 0 0 1 1 1 0 1 1 0 1
R R R R R R R R R R R R R R R
XO XO XO XO XO XO XO XO XO XO XO XO XO XO XO
1 1 1 0 1 1 1 1 0 1 0 0 1 0 0 1
Example 1: When M0 changes from 0→1, it will perform the 16-bit code conversion
M0 56P.G B
˙Converting the 16-bit Gray-code in D0 into Binary-code,
EN S : D0
and then storing the result into D100.
D : D100
7-45
Code Conversion Instructions
FUN56 D P FUN56 D P
GRAY-CODE TO BINARY-CODE CONVERSION
G→ B G→ B
7-46
Code Conversion Instructions
FUN 57 P FUN 57 P
DECODE
DECOD DECOD
N
● This instruction, will set a single bit among the total of 2 L discrete points (D) to 1 and the others bit are set to
0. The bit number to be set to 1 is specified by the value comprised by BNS~BNS+NL−1 of S(which is called
the decode value, BNS is the starting bit of the decode value, and BNS+NL−1 is the end value).
● When decode control "EN" = 1 or has a transition from 0 to 1 ( P instruction), will take out the value BNS~
BNS+NL−1 from S. And with this value to locate the bit position and set D accordingly, and set all the other bit
to zero
● This instruction only provides 16 bit operand, which means S only has B0~B15. Therefore the effective range
of Ns is 0~15, and the NL length of the decode value is limited to 1~8 bits. Therefore the width of the decoded
result D is 21~8 points = 2~256 points = 1~16 words (if 16 points are not sufficient, 1 word is still occupied). If
the value of NS or NL is beyond the above range, will set the range-error flag "ERR" to 1, and do not carry out
this instruction.
● If the end bit value exceeds the B15 of S, then will extend toward B0 of S + 1. However if this occurs then
S+1 can’t exceed the range of specific type of operand (ie. If S is of D type register then S+1 can’t be D3072).
If violate this, then this instruction only takes out the bits from starting bit BNs to its highest limit as the decode
value.
X15 X7 X3 X0
S 0 0 1 1 0 0 0 0 0 1 0 0 1 1 1 0
Length of decode value NL=5,so bit value is formed by X7~X3 (equal 9)
ØX0=
R3 R2
D 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
B31 B9 B0
Because NL=5,the width of D is 25= 32 point = 2 word. That is, D is formed by R3R2, and the decoded value is
01001=9, therefore B9 (the 10th point) within D is set to 1, and all other points are 0.
7-47
Code Conversion Instructions
FUN 58 P FUN 58 P
ENCODE
ENCOD ENCOD
S ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
NS ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ 0~15 ○
NL ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ 2~256 ○
D ○ ○ ○ ○ ○ ○ ○ ○* ○* ○ ○
● When encode control "EN" = 1 or has a transition from 0 to 1 ( P instruction), will starting from the points
specified by Ns within S, take out towards the left (high position direction) NL number of successive bits BNS~
BNS+NL−1 (BNS is called the encoding start point, and its relative bit number is b0;BNS+NL−1 is called the
encoding end point, and its relative bit number is BNL-1). From left to right do higher priority (when H/L=1)
encoding or from right to left do lower priority (when H/L=0) encoding (i.e. seek the first bit with the value of 1,
and the relative bit number of this point will be stored into the low byte (B0~B7) of encoded resultant register
D, and the high byte of D will be filled with 0.
D 00000000 H or L
● As shown in the diagram above, for high priority encoding, the bit first to find is bH (with a value of 12), and for
low priority encoding, the bit first to find bL (with a value of 4). Among the NL discrete points there must be at
least one bit with value of 1. If all bits are 0, will not to carry out this instruction, and the all zero flag "D=0" will
set to 1.
● Because S is a 16-bit register, Ns can be 0~15, and is used to assign a point of B0~B15 within S as the
encoding start point (b0). The value of NL can be 2~256, and it is used to identify the encoding end point, i.e. it
assigns NL successive single points starting from the start point (b0) towards the left (high position direction)
as the encoding zone (i.e. b0~bNL−1). If the value of Ns or NL exceeds the above value, then do not carry out
this instruction, and set the range-error flag "ERR" as 1.
7-48
Code Conversion Instructions
FUN 58 P FUN 58 P
ENCODE
ENCOD ENCOD
● If the encoding end point (bNL−1) beyond the B15 of S, then continue extending towards S+1, S+2, but it must
not exceed the range of specific type of operand. If it goes beyond this, then this instruction can only take the
discrete points between b0 and the highest limit into account for encoding.
S D
(b0)
B15 B9 B0
R0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Y15 Y0
X0=
R1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 WY0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0
R2 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0
Ö
B47 B44 ↑ B32 High byte always =26
(b35) (b26) (encode value)
fill with "0"
7-49
Code Conversion Instructions
FUN 59 P FUN 59 P
7-SEGMENT CONVERSION
→7SG →7SG
● When conversion control "EN" = 1 or has a transition from 0 to 1 ( P instruction), will convert N+1 number of
nibbles (A nibble is comprised by 4 successive bits, so B0~B3 of S form nibble 0, B4~B7 form nibble 1,
etc...)within S to 7-segment code, and store the code into a low byte of D (High bytes does not change).
The 7 segment within D are put in sequence, with "a" segment placed at B6, "b" segment at B5, .... ,"g"
segment at B0. B7 is not used and is fixed as 0. For details please refer the "7-segment code and display
pattern table".
● Because this instruction is limited to 16 bits, and S only has 4 nibbles (NB0~NB3), the effective range of N
is 0~3. Beyond this range, will set the N value flag error "ERR" to 1, and does not carry out this instruction.
● Care should be taken on total nibbles to be converted is N+1. N=0 means one digit to convert, N=1 means
two digits to convert etc…
● When using the FATEK 7-segment expansion module(FBs-7SGxx) and the FUN84 (7SEG) handy
instruction for mixing decoding and non-decoding application, FUN59 and FUN84 can be combined to
simplify the program design.
7-50
Code Conversion Instructions
FUN 59 P FUN 59 P
7-SEGMENT CONVERSION
→7SG →7SG
Original R100=0000H
R0=0001H Î R100=0030H(1)
M1 59. 7SG ․Instruction at left will convert the first and the second
EN S : R0 ERR digit of R0 to 7-segment and store in R100.
N : 1 ․The low byte of R100 stores first digit.
D : R100 ․The high byte of R100 stores second digit.
R0=0056H Î R100=5B5FH(56)
Original R101=0000H
R0=0A48H Î R100=337FH(48)
R101=0077H(A)
R0=2790H Î R100=7B7EH(90)
R101=6D72H(27)
7-51
Code Conversion Instructions
FUN 59 P FUN 59 P
7-SEGMENT CONVERSION
→7SG →7SG
0 0000 0 1 1 1 1 1 1 0
1 0001 0 0 1 1 0 0 0 0
2 0010 0 1 1 0 1 1 0 1
3 0011 0 1 1 1 1 0 0 1
B6
4 0100 a 0 0 1 1 0 0 1 1
B1 f b B5
5 0101 B0
g
0 1 0 1 1 0 1 1
B2 e c B4
6 0110 0 1 0 1 1 1 1 1
d
B7
B3 P
7 0111 0 1 1 1 0 0 1 0
8 1000 0 1 1 1 1 1 1 1
9 1001 0 1 1 1 1 0 1 1
A 1010 0 1 1 1 0 1 1 1
B 1011 0 0 0 1 1 1 1 1
C 1100 0 1 0 0 1 1 1 0
D 1101 0 0 1 1 1 1 0 1
E 1110 0 1 0 0 1 1 1 1
F 1111 0 1 0 0 0 1 1 1
7-52
Code Conversion Instructions
FUN 60 P FUN 60 P
ASCII CONVERSION
→ASC →ASC
● When conversion control "EN" = 1 or has a transition from 0 to 1 ( P instruction), will convert alphabets and
numbers stored in S (S has a maximum of 12 alphanumeric character) into ASCII and store it into registers
starting from D. Each 2 alphanumeric characters occupy one 16-bit register.
● The application of this instruction, most often, stores alphanumeric information within a program, and waits
until certain conditions occur, then converts this alphanumeric information into ASCII and conveys it to
external display devices which can accept ASCII code.
D : R0
S D
High Byte Low Byte
R0 42(B) 41(A)
Alphabet X0=
R1 44(D) 43(C)
ABCDEF Ö R2 46(F) 45(E)
7-53
Code Conversion Instructions
FUN 61 P FUN 61 P
HOUR:MINUTE:SECOND TO SECONDS CONVERSION
→SEC →SEC
z When conversion control "EN" = 1 or has a transition from 0 to 1 ( P instruction), will convert the hour: minute:
second data of S~S+2 into an equivalent value in seconds and store it into the 32-bit register formed by
combining D and D+1. If the result = 0, then set the "D = 0" flag as 1.
z Among the FBs-PLC instructions, the hour: minute: second time related instructions (FUN61 and 62) use 3
words of register to store the time data, as shown in the diagram below. The first word is the second register,
the second word is the minute register, and finally the third word is the hour register, and in the 16 bits of
each register, only B14~B0 are used to represent the time value. While bit B15 is used to express whether
the time values are positive or negative. When B15 is 0, it represents a positive time value, and when B15
is 1 it represents a negative time value. The B14~B0 time value is represented in binary, and when the time
value is negative, B14~B0 is represented with the 2's complement. The number of seconds that results from
this operation is the result of summation of seconds from the three registers representing hours: minutes:
seconds.
B15 B14 B0 B15B0
S (sec) -32768 sec~32767 sec D the sec. value.
S+1 (min) -32768 min~32767 min Ö D+1
S+2 (hr) -32768 hr~32767 hr B31 B30 B16
↑ ↑ B31 is used to represent the positive or
The B15 of each registers is used to represent the sign of each time value └ negative nature of the sec. value
z Besides FUN61 or 62 instruction which treat hour: minute: second registers as an integral data, other
instructions treat it as individual registers.
z The example program at below converts the hour: minute: second data formed by R20~R22 into their
equivalent value in seconds then stored in the 32-bit register formed by R50~R51. The results are shown
below.
D : R 50 ØX0=
R50 EE45H
D =3599941 sec
R51 0036H
7-54
Code Conversion Instructions
FUN 62 P FUN 62 P
SECOND→HOUR:MINUTE:SECOND
→HMS →HMS
z When conversion control "EN" = 1 or has a transition from 0 to 1 ( P instruction), will convert the second data
from the S~S+1 32-bit register into the equivalent hour : minute : second time value and store it in the three
successive registers D~D+2. All the data in this instruction is represented in binary (if there is a negative
value it is represented using the 2's complement.)
B15 B0 B15 B0
S D (sec) -59 sec~59 sec
S+1
Second Ö D+1 (min) -59 min~59 min
B31 B16 D+2 (hr) -32768 hr~32767 hr
↑ ↑
The bit B31 of the second The bits B15 of each register are used as
register is used as the sign the sign bit of the hour : minute : second
bit of the second value. value.
z As shown in the diagram above, after convert to hour : minute : second value, the minute : second value can
only be in the range of -59 to 59, and the hour number can be in the range of -32768 to 32767 hours.
Because of this, the maximum limit of D is -32768 hours, -59 minutes, -59 seconds to 32767 hours, 59
minutes, 59 seconds, the corresponding second value of S which is in the range of -117968399 to
117964799 seconds. If the S value exceeds this range, this instruction cannot be carried out, and will set the
over range flag "OVR" to 1. If S = 0 then result is 0 flag "D = 0" will be set to 1.
z The program in the diagram below is an example of this instruction. Please note that the content of the
registers are denoted by hexadecimal, and on the right is its equivalent value in decimal notation.
R0 5D17H
6315287 sec
X0 62P. HMS R1 0060H
EN S : R 0 D=0
ØX0=
D : R 10 OVR
R10 002FH 47 sec
R11 000EH 14 min
R12 06DAH 1754 hr
7-55
Code Conversion Instructions
FUN 63 P FUN 63 P
CONVERSION OF ASCII CODE TO HEXADECIMAL VALUE
→HEX →HEX
z When conversion control “EN” =1 or changes from 0→1( P instruction), it will convert the N successive
hexadecimal ASCII character(‘0’~’9’,’A’~’F’) convey by 16 bit registers (Low Byte is effective) into
hexadecimal value, and store the result into the register starting with D. Every 4 ASCII code is stored in one
register. The nibbles of register, which does not involve in the conversion of ASCII code will remain
unchanged.
z When there is ASCII error (neither 30H~39H nor 41H~46H), the output “ERR” is ON.
z The main purpose of this instruction is to convert the hexadecimal ASCII character (‘0’~’9’,’A’~’F’), which is
received by communication port1 or communication port2 from the external ASCII peripherals, to the
hexadecimal values that the CPU can process directly.
7-56
Code Conversion Instructions
FUN 63 P FUN 63 P
CONVERSION OF ASCII CODE TO HEXADECIMAL VALUE
→HEX →HEX
Originally R100=0000H
R0=0039H(9)Î R100=0009H
7-57
Code Conversion Instructions
FUN 64 P FUN 64 P
CONVERSION OF HEXADECIMAL VALUE TO ASCII CODE
→ASCII →ASCII
z When conversion control “EN” =1 or changes from 0→1( P instruction), will convert the N successive
nibbles of hexadecimal value in registers start from S into ASCII code, and store the result to low byte (high
byte remain unchanged) of the registers which start from D.
z The conversion will not be performed when the value of N is 0 or greater than 511.
z The main purpose of this instruction is to convert the numerical value data, which PLC has processed, to
ASCII code and transmit to ASCII peripherals by communication port1 or communication port 4.
7-58
Code Conversion Instructions
FUN 64 P FUN 64 P
CONVERSION OF HEXADECIMAL VALUE TO ASCII CODE
→ASCII →ASCII
〈Example 1〉When M1 changes from OFF→ON, it converts hexadecimal value to ASCII code.
M1 64P. ASCII
S : R0 ․Converts the Nibble 0 of R0 to ASCII code and stores
EN
it into R100 (High byte does not change).
N : 1
D : R100
R0=0009H Î R100=0039H(9)
R0=009AH Î R100=0039H(9)
R101=0041H(A)
D : R100
R0=0123H Î R100=0031H(1)
R101=0032H(2)
R102=0033H(3)
R0=3456H Î R100=0031H(1)
R1=0012H R101=0032H(2)
R102=0033H(3)
R103=0034H(4)
R104=0035H(5)
R105=0036H(6)
7-59
Flow Control Instructions II
No operand
z When end control "EN" = 1, this instruction is activated. Upon executing the END instruction and "EN" = 1, the
program flow will immediately returns to the starting point (0000M) to restart the next scan – i.e. all the
programs after the END instruction will not be executed. When "EN" = 0, this instruction is ignored, and
programs after the END instruction will continue to be executed as the END instruction is not exist.
z This instruction may be placed more than one point within a program, and its input (end control "EN") controls
the end point of program execution. It is especially useful for debugging and for testing.
z It’s not necessary to put any END instructions in the main program, CPU will automatic restart to start point
when reach the end of main program.
0000M
Program 1 Program 1
Program execution
X0
X0=1 ORG X0
EN END END
Program 2 Program 2
X0=0
X1=1
X1 ORG X1
EN END END
7-60
Flow Control Instructions II
FUN 65 FUN 65
LABEL
LBL LBL
z This instruction is used to make a tag on certain address within a program, to provide a target address for
execution of JUMP, CALL instruction and interrupt service. It also can be used for document purpose to
improve the readability and interpretability of the program.
z This instruction serves only as the program address marking to provide the control of procedure flow or for
remark. The instruction itself will not perform any actions; whether the program contains this instruction or not,
the result of program execution will not be influenced by this instruction.
z The label name can be formed by any 1~6 alphanumeric characters and can’t be duplicate in the same
program. The following label names are reserved for interrupt function usage. These “reserved words”, can’t
be used for normal program labels.
Only the interrupt service routine can use the label names listed on above table, if mistaken on using the
reserved label on the normal subroutine can cause the CPU fail or unpredictable operation.
The label of following diagram illustration served only as program remarks (it is not treated as a label for call
or jump target). For the application of labeling in jump control, please refer to JMP instruction for
explanation. As to the labeling serves as subroutine names, please refer to CALL instruction for details.
65
LBL PGM1
Program 1
65
LBL PGM2
Program 2
7-61
Flow Control Instructions II
FUN 66 P FUN 66 P
JUMP
JMP JMP
Ladder symbol
66P. LBL : The program label to be jumped
Jump control EN JMP LBL
z When jump control “EN”=1 or changes from 0→1 ( P instruction), PLC will jump to the location behind the
marked label and continuous to execute the program.
z This instruction is especially suit for the applications where some part of the program will be executed only
under certain condition. This can shorter the scan time while not executes the whole program.
z This instruction allows jump backward (i.e. the address of LBL is comes before the address of JMP
instruction). However, care should be taken if the jump action cause the scan time exceed the limit set by the
watchdog timer, the WDT interrupt will be occurred and stop executing.
z The jump instruction allows only for jumping among main program or jumping among subroutine area, it can’t
jump across main/subroutine area.
X0 66
․In the left diagram, when X0=1, the program will jump
EN JMP PATHB directly to the LBL position named PATHB and
continuing to execute program B. Therefore it will
Program A skip the program A and none of the instructions of
program A will be executed. The status of registers
65
LBL PATHB and the coils associated with program A will keep
unchanged (as if there is no program section A).
Program B
7-62
Flow Control Instructions II
FUN 67 P FUN 67 P
CALL
CALL CALL
z When call control “EN”=1 or changes from 0→1 ( P instruction), PLC will call (perform) the subroutine bear
the same label name as the one being called. When execute the subroutine, the program will execute
continuous as normal program does but when the program encounter the RTS instruction then the flow of
the program will return back to the address immediately after the CALL instruction.
SUB3 Program 3
1X 2X 3X 4X 5X 68
RTS
LBL SUB1 LBL SUB2 LBL SUB3 LBL SUB4
7-63
Flow Control Instructions II
FUN 68 FUN 68
RETURN FROM SUBROUTINE
RTS RTS
z This instruction is used to represent the end of a subroutine. Therefore it can only appear within the
subroutine area. Its input side has no control signal, so there is no way to serially connect any contacts.
This instruction is self sustain, and is directly connected to the power line.
z When PLC encounter this instruction, it means that the execution of a subroutine is finished. Therefore it will
return to the address immediately after the CALL instruction, which were previously executed and will
continue to execute the program.
z If this instruction encounters any of the three flow control instructions MC, SKP, or JMP, then this instruction
may not be executed (it will be regarded as not exist). If the above instructions are used in the subroutine
and causing the subroutine not to execute the RTS instruction, then PLC will halt the operation and set the
M1933( flow error flag) to 1. Therefore, no matter what the flow is going, it must always ensure that any
subroutine must be able to execute a matched RTS instruction.
z For the usage of the RTS instruction please refer to instructions for the CALL instruction.
7-64
Flow Control Instructions II
FUN 69 FUN 69
RETURN FROM INTERRUPT
RTI RTI
z The function of this instruction is similar to RTS. Nevertheless, RTS is used to end the execution of sub
program, and RTI is used to end the execution of interrupt service program. Please refer to the explanation
of RTS instruction.
z A RTI instruction can be shared by more than one interrupt service program. The usage is the same as the
sharing of an RTS by many subroutines. Please refer to the explanation of CALL instruction.
z The difference between interrupts and call is that the sub program name (LBL) of a call is defined by user,
and the label name and its call instruction are included in the main program or other sub program.
Therefore, when PLC performs the CALL instruction and the input “EN”=1 or changes from 0→1 (P
instruction), the PLC will call (execute) this sub program. For the execution of interrupt service program, it
is directly used with hardware signals to interrupt CPU to pause the other less important works, and then to
perform the interrupt service program corresponding to the hardware signal (we call it the calling of interrupt
service program). In comparing to the call instruction that need to be scanned to execute, the interrupt is a
more real time in response to the event of the outside world. In addition, the interrupt service program
cannot be called by label name; therefore we preserve the special “reserved words” label name to
correspond to the various interrupts offered by PLC (check FUN65 explanation for details). For example,
the reserved word X0+I is assigned to the interrupt occurred at input point X0; as long as the sub program
contains the label of X0+I, when input point X0 interrupt is occurred (X0: ), the PLC will pause the other
lower priority program and jump to the subroutine address which labeled as X0+I to execute the program
immediately.
z If there is a interrupt occurred while CPU is handling the higher priority (such as hardware high speed
counter interrupt) or same priority interrupt program (please refer to Chapter 10 for priority levels), the PLC
will not execute the interrupt program for this interrupt until all the higher priority programs were finished.
z If the RTI instruction cannot be reached and performed in the interrupt service routine, may cause a serious
CPU shut down. Consequently, no matter how you control the flow of program, it must be assured that the
RTI instruction will be executed in any interrupt service program.
z For the detailed explanation and example for the usage of interrupts, please refer to Chapter 9 for
explanation.
7-65
Flow Control Instructions II
FUN 70 FUN 70
FOR
FOR FOR
z This instruction has no input control, is connected directly to the power line, and cannot be in series with
any conditions.
z The programs within the FOR and NEXT instructions form a program loop (the start of the loop program is
the next instruction after FOR, and the last is the instruction before NEXT). When PLC executes the FOR
instruction, it first records the N value after that instruction (loop execution number), then for N times
successively execution from start to last of the programs in the loop. Then it jumps out of the loop, and
continues executes the instruction immediately after the NEXT instruction.
z The loop can have a nested structure, i.e. the loop includes other loops, like an onion. 1 loop is called a
level, and there can be a maximum of 5 levels. The FOR and NEXT instructions must be used in pairs. The
first FOR instruction and the last NEXT instruction are the outermost (first) level of a nested loop. The
second FOR instruction and the second last NEXT instruction are the second level, the last FOR instruction
and the first NEXT instruction form the loop's innermost level.
7-66
Flow Control Instructions II
FUN 71 FUN 71
LOOP END
NEXT NEXT
z This instruction and the FOR instruction together form a program loop. The instruction itself has no input
control, is connected directly to the power line, and cannot be in series with any conditions.
z When PLC has not yet entered the loop (has not yet executed to the FOR instruction, or has executed but
then jumped out), but the NEXT instruction is reached, then PLC will not take any action, just as if this
instruction did not exist.
z For the usage of this instruction please refer to the explanations for the FOR instruction on the preceding
page.
7-67
I/O Instructions I
FUN 74 P FUN 74 P
IMMEDIATE I/O
IMDIO IMDIO
Range X Y K
Xn of Yn of 1
Ope- Main Main ∣
rand Unit. Unit. 36
D ○ ○
N ○
● For normal PLC scan cycle, the CPU gets the entire input signals before the program is executed, and then
perform the executing of program based on the fresh input signals. After finished the program execution the
CPU will update all the output signals according to the result of program execution. Only after the complete
scan has been finished will all the output results be transferred all at once to the output. Thus for the input
event to output responses, there will be a delay of at least 1 scan time (maximum of 2 scan time). With this
instruction, the input signals or output signals specified by this instruction can be immediately refresh to get
the faster input to output response without the limitation imposed by the scan method.
● When refresh control "EN" = 1 or has a transition from 1 to 0( P instruction), then the status of N input
points or output points (D~D+N-1) will be refreshed.
● The I/O points for FBs-PLC's immediate I/O are only limited to I/O points on the main unit. The table below
shows permissible I/O numbers for 20, 32, 40 and 60 point main units:
Main-unit type
10 14 20 24 32 40 60
Permissible points points points points points points points
numbers
Input signals X0~X5 X0~X7 X0~X11 X0~X13 X0~X19 X0~X23 X0~X35
● If the intended refresh I/O signals of this instruction is beyond the range of I/O points specified on above
table then PLC will be unable to operate and the M1931 error flag will be set to 1. ( for example, if in a
program, D=X11, N=10, which means X11 to X20 are to be immediately retrieved. Supposing the main unit
is FBs-32MA, then its biggest input point is X19, and clearly X20 has already exceeded the main unit's input
point number so under such case M1931 error flag will be set to 1).
● With this instruction, PLC can immediately refresh input/output signals. However, the delay of the hardware
or the software filter impose on the I/O signals still exist. Please pay attention on this.
7-68
I/O Instructions I
FUN 76 D FUN 76 D
DECIMAL- KEY INPUT
TKEY TKEY
z This instruction has designated 10 input points IN~IN+9 (IN0~IN9) to one decimal number entry (IN->0,
IN+1->1…). According to the key-in sequence (ON) of these input points, it is possible to enter 4 or 8
decimal numbers into the registers specified by D.
z When input control "EN" = 0, this instruction will not be executed. KPR output and KL coil status will be 0.
However, the numerical values of D register will remain unchanged.
7-69
I/O Instructions I
FUN 76 D FUN 76 D
DECIMAL- KEY INPUT
TKEY TKEY
The following diagram is the input wiring schematic for this example:
0 1 2 3 4 5 6 7 8 9
C X0 X1 X2 X3 X4 X5 X6 X7 X8 X9
FBS-PLC input side
z If the X0~X3 key-in sequence follow the cdefghi sequence in the following diagram. At step c
and i the X20 is 0, so there was no key generated, only steps defgh are effective. Because the
register can only hold 4 key numbers, Of these 5 steps the first key was kick out. The key strokes 3302 of
the steps efgh are entered in the R0 register.
X20
5
X0
2 7
X1
1 6
X2
3 4
X3
M0
M1
M2
M3
2 3 4 5 6
Y0
R0 0000
0000 0001
0001 0013
0013 0133
0133 1330
1330 3302
3302
7-70
I/O Instructions I
FUN 77 D FUN 77 D
HEX-KEY INPUT
HKEY HKEY
z The numeric (0~9) key function of this instruction is similar as for the TKEY instruction. The hardware
connection for TKEY and HKEY is different. For TKEY instruction each key have one input point to connect,
while HKEY use 4 input points and 4 output points to form a 4x4 multiplex 16 key input. 4×4 means that
there can be 16 input keys, so in addition to the 10 numeric keys, the other 6 keys can be used as function
keys (just like the usual discrete input). The actions of the numeric keys and the function keys are
independent and have no effect on each other.
z When execution control "EN" = 1, this instruction will scan the numeric keys and function keys in the matrix
formed by the 4 input points starting from IN and the 4 output points starting from OT. For the function of the
numeric keys and "NKP" output please refer to the TKEY instruction. The function keys maintain the key-in
status of the A~F keys in the last 6 relays specified by KL (the first 10 store the key-in status of the numeric
keys). If any one of the A~F keys is depressed, FKP (FO1) will set to 1. The OT output points for this
instruction must be transistor outputs.
z The biggest number for a 16-bit operand is 4 digits (9999), and for 32-bit operand is 8 digits (99999999).
However, there are only 6 function keys (A~F), no matter whether it is a 16-bit or 32-bit operand.
77D.HKEY
X10 M10
Function
EN IN : X0 NKP Keys C D E F
OT : Y0
D : R0 M11 8 9 A B
KL : M0 FKP
WR : D0 Numeric
4 5 6 7
Keys
0 1 2 3
․ The instruction in the diagram above S/S X0 X1 X2 X3
uses X0~X3 and Y0~Y3 to form a +
24V PLC (transistor output)
multiplex key input. It can input numeric -
values of 8 digits and stores the results
in R1R0. The input status of the function
keys is stored in M10(A)~M15(F). C Y0 Y1 Y2 Y3
7-71
I/O Instructions I
FUN 78 D FUN 78 D
DIGITAL SWITCH INPUT
DSW DSW
z When input control "EN" = 1, this instruction will readout one digit data from the 4 input points starting from
IN (IN0~IN3). It takes 4 scans to read out a group of 4-digit BCD values (0000~9999) and store them into D
register. With a 32-bit operand, each scan can get 2 digits of data by reading the additional digit from
IN4-IN7 and store it in the D+1 register. Each bit of OT0~OT3 will sequentially set to 1 and get the digit data
respectively into 100(ones), 101(tens), 102(hundreds), and 103(thousands). As long as EN is 1, PLC will
scan and read out in continuous cycles. When each complete cycle is finished (i.e. the 4 digit readout of
100~103 is completed), the readout completed flag "DN" is set to 1. However, it is only kept for one scan. If
any digital readout value is not within the range of 0~9 (BCD), then reading error "ERR" will be set to 1 and
the value of that group of digits will be set to 0000.
z The output points must be transistor outputs.
78.DSW ․In this example, when X10 is 1, then the numeric value of the
X10 M10
thumb wheel switch (5678 in this example) will be read out
EN IN : X0 DN
and stored into the R0 register.
OT : Y0
M11 ․The bits (8,4,2,1) with same digit should be connect together
D : R0
ERR and series with a diode (as shown in diagram below).
WR : D0
․With 32-bit operand a set of similar thumb wheel switch may
be added to X4~X7 (Y0~Y3 are shared with another group).
BCD thumb
wheel swith
8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1
1 2 4 8
S/S X0 X1 X2 X3 X4 X5 X6 X7
C Y0 Y1 Y2 Y3
PLC
7-72
I/O Instructions I
FUN 79 D FUN 79 D
7-SEGMENT OUTPUT WITH LATCH
7SGDL 7SGDL
Ladder symbol
S : Register storing the data (BCD) to be
79D.7SGDL displayed
Execution control EN S : DN Output complete
OT : Starting number of scanning output
OT : N : Specify signal output and polarity of latch
N : WR : Working register, it can't repeat in use
S may combine with V、Z、P0~P9 to serve
WR :
indirect addressing application
z When input control "EN" = 1, the 4 nibbles of the S register, from digit 0 to digit 3, are sequentially sent out to
the 4 output points, OT0~OT3. While output the digit data, the latch signal of that digit (OT4 corresponds to
digit 0, OT5 corresponds to digit 1, etc...) at the same time is also sent out so that the digital value will be
loaded and latched into the 7-segment display respectively.
z When in D (32-bit) instruction, nibbles 0~3 from the S register, and nibbles 0~3 from the S+1 register are
transferred separately to OT0~OT3 and OT8~OT11. Because they are transferred at the same time, they can
use the same latch signal. 16-bit instructions do not use OT8~OT11.
z As long as "EN" remains 1, PLC will execute the transfer cyclically. After each transfer of a complete group of
numerical values (nibbles 0~3 or 0~7), the output completed flag "DN" will set to 1. However, it will only be kept
for 1 scan.
0 2 1 3
1 2 4 8 10 10 10 10 1 2 4 8
C Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7 Y8 Y9 Y10 Y11
NPN
7-73
I/O Instructions I
FUN 79 D FUN 79 D
7-SEGMENT OUTPUT WITH LATCH
7SGDL 7SGDL
z FATEK PLC's transistor output has both a negative logic transistor output (NPN transistor - when the output
status is ON, the terminal voltage of the transistor output is low), and a positive logic transistor output (PNP -
when the output status is ON, the terminal voltage of the transistor output is high). Their structure is as follows:
FBs-PLC negative logic output (NPN transistor) FBs-PLC positive logic output (PNP transistor)
z The data inputs (8,4,2,1) and latch signals of the 7-segment displays on the shelf for positive and negative logic
are all available. For example, for numerical value "8", the positive logic input should be 1000, and the negative
logic input 0111. Similarly, when the latch signal is 0, the positive logic latch permits the display numerical values
to enter through the latch (i.e. be loaded). When the latch signal is 1, the numerical values in the latch are
latched (maintained), and with negative logic they are not. The following diagram of a CD-4511 7-segment
display IC is an example of a positive logic numerical value input with latch.
CD4511
Numberical value input
R
a a
(1)A b
(2)B BCD to LED c f g b
4bit d
(4)C latch 7-segment Drive e e c
f
(8)D g d
n
(10 ) LE LT BI
VCC
Latch sing 1
z Because the PLC output and the 7-segment display input polarity can be positive and negative logic. Therefore,
the polarities between output and input must be coordinated to get the correct result. This instruction uses N to
specify the polarity relation between the PLC transistor output, and the 7-segment display. The table below
shows all the possibility.
z In the diagram above, CD4511 is used as an example. If use NPN output, the data input polarity is different to
PLC, and its latch input polarity is the same as PLC, so N value should chosen as 2.
7-74
I/O Instructions I
FUN 80 FUN 80
MULTIPLEX INPUT
MUXI MUXI
z This instruction uses the multiplex method to read out N lines of input status from 8 consecutive input points
(IN0~IN7) starting from the input point specified by IN. With this method we can obtain 8×N input status, but
only need to use 8 input points and N output points.
z The multiplex scanning method goes through N output points starting from the OT output point. Each scan one
of the N bits will set to 1 and the corresponding line will be selected. OT0 responsible for first line, while OT1
responsible for second line, etc. Until it read all the N lines the 8×N status that has been read out is then stored
into the register starting at D, and the execution completed flag "DN" is set as 1 (but is only kept for one
scanning period).
z With every scan, this instruction retrieves a line for 8 input status, so N lines require N scan cycles before they
can be completed.
Fourth line
M16 M17 M18 M19 M20 M21 M22 M23 Second line
M0 M1 M2 M3 M4 M5 M6 M7
7-75
I/O Instructions I
FUN 81 D FUN 81 D
PULSE OUTPUT
PLSO PLSO
Ladder symbol
MD : Output mode selection
81D.PLSO Fr : Pulse frequency
Output control EN MD : OUT Output go PC : Output pulse count
UY : Up pulse output point (MD=0).
Fr : DY : Down pulse output point (MD=0).
Pause control PAU PC : DN Output completed HO : Cumulative output pulse register.
(Can be not assigned).
UY:or CK CK : Pulse output point (MD=1).
U/D Error DR : Up/Down output point (MD=1).
Up/Down direction DY:or DR ERR
Or DIR DIR: 1- up; 0- down.
HO :
z When MD=0, this instruction performs the pulse output control as following:
z Whenever the output control “EN” changes from 0→1, it first performs the reset action, which is to clear the
output flag “OUT” and “DN” as well as the pulse out register HO to be 0. It gets the pulse frequency and
output pulse count values, and reads status of up and down direction “U/D”, so as to determine the direction
to be upward or downward. As the reset finished, this instruction will check the input status of pause output
“PAU”. No action will be taken if the pause output is 1 (output pause). If the PAU is 0, it will start to output
the ON/OFF pulse with 50% duty at the frequency Fr to the UY(U/D=1) or DY(U/D=0) point. It will increment
the value of HO register each time when a pulse is output, and will stop the output when HO register’s pulse
count is equal to or greater than the cumulative pulse count of PC register and set the output complete flag
“DN” to 1. During the time when output pulse is transmitting the output transmitting flag “OUT” will be set to 1,
otherwise it will be 0.
z Once it starts to transmit pulse, the output control “EN” should kept to 1. If it is changed to 0, it will stop the
pulse sending (output point become OFF) and the flag “OUT” changes back to 0, but the other status or data
will keep unchanged. However, when its “EN” changes again from 0 to 1, it will lead to a reset action and
treat as a new start; the entire procedure will be restarted again.
z If you want to pause the pulse output and not to restart the entire procedure, the ‘pause output’ “PAU” input
can be used to pause it. When “PAU” =1, this instruction will pause the pulse transmitting (output point is
OFF, flag “OUT” change back to 0 and the other status or data keeps unchanged). As it waits until the
“PAU” changes back from 1 to 0, this instruction will return to the status before it is paused and continues the
pulse transmitting output.
z During the pulse transmission, this instruction will keep monitoring the value of pulse frequency Fr and output
pulse count PC. Therefore, as long as the pulse output is not finished, it may allow the changing of the pulse
frequency and pulse count. However, the up/down direction “U/D” status will be got only once when it takes
the reset action (“EN” changes from 0→1), and will keep the status until the pulse output completed or
another reset occur. That is to say, except that at the very moment of reset, the change of “U/D” does not
influence the operation of this instruction.
z The main purpose of this instruction is to drive the stepping motor with the UY (upward) and DY (downward)
two directional pulses control, so as to help you control the forward or reverse rotating of stepping motor.
Nevertheless, if you need only single direction revolving, you can assign just one of the UY or DY (which will
save one output point), and leaving the other output blank. In such case, the instruction will ignore the
up/down input status of “U/D”, and the output pulse will send to the output point you assigned.
7-76
I/O Instructions I
FUN 81 D FUN 81 D
PULSE OUTPUT
PLSO PLSO
z When MD=1, the pulse output will reflect on the control output DIR (pulse direction. DIR=1, up; DIR=0, down)
and CK (pulse output).
z This instruction can only be used once, and UY (CK) and DY (DR) must be transistor output point on the PLC
main unit.
z The effective range of output pulse count PC for 16 bit operand is 0~32767. For the 32 bit operand(
instruction), it is 0~2147483647. If the PC value = 0, it is treated as infinite pulse count, and this instruction
will transmit pulses without end with HO value and “DN” flag set at 0 all the time. The effective range of pulse
frequency (Fr) is 8~2000. If the value PC or Fr exceeds the range, this instruction will not be carried out and
the error flag “ERR” will set to 1.
Output enable X0
Pause
Pause X1
Forward Recerse
Direction X2
1 2 76 77 78 79 80
Up-pulse Y0
1 2 40
Down-pulse Y1
Under output M0
Output done M1
Frequency R0 100 50
Pulse to output R1 80 40
7-77
I/O Instructions I
FUN 82 FUN 82
PULSE WIDTH MODULATION
PWM PWM
To : Pulse ON width
(0~32767mS)
Tp : Pulse period
(1~32676mS)
z When execution control "EN" = 1, will send the pulse to output point OT with the "ON" state for To ms and
period as Tp. OT must be a transistor output point on the main unit. When "EN" is 0, the output point will be
OFF.
To
Tp
z The units for Tp and To are mS, resolution is 1 mS. The minimum value for To is 0 (under such case the
output point OT will always be OFF), and its maximum value is the same as Tp (under such case the output
point OT will always be on). If To > Tp there will be an error, this instruction will not be carried out, and the
error flag "ERR" will set to 1.
7-78
I/O Instructions I
FUN 83 FUN 83
SPEED DETECTION
SPD SPD
Ladder symbol
S : Pulse input point for speed detection
83.SPD TI : Sampling duration
Detection control EN S : OVF Overflow
(units in mS)
TI : D : Register storing results
D :
z This instruction uses the interrupt feature of the 8 high speed input points (X0~X7) on the PLC main unit to
detect the frequency of the input signal. Within a specific sampling time (TI), it will calculate the input pulse
count for S input point, and indirectly find the revolution speed of rotating devices (such as motors).
z While use this instruction to detect the rotating speed of devices, The application should design to generate
more pulse per revolution in order to get better result, but the sum of input frequency of all detected signals
should under 5KHz, otherwise the WDT may occur.
z The D register for storing results uses 3 successive 16-bit registers starting from D (D0~D2). Besides D0
which is used to store counting results, D1 and D2 are used to store current counting values and sampling
duration.
z When detection control "EN" = 1, it starts to calculate the pulse count for the S input point, which can be
shown in D1 register. Meanwhile the sampling timer (D2) is switched on and keeps counting until the value of
D2 is reach to the sampling period (TI). The final counted value is stored into the D0 register, and then a new
counting cycle is started again. The sampling counting will go on repeating until "EN" = 0.
z Because D0 only has 16 bits, so the maximum count is 32767. If the sampling period is too long or the input
pulse is too fast then the counted value may exceed 32767, under that case the overflow flag will set to 1, and
the counting action will stop.
z Because the sampling period TI is already known and if every revolution of attached rotating device produces
"n" pulses, then the following equation can be used to get the revolution
(D0) × 60
speed : N = × 103 (rpm)
n × TI
83.SPD X20
X20
EN S : X 0 OVF
TI : 1000 X0
D : R 0 1000
( 200 ) × 60 0
follows : N = × 10 3 = 200 rpm R1
60 × 1000 a b c
7-79
I/O Instructions I
FUN 84 FUN 84
PATTERN CONVERSION FOR 16/7-SEGMENT DISPLAY
TDSP TDSP
Ladder symbol
84.TDSP Md : Mode selection
Execution control EN Md : S : Starting address of begin converted characters
S : Ns : Start of character
Nl : Length of character
Input control OFF NS :
D : Starting address to store the converted pattern
NL :
S operand can be combined with V, Z, P0~P9 index
Input control ON D :
registers for indirect addressing
Rang HR OR ROR DR K XR
e R0 R3904 R5000 D0 V、Z
∣ ∣ ∣ ∣ 16/32 bit
Operand R3839 R3967 R8071 D4095 P0~P9
Md 0~1
S ○ ○ ○ ○ ○ ○
Ns ○ ○ ○ ○ ○
Nl ○ ○ ○ ○ ○
D ○ ○ ○* ○
● This instruction is used for FBs-7SG1/FBs-7SG2 module’s application. It can convert the source
alphanumeric characters into display patterns suited for 16 segment encoded mode display or perform the
leading zero substitution of the packed BCD number for non-decoded mode 7 segment display.
● When execution control “EN” =1, and input “OFF” = 0, input “ON”=0, if Md=0, this instruction will perform the
display pattern conversion, where S is the starting address storing the being converted characters, Ns is the
pointer to locate the starting address character, NI tells the length of being converted characters, and D is the
starting address to store the converted result.
st nd
Byte 0 of S is the “1 ” displaying character, byte 1 of S is the 2 displaying character,……..
After execution, each 8-bit character of the source will be converted into the corresponding 16-bit display
pattern.
● When input “OFF” = 1, all bits of display pattern will be ‘off’ if Md = 0, if Md=1, all BCD codes will be
substituted by blank code (0F)
● When input “ON” = 1, all bits of display pattern will be ‘on’ if Md=0. If Md=1, all BCD codes will be substituted
by code 8(all light).
● Please refer Chapter 16 “FBs-7SG display module” for more detail description.
7-80
I/O Instructions I
FUN 86 FUN 86
PID TEMPERATURE CONTROL INSTRUCTION
TPCTL TPCTL
7-81
I/O Instructions I
FUN 86 FUN 86
PID TEMPERATURE CONTROL INSTRUCTION
TPCTL TPCTL
z As the gain (Kc) adjustment getting larger, the larger the proportional contribution to the output. This can
obtain a sensitive and rapid control reaction. However, when the gain is too large, it may cause oscillation.
Do the best to adjust “Kc” larger (but not to the extent of making oscillation), which could increase the
process reaction and reduce the steady state error.
z Integral item may be used to eliminate the steady state error. The larger the number (Ti, integral tuning
constant), the larger the integral contribution to the output. When there is steady state error, adjust the “Ti”
larger to decrease the error.
When the “Ti” = 0, the integral item makes no contribution to the output.
For exam. , if the reset time is 6 minutes, Ti=100/6=17;if the integral time is 5 minutes, Ti=100/5=20.
z Derivative item may be used to make the process smoother and not too over shoot. The larger the number
(Td, derivative tuning constant), the larger the derivative contribution to the output. When there is too over
shoot, adjust the “Td” larger to decrease the amount of over shoot.
When the “Td” = 0, the derivative item makes no contribution to the output.
For exa, if the rate time is 1 minute, then the Td = 100; if the differential time is 2 minute, then the Td = 200.
z Properly adjust the PID parameters can obtain an excellent result for temperature control.
z The default solution interval for PID calculation is 4 seconds (Ts=40)
z The default of gain value (Kc) is 110, where Pb=1000/110×0.1%≒0.91%; the system full range is 1638°, it
means 1638×0.91≒14.8°to enter proportional band control.
z The default of integral tuning constant is 17, it means the reset time is 6 minutes (Ti=100/6=17).
z The default of derivative tuning constant is 50, it means the rate time is 0.5 minutes (Td=50).
z When changing the PID solution interval, it may tune the parameters Kc, Ti, Td again.
Instruction guide
z FUN86 will be enabled after reading all temperature channels.
z When execution control “EN” = 1, it depends on the input status of H/C for PID operation to make heating
(H/C=1) or cooling (H/C=0) control. The current values of measured temperature are through the
multiplexing temperature module ; the set points of desired temperature are stored in the registers starting
from Sv. With the calculation of software PID expression, it will respond the error with an output signal
according to the setting of set point, the error's integral and the rate of change of the process variable.
Convert the output of PID calculation to be the time proportional on/off (PWM) output, and via transistor
output to control the SSR for heating or cooling process; where there is a good performance and very low
cost solution. It may also apply the output of PID calculation (stored in registers starting from OR), by way
of D/A analog output module, to control SCR or proportional valve, so as to get more precise process control.
z When the setting of Sn, Zn (0 Sn 31 and 1 Zn 32, as well as 1 Sn + Zn 32) comes error, this
instruction will not be executed and the instruction output “ERR” will be ON.
This instruction compares the current value with the set point to check whether the current temperature falls within
deviation range (stored in register starting from Os). If it falls in the deviation range, it will set the in-zone bit of
that point to be ON; if not, clear the in-zone bit of that point to be OFF, and make instruction output “ALM” to be
ON.
7-82
I/O Instructions I
FUN 86 FUN 86
PID TEMPERATURE CONTROL INSTRUCTION
TPCTL TPCTL
z In the mean time, this instruction will also check whether highest temperature warning (the register for the set
point of highest temperature warning is R4008). When successively scanning for ten times the current
values of measured temperature are all higher than or equal to the highest warning set point, the warning bit
will set to be ON and instruction output “ALM” will be on. This can avoid the safety problem aroused from
temperature out of control, in case the SSR or heating circuit becomes short.
z This instruction can also detect the unable to heat problem resulting from the SSR or heating circuit runs open,
or the obsolete heating band. When output of temperature control turns to be large power (set in R4006
register) successively in a certain time (set in R4007 register), and can not make current temperature fall in
desired range, the warning bit will set to be ON and instruction output “ALM” will be ON.
z WR: Starting of working register for this instruction. It takes 9 registers and can’t be repeated in using.
The content of the two registers WR+0 and WR+1 indicating that whether the current temperature falls
within the deviation range (stored in registers starting from Os). If it falls in the deviation range, the
in-zone bit of that point will be set ON; if not, the in-zone bit of that point will be cleared OFF.
Bit definition of WR+0 explained as follows:
Bit0=1, it represents that the temperature of the Sn+0 point is in-zone…
Bit15=1, it represents that the temperature of the Sn+15 point is in-zone.
Bit definition of WR+1 explained as follows:
Bit0=1, it represents that the temperature of the Sn+16 point is in-zone…
Bit15=1, it represents that the temperature of Sn+31 point is in-zone.
The content of the two registers WR+2 and WR+3 are the warning bit registers, they indicate that
whether there exists the highest temperature warning or heating circuit opened.
Bit definition of WR+2 explained as follows:
Bit0=1, it means that there exists the highest warning or heating circuit opened at the Sn+0 point...
Bit15=1, it means that there exists the highest warning or heating circuit opened at the Sn+15 point.
Bit definition of WR+11 explained as follows:
Bit0=1, it means that there exists the highest warning or heating circuit opened at the Sn+16 point...
Bit15=1 , it means that there exists the highest warning or heating circuit opened at the Sn+31 point.
Registers of WR+4 ~ WR+8 are used by this instruction.
z It needs separate instructions to perform the heating or cooling control.
: The content of High Byte to define the cycle time of PID ON/OFF(PWM)output.
=0,PWM cycle time is 1 seconds.
=1,PWM cycle time is 2 seconds. (System default)
=2,PWM cycle time is 4 seconds.
=3,PWM cycle time is 8 seconds.
=4,PWM cycle time is 16 seconds.
≥5,PWM cycle time is 32 second.
Note 1: When changing the value of R4005, the execution control “EN” of FUN86 must be set at 0. The next time
when execution control “EN” =1, it will base on the latest set point to perform the PID calculation.
Note 2: The smaller the cycle time of PWM, the more even can it perform the heating. However, the error caused
by the PLC scan time will also become greater. For the best control, it can base on the scan time of PLC
to adjust the solution interval of PID calculation and the PWM cycle time.
7-83
I/O Instructions I
FUN 86 FUN 86
PID TEMPERATURE CONTROL INSTRUCTION
TPCTL TPCTL
z R4006: The setting point of large power output detection for SSR or heating circuit opened, or heating band
obsolete. The unit is in % and the setting range falls in 80~100(%); system default is 90(%).
z R4007: The setting time to detect the continuing duration of large power output while SSR or heating circuit
opened, or heating band obsolete. The unit is in second and the setting range falls in 60~65535
(seconds); system default is 600 (seconds).
z R4008: The setting point of highest temperature warning for SSR, or heating circuit short detection. The
unit is in 0.1 degree and the setting range falls in 100~65535; system default is 3500 ( Unit in 0.1°).
z R4012: Each bit of R4012 to tell the need of PID temperature control.
st
Bit0=1 means that 1 point needs PID temperature control.
nd
Bit1=1 means that 2 point needs PID temperature control.
‧
‧
th
Bit15=1 means that 16 point needs PID temperature control.
(The default of R4012 is FFFFH)
z R4013: Each bit of R4013 to tell the need of PID temperature control.
th
Bit0=1 means that 17 point needs PID temperature control.
th
Bit1=1 means that 18 point needs PID temperature control.
‧
‧
th
Bit15=1 means that 32 point needs PID temperature control.
(The default of R4013 is FFFFH)
z While execution control “EN”=1 and the corresponding bit of PID control of that point is ON (corresponding
bit of R4012 or R4013 must be 1), the FUN86 instruction will perform the PID operation and respond to the
calculation with the output signal.
z While execution control “EN”=1 and the corresponding bit of PID control of that point is OFF (corresponding
bit of R4012 or R4013 must be 0), the FUN86 will not perform the PID operation and the output of that point
will be OFF.
z The ladder program may control the corresponding bit of R4012 and R4013 to tell the FUN86 to perform or
not to perform the PID control, and it needs only one FUN86 instruction.
7-84
Cumulateive Timer Instructions
z The operation for this instruction is the same as that for the basic timer (T0~T255), except that the basic
timer only has a "timing control" input - when its input is 1 it starts timing, and when input is 0 it get clear.
Every time the input changes, it starts timing again and is unable to accumulate. Timing with this instruction
is only permissible when enable control "EN" = 1. With this instruction, when timing control "TIM" is 1, it is
the same as a basic timer, but when "TIM" is 0, it does not clear, but keeps the current value. If the timer
need to clear, then change enable control "EN" to 0. When timing control "TIM" is once again to be 1, it will
continue to accumulate from the previous value when the timer last paused. In addition, this instruction also
has two outputs, "Time up TUP" (when time up it is 1, usually it is 0) and "Time not up" (usually it is 1, when
time is up it is 0). Users can utilize input and output combinations to produce timers with various different
functions. For example:
89.T1S
normally not energized. When this timer's
X0 Y0
input control (X0 in this example) is activated
TIM CV : R 0 TUP
PV : 10 (ON), only after delay by 10 sec will output
EN Y0 become energized (ON).
NUP
89.T1S
energized. When this timer's input control X0
X0
is on, only after delay by 10 sec will the
TIM CV : R 0 TUP
PV : 10 Y0 output become de-energized (OFF).
EN NUP
7-85
Cumulative Timer Instructions
89.T1S
When this timer's timing control X0 is off,
X0
only after delay by 10 sec will output Y0
TIM CV : R 0 TUP
PV : 10 Y0 become de-energized (OFF).
EN NUP
z The diagram below shows the relation on input and output for the above 4 kinds of timers.
X0 OFF OFF
10S
ON
ON 10S
ON delay de-energizing
ON
OFF
10S
OFF delay energizing ON ON
OFF
ON 10S
7-86
Watchdog Timer Instructions
FUN 90 P FUN 90 P
WATCHDOG TIMER
WDT WDT
z When execution control "EN" = 1 or transition from 0 to 1( P instruction), will set the watchdog time to
Nx10ms. If the scan time exceeds this preset time, PLC will shut down and not execute the application
program.
z The WDT feature is designed mainly as a safety consideration from the system view for the application. For
example, if the CPU of PLC is suddenly damaged, and there is no way to execute the program or refresh I/O,
then after the WDT time expired, the WDT will automatically switch off all the I/Os, so as to ensure safety. In
certain applications, if the scan time is too long, it may cause safety problems or problems of
non-conformance with control requirements. This instruction can used to establish the limitation of the scan
time that you require.
z Once the WDT time has been set it will always be kept, and there is no need to set it again on each scan.
Therefore, in practice this instruction should use the P instruction.
z For the operation principles of WDT please refer to the RSWDT(FUN 91) instruction.
7-87
Watchdog Timer Instructions
FUN 91 P FUN 91 P
RESET WATCHDOG TIMER
RSWDT RSWDT
z When execution control "EN" = 1 or from 0 to 1 ( P instruction), the WDT timer will be reset (i.e. WDT will
start timing again from 0).
z The functions of WDT have already been described in FUN90 (WDT instruction).
The operation principles of watch dog timer are as follows:
The watchdog timer is normally implemented by a hardware one-shot timer (it can not be software,
otherwise if CPU fail, the timer becomes ineffective, and safeguards are quite impossible). "One-shot"
means that after triggered the timer once, the timing value will immediately be reset to 0 and timing will
restart. If WDT has begun timing, and never triggered it again, then the WDT timing value will continue
accumulating until it reach the preset value of N, at that time WDT will be activated, and PLC will be shut
down. If trigger the WDT once every time before the WDT time N has been reached, then WDT will never
be activated. PLC can use this feature to ensure the safety of the system. Each time when PLC enters into
system housekeeping after finished the program scanning and I/O refresh, it will usually trigger WDT once,
so if the system functions normally and scan time does not exceed WDT time then WDT is never activated.
However, if CPU is damaged and unable to trigger WDT, or the scan time is too long, then there will not be
enough time to trigger WDT within the period N, WDT will be activated and will shut off PLC.
z In some applications, when you set the WDT time (FUN90) to desire, the scan time of your program in certain
situations may temporarily exceed the preset time of WDT. This situation can be anticipated and allowed for,
and you naturally do not wish PLC to shut down for this reason. You can use this instruction to trigger WDT
once and avoid the activation of WDT. This is the main purpose of this instruction.
7-88
High Speed Counting/Timing Instruction
FUN 92 D P FUN 92 D P
HARDWARE HIGH SPEED COUNTER CURRENT VALUE (CV) ACCESS
HSCTR HSCTR
z The HSC0~HSC3 counters of FBs-PLC are 4 sets of 32bit high speed counter with the variety counting
modes such as up/down pulse, pulse-direction, AB-phase. All the 4 high speed counters are built in the ASIC
hardware and could perform count, compare, and send interrupt independently without the intervention of the
CPU. In contrast to the software high speed counters HSC4~HSC7, which employ interrupt method to
request for CPU processing, hence if there are many counting signals or the counting frequency is high, the
PLC performance (scanning speed) will be degraded dramatically. Since the current values CV of HSC0~
HSC3 are built in the internal hardware circuits of ASIC, the user control program (ladder diagram) cannot
retrieve them directly from ASIC. Therefore, it must employ this instruction to get the CV value from hardware
HSC and put it into the register which control program can access. The following is the arrangement of CV,
PV in ASIC and their corresponding CV, PV registers of PLC for HSC0~HSC3.
z When access control “EN” =1 or changes from 0→1( P instruction), will gets the CV value of HSC designated
by CN from ASIC and puts into the HSC corresponding CV register (i.e. the CV of HSC0 will be read and put
into DR4096 or the CV of HSC1 will be read and put into DR4100).
z Although the PV within ASIC has a corresponding PV register in CPU, but it is not necessary to access it
(actually it can’t be) for that the PV value within ASIC comes from the PV register in CPU.
z HSTA is a timer, which use 0.1ms as its time base. The content of CV represents elapse time counting at
0.1mS tick.
z For detailed applications, please refer to Chapter 10 “The high speed counter and high speed timer of
FBs-PLC”.
7-89
High Speed Counting/Timing Instruction
FUN 93 D P HARDWARE HIGH SPEED COUNTER CURRENT VALUE AND PRESET FUN 93 D P
HSCTW VALUE WRITING HSCTW
z Please refer first to FUN92 for the relation between the CV or PV value of HSC0~HSC3 and HSTA within
ASIC and their corresponding CV and PV registers in CPU.
z When write control “EN”=1 or changes from 0→1 ( P instruction), it writes the content of CV or PV register of
high speed counter designed by CN of CPU, to the corresponding CV or PV of HSC within ASIC.
z It is quit often to set the PV value for most application program, When the count value reaches the preset
value, the counter will send out interrupt signal immediately. By way of the interrupt service program, you can
implement different kinds of precision counting or positioning control.
z When there is an interrupt of power supply for FBs-PLC, the values of current value registers CV of HSC0~
HSC3 within ASIC will be read out and wrote into the HSC0~HSC3 CV registers (with power retentive
function) of CPU automatically. When power comes up, these CV values will be restored to ASIC. However,
if your application demands that when power is on, the values should be cleared to 0 or begin counting from a
certain value, then you have to use this instruction to write in the CV value for HSC in ASIC.
z When write a non-zero value into the PV register of HSTA will cause the HSTAI interrupt subroutine to be
executed for every PV×0.1ms.
z For detailed applications, please refer Chapter 10 “The high speed counter and high speed timer of
FBs-PLC”.
7-90
Report Printing Instructions
FUN 94 P FUN 94 P
ASCII WRITE
ASCWR ASCWR
z When MD=0 and output control “ENU” changes from 0→1, it transmits the ASCII data which starting from S to
the communication port 1 (Port1), until reach end of file.
z S file data can be edited with the programming software PROLADDER or WinProladder (please refer to the
explanation of Chapter 14 “ASCII function application”.). If necessary the user can also edit the ASCII file
directly by change the value of data registers. However, the edited data must be follow the ASCII file format
(the details described in chapter 14), otherwise, this instruction will halt the transmission and set the error flag
“ERR” to 1. If the entire file is correctly and successfully transmitted, then the output is completed and “DN”
is set to 1.
z The control input of this instruction is of positive edge triggered. Once “ENU” changes from 0→1 then this
instruction starts the execution, until finished the transmission of the entire file then the execution is completed.
During the transmission, the action flag “ACT” will be kept at 1 all the time. Only when output pause, error, or
abort occurs, will it change back to 0.
z This instruction can be repeatedly used, but only one will be executed (transmit data) at any certain time. It is
the obligation of user to make sure the right execution sequence.
z While this instruction is in execution, if the pause “PAU” is 1, this instruction will pause the transmission of file
data. It will resume transmission when the pause “PAU” backs to 0.
z While this instruction is in execution, if the abort “ABT” is 1, this instruction will abandon the transmission of
file data, and then it is able to take next instruction for execution.
z or detail applications, please refer to Chapter 14 “The Application of ASCII file output function”.
7-91
Report Printing Instructions
FUN 94 FUN 94
ASCII WRITE
ASCWR ASCWR
z Interface signals:
M1927: This signal is control by CPU, it is applied in ASCWR MD:0
: ON, it represents that the RTS (connect to the CTS of PLC) of the printer is “False”.
I.e. the printer is not ready or abnormal.
: OFF, it represents that the RTS of the Printer is “True”; Printer is Ready.
Note: Using the M1927 associates with timer can detect if the printer is abnormal or not.
7-92
Slow Up/Slow Down Instructions
FUN 95 P FUN 95 P
RAMP FUNCTION FOR D/A OUTPUT
RAMP RAMP
Description
z Tn must be a 0.01 sec time base timer and never used in other part of program.
z PV is the preset value of ramp timer. Its unit is 10ms (0.01 second).
z When input control “ENU” changes from 0→1, it first reset the timer Tn to 0.
When “U/D”=1 it will load the value of SL to register D. And when M1974 = 0 it will be increased by SU−SL /
PV every 0.01 sec or when M1974 = 1 it will increase by PV every 0.01 sec. When the D value reaches the
SU value the output “ASU” =1.
When “U/D”=0 it will load the value of SU to register D. When M1974 = 0 it will be decreased by SU−SL / PV
every 0.01 sec or when M1974 = 1 it will be decreased by PV every 0.01 sec. When the D value reaches the
SL value the output “ASL” =1.
z The ramping direction(U/D) is determined at the time when input control “ENU” changes from 0→1. After the
output D start to ramp, the change of U/D is no effect.
z If it is required to pause the ramping action, it must let the input control “PAU” = 1; when “PAU”=0, and the
ramping action is not completed, it will continue to complete the ramping action.
z The value of SU must be larger than SL, otherwise the ramp function will not be performed, and the output
“ERR” will set to 1.
z This instruction use the register D to store the output ramping value; if the application use the D/A module to
send the speed command, then speed command can be derived from the RAMP function to get a more
smooth movement.
z In addition to use register D to store the ramping value, this instruction also used the register D+1 to act as
internal working register; therefore the other part of program can not use the register D+1.
7-93
Slow Up/Slow Down Instructions
FUN 95 P FUN 95 P
RAMP FUNCTION FOR D/A OUTPUT
RAMP RAMP
Program example
95.RAMP
M0 M100
EN Tn : T20 ERR Move the ramping value to AO output register
M1 PV : R100 M101 R3904
PAU SL : R101 ASL
M2 SU : R102 M102
U/D D : R103 ASU
8.MOV
M0
EN S : R103
D : R3904
z If M1974=0, When input control M0 changes from 0→1, it first reset the timer T20 to 0. If M2=1, it will load
the R101 (lower limit) value into the R103, and it will increase the output with fixed value (R102-R101 / R100)
for every 0.01 second and stores it to register R103. When the T2 timer going up to the preset value R100,
the output value equals to R102, and the output M102 will set to 1. If M2=0, will load the R102 (upper limit)
value into the R103, and it will decrease the output amount with fixed ratio (R102-R101 / R100) for every 0.01
second and store it to register R103. The T2 timer going up to the preset value R100, the output value equals
to R102, and the output M101 will set to 1.
z The value of R102 must be greater than R101, otherwise the ramp action will not be performed, and the
output M100 will set to 1.
SU
SL
t
PV PV
7-94
Slow Up/Slow Down Instruction
FUN 98 FUN 98
TRACKING TYPE RAMP FUNCTION FOR D/A OUTPUT
R AM P2 R AM P2
98.RAMP2
Om:Maximum output; range from 0~65535
Execution EN Om : ACC Ta :The acceleration time for the output from 0 up to
Ta : maximum;
Range from 0~65000, unit is in mS
Td : DEC
Td :The deceleration time for the output from
Rt : maximum down to 0;
Rc : Range from 0~65000, unit is in mS
WR : Rt :Register of target output;
Range from 0~65535
Rc :Register of current output, it is used for analog
output
WR:Starting address of working registers, it needs 4
registers
*This instruction can be supported in PLC OS
firmware V4.60 or late
HR OR ROR DR K
Operand
Range
R0 R3904 R5000 D0
∣ ∣ ∣ ∣ 16bit
R3839 R3967 R8071 D3999
Om ○ ○ ○ ○ 0~65535
Ta ○ ○ ○ ○ 0~65000
Td ○ ○ ○ ○ 0~65000
Rt ○ ○ ○ ○
Rc ○ ○ ○ ○
WR ○ ○ ○* ○
● When execution 〝EN〞=0, current output value (Rc) will be 0 immediately; the output indicators
ACC=0 and DEC=0.
● When execution 〝EN〞=1, this instruction being executed; it will output current value (Rc) first, and
then compare the target output value (Rt) with current output value (Rc) every scan; if the target
output value is greater than current output value, the current output will be increased according to
the rate, which is decided by the settings of acceleration time (Ta) and maximum output (Om), till
current output value is equal to the target output value (ACC=1 during this time); if the target
output value is less than current output value, the current output will be decreased according to
the rate, which is decided by the settings of deceleration time (Td) and maximum output (Om), till
current output value is equal to the target output value (DEC=1 during this time).
● If the setting value of target output (Rt) is greater than maximum output(Om), the output value will
be clamped by the maximum value.
● It can have smooth activity for acceleration and deceleration control via the execution of this
instruction by using current output value (Rc) for analog output (R39044~R3967).
● The setting value of target output (Rt) needs to stay two scan times at least for proper operation.
● It needs 4 registers for working, they can not be repeated in use。
● This instruction is for positive value operation, but it also can have negative output by short and
easy application program for help. Please see example 2.
7-95
Slow Up/Slow Down Instruction
FUN 98 FUN 98
TRACKING TYPE RAMP FUNCTION FOR D/A OUTPUT
R AM P2 R AM P2
Om
Rt
Rt Rt
Rc
Rt
t
Ta Td
7-96
Slow Up/Slow Down Instruction
FUN 98 FUN 98
TRACKING TYPE RAMP FUNCTION FOR D/A OUTPUT
R AM P2 R AM P2
7-97
Slow Up/Slow Down Instruction
FUN 98 FUN 98
TRACKING TYPE RAMP FUNCTION FOR D/A OUTPUT
R AM P2 R AM P2
Om
Rt
Rt Rt Rt
Rc
Ta Td
Rc
-Om
7-98
Table Instructions
Table Instructions
● A table consists of 2 or more consecutive registers (16 or 32 bits). The number of registers that comprise the
table is called the table length (L). The operation object of the table instructions always takes the register as
unit (i.e. 16 or 32 bit data).
● The operation of table instructions are used mostly for data processing such as move, copy, compare, search
etc, between tables and registers, or between tables. These instructions are convenient for application.
● Among the table instructions, most instructions use a pointer to specify which register within a table will be
the target of operation. The pointer for both 16 and 32-bit table instructions will always be a 16-bit register.
The effective range of the pointer is 0 to L-1, which corresponds to registers T0 to TL-1 (a total of L registers).
The table shown below is a schematic diagram for 16-bit and 32-bit tables.
● Among the table operations, shift left/right, rotate left/right operations include a movement direction. The
direction toward the higher register is called left, while the direction toward the lower register is called right, as
shown in the diagram below.
Pointer Pr Pointer Pr
4 ──┐ 2 ──┐
B15 B0 │ B15 B0 │
│ │
T │ T │
(right) │ │
B15 B0 B31 B0
(right)│ (right)│
T0 R0 │ T0 R1 R0 │
T1 R1 │ T1 R3 R2 │
T2 R2 │ T2 R5 R4 │
│ │
Table length
Table length
T3 R3 T3 R7 R6
︷ T4 R4 ←─┘
︷ T4 R9 R8 ←─┘
......
......
......
......
7-99