The text of a manual · part 21 of 68
Programmable Controllers C200HX-CPU-ZE, C200HG-CPU-ZE, C200HE-CPU-ZE Operation Manual: SECTION 5 Instruction Set, pages 174 to 183
Pages 174 to 183 of 613, from Programmable Controllers C200HX-CPU-ZE, C200HG-CPU-ZE, C200HE-CPU-ZE Operation Manual
The original document is the PDF (3.8 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
Filed in the catalog under the Omron C200H-SP001 and Omron C200HW-PA204
Page 174
Section
Bit Control Instructions
5-9
OUT turns ON the designated bit for an ON execution condition, and turns OFF the designated bit for an OFF execution condition. With a TR bit, OUT appears at a branching point rather than at the end of an instruction line. Refer to 4-7-7 Branching Instruction Lines for details. OUT NOT turns ON the designated bit for a OFF execution condition, and turns OFF the designated bit for an ON execution condition. OUT and OUT NOT can be used to control execution by turning ON and OFF bits that are assigned to conditions on the ladder diagram, thus determining execution conditions for other instructions. This is particularly helpful and allows a complex set of conditions to be used to control the status of a single work bit, and then that work bit can be used to control other instructions. The length of time that a bit is ON or OFF can be controlled by combining the OUT or OUT NOT with TIM. Refer to Examples under 5-14-1 TIMER – TIM for details. Flags
There are no flags affected by these instructions.
5-9-2 DIFFERENTIATE UP and DOWN – DIFU(013) and DIFD(014) Ladder Symbols
Operand Data Areas
DIFU(013) B
B: Bit IR, AR, HR, LR, SR
DIFD(014) B
B: Bit IR, AR, HR, LR, SR
Limitations
Any output bit can generally be used in only one instruction that controls its status. Refer to 3-3 IR Area for details.
Description
DIFU(013) and DIFD(014) are used to turn the designated bit ON for one cycle only. Whenever executed, DIFU(013) compares its current execution with the previous execution condition. If the previous execution condition was OFF and the current one is ON, DIFU(013) will turn ON the designated bit. If the previous execution condition was ON and the current execution condition is either ON or OFF, DIFU(013) will either turn the designated bit OFF or leave it OFF (i.e., if the designated bit is already OFF). The designated bit will thus never be ON for longer than one cycle, assuming it is executed each cycle (see Precautions, below). Whenever executed, DIFD(014) compares its current execution with the previous execution condition. If the previous execution condition was ON and the current one is OFF, DIFD(014) will turn ON the designated bit. If the previous execution condition was OFF and the current execution condition is either ON or OFF, DIFD(014) will either turn the designated bit OFF or leave it OFF. The designated bit will thus never be ON for longer than one cycle, assuming it is executed each cycle (see Precautions, below). These instructions are used when differentiated instructions (i.e., those prefixed with an @) are not available and single-cycle execution of a particular instruction is desired. They can also be used with non-differentiated forms of instructions that have differentiated forms when their use will simplify programming. Examples of these are shown below.
Flags
162
There are no flags affected by these instructions.
Page 175
Section
Bit Control Instructions
5-9
Precautions
DIFU(013) and DIFD(014) operation can be uncertain when the instructions are programmed between IL and ILC, between JMP and JME, or in subroutines. Refer to 5-10 INTERLOCK and INTERLOCK CLEAR – IL(002) and ILC(003), 5-11 JUMP and JUMP END – JMP(004) and JME(005), and 5-24 Subroutines and Interrupt Control for details.
Example 1: When There is No Differentiated Instruction
In diagram A, below, whenever CMP(020) is executed with an ON execution condition it will compare the contents of the two operand words (HR 10 and DM 0000) and set the arithmetic flags (GR, EQ, and LE) accordingly. If the execution condition remains ON, flag status may be changed each cycle if the content of one or both operands change. Diagram B, however, is an example of how DIFU(013) can be used to ensure that CMP(020) is executed only once each time the desired execution condition goes ON.
00000 CMP(020) HR 10
Diagram A
DM 0000
Address
Instruction
00000 00001
LD CMP(020)
Operands 00000 HR 10 DM 0000
00000 DIFU(013) 22500 22500 CMP(020) HR 10
Diagram B
DM 0000
Address
Instruction
00000 00001 00002 00003
LD DIFU(013) LD CMP(020)
Operands 00000 22500 22500 HR 10 DM 0000
Example 2: Simplifying Programming
Although a differentiated form of MOV(021) is available, the following diagram would be very complicated to draw using it because only one of the conditions determining the execution condition for MOV(021) requires differentiated treatment.
00000 DIFU(013) 22500 22500 MOV(021) 00001
00002
00003
HR 10 DM 0000
00004
00005
Address
Instruction
00000 00001 00002 00003 00004 00005 00006 00007 00008 00009 00010
LD DIFU(013) LD LD AND NOT AND NOT OR LD LD AND NOT OR LD MOV(021)
Operands 00000 22500 22500 00001 00002 00003 --00004 00005 --HR 10 DM 0000
163
Page 176
Section
Bit Control Instructions
5-9
5-9-3 SET and RESET – SET and RSET Ladder Symbols
Operand Data Areas B: Bit
SET B
IR, SR, AR, HR, LR
B: Bit
RSET B
IR, SR, AR, HR, LR
Description
SET turns the operand bit ON when the execution condition is ON, and does not affect the status of the operand bit when the execution condition is OFF. RSET turns the operand bit OFF when the execution condition is ON, and does not affect the status of the operand bit when the execution condition is OFF. The operation of SET differs from that of OUT because the OUT instruction turns the operand bit OFF when its execution condition is OFF. Likewise, RSET differs from OUT NOT because OUT NOT turns the operand bit ON when its execution condition is OFF. Note The instructions SET and RESET are input as follows: Operand SET: RESET:
Operand
Precautions
The status of operand bits for SET and RSET programmed between IL(002) and ILC(003) or JMP(004) and JME(005) will not change when the interlock or jump condition is met (i.e., when IL(002) or JMP(004) is executed with an OFF execution condition).
Flags
There are no flags affected by these instructions.
Examples
The following examples demonstrate the difference between OUT and SET/ RSET. In the first example (Diagram A), IR 10000 will be turned ON or OFF whenever IR 00000 goes ON or OFF. In the second example (Diagram B), IR 10000 will be turned ON when IR 00001 goes ON and will remain ON (even if IR 00001 goes OFF) until IR 00002 goes ON. 00000 10000
Diagram A
Address
Instruction
00000 00001
LD OUT
Address
Instruction
00000 00001 00002 00003
LD SET LD RSET
Operands 00000 10000
00001 SET 10000 00002 RSET 10000
Diagram B
164
Operands 00001 10000 00002 10000
Page 177
Section
Bit Control Instructions
5-9
5-9-4 KEEP – KEEP(011) Ladder Symbol
Operand Data Areas S
B: Bit
KEEP(011) B
IR, AR, HR, LR
R
Limitations
Any output bit can generally be used in only one instruction that controls its status. Refer to 3-3 IR Area for details.
Description
KEEP(011) is used to maintain the status of the designated bit based on two execution conditions. These execution conditions are labeled S and R. S is the set input; R, the reset input. KEEP(011) operates like a latching relay that is set by S and reset by R. When S turns ON, the designated bit will go ON and stay ON until reset, regardless of whether S stays ON or goes OFF. When R turns ON, the designated bit will go OFF and stay OFF until reset, regardless of whether R stays ON or goes OFF. The relationship between execution conditions and KEEP(011) bit status is shown below. S execution condition R execution condition
Status of B
KEEP(011) operates like the self-maintaining bit described in 4-8-3 Self-maintaining Bits. The following two diagrams would function identically, though the one using KEEP(011) requires one less instruction to program and would maintain status even in an interlocked program section. 00002
00003
Address
Instruction
00000 00001 00002 00003
LD OR AND NOT OUT
S
Address
Instruction
R
00000 00001 00002
LD LD KEEP(011)
00500 00500
00002
KEEP(011) 00500
00003
Operands 00002 00500 00003 00500
Operands 00002 00003 00500
Flags
There are no flags affected by this instruction.
Precautions
Exercise caution when using a KEEP reset line that is controlled by an external normally closed device. Never use an input bit in an inverse condition on the reset (R) for KEEP(011) when the input device uses an AC power supply. The delay in shutting down the PC’s DC power supply (relative to the AC power supply
165
Page 178
Section
Bit Control Instructions
5-9 to the input device) can cause the designated bit of KEEP(011) to be reset. This situation is shown below. Input Unit A
S KEEP(011)
NEVER
B
A R
Bits used in KEEP are not reset in interlocks. Refer to the 5-10 INTERLOCK – and INTERLOCK CLEAR IL(002) and ILC(003) for details. Example
If a HR bit or an AR bit is used, bit status will be retained even during a power interruption. KEEP(011) can thus be used to program bits that will maintain status after restarting the PC following a power interruption. An example of this that can be used to produce a warning display following a system shutdown for an emergency situation is shown below. Bits 00002, 00003, and 00004 would be turned ON to indicate some type of error. Bit 00005 would be turned ON to reset the warning display. HR 0000, which is turned ON when any one of the three bits indicates an emergency situation, is used to turn ON the warning indicator through 00500.
00002
S KEEP(011)
00003
Indicates emergency situation
HR 0000
00004 R Reset input 00005
HR 0000 00500
Address
Instruction
00000 00001 00002 00003 00004 00005 00006
LD OR OR LD KEEP(011) LD OUT
Operands 00002 00003 00004 00005 HR 0000 HR 0000 00500
Activates warning display
KEEP(011) can also be combined with TIM to produce delays in turning bits ON and OFF. Refer to 5-14-1 TIMER – TIM for details.
5-9-5 BIT TEST: TST(350) and TSTN(351) Ladder Symbols
Operand Data Areas
TST(350)
TSTN(351)
S: Source word
S
S
IR, SR, AR, DM, EM, HR, LR
N
N
N: Bit number
---
---
IR, SR, AR, DM, EM, HR, TC, LR, #
Limitations
Any output bit can generally be used in only one instruction that controls its status. Refer to 3-3 IR Area for details.
Description
TST(350) turns ON the execution condition when the specified bit in the specified word is ON and turns OFF the execution condition when the bit is OFF. TSTN(351) turns OFF the execution condition when the specified bit in the specified word is ON and turns ON the execution condition when the bit is OFF.
166
Page 179
Section 5-10
INTERLOCK and INTERLOCK CLEAR – IL(002) and ILC(003)
The bit position is designated in N between 0000 and 0015 in BCD. Precautions
TST(350) and TSTN(351) cannot be used as right-hand instructions, i.e., another instruction must appear between them and the right bus bar. N must be BCD between 0000 and 0015.
Flags
ER:
N is not BCD from 0000 to 0015. The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.
Example
In the first instruction line below, when IR 00000 turns ON, TST(350) checks whether the designated bit (bit 00 in DM 0010) is ON or OFF. In this case, because it is ON, IR 05000 is turned ON. In the second instruction line below, when IR 00001 turns ON, TST(350) checks whether the designated bit (bit 05 in DM 0020) is ON or OFF. In this case, because it is OFF, IR 05001 is turned ON.
00000 05000
TST(350) DM 0010
Address
Instruction
00000
LD
00001
TST(350)
#0000
Operands 00000 DM 0010 #0000
00001 05001
TSTN(351)
00002
OUT
05000
DM 0020
00003
LD
00001
#0005
00004
TSTN(351) DM 0020 #0005
00005
OUT
05001
DM 0010 Designated bit
DM 0020 Designated bit
5-10 INTERLOCK and INTERLOCK CLEAR – IL(002) and ILC(003)
Description
Ladder Symbol
IL(002)
Ladder Symbol
ILC(003)
IL(002) is always used in conjunction with ILC(003) to create interlocks. Interlocks are used to enable branching in the same way as can be achieved with TR bits, but treatment of instructions between IL(002) and ILC(003) differs from that with TR bits when the execution condition for IL(002) is OFF. If the execution condition of IL(002) is ON, the program will be executed as written, with an ON execution condition used to start each instruction line from the point where IL(002) is located through the next ILC(003). Refer to 4-7-7 Branching Instruction Lines for basic descriptions of both methods.
167
Page 180
Section 5-10
INTERLOCK and INTERLOCK CLEAR – IL(002) and ILC(003)
If the execution condition for IL(002) is OFF, the interlocked section between IL(002) and ILC(003) will be treated as shown in the following table: Instruction
Treatment
OUT and OUT NOT
Designated bit turned OFF.
SET and RSET
Bit status maintained.
TIM and TIMH(015)
Reset.
TTIM(087)
PV maintained.
CNT, CNTR(012)
PV maintained.
KEEP(011)
Bit status maintained.
DIFU(013) and DIFD(014)
Not executed (see the following DIFU(013) and DIFD(014) in Interlocks). Not executed.
All others
IL(002) and ILC(003) do not necessarily have to be used in pairs. IL(002) can be used several times in a row, with each IL(002) creating an interlocked section through the next ILC(003). ILC(003) cannot be used unless there is at least one IL(002) between it and any previous ILC(003). DIFU(013) and DIFD(014) in Interlocks
Changes in the execution condition for a DIFU(013) or DIFD(014) are not recorded if the DIFU(013) or DIFD(014) is in an interlocked section and the execution condition for the IL(002) is OFF. When DIFU(013) or DIFD(014) is execution in an interlocked section immediately after the execution condition for the IL(002) has gone ON, the execution condition for the DIFU(013) or DIFD(014) will be compared to the execution condition that existed before the interlock became effective (i.e., before the interlock condition for IL(002) went OFF). The ladder diagram and bit status changes for this are shown below. The interlock is in effect while 00000 is OFF. Notice that 01000 is not turned ON at the point labeled A even though 00001 has turned OFF and then back ON.
00000 IL(002) 00001 DIFU(013) 01000 ILC(003)
A
Address
Instruction
00000 00001 00002 00003 00004
LD IL(002) LD DIFU(013) ILC(003)
Operands 00000 00001 01000
ON
00000
OFF ON
00001
OFF ON
01000
OFF
Precautions
There must be an ILC(003) following any one or more IL(002). Although as many IL(002) instructions as are necessary can be used with one ILC(003), ILC(003) instructions cannot be used consecutively without at least one IL(002) in between, i.e., nesting is not possible. Whenever a ILC(003) is executed, all interlocks between the active ILC(003) and the preceding ILC(003) are cleared. When more than one IL(002) is used with a single ILC(003), an error message will appear when the program check is performed, but execution will proceed normally.
Flags
168
There are no flags affected by these instructions.
Page 181
Section 5-11
JUMP and JUMP END – JMP(004) and JME(005) Example
The following diagram shows IL(002) being used twice with one ILC(003). 00000 IL(002) 00001 TIM TIM511 511 #0015
001.5 s
Address
Instruction
00000 00001 00002 00003
LD IL(002) LD TIM
00004 00005 00006 00007 00008 00009
LD IL(002) LD AND NOT LD CNT
00010 00011 00012
LD OUT ILC(003)
Operands 00000
00002 IL(002) 00003 00100
00004
CP R
CNT 001 IR 010
00005 00502
ILC(003)
00001 511 #0015 00002 00003 00004 00100 001 010 00005 00502
When the execution condition for the first IL(002) is OFF, TIM 511 will be reset to 1.5 s, CNT 001 will not be changed, and 00502 will be turned OFF. When the execution condition for the first IL(002) is ON and the execution condition for the second IL(002) is OFF, TIM 511 will be executed according to the status of 00001, CNT 001 will not be changed, and 00502 will be turned OFF. When the execution conditions for both the IL(002) are ON, the program will execute as written.
5-11 JUMP and JUMP END – JMP(004) and JME(005) Ladder Symbols JMP(004) N
Definer Values N: Jump number # (00 to 99)
JME(005) N
N: Jump number # (00 to 99)
Limitations
Jump numbers 01 through 99 may be used only once in JMP(004) and once in JME(005), i.e., each can be used to define one jump only. Jump number 00 can be used as many times as desired.
Description
JMP(004) is always used in conjunction with JME(005) to create jumps, i.e., to skip from one point in a ladder diagram to another point. JMP(004) defines the point from which the jump will be made; JME(005) defines the destination of the jump. When the execution condition for JMP(004) in ON, no jump is made and the program is executed consecutively as written. When the execution condition for JMP(004) is OFF, a jump is made to the JME(005) with the same jump number and the instruction following JME(005) is executed next. If the jump number for JMP(004) is between 01 and 99, jumps, when made, will go immediately to JME(005) with the same jump number without executing any instructions in between. The status of timers, counters, bits used in OUT, bits used in OUT NOT, and all other status bits controlled by the instructions between JMP(004) and JMP(005) will not be changed. Each of these jump numbers can be used to define only one jump. Because all of instructions between JMP(004) and JME(005) are skipped, jump numbers 01 through 99 can be used to reduce cycle time.
169
Page 182
Section 5-13
NO OPERATION – NOP(000)
If the jump number for JMP(004) is 00, the CPU Unit will look for the next JME(005) with a jump number of 00. To do so, it must search through the program, causing a longer cycle time (when the execution condition is OFF) than for other jumps. The status of timers, counters, bits used in OUT, bits used in OUT NOT, and all other status controlled by the instructions between JMP(004) 00 and JMP(005) 00 will not be changed. jump number 00 can be used as many times as desired. A jump from JMP(004) 00 will always go to the next JME(005) 00 in the program. It is thus possible to use JMP(004) 00 consecutively and match them all with the same JME(005) 00. It makes no sense, however, to use JME(005) 00 consecutively, because all jumps made to them will end at the first JME(005) 00. DIFU(013) and DIFD(014) in Jumps
Although DIFU(013) and DIFD(014) are designed to turn ON the designated bit for one cycle, they will not necessarily do so when written between JMP(004) and JME (005). Once either DIFU(013) or DIFD(014) has turned ON a bit, it will remain ON until the next time DIFU(013) or DIFD(014) is executed again. In normal programming, this means the next cycle. In a jump, this means the next time the jump from JMP(004) to JME(005) is not made, i.e., if a bit is turned ON by DIFU(013) or DIFD(014) and then a jump is made in the next cycle so that DIFU(013) or DIFD(014) are skipped, the designated bit will remain ON until the next time the execution condition for the JMP(004) controlling the jump is ON.
Precautions
When JMP(004) and JME(005) are not used in pairs, an error message will appear when the program check is performed. Although this message also appears if JMP(004) 00 and JME(005) 00 are not used in pairs, the program will execute properly as written.
Flags
There are no flags affected by these instructions.
Examples
Examples of jump programs are provided in 4-7-8 Jumps.
5-12 END – END(001) Ladder Symbol
Description
END(001)
END(001) is required as the last instruction in any program. If there are subroutines, END(001) is placed after the last subroutine. No instruction written after END(001) will be executed. END(001) can be placed anywhere in the program to execute all instructions up to that point, as is sometimes done to debug a program, but it must be removed to execute the remainder of the program. If there is no END(001) in the program, no instructions will be executed and the error message “NO END INST” will appear.
Flags
END(001) turns OFF the ER, CY, GR, EQ, and LE Flags.
5-13 NO OPERATION – NOP(000) Description
NOP(000) is not generally required in programming and there is no ladder symbol for it. When NOP(000) is found in a program, nothing is executed and the program execution moves to the next instruction. When memory is cleared prior to programming, NOP(000) is written at all addresses. NOP(000) can be input through the 00 function code.
Flags
There are no flags affected by NOP(000).
170
Page 183
Section 5-14
Timer and Counter Instructions
5-14 Timer and Counter Instructions TIM and TIMH are decrementing ON-delay timer instructions which require a TC number and a set value (SV). CNT is a decrementing counter instruction and CNTR is a reversible counter instruction. Both require a TC number and a SV. Both are also connected to multiple instruction lines which serve as an input signal(s) and are reset. Any one TC number cannot be defined twice, i.e., once it has been used as the definer in any of the timer or counter instructions, it cannot be used again. Once defined, TC numbers can be used as many times as required as operands in instructions other than timer and counter instructions. TC numbers run from 000 through 511. No prefix is required when using a TC number as a definer in a timer or counter instruction. Once defined as a timer, a TC number can be prefixed with TIM for use as an operand in certain instructions. The TIM prefix is used regardless of the timer instruction that was used to define the timer. Once defined as a counter, a TC number can be prefixed with CNT for use as an operand in certain instructions. The CNT is also used regardless of the counter instruction that was used to define the counter. TC numbers can be designated as operands that require either bit or word data. When designated as an operand that requires bit data, the TC number accesses a bit that functions as a ‘Completion Flag’ that indicates when the time/count has expired, i.e., the bit, which is normally OFF, will turn ON when the designated SV has expired. When designated as an operand that requires word data, the TC number accesses a memory location that holds the present value (PV) of the timer or counter. The PV of a timer or counter can thus be used as an operand in CMP(020), or any other instruction for which the TC area is allowed. This is done by designating the TC number used to define that timer or counter to access the memory location that holds the PV. Note that “TIM 000” is used to designate the TIMER instruction defined with TC number 000, to designate the Completion Flag for this timer, and to designate the PV of this timer. The meaning of the term in context should be clear, i.e., the first is always an instruction, the second is always a bit operand, and the third is always a word operand. The same is true of all other TC numbers prefixed with TIM or CNT. An SV can be input as a constant or as a word address in a data area. If an IR area word assigned to an Input Unit is designated as the word address, the Input Unit can be wired so that the SV can be set externally through thumbwheel switches or similar devices. Timers and counters wired in this way can only be set externally during RUN or MONITOR mode. All SVs, including those set externally, must be in BCD.
5-14-1 TIMER – TIM Definer Values N: TC number
Ladder Symbol
# (000 through 511) TIM N SV
Operand Data Areas SV: Set value (word, BCD) IR, AR, DM, EM, HR, LR, #, SR
Limitations
SV is between 000.0 and 999.9. The decimal point is not entered.
171