1. Trang chủ >
  2. Kỹ Thuật - Công Nghệ >
  3. Tự động hóa >

1 FNC 00 – CJ / Conditional Jump

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (16.5 MB, 964 trang )


FX3S/FX3G/FX3GC/FX3U/FX3UC Series



8 Program Flow – FNC 00 to FNC 09



Programming Manual - Basic & Applied Instruction Edition



8.1 FNC 00 – CJ / Conditional Jump



Cautions

1. Relationship between the label input position and the list program

The figure below shows programming of a label.

When creating a circuit program, move the cursor to the left side of the bus line in the ladder diagram, and input a label

(P) at the head of the circuit block.



X030



FNC 00

CJ



LD

CJ



P 20



X031



Pointer

Y010



X032



Label

P 20

Bus

line



Y011



X030

P 20



LD

X031

OUT Y010

P 20

LD

X032

OUT Y011



Label



2. Programming a label in a smaller number step than CJ instruction

A label can be programmed in a smaller number step than CJ instruction. However, note that a watchdog timer error

occurs when the scan time exceeds 200 ms (default setting).

Label

P 10



X022

FNC 00

CJ



P 10



3. Jumping to one label from two or more CJ instructions

When the pointer number in operands is same and there is one label, the following operation is caused:

When X020 turns ON, the program execution jumps from CJ instruction corresponding to X020 to the label P9. When

X020 turns OFF and X021 turns ON, the program execution jumps from CJ instruction corresponding to X021 to the

label P9.

X020



FNC 00

CJ



P 9



FNC 00

CJ



P 9



X021



Label

P 9



4. Using a label (P) two or more times

When a label number (including labels for CALL instructions described later) is used two or more times, an error is

caused.

X020



FNC 00

CJ



Label

P9



Bad



P9



Good



User program



Label

P9



Good



FNC 00

CJ



X030



P9



User program

END



222



FX3S/FX3G/FX3GC/FX3U/FX3UC Series



8 Program Flow – FNC 00 to FNC 09



Programming Manual - Basic & Applied Instruction Edition



8.1 FNC 00 – CJ / Conditional Jump



1

Introduction



5. Label unnecessary for the pointer P63

The pointer P63 specifies jump to END step. Do not program P63.

If P63 is programmed, PLCs will display the error code 6507 (defective label definition) and stop.

FNC 00

CJ



2

Overview



Label

P 63



P 63



END



Do not program P63.



3



6. When jumping to a pointer for subroutine

Command



X000



P15



Bad



FNC 01

CALLP



P15



Good



C0



K10



FNC 06

FEND

M8000

RUN monitor

(normally ON)



5



Subroutine program

dedicated to CALL

instruction



User program



Specified the

Device &

Constant



Label

P15



4

Devices

in Detail



X001



FNC 00

CJ



Instruction

List



Any label cannot be shared by CALL instruction and CJ instruction.



Program a label (P) after

FEND instruction.



FNC 02

SRET



7. Unconditional jump if the command contact is normally ON



M8000

RUN monitor



FNC 00

CJ



P5



7

Basic

Instruction



User program

(It is skipped, and is not executed.)

Label

P5



6

Before

Programming



Because M8000 is normally ON while a PLC is operating, unconditional jump is specified when M8000 is used in the

following example:



User program



8

FNC00-FNC09

Program Flow



9

FNC10-FNC19

Move & Compare



10

FNC20-FNC29

Arith. & Logic

Operation



223



FX3S/FX3G/FX3GC/FX3U/FX3UC Series



8 Program Flow – FNC 00 to FNC 09



Programming Manual - Basic & Applied Instruction Edition



8.1 FNC 00 – CJ / Conditional Jump



Program example

1. When a jump is necessary after OFF processing

In one operation cycle after X023 changes from OFF to ON, the CJ P7 instruction becomes valid.

By using this method, jump can be executed after all outputs between the CJ P7 instruction and the label P7 turn OFF.

X023



PLS

M0



M0



FNC 00

CJ



P7



X023



Label

P7



224



User program



FX3S/FX3G/FX3GC/FX3U/FX3UC Series



8 Program Flow – FNC 00 to FNC 09



Programming Manual - Basic & Applied Instruction Edition



1



CJ instruction and operations of contact and coil

In the program example shown below, when X000 turns ON, the program execution jumps from CJ instruction in the

first circuit to the label P8.

While X000 is OFF, jump is not executed; The program is executed from the 1st step in turn, and then the program

execution jumps from CJ instruction in the 11th circuit to the label P9.

Instructions skipped by jump are not executed.



1st

circuit



0

4



8

11



18

22



X002

X003

X004

X005

X006

X007

X010



29

Label

P 8

35

40



X000

X012



M1

S1

T0



• When the reset (RST) instruction for the retentive type timer

T246 is located outside the jump area

Even if the counting coil (OUT T246) is jumped, reset (return

of the contact and clearing of the current value) is valid.



K 10



RST



T246



T246 K1000

RST

C0



• When the reset (RST) instruction for the counter C0 is

located outside the jump area

Even if the counting coil is jumped, reset (return of the

contact and clearing of the current value) is valid.



C 0

K 20



FNC 12

MOV



FNC 00

CJ



K 3



D 0



P 9



Y001



Label

P 9

X013



T246



• Operation of the high-speed counters C235 to C255

A high-speed counter continues its operation even if it is

jumped after the coil is driven, and the output contact is

activated.



C 0



When each input changes during jump in the above

program, each coil executes the following operation:

Classification



Contact status before jump



Coil operation during jump



X001, X002, X003 ON



Y001, M1 and S1 turn ON



10 ms timer and

100 ms timer (T0)



X004 OFF



Timer is not activated.



X004 ON



Counting is paused (, and is restarted after X000 turns OFF).



X005 OFF

X006 OFF



Timer is not activated.

The deactivation status is reset when X013 turns ON.



X005 OFF

X006 ON



Counting is continued (, and the contact is activated after X000 turns OFF).



X007 OFF

X010 OFF



Counting is not activated.

The deactivation status is reset when X013 turns ON.



X007 OFF

X010 ON



Counting is paused (, and is restarted after X000 turns OFF).



X011 OFF

X011 ON



7



9

FNC10-FNC19

Move & Compare



Applied instruction

(MOV)



6



FNC00-FNC09

Program Flow



Y001, M1 and S1 turn OFF.



Counter

(C0)



5



8



Y, M, S

(Y001, M1, S1)



X001, X002, X003 OFF



1 ms timer

(T246)



4



Basic

Instruction



RST

RST



42



• Operation of the routine timers T192 to T199

A routine timer continues its operation even if it is jumped

after the coil is driven, and the output contact is activated.



3



Before

Programming



11th

circuit



X011



Y001



Specified the

Device &

Constant



25



• Double coil operation of output Y001

While X000 is OFF, output Y001 is activated by X001.

While X000 is ON, output Y001 is activated by X012.

Even in a program divided by conditional jumps, if the same

coil (Y000 in this case) is programmed two or more times

within the jump area or outside the jump area, such a coil is

handled as double coil.



P 8



Devices

in Detail



15



X001



FNC 00

CJ



Instruction

List



6



X000



2

Overview



1. Circuit example 1 for explaining operations



Introduction



8.1.1



8.1 FNC 00 – CJ / Conditional Jump



FNC instruction is not executed during jump.

But instructions FNC 52 to FNC 58 continue their operations.



10

FNC20-FNC29

Arith. & Logic

Operation



225



FX3S/FX3G/FX3GC/FX3U/FX3UC Series



8 Program Flow – FNC 00 to FNC 09



Programming Manual - Basic & Applied Instruction Edition



8.1 FNC 00 – CJ / Conditional Jump



2. Circuit example 2 for explaining operations (when only an RST instruction for a timer or counter

is jumped)

X012



C0



X011



K10



FNC 00

CJ



X010



When X011 turns ON while the RST instruction for the

counter C0 is operating (X010 is ON), the program

execution jumps past the RST instruction due to the CJ

(FNC 00) instruction.

In this jump status, the counter C0 remains reset.

Accordingly, the current value of C0 remains "0" even if

X012 turns ON.

To clear this reset status, it is necessary to turn OFF

the RST instruction for counter C0. (Refer to the

program shown below.)



P0



RST



C0



Label

P0



Timing chart

Jump operation by CJ

instruction driven by X011

X012

Because C0 remains



Current

value of C0



1



Counter reset, its current value

is reset. remains unchanged



3



2



even if X012 turns ON.



X010



1



2



ON



RST

C0



Remains reset.



Program example for activating a timer and counter even during a jump

X012



C0



X011



K10



FNC 00

CJ



X010



P0



RST



C0



RST



C0



Label

P0

M8000



Clears the reset status of

counter C0 during jump.



Timing chart

Jump operation by CJ

instruction driven by X011

X012



Current

value of C0



1



2



Counter

is reset.



3



1



X010



3



5



ON



RST

C0

*1



226



2



4



*1 In the same operation cycle as the

reset, the reset status of counter

C0 is cleared.



FX3S/FX3G/FX3GC/FX3U/FX3UC Series



8 Program Flow – FNC 00 to FNC 09



Programming Manual - Basic & Applied Instruction Edition



1



Relationship between master control instruction and jump instruction



Introduction



The figure below shows the contents of operation and the relationship between the master control instruction.

Avoid using [2], [4] and [5] because the operation will be complicated.



2



CJ P 0



MC N 0 M 1

CJ P 4

MCR N 0



[5] Jump from

inside MC

to inside

another

MC



CJ P 2



CJ P 3



MCR N 0



5



Jump is enabled while M1 is ON.

In circuits after jump, M2 is regarded as ON

regardless of the actual ON/OFF status of M2.

And the first MCR N0 is ignored.



Specified the

Device &

Constant



MCR N 0



[4] Jump from inside MC to

outside MC

Jump is disabled while

M0 is OFF.

Jump is executed while

M0 is ON, but MCR is

invalid.



4



P 4



Devices

in Detail



P 2



Master control



MC N 0 M 2

[3] Jump from inside MC to

inside MC

Jump is disabled while

M0 is OFF.



3

Instruction

List



P 1



[2] Jump from outside MC

to inside MC

Jump is executed

regardless of the MC

operation.

Even if M0 is OFF, M0

is regarded as ON after

P1.



Master control



MC N 0 M 0



[1] Jump from outside MC

to outside MC

Jump is available

arbitrarily.



Overview



CJ P 1



Master control



8.1.2



8.1 FNC 00 – CJ / Conditional Jump



P 3



6

Before

Programming



P 0



7

Basic

Instruction



8

FNC00-FNC09

Program Flow



9

FNC10-FNC19

Move & Compare



10

FNC20-FNC29

Arith. & Logic

Operation



227



FX3S/FX3G/FX3GC/FX3U/FX3UC Series



8 Program Flow – FNC 00 to FNC 09



Programming Manual - Basic & Applied Instruction Edition



8.2 FNC 01 – CALL / Call Subroutine



8.2



FNC 01 – CALL / Call Subroutine



Outline

This instruction calls and executes a program which should be processed commonly in a sequence program.

This instruction reduces the number of program steps, and achieves efficient program design.

For creating a subroutine program, FEND (FNC 06) and SRET (FNC 02) instructions are required.



1. Instruction format



FNC 01

CALL



16-bit Instruction



P



3 steps



Mnemonic



Operation Condition



32-bit Instruction



Mnemonic



CALL

CALLP



Operation Condition







Continuous

Operation

Pulse (Single)

Operation







2. Set data

Operand type



Description



Data type



Pointer number (P) indicating the label number for the jump destination

(FX3S: P0 to P62 and P64 to P255, FX3G/FX3GC: P0 to P62 and P64 to P2047,

FX3U/FX3UC: P0 to P62 and P64 to P4095)



Pn



Pointer number



P63 is dedicated to CJ (FNC 00) instruction (for jump to END step), it cannot be used as a pointer for CALL (FNC 01)

instruction.



3. Applicable devices

Operand

Type



Bit Devices

System User



Word Devices

Digit Specification



System User



X Y M T C S D .b KnX KnY KnM KnS T



Others

Special

Unit



C D R U \G



Index

V



Constant



Z Modify K



H



Real

CharacPointer

Number ter String

E



" "



P



Pn



Explanation of function and operation

1. 16-bit operation

While the command input is ON, CALL instruction is executed and the program execution jumps to a step with a label

Pn .

Then, a subroutine program with the label Pn is executed.

When SRET (FNC 02) instruction is executed, the program execution returns to the step after CALL instruction.

• At the end of the main program, put FEND instruction.

• Put a label (P) for CALL instruction after FEND instruction.

User program

Command



FNC 01

CALL

User program



Label

Pn



Main program

Program area from the step 0 to FEND

instruction



FNC 06

FEND

M8000

RUN monitor

(normally ON)



User program

FNC 02

SRET



228



Pn

Pn



Subroutine program

Program area from a label Pn

instruction



to SRET



FX3S/FX3G/FX3GC/FX3U/FX3UC Series



8 Program Flow – FNC 00 to FNC 09



Programming Manual - Basic & Applied Instruction Edition



8.2 FNC 01 – CALL / Call Subroutine



1

Introduction



Caution

1. Using a label (P) number two or more times

In CALL instructions, the same number can be used two or more times in operands (P).

However, do not use a label (P) and number used in another instruction (CJ instruction).

FNC 00

CJ



X030



FNC 01

CALLP



P9



2



P9



Overview



X020



Bad



3

User program



Instruction

List



Label

P9



1. Example of fundamental use (no nesting)



4



Program examples



FNC 01

CALL



Devices

in Detail



X000



P 10

Main program

While X000 is ON, the program execution jumps to a

step with the label P10.



FNC 06

FEND



5

Specified the

Device &

Constant



Label

P 10



Subroutine program

When SRET instruction is executed after the subroutine

program has executed, the program execution returns to

the original step +1.



FNC 02

SRET



6

Before

Programming



END



2. Example of multiple CALL instructions in subroutines (multiple nesting)

CALL instruction can be used up to 4 times in subroutine programs. Nesting of up to five layers is allowed.

FNC 01

CALLP



P 11



FNC 06

FEND

Label

P 11



Label

P 12



FNC 01

CALL

FNC 02

SRET



P 12



Main program

When X001 turns from OFF to ON, the program execution

jumps to the label P11 only once.



8



Subroutine program 1

When SRET instruction is executed, the program

execution returns to the main program.

If X002 is ON while the subroutine program 1 is

executed, the program execution jumps to a step with the

label P12.



FNC00-FNC09

Program Flow



X002



Basic

Instruction



X001



7



X003



FNC10-FNC19

Move & Compare



FNC 02

SRET



9



Subroutine program 2

The subroutine program with P12 is executed, and then

the program execution returns to the subroutine program

with P11 by SRET instruction.



END



10

FNC20-FNC29

Arith. & Logic

Operation



229



Xem Thêm
Tải bản đầy đủ (.pdf) (964 trang)

×