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

The text of a manual · part 10 of 60

SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual: SECTION 1 PC Setup and Other Features, pages 81 to 90

Pages 81 to 90 of 520, from SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual

The original document is the PDF (2.1 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 CQM1-CPU21

Page 81

Section

CQM1 Interrupt Functions

1-5

In addition, the following data is stored for the comparison table: DM 0000 DM 0001 DM 0002 DM 0003 DM 0004 DM 0005 DM 0006 DM 0007 DM 0008 DM 0009

0003 2500 0000 0100 7500 0000 0101 0000 0001 0102

Number of comparison conditions: 3 Target value 1: 2,500 Comparison 1 interrupt processing routine no.: 100 Target value 2: 7,500 Comparison 2 interrupt processing routine no.: 101 Target value 2: 10,000 Comparison 3 interrupt processing routine no.: 102

00000 @CTBL(63) 001 000

Specifies port 1, saves the comparison table in target matching format, and begins comparing.

DM 0000 @PULS(65) 001

Sets CW pulses for port 1. (Number of pulses not set.)

004 000 @SPED(64) 001

Begins continuous pulse output from port 1 at 10 Hz.

001 #0001 @ACC 001 001 DM 0010

SBN(92)

ACC(––) mode 1 accelerates the frequency to 25 kHz at about 500 Hz/4 ms. DM 0010: 0050 DM 0011: 2500

100

25313 (Always ON) 10000

10000 turns ON.

RET(93) SBN(92)

101

25313 (Always ON) @ACC 001 003 DM 0012

ACC(––) mode 3 decelerates the frequency to 500 Hz at about 500 Hz/4 ms. DM 0012: 0050 DM 0013: 0050

RET(93) SBN(92)

102

25313 (Always ON) SPED(64) 001

Pulse output from port 1 is stopped by setting the frequency to 0.

001 #0000 RET(93)

61

Page 82

Section

CQM1 Interrupt Functions

1-5

1-5-8 Absolute High-speed Counter Interrupts (CQM1-CPU44-EV1) Binary-code signals from an absolute rotary encoder can be input to ports 1 and 2 of the CQM1-CPU44-EV1 and counted at 4 kHz. Interrupt processing can be executed according to the count. The 2 ports can be operated separately. The counter for port 1 is called absolute high-speed counter 1 and the counter for port 2 is called absolute high-speed counter 2. This section describes how to use absolute high-speed counters 1 and 2. Refer to the CQM1 Operation Manual for hardware information such as equipment and wiring specifications. Processing

Input Signals and Count Modes There are two count modes that can be used for absolute high-speed counters 1 and 2. The count mode and the resolution settings are specified in the PC Setup (DM 6643 and DM 6644). 1, 2, 3...

1. BCD Mode: The absolute rotary encoder’s binary code is first converted to normal binary data and then converted to BCD. 2. 360° Mode: The absolute rotary encoder’s binary code is converted to an angular value (0° to 359°) according to the resolution setting. (CTBL(63) settings are made in 5° units.) The following table shows the possible counter PVs in BCD mode and 360° mode for each resolution setting. Possible PVs

Resolution 8-bit 10-bit 12-bit

BCD mode 0 to 255 0 to 1023 0 to 4095

360° mode PV output: 0° to 359° (1° units) Comparison table settings: 0° to 355° (5° units)

Absolute High-speed Counter Interrupt Count The counter’s PV can be compared to up to 16 target values or 8 ranges. Refer to 5-15-6 REGISTER COMPARISON TABLE –CTBL(63) for a description of the comparison tables used with absolute high-speed counters 1 and 2. PC Setup

When using absolute high-speed counter 1 and/or 2 interrupts, make the settings in PROGRAM mode shown below before executing the program. Input Refresh Word Settings (DM 6634 and DM 6635) DM 6634 contains the input refresh word settings for absolute high-speed counter 1, and DM 6635 contains the settings for absolute high-speed counter 2. Make these settings when it is necessary to refresh inputs. Bit 15 DM 6634/DM 6635

Number of words (2 digits BCD)

00 to 12

Beginning word no. (2 digits BCD)

00 to 11

Default: No input refresh

62

0

Page 83

Section

CQM1 Interrupt Functions

1-5

Absolute High-speed Counter Settings (DM 6643 and DM 6644) DM 6643 contains the settings for absolute high-speed counter 1, and DM 6644 contains the settings for absolute high-speed counter 2. These words determine the count modes and resolution settings. Bit 15

0

DM6643/DM 6644

Count mode: 00: BCD mode 01: 360° mode Resolution setting: 00: 8-bit 01: 10-bit 02: 12-bit Defaults: BCD mode, 8-bit resolution

Origin Compensation

It is possible to compensate for an offset between an absolute rotary encoder’s origin and the actual origin. This adjustment can be made separately for ports 1 and 2. Follow the procedure below to set origin compensation. After origin compensation has been set, the data from the encoder will be adjusted before being output as the PV.

1, 2, 3...

1. Set the absolute rotary encoder to the desired origin location. 2. Make sure that pin 1 of the CPU Unit’s DIP switch is OFF (enabling Peripheral Devices to overwrite DM 6614 through DM 6655) and switch the PC to PROGRAM mode. 3. Set the resolution setting in DM 6643 or DM 6644. 4. Make sure that a fatal error or FALS 9C error have not occurred. 5. Read the high-speed counter’s PV from IR 232 and IR 233 (port 1) or IR 234 and IR 235 (port 2) to determine the PV before origin compensation. 6. Turn ON the Port 1 Origin Compensation flag (SR 25201) or Port 2 Origin Compensation flag (SR 25202) from a Peripheral Device. The compensation value will be written to DM 6611 (port 1) or DM 6612 (port 2) and the Origin Compensation flag will be turned OFF automatically. The compensation value will be recorded in BCD between 0000 and 4095 whether the counter is set to BCD mode or 360° mode. 7. Read the high-speed counter’s PV to determine the PV after origin compensation. The PV should be 0000 after origin compensation. The compensation value will be valid until it is changed again by the procedure above.

Programming

Use the following steps to program absolute high-speed counters 1 and 2. Absolute high-speed counters 1 and 2 begin counting when the proper PC Setup settings are made, but comparisons will not be made with the comparison table and interrupts will not be generated unless the CTBL(63) instruction is executed. The present value of absolute high-speed counter 1 is maintained in IR 232 and IR 233 and the present value of absolute high-speed counter 2 is maintained in IR 234 and IR 235.

63

Page 84

Section

CQM1 Interrupt Functions

1-5

Controlling Absolute High-speed Counter Interrupts 1, 2, 3...

1. Use the CTBL(63) instruction to save the comparison table in the CQM1 and begin comparisons. P: Port specifier (001: Port 1; 002: Port 2)

(@)CTBL(63) P C TB

C: (3 digits BCD) 000: Target table set and comparison begun 001: Range table set and comparison begun 002: Target table set only 003: Range table set only TB: Beginning word of comparison table

P specifies the port. Set P=001 to specify absolute high-speed counter 1, or P=002 to specify absolute high-speed counter 2. If C is set to 000, then comparisons will be made by the target matching method; if 001, then they will be made by the range comparison method. The comparison table will be saved, and, when the save operation is complete, then comparisons will begin. While comparisons are being executed, high-speed interrupts will be executed according to the comparison table. Refer to 5-15-6 REGISTER COMPARISON TABLE –CTBL(63) for details on the structure of the comparison tables. Note The comparison results are normally stored in AR 0500 through AR 0507 (port 1) and AR 0600 through AR 0607 (port 2) while the range comparison is being executed. If C is set to 002, then comparisons will be made by the target matching method; if 003, then they will be made by the range comparison method. For either of these settings, the comparison table will be saved, but comparisons will not begin, and the INI(61) instruction must be used to begin comparisons. 2. To stop comparisons, execute the INI(61) instruction as shown below. Specify port 1 or 2 in P (P=001 or 002). (@)INI(61) P 001 000

To start comparisons again, set the second operand to “000” (execute comparison), and execute the INI(61) instruction. Once a table has been saved, it will be retained in the CQM1 during operation (i.e., during program execution) as long as no other table is saved. Reading the PV There are two ways to read the PV. The first is to read it from IR 232 and IR 233 (port 1) or IR 234 and IR 235 (port 2), and the second is to use PRV(62). Reading IR 232 and IR 233 or IR 234 and IR 235 The PV of absolute high-speed counter 1 is stored in IR 232 and IR 233, and the PV of absolute high-speed counter 2 is stored in IR 234 and IR 235 as shown below. Leftmost 4 digits

Rightmost 4 digits

Port 1:

IR 233

IR 232

Port 2:

IR 235

IR 234

BCD Mode

Mode

0000 0000 to 0000 4095

0000 0000 to 0000 0359

Note These words are refreshed only once every cycle, so there may be a difference from the actual PV.

64

Page 85

Section

CQM1 Interrupt Functions

1-5

Using the PRV(62) Instruction Read the PV of an absolute high-speed counter by using the PRV(62) instruction. Specify absolute high-speed counter 1 or 2 in P (P=001 or 002). (@)PRV(62) P 000

P: Port (001: port 1; 002: port 2) P1: Leading word of PV

P1

The PV of the specified absolute high-speed counter is stored as shown below. Leftmost 4 digits

Rightmost 4 digits

BCD Mode

Mode

D+1

D

0000 0000 to 0000 4095

0000 0000 to 0000 0359

The PV is read when the PRV(62) instruction is actually executed. Reading Absolute High-speed Counter Status

The status of absolute high-speed counters 1 and 2 can be determined either by reading the status of the relevant flags in the AR area or executing PRV(62). The following table shows the relevant AR area flags and their functions. Word

Bit(s)

AR 04

08 to 15

Function Indicates absolute high-speed counter status.

AR 05

00 to 07 08

00: normal 01 or 02: Hardware error 03: PC Setup error Counter 1 Comparison Result flags for ranges 1 to 8. (0: Not in range; 1: In range) Counter 1 Comparison flag (0: Stopped; 1: Comparing)

AR 06

00 to 07 08

Counter 2 Comparison Result flags for ranges 1 to 8. (0: Not in range; 1: In range) Counter 2 Comparison flag (0: Stopped; 1: Comparing)

The comparison flag status of absolute high-speed counters 1 and 2 can also be determined by executing PRV(62). Specify absolute high-speed counter 1 or 2 (P=001 to 002) and the destination word D. The flag status (0: Stopped; 1: Comparing) will be written to bit 00 of D. Bits 01 to 15 will be set to 0. Execution condition @PRV(62) P 001 D

Operation Example

This example shows a program that receives an input signal from an absolute rotary encoder at port 1 and uses this input to control outputs IR 10000 through IR 10003. Absolute high-speed counter 1 is set for 8-bit resolution and 360° Mode, and range comparisons are used. Before executing the program, set DM 6643 to 0100 (Port 1: 360° Mode, 8-bit resolution). Other PC Setup settings use the default settings. (Inputs are not refreshed at the time of interrupt processing.) In addition, the following data is stored for the comparison table:

65

Page 86

Section

CQM1 Interrupt Functions DM 0000 DM 0001 DM 0002 DM 0003 DM 0004 DM 0005 DM 0006 DM 0007 DM 0008 DM 0009 DM 0010 DM 0011 DM 0012 DM 0013 DM 0014 DM 0015 DM 0016 DM 0017 DM 0018 DM 0019 DM 0020 DM 0021 DM 0022 DM 0023

0000 0085 0100 0090 0175 0101 0180 0265 0102 0270 0355 0103 0000 0000 FFFF 0000 0000 FFFF 0000 0000 FFFF 0000 0000 FFFF

Lower limit #1 (0°) Upper limit #1 (85°) Subroutine number 100 Lower limit #2 (90°) Upper limit #2 (175°) Subroutine number 101 Lower limit #3 (180°) Upper limit #3 (265°) Subroutine number 102 Lower limit #4 (270°) Upper limit #4 (355°) Subroutine number 103 Lower limit #1 (0°) Upper limit #1 (0°) No subroutine number Lower limit #1 (0°) Upper limit #1 (0°) No subroutine number Lower limit #1 (0°) Upper limit #1 (0°) No subroutine number Lower limit #1 (0°) Upper limit #1 (0°) No subroutine number

1-5

First range setting (0° to 85°)

Second range setting (90° to 175°)

Third range setting (180° to 265°)

Fourth range setting (270° to 355°)

Fifth range setting (Not used.)

Sixth range setting (Not used.)

Seventh range setting (Not used.)

Eighth range setting (Not used.)

00000 @CTBL(63) 001 001

Specifies port 1, saves the comparison table in range matching format, and begins comparing.

DM 0000 SBN(92)

100

25313 (Always ON) MOV(21) #0001

Turns ON 10000. Turns other bits in IR 100 OFF.

100

RET(93) SBN(92)

101

25313 (Always ON) MOV(21) #0002

Turns ON 10001. Turns other bits in IR 100 OFF.

100

RET(93) SBN(92)

102

25313 (Always ON) MOV(21) #0004

Turns ON 10002. Turns other bits in IR 100 OFF.

100

RET(93) SBN(92)

103

25313 (Always ON) MOV(21) #0008 100

RET(93)

66

Turns ON 10003. Turns other bits in IR 100 OFF.

Page 87

Section

CPM1/CPM1A Interrupt Functions

1-6

The following diagram shows the relationship between absolute high-speed counter 1’s PV and Range Comparison Result flags AR 0500 to AR 0507 as the above program is executed. AR 0500 AR 0501 AR 0502 AR 0503

AR 0504 to AR 0507

PV=0

1-6

85 90

175 180

265

270

355

360

CPM1/CPM1A Interrupt Functions This section explains the settings and methods for using the CPM1/CPM1A interrupt functions.

1-6-1 Types of Interrupts The CPM1/CPM1A has three types of interrupt processing, as outlined below. Input Interrupts CPM1/CPM1A PCs have two or four interrupt inputs. Interrupt processing is executed when one of these inputs is turned ON from an external source. Interval Timer Interrupts Interrupt processing is executed by an interval timer with a precision of 0.1 ms. High-speed Counter Interrupts The high-speed counter counts pulse inputs to one of CPU bits 00000 to 00002. Interrupt processing is executed when the count reaches the set value of a builtin high-speed counter. Interrupt Priority

When an interrupt is generated, the specified interrupt processing routine is executed. Interrupts have the following priority ranking. Input interrupts > Interval interrupts = High-speed counter interrupts When an interrupt with a higher priority is received during interrupt processing, the current processes will be stopped and the newly received interrupt will be processed instead. After that routine has been completely executed, then processing of the previous interrupt will be resumed. When an interrupt with a lower or equal priority is received during interrupt processing, then the newly received interrupt will be processed as soon as the routine currently being processed has been completely executed. When two interrupts with equal priority are received at the same time, they are executed in the following order: Input interrupt 0 > Input interrupt 1 > Input interrupt 2 > Input interrupt 3 Interval interrupts > High-speed counter interrupts

Interrupt Program Precautions

Observe the following precautions when using interrupt programs: 1, 2, 3...

1. A new interrupt can be defined within an interrupt program. Furthermore, an interrupt can be cleared from within an interrupt program. 2. Another interrupt program cannot be written within an interrupt program. 3. A subroutine program cannot be written within an interrupt program. Do not write a SUBROUTINE DEFINE instruction, SBN(92), within an interrupt program.

67

Page 88

Section

CPM1/CPM1A Interrupt Functions

1-6

4. An interrupt program cannot be written within a subroutine program. Do not write an interrupt program between a SUBROUTINE DEFINE instruction (SBN(92)) and a RETURN instruction (RET(93)). Inputs used as interrupts cannot be used as regular inputs. High-speed Counter Instructions and Interrupts

The following instructions cannot be executed in an interrupt subroutine when an instruction that controls high-speed counters is being executed in the main program: INI(61), PRV(62), or CTBL(63) The following methods can be used to circumvent this limitation: Method 1 All interrupt processing can be masked while the instruction is being executed. @INT(89) 100 000 000 INI(61) 000 000 000 @INT(89) 200 000 000

Method 2 Execute the instruction again in the main program. 1, 2, 3...

1. This is the program section from the main program: @PRV(62) 000 002 DM 0000 LR 0000 CTBL(63) 000 000 DM 0000 RSET LR 0000

2. This is the program section from the interrupt subroutine: SBN(92) 000 25313 @CTBL(63) 000 000 DM 0000 25313

68

LR 0000

Page 89

Section

CPM1/CPM1A Interrupt Functions Note

1-6

1. Define interrupt routines at the end of the main program with SBN(92) and RET(93) instructions, just like regular subroutines. 2. When defining an interrupt routine, a “SBS UNDEFD” error will occur during the program check operation, but the program will be executed normally.

1-6-2 Input Interrupts The 10-pt CPU Units and have two interrupt inputs (00003 and 00004). The 20-, 30-, and 40-pt CPU Units and have four interrupt inputs (00003 to 00006). There are two modes for input interrupts: input interrupt mode and counter mode. CPM1 PCs

00004

00003 00004 00005 00006

20- and 30-pt CPU Units and

00003

10-pt CPU Units

NC 24VDC

CPM1A PCs 10-pt CPU Units

CPU Unit

20-, 30-, and 40-pt CPU Units and

Input

Interrupt number

00003 00004 00003

00 01 00

00004

00003

00004

01

Response time Interrupt mode Counter mode 0.3 ms max. 1 kHz (Time until the interrupt program is executed.)

02 03

Note If input interrupts are not used, use inputs 00003 to 00006 as regular inputs.

69

Page 90

Section

CPM1/CPM1A Interrupt Functions Input Interrupt Settings

1-6

Inputs 00003 to 00006 must be set as interrupt inputs in DM 6628 if they are to be used for input interrupts in the CPM1/CPM1A. Set the corresponding digit to 1 if the input is to be used as an interrupt input (input interrupt or counter mode); set it to 0 if it is to be used as a regular input. Word DM 6628

Setting 0: Regular input (default setting) 1: Interrupt input 2: Quick-response input Bit 15

0

DM 6628

Setting for input 00006: Set to 1 Setting for input 00005: Set to 1 Setting for input 00004: Set to 1 Setting for input 00003: Set to 1

Interrupt Subroutines

Interrupts from inputs 00003 to 00006 are allocated interrupt numbers 00 to 03 and call subroutines 000 to 003. If the input interrupts aren’t being used, subroutines 000 to 003 can be used in regular subroutines. Input number

Interrupt number

Subroutine number

00003

0

000

00004

1

001

00005

2

002

00006

3

003

Input Refreshing

If input refreshing is not used, input signal status within the interrupt routine will not be reliable. Depending on the input time constant, the input signals might not go ON even if input refreshing is used. This includes the status of the interrupt input bit that activated the interrupt. For example, IR 00000 would not be ON in interrupt routine for input interrupt 0 unless it was refreshed. In this case, use the Always ON Flag, SR 25313 in the interrupt routine instead of IR 00000.

Input Interrupt Mode

When an input interrupt signal is received, the main program is interrupted and the interrupt program is executed immediately, regardless of the point in the cycle in which the interrupt is received. The signal must be ON for 200 µs or more to be detected. Main program

Main program

Interrupt program

Input interrupt

Use the following instructions to program input interrupts using the Input Interrupt Mode. Masking/Unmasking of Interrupts With the INT(89) instruction, set or clear input interrupt masks as required. (@)INT(89) 000 000 D

70

Make the settings with word D bits 0 to 3, which correspond to input interrupts 0 to 3. 0: Mask cleared. (Input interrupt enabled.) 1: Mask set. (Input interrupt disabled.)