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

The text of a manual · part 11 of 60

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

Pages 91 to 100 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 91

Section

CPM1/CPM1A Interrupt Functions

1-6

All of the input interrupts are masked when PC operation is started. If input interrupt mode is being used, be sure to enable the inputs by executing INT(89) as shown above. Clearing Masked Interrupts If the bit corresponding to an input interrupt turns ON while masked, that input interrupt will be saved in memory and will be executed as soon as the mask is cleared. In order for that input interrupt not to be executed when the mask is cleared, the interrupt must be cleared from memory. Only one interrupt signal will be saved in memory for each interrupt number. With the INT(89) instruction, clear the input interrupt from memory. (@)INT(89) 001 000

If D bits 0 to 3, which correspond to input interrupts 0 to 3, are set to “1,” then the input interrupts will be cleared from memory. 0: Input interrupt retained. 1: Input interrupt cleared.

D

Reading Mask Status With the INT(89) instruction, read the input interrupt mask status. (@)INT(89) 002 000

The status of the rightmost digit of the data stored in word D (bits 0 to 3) show the mask status. 0: Mask cleared. (Input interrupt enabled.) 1: Mask set. (Input interrupt disabled.)

D

Program Example When input 00003 (interrupt no. 0) goes ON, operation moves immediately to the interrupt program with subroutine number 000. Inputs for DM 6628 have been set to 0001. 25315 First Cycle Flag ON for 1 cycle @INT(89) 000

Mask/unmask input interrupts.

000 #000E

SBN(92)

Unmasks 00003 (interrupt input 0), masks others.

000

Interrupt program RET(93)

Counter Mode

External signal inputs are counted at high speed and an interrupt is generated when the count reaches the set value. When an interrupt is generated, the main program is interrupted and the interrupt program is executed. Signals up to 1 kHz can be counted. Main program

Main program

Interrupt program

Input interrupt

Set value

71

Page 92

Section

CPM1/CPM1A Interrupt Functions

1-6

Use the following steps to program input interrupts using the Counter Mode. 1, 2, 3...

1. Write the set values for counter operation to the SR words shown in the following table. The set values are written between 0000 and FFFF (0 to 65,535). A value of 0000 will disable the count operation until a new value is set and step 2, below, is repeated. Interrupt

Word

Input interrupt 0

SR 240

Input interrupt 1

SR 241

Input interrupt 2

SR 242

Input interrupt 3

SR 243

The SR words used in the Counter Mode (SR 240 to SR 243) contain hexadecimal data, not BCD. If the Counter Mode is not used, these words can be used as work bits. Note These SR words are cleared at the beginning of operation, and must be written from the program. 2. With the INT(89) instruction, refresh the Counter Mode set value and enable interrupts. (@)INT(89) 003 000 D

If D bits 0 to 3, which correspond to input interrupts 0 to 3, are set to “0,” then the set value will be refreshed and interrupts will be permitted. 0: Counter mode set value refreshed and mask cleared. 1: Not refreshed.

Be sure to set the corresponding bit to 1 if an input interrupt isn’t being controlled. The input interrupt for which the set value is refreshed will be enabled in Counter Mode. When the counter reaches the set value, an interrupt will occur, the counter will be reset, and counting/interrupts will continue until the counter is stopped. Note

1. If the INT(89) instruction is used during counting, the present value (PV) will return to the set value (SV). You must, therefore, use the differentiated form of the instruction or an interrupt may never occur. 2. The set value will be set when the INT(89) instruction is executed. If interrupts are already in operation, then the set value will not be changed just by changing the content of SR 240 to SR 243, i.e., if the contents are changed, the set value must be refreshed by executing the INT(89) instruction again. Interrupts can be masked using the same process used with the Input Interrupt Mode, but if the masked interrupts are cleared using the same process, the interrupts will operate in Input Interrupt Mode, not Counter Mode. Interrupt signals received for masked interrupts can also be cleared using the same process as for the Input Interrupt Mode. Counter PV in Counter Mode When input interrupts are used in Counter Mode, the counter PV will be stored in the SR word corresponding to input interrupts 0 to 3. Values are 0000 to FFFE (0 to 65,534) and will equal the counter PV minus one. Interrupt

Word

Input interrupt 0

SR 244

Input interrupt 1

SR 245

Input interrupt 2

SR 246

Input interrupt 3

SR 247

Example: The present value for an interrupt whose set value is 000A will be recorded as 0009 immediately after INT(89) is executed. Note Even if input interrupts are not used in Counter Mode, these SR bits cannot be used as work bits.

72

Page 93

Section

CPM1/CPM1A Interrupt Functions

1-6

Program Example When input 00003 (interrupt no. 0) goes ON 10 times, operation moves immediately to the interrupt program with subroutine number 000. The following table shows where the counters‘ set values and present values –1 are stored. Inputs for DM 6628 have been set to 0001. Interrupt Input 00003 (input interrupt 0)

Word containing SV SR 240

Word containing PV–1 SR 244

Input 00004 (input interrupt 1)

SR 241

SR 245

Input 00005 (input interrupt 2)

SR 242

SR 246

Input 00006 (input interrupt 3)

SR 243

SR 247

25315 First Cycle Flag ON for 1 cycle MOV(21) #000A

Sets the SV to 10. (0000 to FFFF)

240

Word containing the SV (SR 240)

003

Refresh counter SVs.

@INT(89)

000 #000E

SBN(92)

Refreshes the SV of 00003 (interrupt input 0) only.

000

Interrupt program RET(93)

1-6-3 Masking All Interrupts All interrupts, including input interrupts, interval timer interrupts, and high-speed counter interrupts, can be masked and unmasked as a group by means of the INT(89) instruction. The mask is in addition to any masks on the individual types of interrupts. Furthermore, clearing the masks for all interrupts does not clear the masks on the individual types of interrupts, but restores them to the masked conditions that existed before INT(89) was executed to mask them as a group. Do not use INT(89) to mask interrupts unless it is necessary to temporarily mask all interrupts and always use INT(89) instructions in pairs to do so, using the first INT(89) instruction to mask and the second one to unmask interrupts. INT(89) cannot be used to mask and unmask all interrupts from within interrupt routines. Masking Interrupts

Use the INT(89) instruction to disable all interrupts. (@)INT(89) 100 000 000

If an interrupt is generated while interrupts are masked, interrupt processing will not be executed but the interrupt will be recorded for the input, interval timer, and high-speed counter interrupts. The interrupts will then be serviced as soon as interrupts are unmasked.

73

Page 94

Section

CPM1/CPM1A Interrupt Functions Unmasking Interrupts

1-6

Use the INT(89) instruction to unmask interrupts as follows: (@)INT(89) 200 000 000

1-6-4 Interval Timer Interrupts The CPM1/CPM1A is equipped with one interval timer. When the interval timer times out, the main program is interrupted and the interrupt program is executed immediately, regardless of the point in the cycle. There are two modes for interval timer operation, the One-shot Mode, in which only one interrupt will be executed when time expires, and the Scheduled Interrupt Mode in which the interrupt is repeated at a fixed interval. The interval timer’s set value can be set anywhere from 0.5 to 319968 ms, in units of 0.1 ms. Operation

Use the following instruction to activate and control the interval timer. Starting Up in One-Shot Mode Use the STIM(69) instruction to start the interval timer in the one-shot mode. (@)STIM(69) C1 C2 C3

1, 2, 3...

C1 C2 C3

74

C2: Timer set value (first word address) C3: Subroutine no. (4 digits BCD): 0000 to 0049

1. When C2 is entered as a word address: C2: Decrementing counter set value (4 digits BCD): 0000 to 9999 C2 + 1: Decrementing time interval (4 digits BCD; unit: 0.1 ms): 0005 to 0320 (0.5 ms to 32 ms) Each time that the interval specified in word C2 + 1 elapses, the decrementing counter will decrement the present value by one. When the PV reaches 0, the designated subroutine will be called just once and the timer will stop. The time from when the STIM(69) instruction is executed until time elapses is calculated as follows: (Content of C2) × (Content of C2 + 1) × 0.1 ms = (0.5 to 319,968 ms) 2. When C2 is entered as a constant: The set value of the decrementing counter will equal the specified constant (in ms) and the decrementing time interval will be 10 (1 ms). Starting Up in Scheduled Interrupt Mode Use the STIM(69) instruction to start the interval timer in the scheduled interrupt mode. (@)STIM(69)

1, 2, 3...

C1: Interval timer, one-shot mode (000)

C1: Interval timer, scheduled interrupt mode (003) C2: Timer set value (leading word no.) C3: Subroutine no. (4 digits BCD): 0000 to 0049

1. When C2 is entered as a word address: C2: Decrementing counter set value (4 digits BCD): 0000 to 9999 C2 + 1: Decrementing time interval (4 digits BCD; unit: 0.1 ms): 0005 to 0320 (0.5 ms to 32 ms) The meanings of the settings are the same as for the one-shot mode, but in the scheduled interrupt mode the timer PV will be reset to the set value and decrementing will begin again after the subroutine has been called. In the scheduled interrupt mode, interrupts will continue to be repeated at fixed intervals until the operation is stopped.

Page 95

Section

CPM1/CPM1A Interrupt Functions

1-6

2. When C2 is entered as a constant: The settings are the same as for the one-shot mode, but interrupts will continue to be repeated at fixed intervals until the operation is stopped. Reading the Timer’s Elapsed Time Use the STIM(69) instruction to read the timer’s elapsed time. (@)STIM(69) C1 C2 C3

C1: Read elapsed time (006) C2: Leading word of parameter 1 C3: Parameter 2

C2: Number of times the decrementing counter has ben decremented (4 digits BCD) C2 + 1: Decrementing counter time interval (4 digits BCD; unit: 0.1 ms) C3: Elapsed time from previous decrement (4 digits BCD; unit: 0.1 ms) The time from when the interval timer is started until the execution of this instruction is calculated as follows: {(Content of C2) × (Content of C2+1) + (Content of C3)} × 0.1 ms If the specified interval timer is stopped, then “0000” will be stored. Stopping the Timer Use the STIM(69) instruction to stop the interval timer. The interval timer will be stopped. (@)STIM(69) C1

C1: Stop interval timer (010)

000 000

Application Example (One-shot Mode)

In this example, an interrupt is generated 2.4 ms (0.6 ms × 4) after input 00005 goes ON; the interrupt executes interrupt subroutine number 23.

25315 First Cycle Flag ON for 1 cycle MOV(21) #0004 DM 0010

Sets the decrementing counter‘s set value to 4. (BCD: 0000 to 9999)

MOV(21) #0006 DM 0011

Sets the decrementing time interval to 0.6 ms. (BCD: 0005 to 0320)

00005 @STIM(69) 000 DM 0010 #0023

SBN(92)

Starts the interval timer in one-shot mode. Specifies the first word containing the set value. Specifies the subroutine number (23).

023

Interrupt program RET(93)

75

Page 96

Section

CPM1/CPM1A Interrupt Functions Application Example (Scheduled Interrupt Mode)

1-6

In this example, an interrupt is generated every 4.0 ms (1.0 ms × 4) after input 00005 goes ON; the interrupts execute interrupt subroutine number 23.

25315 First Cycle Flag ON for 1 cycle MOV(21) #0004 DM 0010

Sets the decrementing counter‘s set value to 4. (BCD: 0000 to 9999)

MOV(21) #0010 DM 0011

Sets the decrementing time interval to 1.0 ms. (BCD: 0005 to 0320)

00005 @STIM(69) 003 DM 0010 #0023

SBN(92)

Starts the interval timer in scheduled interrupt mode. Specifies the first word containing the set value. Specifies the subroutine number (23).

023

Interrupt program RET(93)

1-6-5 High-speed Counter Interrupts CPM1/CPM1A PCs have a high-speed counter function that can be used in incrementing mode or up/down mode. The high-speed counter can be combined with input interrupts to perform target value control or zone comparison control that isn’t affected by the PC’s cycle time. High-speed counter signals can be input to CPU bits 00000 through 00002.

NC 24VDC

CPM1A PCs

76

00002

00001

00000

CPM1 PCs

Page 97

Section

CPM1/CPM1A Interrupt Functions Mode

Input functions

Input method

Up/Down

00000: A-phase input 00001: B-phase input 00002: Z-phase input

Incrementing

00000: Count input 00001: See note. 00002: Reset input

Count Count frequency range Phase-difference, 2.5 kHz max. –32767 4× inputs to 32767 Individual inputs

5.0 kHz max. 0 to 65535

1-6

Control methods Target value control: Up to 16 target values and interrupt subroutine numbers can be registered. Zone comparison control: Up to 8 sets of upper limit values, lower limit values, and interrupt subroutine numbers can be registered.

Note In incrementing mode, input 00001 can be used as a regular input. When the reset method is used for the software reset, input 00002 can be used as a regular input. Also, even when used for the Z-phase signal and software reset, the input status is reflected inn 00002 of the I/O memory. High-speed Counter Settings The following settings must be made in DM 6642 when using the CPM1/CPM1A’s high-speed counter function. DM 6642 Bits

Settings

Function

00 to 03

Sets the counter mode:

Incrementing Up/Down 4 0

Not used 0 or 4

04 to 07

0: Up/down 4: Incrementing Sets the reset method:

0 or 1

0 or 1

0 or 1

08 to 15

0: Z-phase + software reset 1: Software reset Sets the counter:

01

01

00

00: Counter not being used. 01: Counter being used.

Count Range

The CPM1/CPM1A’s high-speed counter uses linear operation and the count (present value) is stored in SR 248 and SR 249. (The upper four digits are stored in SR 249 and the lower four digits are stored in SR 248.) Mode

Count range

Up/Down

F003 2767 to 0003 2767 (–32,767 to 32,767) The leftmost digit in SR 248 indicates the sign. F is negative, 0 is positive.

Incrementing

0000 0000 to 0006 5535 (0 to 65,535)

An overflow will occur if the count exceeds the upper limit in the count range and an underflow will occur if the count goes below the lower limit in the count range. Error

Incrementing

Overflow

Occurs when the count is incremented from 65,535. ---

Underflow

Processing

Up/Down

Present value 0FFF FFFF

Occurs when the count is incremented from 32,767. Occurs when the count is FFFF FFFF decremented from –32,767.

Two types of signals can be input from a pulse encoder. The count mode used for the high-speed counter will depend on the signal type. The count mode and reset mode are set in DM 6642; these settings become effective when the power is turned on or PC operation is started. Up/Down Mode: A phase-difference 4× two-phase signal (A-phase and B-phase) and a Zphase signal are used for inputs. The count is incremented or decremented according to differences in the 2-phase signals.

77

Page 98

Section

CPM1/CPM1A Interrupt Functions

1-6

Incrementing Mode: One single-phase pulse signal and a count reset signal are used for inputs. The count is incremented according to the single-phase signal. Incrementing Mode

Up/Down Mode Pulse input

A-phase

B-phase

Count

Count

1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 0 –1 –2

Incremented

1

2

3

4

Incremented only

Decremented

Note One of the reset methods described below should always be used to reset the counter when restarting it. The counter will be automatically reset when program execution is started or stopped. The following signal transitions are handled as forward (incrementing) pulses: A-phase leading edge to B-phase leading edge to A-phase trailing edge to Bphase trailing edge. The following signal transitions are handled as reverse (decrementing) pulses: B-phase leading edge to A-phase leading edge to Bphase trailing edge to A-phase trailing edge. The Up/Down Mode always uses a 4× phase-difference input. The number of counts for each encoder revolution would be 4 times the resolution of the counter. Select the encoder based on the countable ranges. Reset Methods Either of the two methods described below may be selected for resetting the PV of the count (i.e., setting it to 0). Z-phase signal + software reset: The PV is reset when the Z-phase signal (reset input) is turned ON while the High-speed Counter Reset Bit (SR 25200) is ON. Software reset: The PV is reset when the High-speed Counter Reset Bit (SR 25200) is turned ON. Z-phase Signal + Software Reset I/O refresh Common processing, communications servicing, etc.

1 cycle CPU processing

Program execution

Program execution

(2)

Not reset

Program execution

Program execution

Program execution

(3)

(4)

(5)

Reset

Reset

25200

(1) Z-phase Not reset

78

Not reset

Program execution

Page 99

Section

CPM1/CPM1A Interrupt Functions No.

Operation timing

(1)

Z-phase signal turns ON when SR 25200 turns OFF. Z-phase signal turns ON within one cycle after SR 25200 turns ON. Z-phase signal turns ON after at least one cycle elapses after SR 25200 turns ON.

Not reset.

Z-phase signal turns ON within one cycle after SR 25200 turns OFF. SR 25200 turns ON when Z-phase signal is ON.

Reset with Z-phase leading edge.

(2) (3)

(4) (5)

1-6

Reset

Not reset. Reset with Z-phase leading edge.

Not reset.

Note The High-speed Counter Reset Bit (SR 25200) is refreshed once every cycle, so in order for it to be read reliably it must be ON for at least one cycle. The “Z” in “Z-phase” is an abbreviation for “Zero.” It is a signal that shows that the encoder has completed one cycle. High-speed Counter Interrupt Count For high-speed counter 0 interrupts, a comparison table is used instead of a “count up.” The count check can be carried out by either of the two methods described below. In the comparison table, comparison conditions (for comparing to the PV) and interrupt routine combinations are saved. Target value: A maximum of 16 comparison conditions (target values and count directions) and interrupt routine combinations are saved in the comparison table. When the counter PV and the count direction match the comparison conditions, then the specified interrupt routine is executed. Range (zone) comparison: Eight comparison conditions (upper and lower limits) and interrupt routine combinations are saved in the comparison table. When the PV is greater than or equal to the lower limit and less than or equal to the upper limit, then the specified interrupt routine is executed. The current count is compared to the target values in the order that target values are set in the comparison table and interrupts are generated as the count equals each target value. Once the count has equaled all of the target values in the table, the target value is set to the first target value in the table, which is again compared to the current counted until the two values are equal.

Target Value Comparisons

Count

Interrupts

Comparison Table Target value 1 Target value 2 Target value 3 Target value 4 Target value 5

Initial value Target value

Range Comparisons

1

2

3

4

5

The current count is compared in cyclic fashion to all of the ranges at the same time and interrupts are generated based on the results of the comparisons.

79

Page 100

Section

CPM1/CPM1A Interrupt Functions

1-6

Comparison Table Rage setting 1 Rage setting 2 Rage setting 3 Rage setting 4

0 Count 1

3 2

4

Note When performing target value comparisons, do not repeatedly use the INI instruction to change the current value of the count and start the comparison operation. The interrupt operation may not work correctly if the comparison operation is started immediately after changing the current value from the program. (The comparison operation will automatically return to the first target value once an interrupt has been generated for the last target value. Repetitious operation is thus possible merely by changing the current value.) Programming

Use the following steps to program the high-speed counter. The high-speed counter begins the counting operation 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 high-speed counter is reset to “0” when power is turned ON and when operation begins. The present value of high-speed counter is maintained in SR 248 and SR 249. Controlling High-speed Counter Interrupts 1, 2, 3...

1. Use the CTBL(63) instruction to save the comparison table in the CPM1/CPM1A and begin comparisons. (@)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

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. For details on the contents of the comparison tables that are saved, refer to the explanation of the CTBL(63) instruction in Section 5 Instruction Set. Note The comparison results are normally stored in AR 1100 through AR 1107 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. (@)INI(61) 000 001 000

80