Posted in

By

6 of 12Updated 2026-11-1734 min read中文版

Basic Function Instruction

T

TIMER

T

Symbol

Operand

Tn: Timer Number

TB: Time Base (0.01S, 0.1S, 1S)

HR

PV: Preset value of the timer.

Range

WX

WY

WM

WS

TMR

CTR

IR

OR

SR

ROR

DR

K

R0

R3840

R3904

R3968

R5000

D0

0

WX0

WY0

WM0

WS0

T0

C0

Ope-

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

rand

WX240

WY240

WM1896

WS984

T255

C255

R3839

R3903

R3967

R4167

R8071

D4095

32767

Tn

○

○

○

○

○

○

○

○

PV

○

○

○

○

○

○

The total number of timers is 256 (T0~T255) with three different time bases, 0.01S, 0.1S and 1S.The default number and allocation of timers is shown as below (Can be adjusted according to user’s actual requirements by the “Configuration” function):
T0~T49:0.01S timer(default as 0.00~327.67S)。

T50~T199:0.1S timer(default as 0.0~3276.7S)。

T200~T255:1S timer(default as 0~32767S)。

FBs-PLC programming tool will lookup the timer’s time base automatically according to the “Memory Configuration” after the timer number is keyed in. Timer’s time = Time base x Preset value. In the example 1 below, the time base T0 = 0.01S and the PV value = 1000, therefore the T0 timer’s time = 0.01S x 1000 = 0S.

If PV is a register, then Timer’s time = Time base x register content. Therefore, you only need to change the register content to change the timer’s time. Please refer to Example 2.

The maximum error of a timer is a time base plus a scan time. In order to reduce the timing error in the application, please use the timer with a smaller time base.

Description

n the time control “EN” is 1, the timer will start timing (the current value will accumulate from 0) until e Up” (i.e. CV≧PV), then the Tn contact and TUP (FO0) will change to 1. As long as the timer control input is kept as 1, even the CV of Tn has reached or exceeded the PV, the CV of the timer will nue accumulating (with M1957 = 0) until it reaches the maximum limit (32767). The Tn contact status flag will remain as 1 when CV≧PV, unless the “EN” input is 0. When “EN” input is 0, the CV of Tn will set to 0 immediately and the Tn contact and “Time Up” flag TUP will also change to 0 (please refer to the diagram c below).

e FBS-PLC OS version is higher than V3.0 (inclusive), the M1957 can be set to 1 so the CV will not mulate further after “Time Up” and stops at the PV value. The default value of the M1957 is 0, fore the status of M1957 can be set before executing any timer instruction in the program to idually set the timer CV to continue accumulating or stop at the PV after “Time Up” (please refer to the diagram d below).

Basic Function Instruction

T

Constant preset value

Y0

ORG

TIMER

T

Example 1

X1

Ladder diagram

Key operations

Mnemonic code

ORG X 1

.01S

EN

T0

1000

TUP

T0 PV: 1000

P

X1

EN

SET

M1957

TUP

OUT

FO 0

.01S

T1

1000

OUT Y 0

ORG

ORG SHORT

SET M1957

An example of taking

ORG

ORGX1

“Time-Up” signal directly from FO0.

X1

Example 2

c

Y0

or

T0

0

1000

CV

(CV)

M1957=0

0

1000

T0

(Defaulted)

T1

d

(CV)

M1957=1

T1

Time Start

Time-Up

Variable PV

The preset value (PV) shown in example 1 is a constant which is equal to 1000. This value is fixed and can not be changed once programmed. In many circumstances, the preset time of the timers needs to be varied while PLC running. In order to change the preset time of a timer, can first use a register as the PV operand (R or WX, WY…) and then the preset time can be varied by changing the register content. As shown in this example, if set R0 to100, then T becomes a 10S Timer, and hence if set R0 to 200, then T becomes a 20S Timer.

Basic Function Instruction

T

Ladder diagram

TIMER

Mnemonic code

T

Key operations

X1

EN

.1S

R 0

TUP

Y0

ORG X 1

T50

T50

T 50 PV: R 0

ORG T50

An example of applying

OUT Y 0

the “time-up” status by
using the T50 contact.

X1

200 100
T50 0
(current value)

c

When R0=100

Y0

10.0S

c

20.0S

d

Time-Up

When R0=200

Y0

d

Time Start

Time-Up

Remark: If the preset value of the timer is equal to 0, then the timer’s contact status and FO0 (TUP) become 1 ("EN" input must be at 1) immediately after the PLC finishes its first scan because "Time-Up" has occurred. (TUP) stays at 1 until "EN" input changes to 0.

Basic Function Instruction

C

COUNTER
(16-Bit: C0~C199,32-Bit: C200~C255)

C

Symbol

Operand

Cn: The Counter number

WY

WM

IR

PV: Preset value

DR

K

WS

TMRCTR

HR

OR

SR

ROR

Range

WX

WX0

WY0

WM0

WS0

T0

C0

R0

R3840

R3904

R3968

R5000

D0

0

e-

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

d

WX240

WY240

WM1896

WS984

T255

C255

R3839

R3903

R3967

R4167

R8071

D4095

2147483647

Cn

○

○

○

○

○

○

○

○

○

○

○

PV

○

○

○

e are total 200 16-Bit counters (C0~C199). The range of preset value is between 0~32767. C0~C139 Retentive Counters and the CV value will be retained when the PLC turns on or RUN again after a er failure or a PLC STOP. For Non Retentive Counters, if a power failure or PLC STOP occurs, the CV value will be reset to 0 when the PLC turns on or RUN again.

e are total 56 32-Bit counters (C200~C255). The range of the preset value is between 0~2147483647. C200~C239 are Retentive Counters and C240~C255 are Non Retentive Counters.

default number and assignment of the counters are shown below, if necessary can use the "CONFIGURATION" function to change the settings.

To insure the proper counting, the sustain time of input status of CLK should greater than 1 scan time.

max. counting frequency with this instruction can only up to 20Hz, for higher frequency please use the high-speed soft/hardware counter.

Description

n "CLR" is at 1, all of the contact Cn, FO0 (CUP), and CV value of the counter CV are cleared to 0 and the counter stops counting.

n "CLR" is at 0, the counter is allowed to count up. The Counter counts up every time the clock "CK↑" ges from 0 to 1 (adds 1 to the CV) until the cumulative current value is equal to or greater than the et value (CV>=PV), the counter "Count-Up" and the contact status of the counter Cn and FO0 (CUP) ges to 1. If the input status of clock continues to change, even the cumulative current value is equal greater than the preset value, the CV value will still accumulate until it reaches the up limit at 32767 or 483647. The contact Cn and FO0 (CUP) stay at 1 as long as CV>=PV unless the "CLR" input is set to 1.(please refer the diagram c below)。

e FBS-PLC OS version is higher than V3.0 (inclusive), the M1973 can set to 1 so the CV will not mulate further after “Count Up” and stops at the PV. M1973 default value is 0, therefore the status of 73 can be set before executing any counter instruction in the program to individually set the counter CV to continue accumulating or stops at the PV after “Count Up” (please refer to the diagram d below).

Basic Function Instruction

C

COUNTER

C

(16-Bit: C0~C199, 32-bit: C200~C255)

Example 1

16-Bit Fixed Counter

Mnemonic code

Ladder diagram

Key operations

X0

ORG

ORG

SHORT

RST

M1973

RST

M1973

Y1

ORG

X

0

C 1

CUP

ORG

PSU

X1

PV :

5

LD

LD

X

1

CLR

C 1 PV: 5

X0

SET

M1973

OUT

FO

0

X1

PSU

C 2

CUP

OUT

Y

1

PV :

5

CLR

ORG

ORG

SHORT

An example of applying

ORG

SET

M1973

ORG

X

0

the “Count-Up” status by

LD

LD

X

1

using FO0 directly.

C 2 PV: 5

X0

X1

c

C1

0

1

2

3

4

5

6

5

32766

32767

0

32767 times

0

M1973=0

5 times

(Defaulted)

Y1

C2

0

1

2

3

4

d

(CV)

M1973=1

C2

Example 2

Count Start

Count-Up

32-Bit counter with variable preset value

Like a timer, if the PV of a counter is changed to a register (such as R, D, and so on), the counter will use the register contents as the counting PV. Therefore, only need to change the register contents to change the PV of the counter while PLC is running. Below is an example of a 32-bit counter that uses the data register R0 as the PV (in fact it is the 32-bit PV formed by R1 and R0).

Basic Function Instruction

C

X0

COUNTER

Mnemonic code

C

(16-Bit: C0~C199, 32-Bit: C200~C255)

Ladder diagram

Key operations

EN

C200

CUP

ORG

ORG

X

0

X1

CLR

PV :

R 0

LD

LD

X

1

C200

Y1

C200

ORG

PV: R

0

ORG

C

200

OUT

OUT

Y

1

An example of applying

the “time-up” status by
using the C200 contact.

X0

X1

c

(R1=0)

C200

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

4 times

Y1

When R0=4

d

When R0=9

Y1

Count Start

9 times

Count-Up

Count-Up

Remark: If the preset value of the counter is 0 and "CLR" input also at 0, then the Cn contact status and FO0 (CUP) becomes 1 immediately after the PLC finishes its first scan because the "Count-Up" has occurred. It will stay at 1 regardless how the CV value varies until "CLR" input changes to 1.

Basic Function Instruction

SET DP

SET
(Set coil or all the bits of register to 1)

SET DP

Symbol

Operand

D: destination to be set

SM

S

WY

WM

WS

TMR

(the number of a coil or a register)

Range

Y

M

CTR

HR

OR

SR

ROR

DR

pe-

Y0

M0

M1912

S0

WY0

WM0

WS0

T0

C0

R0

R3904

R3968

R5000

D0

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

nd

Y255

M1911

M2001

S999

WY240

WM1896

WS984

T255

C255

R3839

R3967

R4167

R8071

D4095

D

○

○

○*

○

○

○

○

○

○

○

○

○*

○*

○

Description

he set control "EN" =1 or from 0 → 1 ( P instruction ), sets the bit of a coil or all bits of a register to 1.

Example 1

Single Coil Set

Ladder Diagram

X0

EN

P

SET

X1

EN

P

RST

am Key Operations

ORG

Y 0

Y 0

ORG

Mnemonic C

ORG X

SET P Y

ORG X

RST P Y

odes

0

0

1

0

X0
SET

X1

RST

Y0

Basic Function Instruction

SET DP

Set 16-Bit Register

SET

SET DP

(Set coil or all the bits of register to 1)

Example 2

X0

Ladder Diagram

Key Operations

Mnemonic Codes

ORG

X

0

P

ORG

EN

SET

R 0

B15

SET P

R

0

B0

Example 3

X0

D

R0

↓

1

1

0

1

1

0

1

1

1

0

1

1

↓

1 0

0

0

D

R0

B15

1

ØX0=•

1

1

1

B0

↓

↓

1

1

1

1

1

1

1

1

1 1

1

1

32-Bit Register Set

R1

Key Operations

Mnemonic Codes

Ladder Diagram

D

ORG

ORG

X

0

EN

SET

R 0

SET D

R

0

B31

R0

B0

D

R0

↓

∣

↓

1 0 1 10 1 1 0 1 0111011111101011 0 1 1 0 0 0 1

ØX0=1

D

R0

1 1 1 11 1 1 1 1 1111111111111111 1 1 1 1 1 1 1

Basic Function Instruction

RST DP

RESET
(Reset the coil or the register to 0)

RST DP

Symbol

Operand

D: Destination to be reset

S

WY

WM

WS

TMR

(the number of a coil or a register)

Range

Y

M

SM

CTR

HR

OR

SR

ROR

DR

Y0

M0

M1912

S0

WY0

WM0

WS0

T0

C0

R0

R3904

R3968

R5000

D0

–

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

d

Y255

M1911

M2001

S999

WY240

WM1896

WS984

T255

C255

R3839

R3967

R4167

R8071

D4095

D

○

○

○*

○

○

○

○

○

○

○

○

○*

○*

○

Description

●When the reset control "EN" =1 or from 0 → 1 ( P instruction ), resets the coil or register to 0.

Example 1

Single Coil Reset

Please refer to example 1 for the SET instruction shown in page 6-8.

Example 2

16-Bit Register Reset

Ladder Diagram

ORG

Key Operations

Mnemonic Codes

ORG

X

0

RST P

R

0

Basic Function Instruction

RST DP

D

R0

RESET

1

1

1

1

B0

RST DP

(Reset the coil or register to 0)

B15

↓

↓

1 1

0

1

1

1

1

0

1

1

1

0

ØX0=•

Example 3

D

R0

B15

0

0

0

0

0

0

0

0

0

0

0

0

0

B0

↓

↓

0 0

0

32-Bit Register Reset

Key Operations

Mnemonic Codes

Ladder Diagram

X0

D

WM1368

ORG

ORG

X

0

RST D WM1368

EN

RST

M1399

WM1384

WM1368

M1368

D

WM1368

↓

∣

↓

0 1 10 1 1 1 0 00001101110111011 1 0 1 1 1 01

ØX0=1

D

WM1368

0 0 00 0 0 0 0 00000000000000000 0 0 0 0 0 00

Basic Function Instruction

FUN 0

MASTER CONTROL LOOP START

FUN 0

MC

MC

Symbol

Master control

EN

Ladder symbol

Operand

0.

N: Master Control Loop number (N=0~127)

MC

N

the number N cannot be used repeatedly.

Description

●

There are a total of 128 MC loops (N=0~127). Every Master Control Start instruction, MC N, must

correspond to a Master Control End instruction, MCE N, which has the same loop number as MC N. They must always be used in pairs and you should also make sure that the MCE N instruction is after the MC N instruction.

● When the Master Control input "EN/" is 1, then this MC N instruction will not be executed, as it does not exist.

● When the Master Control input "EN/" is 0, the master control loop is active, the area between the MC N and MCE N is called the Master Control active loop area. All the status of OUT coils or Timers within Master Control active loop area will be cleared to 0. Other instructions will not be executed.

Example

Ladder Diagram

Mnemonic Codes

Key Operations

X0

0.

Y0

ORG

ORG

X

0

EN

MC

1

FUN

0

X1

N:

1

X2

1S

Y1

ORG

ORG

X

1

OUT

OUT

Y

0

T201

10

T201

ORG

ORG

X

2

T201 PV:

10

1.

X1

MCE

1

Y2

ORG

ORG

T

201

OUT

OUT

Y

1

ORG

FUN

1

1

N:

1

ORG

X

OUT

OUT

Y

2

Basic Function Instruction

FUN 0

MASTER CONTROL LOOP START

FUN 0

MC

MC

X0

X1

X2

10

T201 0

Y0

Y1

10S

Y2

Remark1:MC/MCE instructions can be used in nesting or

X0

MC

0.

1

interleaving as shown to the right:

MC

Remark2:‧When M1918=0 and the master input changes from

0→1, and if pulse type function instructions exist in

X1

MC

0.

2

the master control loop, then these instructions will

MC

have a chance to be executed only once (when the

first time the master control input changes from 0→1).

X2

MC

0.

3

Afterwards, no matter how many times the master

MC

control input changes from 0→1, the pulse type

function instructions will not be executed again.

MC

1.

2

‧ When M1918=1 and the master control input

MC

changes from 0 →1, and if pulse type function

instructions exist in the master control loop, then

MC

1.

1

each time the master control input changes from 0→

MC

1 the pulse type function instructions in the master

control loop will be executed as long as the action

MC

1.

3

conditions are satisfied.

MC

‧When a counting instruction exists in the master

control loop, set M1918 to 0 can avoid counting error.

‧When the pulse type function instructions in the

master control loop must act upon the 0→1 input

change by the master control, the flag M1918 should

be set to 1.

Basic Function Instruction

FUN 1
MCE

MASTER CONTROL LOOP END

FUN 1
MCE

Symbol

Ladder symbol

1.

Operand

N: Master Control End number (N=0~127) N

can not be used repeatedly.

MCE

N

Description

y MCE N must correspond to a Master Control Start instruction. They must always be used as a pair you should also make sure that the MCE N instruction is after the MC N instruction. After the MC N uction has been executed, all output coil status and timers will be cleared to 0 and no other instructions e executed. The program execution will resume until a MCE instruction which has the same N number as MC N instruction appears.

instruction does not require an input control because the instruction itself forms a network which other uctions can not connect to it. If the MC instruction has been executed then the master control operation e completed when the execution of the program reaches the MCE instruction. If MC N instruction has never been executed then the MCE instruction will do nothing.

Description

Please refer to the example and explanations for MC instruction.

Basic Function Instruction

FUN 2

SKIP START

FUN 2

SKP

SKP

Symbol

Skip control

EN

Ladder symbol

Operand

2.

N: Skip loop number (N=0~127),

SKP

N

N can not be used repeatedly.

Description

●

There are total 128 SKP loops (N=0~127). Every skip start instruction, SKP N, must correspond to a skip

end instruction, SKPE N, which has the same loop number as SKP N. They must always be used as a pair and you should also make sure that the SKPE N instruction is after the SKP N instruction.

● When the skip control "EN" is 0, then the Skip Start instruction will not be executed.

● When the skip control "EN" is 1, the range between the SKP N and SKPE N which is so called the Skip active loop area will be skipped, that is all the instructions in this area will not be executed. Therefore the statuses of the discrete or registers in this Skip active loop area will be retained.

Example

Ladder Diagram

Key Operations

Mnemonic Codes

X0

2.

Y0

ORG

ORG

X

0

EN

SKP

1

FUN

2

X1

X2

1S

Y1

ORG

N:

1

ORG

X

1

EN

T201

10

OUT

OUT

Y

0

T201

ORG

ORG

X

2

X1

3.

Y2

ORG

T201 PV:

10

SKPE

1

ORG

T

201

OUT

OUT

Y

1

ORG

FUN

3

N:

1

ORG

X

1

OUT

OUT

Y

2

Basic Function Instruction

FUN 2
SKP

SKIP START

FUN 2
SKP

X0

X1

X2

10

T201

0

0

Y0

10S

Y1

Y2

Basic Function Instruction

FUN 3
SKPE

SKIP END

FUN 3
SKPE

Symbol

Operand

Ladder symbol
3.

N: SKIP END Loop number (N=0~127) N

can not be used repeatedly.

SKPE

N

Description

y SKPE N must correspond to a SKP N instruction. They must always be used as a pair and you should also make sure that the SKPE N instruction is behind the SKP N instruction.

E instruction does not require an input control because the instruction itself forms a network which r instructions can not connect to it. If the SKP N instruction has been executed then the skip operation e completed when the execution of the program reaches the SKPE N instruction. If SKP N instruction has never been executed then the SKPE instruction will do nothing.

Example

● Please refer to the example and explanations for SKP N instruction.

SKP/SKPE instructions can be used by nesting or interleaving. The coding rules are the same as for

the MC/MCE instructions. Please refer to the section of MC/MCE instructions.

Basic Function Instruction

FUN 4
DIFU

DIFFERENTIAL UP

FUN 4
DIFU

Symbol

Operand

D: a specific coil number where the result of

Range

Y

M

SM

the Differential Up operation is stored.

S

Y0

M0

M1912

S0

Ope-

∣

∣

∣

∣

rand

Y255

M1911

M2001

S999

D

○

○

○*

○

Description

DIFU instruction is used to output the up differentiation of a node status (status input to "TGU") and the e signal resulting from the status change at the rising edge of the "TGU" for one scan time is stored to a coil specified by D.

The functionality of this instruction can also be achieved by using a TU contact.

Example

The results of the following two samples are exactly the same

Ladder Diagram

Key Operations

Mnemonic Codes

Exam X1

ple

T

1

G

4P.

U

DIFU

Y 0

ORG ORG

FUN FUN

D:

X 4
Y

1

0

Exam

ple

2

ORG ORG TU

X

1

X

Y0

OUT OUT

Y

0

X1
t

Y0

t : scan time

Basic Function Instruction

FUN 5 P

DIFD

DIFFERENTIAL DOWN

FUN 5 P

DIFD

Symbol

Operand

N: a specific coil number where the result of

Range

Y

M

SM

the Differential Down operation is stored.

S

Y0

M0

M1912

S0

Ope-

∣

∣

∣

∣

rand

Y255

M1911

M2001

S999

D

○

○

○*

○

Description

DIFD instruction is used to output the down differentiation of a node status (status input to "TGD") and pulse signal resulting from the status change at the falling edge of the"TGD" for one scan time is stored to a coil specified by D.

The functionality of this instruction can also be achieved by using a TD contact.

Example

The results of the following two samples are exactly the same

le 1

Ladder Diagram

Key Operations

Mnemonic Codes

ORG

X

1

ORG

X1

TGD

5P.

Y 0

FUN

FUN

D: Y

5

DIFD

0

E

xam

E

xam

p

le

2

X

1

Y0

OUT OUT

X1

t

t : scan time

Y0

Basic Function Instruction

FUN 6 DP

BIT SHIFT

FUN 6 DP

BSHF

(Shifts the data of the 16-bit or 32-bit register to left or to right by one bit)

BSHF

Symbol

Operand

D: The register number for shifting

Range

WY

WM

WS

TMRCTR

HR

OR

SR

ROR

DR

Ope-

WY0

WM0

WS0

T0

C0

R0

R3904

R3968

R5000

D0

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

rand

WY240

WM1896

WS984

T255

C255

R3839

R3967

R4167

R8071

D4095

D

○

○

○

○

○

○

○

○*

○*

○

Description

● When the status of clear control "CLR" is at 1, then the data of register D and FO0 will all be cleared to 0.

Other input signals are all in effect.

● When the status of clear control is "CLR" at 0, then the shift operation is permissible. When the shift control

"EN" = 1 or from 0 →1 ( P instruction), the data of the register will be shifted to right (L/R=0) or to left

(L/R=1) by one bit. The shifted-out bit (MSB when shift to left and LSB when shift to right) for both cases

will be sent to FO0. The vacated bit space (LSB when shift to left and MSB when shift to right) due to shift

operation will be filled in by the input status of fill-in bit "INB".

Example Shifts the 16-bit register data

Ladder diagram Key Operations Mnemonic Codes

ORG ORG X 1

X1 6P.BSHF Y0 LD LD X 2

EN D : R 3 OTB

LD LD X 3

X2

INB LD LD X 4

X3 FUN FUN 6P

L/R

D: R 3

X4

CLR FO 0

OUT OUT Y 0

B15 B0

X3=1

←←←←←←←←←←←←←←←←←←

(Left shift) Y0 Shifts the 16-bit data to left by one bit X2

B15 B0

X3=0

→→→→→→→→→→→→→→→→→→

(Right shift) X2 Shifts the 16-bit data to right by one bit Y0

Basic Function Instruction

FUN 7 DP

UP/DOWN COUNTER

FUN 7 DP

UDCTR

(16-bit or 32-bit up and down 2-phase Counter)

UDCTR

Symbol

Operand

CV: The number of the Up/Down Counter

PV: Preset value of the counter or it’s

register number

Range

WX

WY

WM

WS

TMRCTR

HR

IR

OR

SR

ROR

DR

K

Ope-

WX0

WY0

WM0

WS0

T0

C0

R0

R3840

R3904

R3968

R5000

D0

16/32-bit

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

+/− number

rand

WX240

WY240

WM1896

WS984

T255

C255

R3839

R3903

R3967

R4167

R8071

D4095

CV

○

○

○

○

○

○

○

○

○

○*

○*

○

○

PV

○

○

○

○

○

○

○

○

○

○

Description

● When the clear control “CLR” is 1, the counter’s CV will be reset to 0 and the counter will not be able to count.

● When the clear control “CLR” is 0, counting will then be allowed. The nature of the instruction is a P instruction. Therefore, when the count-pulse “PLS” is from 0→1 (rising edge), the CV will increased by 1 (if U/D=1) or decreased by 1 (if U/D=0).

● When CV=PV, FO0(“Count-Up) will change to 1”. If there are more clocks input, the counter will continue counting which cause CV≠PV. Then, FO0 will immediately change to 0. This means the “Count-Up” signal will only be equal to 1 if CV=PV, or else it will be equal to 0 (Care should be taken to this difference from the “Count-Up” signal of the general counter).

● The upper limit of up count value is 32767 (16-bit) or 2147483647 (32-bit). After the upper limit is reached, if another up count clock is received, the counting value will become –32768 or -2147483648 (the lower limit of down count).

● The lower limit of down count value is -32767 (16-bit) or -2147483647 (32-bit). After the lower limit is reached, if another down count clock is received, the counting value will become 32768 or 2147483648 (the upper limit of up count).

● If U/D is fixed as 1, the instruction will become a single-phase up count counter. If U/D is fixed as 0, the instruction will become a single-phase down count counter.

Basic Function Instruction

FUN 7 DP UDCTR

UP/DOWN COUNTER
(16-bit or 32-bit up/down 2-phase Counter)

FUN 7 DP UDCTR

X18

Ladder Diagram

ORG

Key Operations

Mnemonic Codes

ORG

X

18

7P.UDCTR

Y0

LD

LD

X

17

PSU

CV :

R

0

CUP

X17

U/D

PV :

–

3

LD

Down(subtract)

LD

X

16

FUN

7

X16

CV: R

0

CLR

OUT

PV:

−

3

FO

0

OUT

Y

0

Up(add)

X16

X17

X18

R0

0

1

2

3

2

1

0

-1

-2

-3

-4

Y0

Remark 1: Since the counting operation of UDCTR is implemented by software scanning, therefore if the clock speed is faster than the scan speed, lose count may then happen (generally the clock should not exceed 20Hz depending on the size of the program). Please use the software or hardware high-speed counter in the PLC. Refer to the “High Speed Counter Application” in the Advanced Manual.

Remark 2: In order to ensure the proper counting, the sustain time of the status of clock input should greater than 1 scan time.

Basic Function Instruction

FUN 8 DP

MOVE

FUN 8 DP

MOV

(Moves data from S to D)

MOV

Description

Move control

EN

Ladder symbol

Operand

8DP.MOV

S: Source register number

S :

D: Destination register number

D :

The S, N, D may combine with V, Z, P0~P9 to serve

indirect addressing

Range

WX

WY

WM

WS

TMRCTR

HR

IR

OR

SR

ROR

DR

K

XR

Ope-

WX0

WY0

WM0

WS0

T0

C0

R0

R3840

R3904

R3968

R5000

D0

16/32-bit

V、Z

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

P0~P9

+/− number

rand

WX240

WY240

WM1896

WS984

T255

C255

R3839

R3903

R3967

R4167

R8071

D4095

S

○

○

○

○

○

○

○

○

○

○

○

○

○

○

D

○

○

○

○

○

○

○

○*

○*

○

○

Description

● Move (write) the data of S to a specified register D when the move control input "EN" =1 or from 0 to 1 ( P instruction).

Example

Writes a constant data into a 16-bit register.

Mnemonic Codes

Ladder Diagram

Key Operations

ORG

ORG

X

0

X0

EN

8P.MOV

S

K

10

FUN

8P

10

S :

10

D :

R 0

S:

D: R

0

ØX0=•

D

R0

10

Basic Function Instruction

FUN 9 DP

MOVE INVERSE

FUN 9 DP

MOV/

(Inverts the data of S and moves the result to a specified device D)

MOV/

Symbol

Move control

EN

Ladder symbol

Operand

9DP.MOV/

S: Source register number

S :

D: Destination register number

D :

S, N, D may combine with V, Z, P0~P9 to serve

indirect addressing

Range

WX

WY

WM

WS

TMRCTR

HR

IR

OR

SR

ROR

DR

K

XR

Ope-

WX0

WY0

WM0

WS0

T0

C0

R0

R3840

R3904

R3968

R5000

D0

16/32-bit

V、Z

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

+/− number

rand

WX240

WY240

WM1896

WS984

T255

C255

R3839

R3847

R3967

R4167

R8071

D4095

P0~P9

S

○

○

○

○

○

○

○

○

○

○

○

○

○

○

D

○

○

○

○

○

○

○

○*

○*

○

○

Description

● Inverts the data of S (changes the status from 0 to 1 and from 1 to 0) and moves the results to a specified register D when the move control input "EN" =1 or from 0 to1 ( P instruction).

Example

Moves the inverted data of a 16-bit register to another 16-bit register.

Ladder Diagram

Key Operations

Mnemonic Codes

ORG

ORG

X

0

X0

EN

9.MOV/

FUN

9

S :

R 0

D :

WY 8

S: R

0

D: WY

8

B15

B0

S

R0

0 1 0 1

0

1

0

1

0

1

0

1

0

1

0

1

5555H

D

WY8

Y23

1

ØX0=1

0

1

0

1

0

1

Y8

AAAAH

↓

↓

0

1

0

1

1 0 1 0

0

Basic Function Instruction

FUN 10 TOGG

TOGGLE SWITCH
(Changes the output status when the rising edge of control input occur)

FUN 10 TOGG

Symbol

Operand

D: the coil number of the toggle switch

Range

Y

M

SM

S

Ope-

Y0

M0

M1912

S0

∣

∣

∣

∣

rand

Y255

M1911

M2001

S999

D

○

○

○*

○

Description

coil D changes its status (from 1 to 0 and from 0 to 1) each time the input "TGU"is triggered from 0 to ing edge).

Example

X0

Ladder Diagram

Key Operations

Mnemonic Codes

10P.

ORG

ORG

X

0

TGU

TOGGY 0

FUN

10

0

X0

Y0

D: Y

Basic Function Instruction

FUN 11 DP

ADDITION

FUN 11 DP

(+)

(Performs addition of the data specified at Sa and Sb and stores the result in D)

(+)

Symbol

Operand

IR

Sa: Augend

Sb: Addend

D : Destination register to store the results

of the addition

Sa, Sb, D may combine with V, Z, P0~P9

to serve indirect addressing

WY

WM

WS TMR

CTR

HR

Range

WX

OR

SR

ROR

DR

K

XR

WX0

WY0

WM0

WS0

T0

C0

R0

R3840

R3904

R3968

R5000

D0

16/32-bit

V、Z

Ope-

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

P0~P9

+/− number

rand

WX240

WY240

WM1896

WS984

T255

C255

R3839

R3903

R3967

R4167

R8071

D4095

Sa

○

○

○

○

○

○

○

○

○

○

○

○

○

○

Sb

○

○

○

○

○

○

○

○

○

○

○

○

○

○

D

○

○

○

○

○

○

○

○*

○*

○

○

Description

●

Performs the addition of the data specified at Sa and Sb and writes the results to a specified register D

when the add control input "EN" =1 orfrom 0 to 1 ( P instruction). If the result of addition is equal to 0 then set FO0 to 1. If carry occurs (the result exceeds 32767 or 2147483647) then set FO1 to 1. If borrow occurs (adding negative numbers resulting in a sum less than -32768 or -2147483648), then set the FO2 to 1. All the FO statuses are retained until this instruction is executed again and overwritten by a new result.

Example

16-bit addition

Mnemonic Codes

X0

Ladder Diagram

Y0

ORG

Key Operations

11P.(+)

ORG

X

0

EN

Sa :

R

0

D=0

OUT

FUN

11P

Sb :

R

1

Sa: R

0

U/S

D :

R

2

CY

Sb: R

1

BR

D:

R

2

FO

1

OUT

Y

0

Sa

R0

12345

R0+R1=32770

Sb

R1

20425

ØX0=•

D

R2

2

32768+2=32770

Y0=1 (carry 1 represents +32768)

Basic Function Instruction

FUN 12DP (−)

SUBTRACTION
(Performs subtraction of the data specified at Sa and Sb and stores the result in D)

FUN 12DP

(−)

Symbol

Ladder symbol

Operand

12DP.(-)

ntrol

Sa :

Sa: Minuend

EN

D=0

Difference=0(FO0)

/Sign

Sb :

Sb: Subtrahend

U/S

CY

Carry(FO1)

D : Destination register to store the

D :

results of the subtraction

Sa, Sb, D may combine with V, Z, P0~P9

nge

WX

WY

WM

BR

Borrow(FO2)

IR

OR

to serve indirect addressing

WS

TMRCTR

HR

SR

ROR

DR

K

XR

WX0

WY0

WM0

WS0

T0

C0

R0

R3840

R3904

R3968

R5000

D0

16/32-bit

V、Z

–

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

+/− number

P0~P9

WX240

WY240

WM1896

WS984

T255

C255

R3839

R3903

R3967

R4167

R8071

D4095

a

○

○

○

○

○

○

○

○

○

○

○

○

○

○

b

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○*

○*

○

○

Description

● Perf

whe

0 the

orm n th n

s the subtraction of th e subtract control inpu set FO0 to 1. If carry

e data specified at Sa and Sb and writes the results to a specifie t "EN" =1 orfrom 0 to 1 ( P instruction). If the result of subtractio occurs (subtracting a negative number from a positive number a

d register D n is equal to nd the result

exce
nega
the F

ed tiv O

s 32767 or 214748364 e number and the res statuses are retained

7), then set FO1 to 1. If borrow occurs (subtracting a positive nu ulted difference is less than -32768 or -2147483648), then set F until this instruction is executed again and overwritten by a new re

mber from a O2 to 1. All sult.

Example

16-bit subtraction

Ladder Diagram

12P.(-)

EN

Sa :

R

0

U/S

Sb :

R

1

D :

R

2

Sa

R0

Sb R1

D R2

Y2=1(

D=0

Y2

Key Operations

Mnemonic Codes

ORG

ORG

X

0

FUN

12

Sa: R

0

CY

Sb: R

1

D:

R

2

BR

OUT

FO

2

OUT

Y

2

-5

R0-R1=-32772

32767

ØX0=1

Ladder Diagram

X0

EN

12P.(-)

0

Sa :

R

U/S

Sb :

R

1

D :

R

2

Sa

R0

Sb R1

D R2

Y2=1(

Basic Function Instruction

FUN 13 DP (*)

MULTIPLICATION
(Performs multiplication of the data specified at Sa and Sb and stores the result in D)

FUN 13 DP (*)

Symbol

n contro

EN

Ladder symbol

Product=0(FO0)

Operand

13DP.(*)

Sa: Multiplicand

Sa :

D=0

Sb: Multiplier

ign/Sign

Sb :

Product is negative

D: Destination register to store the

D<0

results of the multiplication.

U/S

D :

Sa, Sb, D may combine with V, Z,

(FO1)

P0~P9 to serve indirect addressing

ge

WX

WY

WM

WS

TMR

CTR

HR

IR

OR

SR

ROR

DR

K

XR

WX0

WY0

WM0

WS0

T0

C0

R0

R3840

R3904

R3968

R5000

D0

16/32-bit

V、Z

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

+/− number

P0~P9

WX240

WY240

WM1896

WS984

T255

C255

R3839

R3903

R3967

R4167

R8071

D4095

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○*

○*

○

○

Description

orms the multiplication of the data specified at Sa and Sb and writes the results to a specified register en the multiplication control input "EN" =1 or from 0 to 1( P instruction). If the product of multiplication is equal to 0 then set FO0 to 1. If the product is a negative number, then set FO1 to 1.

Example 1

16-bit multiplication

Ladder Diagram

D=0

Sa

ORG

Key Operations

Mnemonic Codes

ORG

X

0

13P.(*)

FUN

13P

EN

Sa :

R

0

Sb :

R

1

D<0

R0
12345

Multiplicand

Sa: R

0

U/S

D :

R

2

Sb: R

1

D:

R

2

×

Sb

R1
4567

Multiplier

D

R3

56379615

R2

Product

Basic Function Instruction

FUN 13 DP (*)

MULTIPLICATION
(Performs multiplication of the data specified at Sa and Sb and stores the result in D)

FUN 13 DP

(*)

Example 2

32-bit multiplication

Ladder Diagram

D=0

ORG

Key Operations

R0

Mnemonic Codes

ORG

X

0

13D.(*)

FUN

13D

EN

Sa :

R

0

D<0

R1

Sa: R

0

Sb :

R

2

U/S

D :

R

4

Sb: R

2

D: R

4

×

Sa

12345678

Multiplicand

Sb

R3

R2

Multiplier

D

R7

R6

R5

R4

Product

5629629168

Basic Function Instruction

FUN 14DP (/)

DIVISION
(Performs division of the data specified at Sa and Sb and stores the result in D)

FUN 14DP

(/)

Symbol

trol

EN

Ladder symbol

D=0

Quotient=0 (FO0)

Operand

14DP.(/)

Sa :

Sa: Dividend

ign

U/S

Sb :

ERR

Divisor is 0 (FO1)

Sb: Divisor

D : Destination register to store the results

D :

of the division.

Sa, Sb, D may combine with V, Z, P0~P9

to serve indirect addressing

nge

WX

WY

WM

WS

TMRCTR

HR

IR

OR

SR

ROR

DR

K

XR

WX0

WY0

WM0

WS0

T0

C0

R0

R3840

R3904

R3968

R5000

D0

16/32-bit

V、Z

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

+/− number

P0~P9

WX240

WY240

WM1896

WS984

T255

C255

R3839

R3903

R3967

R4167

R8071

D4095

a

○

○

○

○

○

○

○

○

○

○

○

○

○

○

b

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○

○*

○*

○

○

Description

orms the division of the data specified at Sa and Sb and writes the quotient and remainder to registers ified by register D when the division control input "EN" =1 or from 0 to 1 ( P instruction). If the quotient of ion is equal to 0 then set FO0 to 1. If the divisor Sb=0 then set the error flag FO1 to 1 without executing nstruction.

Example 1

16-bit division

Ladder Diagram

D=0

Sa

Key Operations

Mnemonic Codes

14P.(/)

ORG

ORG

X

0

FUN

14

EN

Sa:

R

0

Sb:

R

1

ERR

R0
256

Dividend

Sa: R

0

U/S

D :

R

2

Sb: R

1

D:

R

2

÷

Sb

R1
12

Divisor

D

R3

R2

4

21

Remainder

Quotient

Basic Function Instruction

FUN 14DP

DIVISION

FUN 14DP

(/)

(Performs division of the data specified at Sa and Sb and stores the result in D)

(/)

Example 2

32-bit division

X0

Ladder Diagram

Key Operations

Mnemonic Codes

EN

14D.(/)

0

D=0

ORG

ORG

X

0

Sa:

R

FUN

14D

Sb:

R

2

Sa: R

0

U/S

D :

R

4

ERR

Sb: R

2

D:

R

4

Sa

R1

R0

Dividend

2147483647

÷

Sb

R3

1234567

R2

Divisor

D

R7

R6

R5

1739

R4

571634

Remainder

Quotient

Basic Function Instruction

FUN 15DP INCREMENT

(+1) (Adds 1 to the D value)

FUN 15DP

(+1)

Operand

D : The register to be increased

WM

WS

SR

D may combine with V, Z, P0~P9 to

serve indirect addressing

Range

WY

TMR

CTR

HR

OR

ROR

DR

XR

Ope-
rand

WY0
∣
WY240

WM0

WS0

T0

C0

R0

R3904

R3968

R5000

D0

V 、Z

∣

∣

∣

∣

∣

∣

∣

∣

∣

WM1896

WS984

T255

C255

R3839

R3967

R4167

R8071

D4095

P 0 ~ P 9

D

○

○

○

○

○

○

○

○*

○*

○

○

● Adds 1 to the register D when the increment control input "EN" =1 orfrom 0 to 1( P instruction). If the value

of D is already at the upper limit of positive number 32767 or 2147483647, adding one to this value will

change it to the lower limit of negative number -32768 or -2147483648. At the same time, the overflow flag

FO0 (OVF) is set to 1.

Example

16-bit increment register

0

Ladder diagram

OVF

ORG

Key operations

Mne

15P.

ORG TU

FUN

EN

(+1)

R 0V

D

When V=100,0+100=100

D

R100

1

ØX0=•

Mnemonic code

X 0 15
D : R 0V

X0

Ladder diagram

OVF

ORG

Key operations

Mne

15P.

ORG TU

FUN

EN

(+1)

R 0V

D

When V=100,0+100=100

D

R100

1

ØX0=•

Basic Function Instruction

FUN 16DP

(-1)

DECREMENT
(Subtracts 1 from the D value)

FUN 16 DP

(-1)

Ladder symbol

Operand

16DP.

Decrement control

EN

UDF

Underflow(FO0)

D : The register to be decreased

(-1)

D

D may combine with V, Z, P0~P9 to

serve indirect addressing

Range

WY

WM

WS

TMRCTR

HR

OR

SR

ROR

DR

XR

Ope-

WY0

WM0

WS0

T0

C0

R0

R3904

R3968

R5000

D0

V 、Z

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

rand

P 0 ~ P 9

WY240

WM1896

WS984

T255

C255

R3839

R3967

R4167

R8071

D4095

D

○

○

○

○

○

○

○

○*

○*

○

○

Description

racts 1 from the register D when the decrement control input "EN" =1 orfrom 0 to 1 ( P instruction). If alue of D is already at the lower limit of negative number -32768 or -2147483648, subtracting one from value will change it to the upper limit of positive number 32767 or 2147483647. At the same time, the underflow flag FO0 (UDF) is set to 1.

Example

16-bit decrement register

Ladder diagram

ORG

Key operations

Mnemonic code

ORG X 0

0

EN

16P.

R 0

UDF

FUN 16P

(-1)

D : R 0

D

R0

0

ØX0=•

D

R0

-1

Basic Function Instruction

FUN 17DP CMP

Compare control

Unsign/Sign

COMPARE

FUN 17DP

(Compares the data of Sa and Sb and outputs the results to function Outputs)

CMP

Ladder symbol

Operand

17DP.CMP

EN

Sa :

a = b

Sa=Sb (FO0)

Sa: The register to be compared

Sb :

Sb: The register to be compared

U/S

a > b

Sa>Sb (FO1)

Sa, Sb may combine with V, Z, P0~P9 to

serve indirect addressing

●

a < b

Sa<Sb (FO2)

Range

WX

WY

WM

WS

TMR

CTR

HR

IR

OR

SR

ROR

DR

K

XR

Ope-

WX0

WY0

WM0

WS0

T0

C0

R0

R3840

R3904

R3968

R5000

D0

16/32 bit

V、Z

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

+/-number

P0~P9

rand

WX240

WY240

WM1896

WS984

T255

C255

R3839

R3903

R3967

R4167

R8071

D4095

Sa

○

○

○

○

○

○

○

○

○

○

○

○

○

○

Sb

○

○

○

○

○

○

○

○

○

○

○

○

○

○

Compares the data of Sa and Sb when the compare control input "EN" =1 or from 0 to 1 ( P instruction). If the

data of Sa is equal to Sb, then set FO0 to 1. If the data of Sa>Sb, then set FO1 to 1. If the data of Sa<Sb,

then set FO2 to 1. If the data of Sa < Sb, then set the FO2 to 1.

Example Compares the data of 16-bit register

Ladder diagram Key operations Mnemonic code

X0 17.CMP ORG ORG X 0

EN Sa : R 0 a=b FUN 17

Sb : R 1

Sa : R 0

U/S a>b

Sb : R 1

Y0

a<b FO 2

OUT OUT Y 0

● From the above example, we first assume the data of R0 is 1 and R1 is 2, and then compare the data by

executing the CMP instruction. The FO0 and FO1 are set to 0 and FO2 (a<b) is set to 1 since a<b.

● If you want to have the compound results, such as≧、≦、< > etc., please send =、< and > results to relay first

and then combine the result from the relays.

● M1919=0, when this command in not executed, FO0, FO1, FO2 will remain in the status at last execution.

● M1919=1, when this command in not executed, FO0, FO1, FO2 are all cleared to 0.

● Control M1919 properly to obtain memory-holding function for functional command output.

Basic Function Instruction

FUN 18DP

LOGICAL AND

FUN 18DP

AND

AND

Operand

Sa: The register to be ANDed
Sb: The register to be ANDed
D : The register to store the result of AND
The Sa, Sb, D may combine with V, Z, P0~P9 to
serve indirect addressing application

●

Range

WX

WY

WM

WS

TMRCTR

HR

IR

OR

SR

ROR

DR

K

XR

Ope-

WX0

WY0

WM0

WS0

T0

C0

R0

R3840

R3904

R3968

R5000

D0

16/32 bit

V、Z

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

+/-number

P0~P9

rand

WX240

WY240

WM1896

WS984

T255

C255

R3839

R3903

R3967

R4167

R8071

D4095

Sa

○

○

○

○

○

○

○

○

○

○

○

○

○

○

Sb

○

○

○

○

○

○

○

○

○

○

○

○

○

○

D

○

○

○

○

○

○

○

○*

○*

○

○

Performs logical AND operation for the data of Sa and Sb when the operation control input "EN" =1 or from 0

to 1( P instruction). This operation compares the corresponding bits of Sa and Sb (B0~B15 or B0~B31). The bit in the D is set to 1 if both of the corresponding bits data of Sa and Sb is 1. The bit in the D is set to 0 if one of the corresponding bits is 0.

Example

Operation of 16-bit logical AND

1

ORG

Key operations

0

1

1

Mnemonic code

Ladder diagram

ORG X 0

X0

18P.AND

1

0

1

1

0

1

1

FUN 18P

EN

Sa :

R

0

D=0

Sa : R 0

Sb :

R

1

D :

R

2

Sb : R 1

D :

R

2

B15

B0

↓

↓

Sa

R0

1 0 1

0

1

Sb

R1

1 1 1

0

1

1

1

0

1

0

1

0

0

1

1

0

ØX0=•

D

R2

B15

0

1

0

1

0

0

0

1

0

0

1

0

B0

↓

↓

1 0 1

0

Basic Function Instruction

FUN 19DP

OR

LOGICAL OR

FUN 19DP

OR

Operand

Sa: The register to be ORed

Sb: The register to be ORed

D : The register to store the result of OR

The Sa, Sb, D may combine with V, Z, P0~P9 to

serve indirect addressing

Range

WX

WY

WM

WS

TMRCTR

HR

IR

OR

SR

ROR

DR

K

XR

Ope-

WX0

WY0

WM0

WS0

T0

C0

R0

R3840

R3904

R3968

R5000

D0

16/32 bit

V、Z

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

+/-number

P0~P9

rand

WX240

WY240

WM1896

WS984

T255

C255

R3839

R3903

R3967

R4167

R8071

D4095

Sa

○

○

○

○

○

○

○

○

○

○

○

○

○

○

Sb

○

○

○

○

○

○

○

○

○

○

○

○

○

○

D

○

○

○

○

○

○

○

○*

○*

○

○

● Performs logical OR operation for the data of Sa and Sb when the operation control input "EN" =1 or from 0

to 1( P instruction). This operation compares the corresponding bits of Sa and Sb (B0~B15 or B0~B31).

The bit in the D is set to 1 if one of the corresponding of Sa or Sb is 1. The bit in the D is set to 0 if both of

the corresponding bits of Sa and Sb is 0.

Example

Operation of 16-bit logical OR

X0

Ladder diagram

D=0

1

1

Key operations

0

1

1

Mnemonic code

19.OR

ORG

ORG X

0

FUN 19

EN

Sa :

R

0

Sb :

R

1

B15

0

1

1

0

1

1

Sa : R

0

D :

R

2

Sb : R

1

D :

R

2

B0

Sa

R0

↓

↓

1 0 1

0

1

Sb

R1

1 1 1

0

1

1

1

0

1

0

1

0

0

1

1

0

ØX0=1

D

R2

B15

1

1

1

1

1

1

1

1

0

1

1

1

B0

↓

↓

1 1 1

1

Basic Function Instruction

FUN 20DP

BIN TO BCD CONVERSION

FUN 20DP

→BCD

(Converts BIN data of the device specified at S into BCD and stores the result in D)

→BCD

Operand

S : The register to be converted

D : The register to store the converted data

(BCD code)

The S, D may combine with V, Z, P0~P9 to serve

indirect addressing

Range

WX

WY

WM

WS

TMRCTR

HR

IR

OR

SR

ROR

DR

K

XR

Ope-

WX0

WY0

WM0

WS0

T0

C0

R0

R3840

R3940

R3968

R5000

D0

16/32 bit

V、Z

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

+/- number

P0~P9

rand

WX240

WY240

WM1896

WS984

T255

C255

R3839

R3903

R3967

R4167

R8071

D4095

S

○

○

○

○

○

○

○

○

○

○

○

○

○

○

D

○

○

○

○

○

○

○

○*

○*

○

○

●

FB-PLC uses binary code to store and to execute calculations. If want to send the internal PLC data to the

external displays such as seven-segment displays, it is more convenient for us to read the result on screen by converting the BIN data to BCD data. For example, it is more clear for us to read the reading "12" instead of the binary code "1100."

● Converts BIN data of the device specified at S into BCD and writes the result in D when the operation control input "EN" =1 orfrom 0 to 1 ( P instruction). If the data in S is not a BCD value (0~9999 or 0~9999999), then the error flag FO0 is set to 1 and the old data of D are retained.

Example

16-bit BIN to BCD conversion

ORG

Key operations

Mnemonic code

X0

Ladder diagram

1

0

0

1

1

ORG X 0

20.

BCD

0

1

1

1

0

0

0

FUN 20

EN

S :

9999

ERR

S : 9999

D :

R

0

D : R

0

B15

B0

↓

↓

S

K

0 0

1

1

ØX0=1

D

R0

B15

0

1

1

0

0

1

1

0

0

1

1

0

0

B0

↓

↓

1 0

1

Basic Function Instruction

FUN 21DP

BCD TO BIN CONVERSION

FUN 21DP

→BIN

(Converts BCD data of the device specified at S into BIN and stores the result in D)

→BIN

Operand

S : The register to be converted

D : The register to store the converted data

(BIN code)

The S, D may combine with V, Z, P0~P9 to

serve indirect addressing

Range

WX

WY

WM

WS

TMRCTR

HR

IR

OR

SR

ROR

DR

XR

WX0

WY0

WM0

WS0

T0

C0

R0

R3840

R3904

R3968

R5000

D0

V、Z

Ope-

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

∣

rand

WX240

WY240

WM1896

WS984

T255

C255

R3839

R3903

R3967

R4167

R8071

D4095

P0~P9

S

○

○

○

○

○

○

○

○

○

○

○

○

○

D

○

○

○

○

○

○

○

○*

○*

○

○

●

The decimal (BCD) data must be converted to binary (BIN) data first in order for PLC to accept the data

which is originally in decimal unit (BCD code) inputted from external device such as digital switch because the BCD data can not be accepted by PLC for its operations.

● Converts BCD data of the device specified at S into BIN and writes the result in D when the operation control input "EN" =1 or from 0 to 1 ( P instruction). If the data in S is not in BCD, then the error flag FO0 is set to 1 and the old data of D are retained.

● Constant is converted to BIN automatically when store in program and can not be used as a source operand of this function.

Example

16-bit BCD to BIN conversion

ORG

Key operations

Mnemonic code

X0

Ladder diagram

1

1

1

0

1

21P. BIN

2

3

ORG X

0

FUN 21P

EN

S :

WX 0

ERR

D :

R

1

S : WX 0

D : R

1

X15

X0

↓

4

↓

S WX0 0 0

0

0

0

1

0

0

0

1

0

0

ØX0=•

D

R1

B15

0

0

0

1

0

0

1

1

0

1

0

0

1

B0

↓

↓

0 0

0

Was this page helpful?

Tip: press ← → to switch chapters, Ctrl+K to search