Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 36 of 68

Programmable Controllers C200HX-CPU-ZE, C200HG-CPU-ZE, C200HE-CPU-ZE Operation Manual: SECTION 5 Instruction Set, pages 324 to 333

Pages 324 to 333 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 324

Section 5-22

Special Math Instructions

3. Output the operation amount of the heater to bits 0 to 11 of word 110 by means of the first PID(190) 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(190) 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(194), and output it to DM 0200. Program 00000

25315 @MOV(021) #0F00

Target value

DM0000

@MOV(021) DM0000

Parameter leading word for first PID(190) instruction

HR00

@MOV(021) DM0000 HR40

PID(190)

Parameter leading word for second PID(190) instruction

PV of temperature sensing element

101 HR00

Heater operation amount

110

PID(190) 101 HR40

Fan operation amount

111

SCL(194) 101

PV of temperature sensing element (binary) Leading word of converted parameter

DM0100 DM0200

END

312

Present temperature of temperature sensing element (°C)

Page 325

Section 5-23

Logic Instructions

Note When using PID(190) or SCL(194), make the data settings in advance with a Programming Device such as the Programming Console or SYSMAC-CPT Support Software. 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

Fan

SCL Parameters 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-23 Logic Instructions The logic instructions – COM(029), ANDW(034), ORW(035), XORW(036), and XNRW(037) – perform logic operations on word data.

5-23-1 COMPLEMENT – COM(029) Ladder Symbols

Description

Operand Data Areas

COM(029)

@COM(029)

Wd

Wd

Wd: Complement word IR, SR, AR, DM, EM, HR, LR

When the execution condition is OFF, COM(029) is not executed. When the execution condition is ON, COM(029) clears all ON bits and sets all OFF bits in Wd. COM(029) will alternate between complements of Wd each cycle while the execution condition is ON; Use @COM(029) 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

313

Page 326

Section 5-23

Logic Instructions Flags

ER:

The content of an word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.

EQ:

ON when the result is 0.

N:

ON when bit 15 of Wd is set to 1.

5-23-2 LOGICAL AND – ANDW(034) Operand Data Areas Ladder Symbols

I1: Input 1 IR, SR, AR, DM, EM, HR, TC, LR, #

Description

ANDW(034)

@ANDW(034)

I1

I1

I2

I2

R

R

I2: Input 2 IR, SR, AR, DM, EM, HR, TC, LR, # R: Result word IR, SR, AR, DM, EM, HR, LR

When the execution condition is OFF, ANDW(034) is not executed. When the execution condition is ON, ANDW(034) 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

314

0

1

1

00 0

0

1

0

0

0

1

0

0

0

1

0

0

0

1

ER:

The content of an word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.

EQ:

ON when the result is 0.

N:

ON when bit 15 of R is set to 1.

Page 327

Section 5-23

Logic Instructions

5-23-3 LOGICAL OR – ORW(035) Operand Data Areas I1: Input 1

Ladder Symbols

IR, SR, AR, DM, EM, HR, TC, LR, #

Description

ORW(035)

@ORW(035)

I1

I1

I2

I2

R

R

I2: Input 2 IR, SR, AR, DM, EM, HR, TC, LR, # R: Result word IR, SR, AR, DM, EM, HR, LR

When the execution condition is OFF, ORW(035) is not executed. When the execution condition is ON, ORW(035) logically 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

1

1

0

1

1

1

0

1

1

1

0

1

1

1

0

1

15

R Flags

1

1

00

ER:

The content of an word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.

EQ:

ON when the result is 0.

N:

ON when bit 15 of R is set to 1.

315

Page 328

Section 5-23

Logic Instructions

5-23-4 EXCLUSIVE OR – XORW(036) Operand Data Areas I1: Input 1

Ladder Symbols

IR, SR, AR, DM, EM, HR, TC, LR, #

Description

XORW(036)

@XORW(036)

I1

I1

I2

I2

R

R

I2: Input 2 IR, SR, AR, DM, EM, HR, TC, LR, # R: Result word IR, SR, AR, DM, EM, HR, LR

When the execution condition is OFF, XORW(036) is not executed. When the execution condition is ON, XORW(036) 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

316

1

1

1

00 1

0

0

1

1

0

0

1

1

0

0

1

1

0

0

ER:

The content of an word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.

EQ:

ON when the result is 0.

N:

ON when bit 15 of R is set to 1.

Page 329

Section 5-24

Subroutines and Interrupt Control

5-23-5 EXCLUSIVE NOR – XNRW(037) Operand Data Areas I1: Input 1

Ladder Symbols

IR, SR, AR, DM, EM, HR, TC, LR, # XNRW(037)

@XNRW(037)

I1

I1

I2

I2

R

R

I2: Input 2

Description

IR, SR, AR, DM, EM, HR, TC, LR, # R: Result word IR, SR, AR, DM, EM, HR, LR

When the execution condition is OFF, XNRW(037) is not executed. When the execution condition is ON, XNRW(037) 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

The content of an word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded. ON when the result is 0. ON when bit 15 of R is set to 1.

5-24 Subroutines and Interrupt Control 5-24-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(099) 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.

317

Page 330

Section 5-24

Subroutines and Interrupt Control

INT(089) is used to control the interrupt signals received from the Interrupt Input Unit, and also to control the scheduling of the scheduled interrupt. INT(089) provides such functions as masking of interrupts (so that they are recorded but ignored) and clearing of interrupts. Refer to 5-24-2 Interrupts for more details on interrupts. MCRO(099)

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-24-5 MACRO – MCRO(099) for more details on this instruction.

5-24-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

318

Page 331

Section 5-24

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

319

Page 332

Section 5-24

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(089) 100 000 000

Reading and writing common data words

Unmasks all interrupts.

(@)INT(089) 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.

320

Page 333

Section 5-24

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-24-3 SUBROUTINE ENTER – SBS(091) Ladder Symbol

Definer Data Areas N: Subroutine number

@SBS(091)

SBS(091) 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(091) in the main program at the point where the subroutine is desired. The subroutine number used in SBS(091) indicates the desired subroutine. When SBS(091) is executed (i.e., when the execution condition for it is ON), the instructions between the SBN(092) with the same subroutine number and the first RET(093) after it are executed before execution returns to the instruction following the SBS(091) that made the call. Main program SBS(091)

000

Main program

SBN(092)

000

Subroutine RET(093) END(001)

SBS(091) 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(091) 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(093) 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(091) 000 cannot be programmed within the subroutine defined with SBN(092) 000). The following diagram illustrates two levels of nesting.

SBS(091) 010

SBN(092) 010

SBN(092) 011

SBS(091) 011

SBS(091) 012

RET(093)

RET(093)

SBN(092) 012

RET(093)

321