The text of a manual · part 7 of 60
SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual: SECTION 1 PC Setup and Other Features, pages 51 to 60
Pages 51 to 60 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 51
Section
Pulse Output Function (CQM1 Only)
1-3
The following diagram shows the frequency of pulse outputs from port 2 as the program is executed. Frequency 20 kHz
About 500 Hz/4 ms 1 kHz
Time 00000 goes ON
Example 6: ACC(––) Mode 2
00001 goes ON
The following example shows mode 2 of ACC(––) used decrease the frequency of a pulse output from port 1. The 2-kHz pulse output is already in progress in independent mode and stops automatically when the number of pulses is reached. DM 0000 DM 0001
0050 0001
00000 @ACC(––) 001
When 00000 goes ON, ACC(––) begins decelerating the port 1 pulse output at about 500 Hz/4 ms until it reaches the target frequency of 10 Hz.
002 DM 0000
The following diagram shows the frequency of pulse outputs from port 1 as the program is executed. Frequency 2 kHz
About 500 Hz/4 ms
1 kHz Time 00000 goes ON
Specified number of pulses output
Note The pulse output can be stopped by executing ACC(––) mode 2 with a target frequency of 0, but the pulse output cannot be stopped at the correct number of pulses, so this method should not be used except for emergency stops. Example 7: ACC(––) Mode 3
The following example shows mode 3 of ACC(––) used decrease the frequency of a pulse output from port 1. The 20-kHz pulse output is already in progress in continuous mode. DM 0000 DM 0001
0100 0500
00000 @ACC(––) 001
When 00000 goes ON, ACC(––) begins decelerating the port 1 pulse output at about 1 kHz/4 ms until it reaches the target frequency of 5 kHz.
003 DM 0000
31
Page 52
Section
Pulse Output Function (CQM1 Only)
1-3
The following diagram shows the frequency of pulse outputs from port 1 as the program is executed. Frequency 20 kHz About 1 kHz/4 ms 5 kHz Time 00000 goes ON
1-3-4 Variable-duty-ratio Pulse Output from Ports 1 and 2 With the CQM1-CPU43-EV1, variable-duty-ratio pulses can be output from ports 1 and/or 2 using PWM(––). The pulse frequency can be set to 91.6 Hz, 1.5 kHz, or 5.9 kHz. This function can be used for various kinds of control outputs, such as light intensity output or speed control output to an inverter. CPU Unit
Frequency = 91.6 Hz, 1.5 kHz, 5.9 kHz t on + 1% to 99% T ton Port 1 Port 2 T
Note Only the CQM1-CPU43-EV1 CPU Unit can output pulses from ports 1 and 2. PC Setup Settings
Before outputting variable-duty-ratio pulses from port 1 or 2, switch the PC to PROGRAM mode and make the following settings in the PC Setup. Specify variable-duty-ratio pulse outputs in DM 6643 (port 1) and/or DM 6644 (port 2).
Bit 15 DM 6643 1
0
Bit 15 DM 6644 1
0
Port 1 pulse type setting 1: Variable-duty-ratio pulse output
Port 2 pulse type setting 1: Variable-duty-ratio pulse output
Default: Standard pulse output
Default: Standard pulse output
Standard pulses cannot be output from a port if it has been set for standard variable-duty-ratio pulse output in DM 6643 or DM 6644. Starting the Pulse Output
Pulses will begin to be output from the specified port when PWM(––) is executed. Specify port 1 or 2 (P=001 to 002). Set the frequency to 5.9 kHz, 1.5 kHz, or 91.6 Hz (F=000, 001, or 002). Set the duty ratio from 1% to 99% (D=0001 to 0099, BCD). Execution condition @PWM(––) P F D
32
Page 53
Section
Pulse Output Function (CQM1 Only)
1-3
The pulse output will continue with the specified frequency and duty ratio until PWM(––) is executed again with different settings or INI(61) is executed to stop pulse outputs from the specified port. Stopping the Pulse Output
The pulse output from a port can be stopped by executing INI(61) with C=003. Specify port 1 or 2 (P=001 to 002). Execution condition @INI(61) P 003 000
Example: Using PWM(––)
The following example shows PWM(––) used to start a 1.5 kHz pulse output from port 1 and change the duty ratio from 50% to 25%.The pulse output is then stopped with INI(61). Before executing the program make sure that DM 6643 is set to 1000 (variableduty-ratio pulse setting for port 1). 00000 @PWM(––)
When 00000 goes ON, a 1.5 kHz signal is output from port 1 with a duty ratio of 50%.
001 001 #0050 00001 @PWM(––)
When 00001 goes ON, the duty ratio is changed to 25%.
001 001 #0025 00002 @INI(61)
When 00002 goes ON, INI(61) stops the pulse output from port 1.
001 003 000
The following diagram shows the duty ratio of the pulse output from port 1 as the program is executed. 50% duty ratio pulses
00000 goes ON
00001 goes ON
25% duty ratio pulses
00002 goes ON
33
Page 54
Section
Pulse Output Function (CQM1 Only)
1-3
1-3-5 Determining the Status of Ports 1 and 2 The status of pulse outputs (for standard or variable-duty-ratio pulses) of ports 1 and 2 can be determined either by reading the status of the relevant flags in the SR and AR areas or by executing PRV(62). Reading Flag Status
The status of pulse outputs can be determined by reading the contents of the words and flags shown in the following table.
Word(s)
Bit(s)
Function
SR 236 and SR 237 SR 238 and SR 239 AR 04
00 to 15
Port 1 PV
00 to 15
Port 2 PV
08 to 15
Pulse output status
Description Indicates the 8-digit present value of the number of pulses output from port 1. SR 237 contains the higher four digits. Indicates the 8-digit present value of the number of pulses output from port 2. SR 239 contains the higher four digits. Indicates pulse output status. 00: normal 01 or 02: Hardware error 03: PC Setup error 04: Operation stopped during pulse output
AR 05
AR 06
12
Port 1 Deceleration flag
13
Port 1 Number of Pulses flag
14 15
Port 1 Pulse Output Completed flag Port 1 Pulse Output Status flag
12
Port 2 Deceleration flag
13
Port 2 Number of Pulses flag
14
Port 2 Pulse Output Completed flag Port 2 Pulse Output Status flag
15
Executing PRV(62)
Indicates deceleration. (0: Not specified; 1: Specified.) Indicates whether the number of pulses are set. (0: Not specified; 1: Specified.) Indicates whether pulse output has been completed. (0: Not completed; 1: Completed.) Indicates whether pulses are being output. (0: No output; 1: Output in progress.) Indicates deceleration. (0: Not specified; 1: Specified.) Indicates whether the number of pulses are set. (0: Not specified; 1: Specified.) Indicates whether pulse output has been completed. (0: Not completed; 1: Completed.) Indicates whether pulses are being output. (0: No output; 1: Output in progress.)
The status of pulse outputs can be determined by executing PRV(62). Specify port 1 or 2 (P=001 to 002) and the destination word D. The port status information will be written to bits 04 to 07 of D and bits 00 to 03 and 08 to 15 will be set to 0. When PRV(62) is used to read the port’s status, the most recent information will be read, so the PC’s cycle time will not be a factor. Execution condition @PRV(62) P 001 D
Bits 04 through 07 of D contain the specified port’s status information. Bit
Deceleration flag
05
Number of Pulses flag Pulse Output Completed flag Pulse Output Status flag
06 07
34
Function
04
Description Indicates deceleration. (0: Not decelerating; 1: Decelerating) Indicates whether the total number of pulses have been specified. (0: Not specified; 1: Specified.) Indicates whether pulse output has been completed. (0: Not completed; 1: Completed.) Indicates whether pulses are being output. (0: No output; 1: Output in progress.)
Page 55
Section
Pulse Output Function (CPM1A Only)
1-4
1-4
Pulse Output Function (CPM1A Only) The CPM1A PCs with transistor outputs have a pulse output function capable of outputting a pulse of 20 Hz to 2 kHz (single-phase). Either IR 01000 or IR 01001 can be selected for pulse output, and the pulse output can be set to either the continuous mode, under which the output can be stopped by an instruction, or the independent mode, under which the output is stopped after a preset number of pulses (1 to 16,777,215). Refer to the CPM1A Operation Manual for details on hardware connections to output points and ports.
Pulses are output at the specified frequency until stopped. Continuous mode
Pulse output is stopped automatically when the specified number of pulses has been output. Single mode Specified number off pulses
Stepping motor
Stepping motor
Control input
Motor controller
CW/CCW control output
Pulse output (single-phase output) IR 01000 or IR 01001
Note
1. The CPM1A uses a single-phase pulse output. The control signal for the direction of rotation (CW/CCW) for the motor driver must be written in the program. 2. Be sure to use a CPU Unit with transistor outputs.
35
Page 56
Section
Pulse Output Function (CPM1A Only)
1-4
1-4-1 Programming Example in Continuous Mode In this example program, pulse output begins from IR 01000 when input IR 00004 turns ON, and is stopped when input IR 00005 turns ON. SPED(64) can be used to stop pulse output. When using SPED(64) for that purpose, specify #0000 (constant or word contents) as the pulse frequency. 00004 (pulse output condition) @SPED(64)
Begins pulse output.
000
Output from 01000
001
Continuous mode
#0100
Pulse frequency: 1 kHz
00005 (pulse output stop condition) @INI(61)
Stops pulse output.
000 003 000
1-4-2 Programming Example in Independent Mode In this example program, pulse output begins from IR 01000 when input IR 00004 turns ON, and is stopped after the specified number of pulses have been output. The pulse amount is set in DM 0100 and DM 0101. 00004 (pulse output condition) @PULS(65)
Sets the number of pulses.
000 000 D0100
Pulse number setting
00004 (pulse output condition) @SPED(64)
Begins pulse output.
000 000
Single mode
#0100
Pulse frequency: 1 kHz
1-4-3 Using Pulse Output Instructions Setting the Number of Pulses
Before beginning pulse output using the independent mode use PULS(65) as shown below to set the number of pulses to be output. This setting is not required for the continuous mode. @PULS(65) 000 000 N
In N, set the beginning word address of the words where the number of pulses is set. Store the number of pulses in words N and N+1, in eight digits BCD, with the leftmost four digits in N+1 and the rightmost four digits in N. Make the setting within a range of 00000001 to 16777215 (BCD).
36
Page 57
Pulse Output Function (CPM1A Only) Beginning Pulse Output
Section
1-4
With SPED(64), set the bit location for pulse outputs (IR 01000 or IR 01001), the output mode (independent, continuous), and the pulse frequency to begin the pulse output. @SPED(64) P M F
P (3 digits BCD) M (3 digits BCD) F (4 digits BCD)
Note
000: Outputs to IR 01000 010: Outputs to IR 01001 000: Independent mode 001 Continuous mode For the beginning pulse output frequency, specify a constant or word contents. The specified value and set frequency are as follows: Specified value: 0002 to 0200 Set frequency: 20 to 2,000 Hz
1. Pulses can be output from only one bit at a time. 2. When pulse output is begun in independent mode, the number of pulses is read when SPED(64) is executed. PULS(65) cannot be used to change the number of pulses while pulses are being output.
1-4-4 Changing the Frequency To change the frequency during pulse output, change the frequency setting with SPED(64). At that time, set the operands other than the frequency to the same settings as at the beginning of pulse output. @SPED(64) P M F
P (3 digits BCD) M (3 digits BCD) F (4 digits BCD)
Same as at beginning of pulse output. Same as at beginning of pulse output. For the changed pulse output frequency, specify a constant or word contents. The specified value and set frequency are as follows: Specified value: 0002 to 0200 Set frequency: 20 to 2,000 Hz
1-4-5 Stopping Pulse Output When pulses are output in the independent mode, the pulse output will automatically stop after the number of pulses specified with PULS(65) has been output. When pulses are output in the continuous mode, either of the following two methods can be used to stop the pulse output. 1. Use SPED(64) to set the frequency to 0. 2. Use INI(61) to stop the pulse output. Using SPED(64)
The first method is to use SPED(64) to stop the pulse output by setting the frequency to 0. For details, refer to 1-4-4 Changing the Frequency.
Using INI(61)
The second method is to use INI(61) to stop the pulse output, as follows: @INI(61) 000 003 000
37
Page 58
Section
CQM1 Interrupt Functions
1-5
1-5
CQM1 Interrupt Functions This section explains the settings and methods for using the CQM1 interrupt functions.
1-5-1 Types of Interrupts The CQM1 has three types of interrupt processing, as outlined below. Input interrupts: Interrupt processing is executed when an input from an external source turns ON one of CPU bits 00000 to 00003. Interval timer interrupts: Interrupt processing is executed by an interval timer with a precision of 0.1 ms. High-speed counter interrupts: Interrupt processing is executed according to the present value (PV) of a built-in high-speed counter. All CQM1 CPU Units are equipped with high-speed counter 0, which counts pulse inputs to one of CPU bits 00004 to 00006. Two-phase pulses up to 2.5 kHz can be counted. The CQM1-CPU43/44-EV1 CPU Units can also count inputs to ports 1 and 2: CQM1-CPU 43-EV1: High-speed counters 1 and 2 count high-speed pulse inputs to ports 1 and 2. Two-phase pulses up to 25 kHz can be counted. CQM1-CPU44-EV1: High-speed counters 1 and 2 count absolute rotary encoder codes input to ports 1 and 2. Interrupt Processing
1, 2, 3...
When an interrupt is generated, the specified interrupt processing routine is executed. Interrupts have the following priority ranking. (Input interrupt 0 has the highest priority and high-speed counter interrupt 0 has the lowest.) 1. Input interrupt 0 > Input interrupt 1 > Input interrupt 2 > Input interrupt 3 2. High-speed counter interrupt 1 > High-speed counter interrupt 2 3. Interval timer interrupt 0 > Interval timer interrupt 1 > Interval timer interrupt 2 (Interval timer interrupt 2 is high-speed counter interrupt 0.) 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. Just as with ordinary subroutines, interrupt processing routines are defined using SBN(92) and RET(93) at the end of the main program. When interrupt processing routines are executed, a specified range of input bits can be refreshed. When an interrupt processing routine is defined, a “no SBS error” will be generated during the program check but execution will proceed normally. If this error occurs, check all normal subroutines to be sure that SBS(91) has been programmed before proceeding.
Pulse Output Instructions and Interrupts
With the CQM1-CPU43/44-EV1 CPU Units, the following instructions cannot be executed in an interrupt subroutine when an instruction that controls pulse I/O or high-speed counters is being executed in the main program: (25503 turns ON) INI(61), PRV(62), CTBL(63), SPED(64), PULS(65), PWM(––), PLS2(––) and ACC(––)
38
Page 59
Section
CQM1 Interrupt Functions
1-5
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 @PLS2(––) 001 000 DM 0010 @INT(89) 200 000 000
Method 2
Execute the instruction again in the main program. This is the program section from the main program:
@PRV(62) 001 002 DM 0000 @CTBL(63) 001 000 DM 0000 RSET LR 0000
This is the program section from the interrupt subroutine:
SBN(92) 000 25313 @CTBL(63) 001 000 DM 0000 25313
LR 0000
1-5-2 Input Interrupts The CPU Unit’s inputs allocated IR 00000 to IR 00003 can be used for interrupts from external sources. Input interrupts 0 through 3 correspond respectively to these bits and are always used to call the subroutines numbered 000 through 003 respectively. When input interrupts are not used, subroutine numbers 000 to 003 can be used for ordinary subroutines.
39
Page 60
Section
CQM1 Interrupt Functions Processing
1-5
There are two modes for processing input interrupts. The first is the Input Interrupt Mode, in which the interrupt is carried out in response to an external input. The second is the Counter Mode, in which signals from an external source are counted at high speed, and an interrupt is carried out once for every certain number of signals. In the Input Interrupt Mode, signals with a length of 100 or more can be detected. In the Counter Mode, signals up to 1 kHz can be counted.
PC Setup Parameters
Before executing the program, make the following settings in the PC Setup in PROGRAM mode. Interrupt Input Settings (DM 6628) If these settings are not made, interrupts cannot be used in the program. Bit 15
0
DM6628
Input interrupt 3 setting Input interrupt 2 setting Input interrupt 1 setting Input interrupt 0 setting 0: Normal input 1: Interrupt input Default: All normal inputs.
Input Refresh Word Settings (DM 6630 to DM 6633) Make these settings when it is necessary to refresh inputs. Bit 15 DM 6630: Interrupt 0 DM 6631: Interrupt 1 DM 6632: Interrupt 2 DM 6633: Interrupt 3
0
DM6630 to DM 6633
Number of words (2 digits BCD)
00 to 08
Beginning word (2 digits BCD)
00 to 07
Default: No input refresh
Example: If DM 6630 is set to 0100, IR 000 will be refreshed when a signal is received for interrupt 0. Note If input refreshing is not used, input signal status within the interrupt routine will not be reliable. This includes even 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, the Always ON Flag, SR 25313 could be used in place of IR 00000). Input Interrupt Mode
Use the following instructions to program input interrupts using the Input Interrupt Mode. Masking of Interrupts With the INT(89) instruction, set or clear input interrupt masks as required. (@)INT(89) 000 000 D
40
Make the settings with the D bits 0 to 3, which correspond to input interrupts 0 to 3. 0: Mask cleared. (Input interrupt permitted.) 1: Mask set. (Input interrupt not permitted.)