The text of a manual · part 31 of 60
C200HX/C200HG/C200HE Programmable Controllers Operation Manual, pages 294 to 303
Pages 294 to 303 of 586
The original document is the PDF (3.4 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.
For the Omron C200HE-CPU42-E
Page 294
Section 5-21
Special Math Instructions Creating the Program Follow the procedure outlined below in creating the program. 1, 2, 3...
1. Set the target value (binary 0000 to 0FFF) in DM 0000. 2. Input the PV of the temperature sensing element (binary 000 to 0FFF) in bits 0 to 11 of word 101. 3. Output the operation amount of the heater to bits 0 to 11 of word 110 by means of the first PID(––) instruction in the following program. 4. Output the operation amount of the fan to bits 0 to 11 of word 111 by means of the second PID(––) instruction in the following program. 5. Convert the PV of the temperature sensing element (binary 000 to FFF) to temperature data (0000°C to 0200°C) by means of SCL(––), and output it to DM 0200. Program
00000
25315 @MOV(21) #0F00
Target value
DM0000
@MOV(21) DM0000
Parameter leading word for first PID(––) instruction
HR00
@MOV(21) DM0000 HR40
PID(––)
Parameter leading word for second PID(––) instruction
PV of temperature sensing element
101 HR00
Heater operation amount
110
PID(––) 101 HR40
Fan operation amount
111
SCL 101
PV of temperature sensing element (binary) Leading word of converted parameter
DM0100 DM0200
END
276
Present temperature of temperature sensing element (°C)
Page 295
Section 5-22
Logic Instructions
Note When using PID(––) or SCL(––), make the data settings in advance with a Peripheral Device such as the Programming Console or SSS. Heater HR 00
(DM0000)
Target value HR
HR 01
0080
Proportional band
HR 02
0200
Integral time/sampling period
HR 03
0100
Derivative time/sampling period
HR 04
0001
Sampling period
HR 05
0000
HR 06
0404
Forward/reverse designation/ PID parameters I/O range and time unit settings
SCL Parameters
Fan
DM 0100
0000
HR 40
(DM0000)
DM 0101
0000
HR 41
0060
DM 0102
0200
HR 42
0150
DM 0103
0FFF
HR 43
0100
HR 44
0001
HR 45
0001
HR 46
0404
5-22 Logic Instructions The logic instructions – COM(29), ANDW(34), ORW(35), XORW(36), and XNRW(37) – perform logic operations on word data.
5-22-1 COMPLEMENT – COM(29) Ladder Symbols
Description
Operand Data Areas
COM(29)
@COM(29)
Wd
Wd
Wd: Complement word IR, SR, AR, DM, HR, LR
When the execution condition is OFF, COM(29) is not executed. When the execution condition is ON, COM(29) clears all ON bits and sets all OFF bits in Wd. COM(29) will alternate between complements of Wd each cycle while the execution condition is ON; Use @COM(29) when necessary. 15
Example Original
1
00 0
0
1
1
0
0
1
1
0
0
1
1
0
0
15 Complement 0
1
00 1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
277
Page 296
Section 5-22
Logic Instructions Flags
ER:
Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)
EQ:
ON when the result is 0.
N:
ON when bit 15 of Wd is set to 1.
5-22-2 LOGICAL AND – ANDW(34) Operand Data Areas Ladder Symbols
I1: Input 1 IR, SR, AR, DM, HR, TC, LR, #
Description
ANDW(34)
@ANDW(34)
I1
I1
I2
I2
R
R
I2: Input 2 IR, SR, AR, DM, HR, TC, LR, # R: Result word IR, SR, AR, DM, HR, LR
When the execution condition is OFF, ANDW(34) is not executed. When the execution condition is ON, ANDW(34) logically AND’s the contents of I1 and I2 bit-by-bit and places the result in R. 15
Example I1
1
00 0
0
1
1
0
0
1
1
0
0
1
1
0
0
15
I2
0
00 1
0
1
0
1
0
1
0
1
0
1
0
1
0
15
R Flags
278
0
1
1
00 0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
ER:
Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)
EQ:
ON when the result is 0.
N:
ON when bit 15 of R is set to 1.
Page 297
Section 5-22
Logic Instructions
5-22-3 LOGICAL OR – ORW(35) Operand Data Areas I1: Input 1
Ladder Symbols
IR, SR, AR, DM, HR, TC, LR, #
Description
ORW(35)
@ORW(35)
I1
I1
I2
I2
R
R
I2: Input 2 IR, SR, AR, DM, HR, TC, LR, # R: Result word IR, SR, AR, DM, HR, LR
When the execution condition is OFF, ORW(35) is not executed. When the execution condition is ON, ORW(35) logically OR’s the contents of I1 and I2 bitby-bit and places the result in R. 15
Example I1
1
00 0
0
1
1
0
0
1
1
0
0
1
1
0
0
15
I2
0
00 1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
1
0
1
1
1
0
1
1
1
0
1
1
1
0
1
15
R Flags
1
1
00
ER:
Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)
EQ:
ON when the result is 0.
N:
ON when bit 15 of R is set to 1.
279
Page 298
Section 5-22
Logic Instructions
5-22-4 EXCLUSIVE OR – XORW(36) Operand Data Areas I1: Input 1
Ladder Symbols
IR, SR, AR, DM, HR, TC, LR, #
Description
XORW(36)
@XORW(36)
I1
I1
I2
I2
R
R
I2: Input 2 IR, SR, AR, DM, HR, TC, LR, # R: Result word IR, SR, AR, DM, HR, LR
When the execution condition is OFF, XORW(36) is not executed. When the execution condition is ON, XORW(36) exclusively OR’s the contents of I1 and I2 bit-by-bit and places the result in R. 15
Example I1
1
00 0
0
1
1
0
0
1
1
0
0
1
1
0
0
15
I2
0
00 1
0
1
0
1
0
1
0
1
0
1
0
1
0
15
R Flags
280
1
1
1
00 1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
ER:
Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)
EQ:
ON when the result is 0.
N:
ON when bit 15 of R is set to 1.
Page 299
Section 5-23
Subroutines and Interrupt Control
5-22-5 EXCLUSIVE NOR – XNRW(37) Operand Data Areas I1: Input 1
Ladder Symbols
IR, SR, AR, DM, HR, TC, LR, # XNRW(37)
@XNRW(37)
I1
I1
I2
I2
R
R
I2: Input 2
Description
IR, SR, AR, DM, HR, TC, LR, # R: Result word IR, SR, AR, DM, HR, LR
When the execution condition is OFF, XNRW(37) is not executed. When the execution condition is ON, XNRW(37) exclusively NOR’s the contents of I1 and I2 bit-by-bit and places the result in R. 15
I1
1
00 0
0
1
1
0
0
1
1
0
0
1
1
0
0
15
I2
0
00 1
0
1
0
1
0
1
0
1
0
1
0
1
0
15
R Flags
ER: EQ: N:
0
1
1
00 0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.) ON when the result is 0. ON when bit 15 of R is set to 1.
5-23 Subroutines and Interrupt Control 5-23-1 Subroutines Subroutines break large control tasks into smaller ones and enable you to reuse a given set of instructions. When the main program calls a subroutine, control is transferred to the subroutine and the subroutine instructions are executed. The instructions within a subroutine are written in the same way as main program code. When all the subroutine instructions have been executed, control returns to the main program to the point just after the point from which the subroutine was entered (unless otherwise specified in the subroutine). Subroutines may also be activated by interrupts or the MCRO(99) instruction. Interrupts
Like subroutine calls, interrupts cause a break in the flow of the main program execution such that the flow can be resumed from that point after completion of the subroutine. An interrupt is caused either by an external source, such as an input signal from an Interrupt Input Unit, or a scheduled interrupt. In the case of the scheduled interrupt, the interrupt signal is repeated at regular intervals. Whereas subroutine calls are controlled from within the main program, subroutines activated by interrupts are triggered when the interrupt signal is received. In the case of the scheduled interrupt, the time interval between interrupts is set by the user and is unrelated to the cycle timing of the PC. This capability is useful for periodic supervisory or executive program execution.
281
Page 300
Section 5-23
Subroutines and Interrupt Control
INT(89) is used to control the interrupt signals received from the Interrupt Input Unit, and also to control the scheduling of the scheduled interrupt. INT(89) provides such functions as masking of interrupts (so that they are recorded but ignored) and clearing of interrupts. Refer to 5-23-2 Interrupts for more details on interrupts. MCRO(99)
The MACRO instruction allows a single subroutine (programming pattern) to replace several subroutines that have identical structure but different operands. Since a number of similar program sections can be managed with just one subroutine, the number of program steps can be greatly reduced. Refer to 5-23-5 MACRO – MCRO(99) for more details on this instruction.
5-23-2 Interrupts The C200HX/HG/HE PCs support both input interrupts and scheduled interrupts. Interrupts stop execution of the program to run a subroutine in must be executed immediately (input interrupts from an Interrupt Input Unit) or subroutines that must be executed periodically (scheduled interrupts). There are two interrupt modes. In normal mode the CPU Unit waits until the current process is completed before stopping the main program. In high-speed mode the CPU Unit interrupts the current process. The normal mode is the default mode in C200HX/HG/HE PCs, but high-speed mode can be selected in the PC Setup. Normal Interrupt Mode
The following setting is used for normal interrupt mode. DM 6620
0
0
0
0
In normal interrupt mode, the following processing will be completed once started even if an interrupt occurs The interrupt will be processed as soon as the current process is completed. • Host Link servicing • Remote I/O servicing • Special I/O Unit servicing • Individual instruction execution Use this mode whenever using C200H interrupt subroutines without modification or whenever possible considering the response time required for interrupts. Note The C200HX/HG/HE is set to normal interrupt mode by default. High-speed Interrupt Mode
The following setting is used for high-speed interrupt mode. DM 6620
1
–
–
–
Interrupt mode (1 = high-speed)
In high-speed interrupt mode, the following processing will be interrupted and the interrupt subroutine executed as soon as an interrupt is generated. • Host Link servicing • Remote I/O servicing • Special I/O Unit servicing • Individual instruction execution Use this mode whenever interrupt response time must be accurate to 1.0 ms. Data will not necessarily be concurrent if the high-speed interrupt mode is used because Host Link servicing, remote I/O servicing, Special I/O Unit servicing, and individual instruction execution will not necessarily be completed when
282
Page 301
Section 5-23
Subroutines and Interrupt Control started. The program must be designed to allow for this when required by the application. (See the section on data concurrence for further details.) Input Interrupts
Input interrupts are executed when external inputs are received via an Interrupt Input Unit. Up to two Interrupt Input Units can be mounted to the CPU Rack and each Interrupt Input Unit provides 8 inputs numbered IN 0 through IN7. Inputs IN0 through IN7 on the first Unit generate interrupts #00 to #07 and inputs IN0 through IN7 on the second Unit generate interrupts #08 to #15. Generally speaking, subroutines #00 to #15 are executed when interrupts #00 to #15 are generated.
Scheduled Interrupts
Scheduled interrupts can be executed at intervals set either in increments of 10 ms or in increments or 1 ms. Interrupt #99 is used and subroutine #99 is executed. The unit used to set the scheduled interrupt interval is set in the PC Setup at DM 6622. Bit 15 DM 6622
00
Schedule Interrupt Setting Interval Setting Enable 00: Setting disabled (interval fixed at 10 ms) 01: Setting in bits 00 to 07 enabled Schedule Interrupt Setting Interval Setting 00: 10 ms 01: 1 ms
Interrupt Priority
The specified subroutine will be executed when an interrupt is generated. If further interrupts are generated during execution of an interrupt subroutine, they will not be processed until execution of the current interrupt subroutine has been completed. If more than one interrupt is generated or is awaiting execution at the same time, the corresponding subroutines will be executed in the following order of priority. Input interrupt 1 > input interrupt 2 > ... > input interrupt 7 > scheduled interrupt
Special I/O in Interrupt Subroutines
I/O for Special I/O Units can be refreshed from within interrupt subroutines by using the I/O REFRESH (IORF) instruction. If the high-speed interrupt mode is used, refreshing in the normal cycle (END refreshing and IORF refreshing in the main program) must be disabled for the Special I/O Unit that is to be refreshed in the interrupt subroutine. An interrupt programming error (system FAL error 8B) will occur if the same special I/O is refreshed both within an interrupt program and within the normal cycle, and the special I/O will not be refreshed within the interrupt subroutine. The PC Setup contains settings in DM 6620 that disable refreshing in the normal cycle for specific Special I/O Units. This settings are as shown below. DM6620 12
Bit 15
1
00
0
0
Interrupt mode (1 = high-speed)
*
*
*
*
*
*
*
*
*
*
Unit #0 Unit #1 . . . Unit #9
283
Page 302
Section 5-23
Subroutines and Interrupt Control
Note Disabling special I/O refreshing in the normal cycle to refresh special I/O in an interrupt subroutine is necessary only in the high-speed mode. Disabling normal cycle refreshing of special I/O during normal interrupt mode will be ignored and the special I/O will be refreshed both in the normal cycle and in the interrupt subroutine. The execution time of interrupt subroutines must be kept to less than10 ms if the high-speed interrupt mode is used and Special I/O Units, Host Link Units, or Remote I/O Units are programmed. An interrupt programming error (system FAL error 8B) will occur if the execution time is 10 ms or greater. The execution time of interrupt subroutine with the longest execution time is output to SR 262 and the number of the subroutine with the longest execution time is output to SR 263. Example: 12.3 ms for subroutine #80 SR 262
0
1
2
3
Maximum interrupt subroutine execution time (in 0.1 ms)
SR 263
8
0
*
*
No. of interrupt subroutine with maximum execution time
Note The above 10-ms limit does not apply when the normal interrupt mode is used or when the above Units are not mounted. Data Concurrence
Although data concurrence is not a problem for execution of normal arithmetic instructions or comparison instructions, it can be a problem when executing longer instructions that handle multiple words, such as block transfer instructions, when the high-speed interrupt mode is used and the same data is handled both in the main program and in an interrupt subroutine. Data may not be concurrent in two different situations: 1) if a data write operation in the main program is interrupted and the same data is read in an interrupt subroutine and 2) if a data read operation in the main program is interrupted and the same data is written in an interrupt subroutine. If you must handle the same data both in the main program and in an interrupt subroutine, use programming such as that shown below to be sure that data concurrence is preserved, i.e., mask interrupts while read/writing data that is also handled in an interrupt subroutine. Masks all interrupts.
(@)INT(89) 100 000 000
Reading and writing common data words
Unmasks all interrupts.
(@)INT(89) 200 000 000
Data concurrence can also be a problem if interrupts occur during data transfers occurring in servicing for Special I/O Units, remote I/O, or Host Link Systems. For any of these, data can be non-concurrent down to byte units. Use one of the following methods to preserve data concurrence in the above situations. The second methods applies to Special I/O Units only. • Mask interrupts in the main program while moving data transferred to/from Units to different words and use these alternate words in the interrupt subroutine.
284
Page 303
Section 5-23
Subroutines and Interrupt Control
• Use the I/O REFRESH instruction in interrupt subroutines to refresh required I/O from Special I/O Units and mask interrupts in the main program while reading/writing Special I/O Unit words.
5-23-3 SUBROUTINE ENTER – SBS(91) Ladder Symbol
Definer Data Areas N: Subroutine number
SBS(91) N
000 to 255
Limitations
Subroutine numbers 000 through 015 are used with input interrupts and subroutine number 099 is used for the scheduled interrupt.
Description
A subroutine can be executed by placing SBS(91) in the main program at the point where the subroutine is desired. The subroutine number used in SBS(91) indicates the desired subroutine. When SBS(91) is executed (i.e., when the execution condition for it is ON), the instructions between the SBN(92) with the same subroutine number and the first RET(93) after it are executed before execution returns to the instruction following the SBS(91) that made the call. Main program SBS(91)
000
Main program
SBN(92)
000
Subroutine RET(93) END(01)
SBS(91) may be used as many times as desired in the program, i.e., the same subroutine may be called from different places in the program). SBS(91) may also be placed into a subroutine to shift program execution from one subroutine to another, i.e., subroutines may be nested. When the second subroutine has been completed (i.e., RET(93) has been reached), program execution returns to the original subroutine which is then completed before returning to the main program. There is no limit to the number of nesting levels, unlike the C200HS PCs in which nesting is limited to 16 levels. A subroutine cannot call itself (e.g., SBS(91) 000 cannot be programmed within the subroutine defined with SBN(92) 000). The following diagram illustrates two levels of nesting.
SBS(91) 010
SBN(92) 010
SBN(92) 011
SBS(91) 011
SBS(91) 012
RET(93)
RET(93)
SBN(92) 012
RET(93)
285