The text of a manual · part 16 of 60
C200HX/C200HG/C200HE Programmable Controllers Operation Manual, pages 144 to 153
Pages 144 to 153 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 144
Section 4-12
Special I/O Unit Interface Programs
4-11 Program Execution When program execution is started, the CPU Unit cycles the program from top to bottom, checking all conditions and executing all instructions accordingly as it moves down the bus bar. It is important that instructions be placed in the proper order so that, for example, the desired data is moved to a word before that word is used as the operand for an instruction. Remember that an instruction line is completed to the terminal instruction at the right before executing an instruction lines branching from the first instruction line to other terminal instructions at the right. Program execution is only one of the tasks carried out by the CPU Unit as part of the cycle time. Refer to Section 6 Program Execution Timing for details.
4-12 Special I/O Unit Interface Programs This section provides programming methods and precautions for Special I/O Unit operation.
4-12-1 Restarting Special I/O Units When a Special I/O Unit is restarted, execution of IORF(97) is disabled until Special I/O Unit initialization is completed.
SR 28100 (Unit #0 Restart Bit)
SR 27400 (Unit #0 Restart Flag)
Execution of IORF(97) for Unit #0
ON OFF
ON
Special I/O Unit Initialization
OFF
Enabled
Disabled
Enabled
While the Restart Flag (SR 27400) is ON, normal END refreshing is performed and the Special I/O Unit is initialized. This processing occurs regardless of the settings in DM 6620, DM 6621, and DM 6623, which relate to Special I/O Unit refreshing. IORF(97) instructions in the program won’t be executed for the initializing Unit until initialization is completed. Special I/O Unit data that was to be refreshed might be lost during initialization. When writing a program to restart Special I/O Units, disable programming that depends on data from the initializing Special I/O Unit, such as data used in calculations, while its Restart Flag (SR 27400 to SR 27415) is ON. Normal program operations can continue for Units that aren’t initializing. The Restart Flag won’t turn ON for Special I/O Units mounted on Slave Racks. The standard Special I/O Unit restart time is (20 × the cycle time).
126
Page 145
Section 4-12
Special I/O Unit Interface Programs
4-12-2 Special I/O Unit Error Processing Program Use a program like the one shown below to restart a Special I/O Unit in which an error has occurred. This example program restarts Unit 1.
AR 0001 (Unit #0 Error Flag) AR0001 DIFU(13) AR0101 SR 27401 (Unit #1 Restart Flag) 27401
Restart
Disables calculations during Initialization.
JMP(04) 00
Calculations using data from Special I/O Unit 1 JME(05) 00
4-12-3 Changing the Special I/O Unit Settings In the C200HX/HG/HE, ladder instructions can be used to write data into the Special I/O Unit Areas (DM 1000 to DM 2599) and change the Special I/O Unit settings. Changing the settings is useful when different settings are required for different production processes. In this example there are two production processes that require different Special I/O Unit settings. The settings for the first process are stored in DM 7000 through DM 7999 and the settings for the second process are stored in DM 8000 through DM 8999. Programming Console Operations
1, 2, 3...
Steps 1 through 5 in the following procedure aren’t necessary when XFER(70) is used to overwrite DM 1000 through DM 1999 directly from the program with the contents of fixed DM (DM 6144 through DM 6599). In this case, just restart the Unit from the program after overwriting DM 1000 through DM 1999. 1. Clear the memory (all clear).
The UM Area Allocation operation can’t be performed unless the memory has been cleared. 2. Perform the UM Area Allocation operation to allocate 2K words to the expansion DM area (DM 7000 through DM 8999). CLR
FUN
VER
PLAY SET
CHG
B
9
7
D
1
3
WRITE
3. Perform the Hexadecimal/BCD Data Modification operation to set the Special I/O Unit mode to “C200H-compatible ROM mode 1” by setting DM 6602 to #0100. This mode transfers the contents of DM 7000 through DM 7999 to DM 1000 through DM 1999 at PC startup. This new PC Setup setting won’t be effective until the PC is restarted by turning it off and then on again. 4. Set pin 4 of the CPU Unit’s DIP switch to ON. This setting enables the user to assign expansion instruction function codes.
127
Page 146
Section 4-12
Special I/O Unit Interface Programs
5. Perform the Expansion Instruction Function Code Assignment operation to assign a function code to XDMR(––).
6. Input the program. The following program changes the Special I/O Unit Area settings for Unit 2, restarts the Unit, and disables calculations using data from Unit 2 while the Unit is initializing.
Example Program (Special I/O Unit 2)
End of process 1. 40000 @XDMR #0100 #8200 DM1200
DIFU(13) AR0102
Unit #2 Restart Flag 27402 JMP(04) 00
Calculations using data from Special I/O Unit 2
Transfers the contents of DM 8200 through DM 8299 to DM 1200 through DM 1299. Restarts Unit 2.
Disables calculations during Initialization.
JME(05) 00
4-12-4 Special I/O Unit I/O Refreshing Interval When the interval between I/O refreshes is too short, the processing in the Special I/O Unit can be delayed causing Special I/O Unit errors or otherwise interfering with proper Unit operation. In this case, use the following methods to restore normal operation. Short Interval between END Refreshes 1, 2, 3...
There are two ways to extend the interval between I/O refreshes. Either of these methods can be used. 1. Disable cyclic Special I/O Unit refreshing in the PC Setup (DM 6621) and use IORF(97) to refresh the Special I/O Unit’s I/O only when necessary. To disable cyclic refreshing for all Special I/O Units mounted to the CPU Rack or Expansion I/O Racks, set DM 6621 to #0100. 2. Increase the PC’s cycle time by setting a minimum cycle time in the PC Setup (DM 6619) or executing SCAN(18) in the program. (SCAN(18) is an expansion instruction with default function code 18.)
Short Interval between IORF(97) and END Refresh
Change the program to use either IORF(97) refreshing or END refreshing. It is also possible to increase the PC’s cycle time by setting a minimum cycle time in the PC Setup (DM 6619) or executing SCAN(18) in the program.
Short Interval between IORF(97) Instructions
Change the program to increase the spacing between IORF(97) instructions or use just one IORF(97) instruction.
128
Page 147
Section 4-12
Special I/O Unit Interface Programs
4-12-5 Reducing the Cycle Time
Unit 3
Unit 2
Unit 1
Unit 0
When a Special I/O Unit is mounted in a C200HX/HG/HE PC, END refreshing is performed automatically each cycle without making any special settings. When several Special I/O Units are being used, the cycle time might become too long because of the time required for this automatic I/O refreshing. To reduce the time devoted to I/O refreshing, disable cyclic Special I/O Unit refreshing in the PC Setup (DM 6621) and use IORF(97) to refresh the Special I/O Units instead. I/O refreshing for all Special I/O Units mounted to the CPU Rack or Expansion I/O Racks can be disabled in the PC Setup by setting DM 6621 to #0100. The following example program reduces the Special I/O Unit refreshing time for a PC with four Special I/O Units by refreshing just one Unit each cycle. The Units are refreshed in order: Unit 0, Unit 1, Unit 2, Unit 3, Unit 0, and so on.
C200HX/HG/HE
129
Page 148
Section 4-13
Analog Timer Unit Programming
The following program example is relevant for Special I/O Units mounted to the CPU Rack or Expansion I/O Racks only, because END refreshing is always performed on Special I/O Units mounted to Slave Racks regardless of the PC Setup settings. 30000
30001
30002
30003 30000
30000
30001
30002
30003 30001
30000
30001
30002
30003 30002
30000
30001
30002
30003 30003
30001
30002
30003 30000
30000 IORF(97) 100
Refreshes Unit 0.
100 30001 IORF(97)
1 cycle
110
Refreshes Unit 1.
110 30002 IORF(97) 120
Refreshes Unit 2.
120 30003 IORF(97) 130
Refreshes Unit 3.
130
Note IR 30000 is used in an OUT instruction twice in this program. Although acceptable in the above example, this type of duplication is not usually allowed unless there is a specific reason and then only when proper operation can be ensured.
4-13 Analog Timer Unit Programming An Analog Timer Unit’s timer SV can be changed easily without a Programming Console. The Unit is equipped with an external variable resistor connector, so a variable resistor can be installed in the control panel and connected to the Analog Timer Unit to set or adjust the timer SV manually.
4-13-1 Operation When the Timer Start Input is turned ON, the Timer Set Bits allocated to the Analog Timer Unit (bits 00 to 03 of n) are turned ON, the analog timer begins to operate, and the timer set indicator (SET) on the Unit will light. When the Unit’s timer SV (set internally or externally) elapses, the Unit’s Completion Flags (bits 08 to 11 of n) and the Time-up Output will be turned ON. Also, the time-up indicator on the Unit (TIME UP) will light.
130
Page 149
Section 4-13
Analog Timer Unit Programming
Refer to the Analog Timer Unit’s Operation Manual for details on switching between internal and external timer SV settings, connecting a variable resistor, and switch settings. Timer Start Input
Timer Set Bits (Bits 00 to 03 of n)
Bits 08 to 11 of n
Time-up Output
Completion Flags
Timer Start Input Time-up Output Timer interval
4-13-2 Bit Allocation and DIP Switch Settings The following table shows the use of the word (n) allocated to the Analog Timer Unit. This word address depends upon the slot in which the Unit is mounted. Bit 00 01 02 03 04 05 06 07 08 09 10 11 12 to 15
Timer Range Setting
I/O class Output
Input
---
Comments ON when timer is set.
OFF: Enable timer operation ON: Stop timer operation
ON when timer has timed out.
---
Set the timer range with the upper DIP switch on the front of the Unit. Each timer’s range can be set independently. Range 0.1 to 1 s 1 to 10 s 10 to 60 s 1 to 10 minutes
Selecting Internal/External Timer SV Setting
Function Timer 0 Set Bit Timer 1 Set Bit Timer 2 Set Bit Timer 3 Set Bit Timer 0 Stop Bit Timer 1 Stop Bit Timer 2 Stop Bit Timer 3 Stop Bit Timer 0 Completion Flag Timer 1 Completion Flag Timer 2 Completion Flag Timer 3 Completion Flag Not used.
Timer 0 Pin 8 Pin 7 OFF OFF ON OFF OFF ON ON ON
Timer 1 Pin 6 Pin 5 OFF OFF ON OFF OFF ON ON ON
Timer 2 Pin 4 Pin 3 OFF OFF ON OFF OFF ON ON ON
Timer 3 Pin 2 Pin 1 OFF OFF ON OFF OFF ON ON ON
Select internal or external setting with the lower DIP switch on the front of the Unit. Setting Internal External
Timer 0 (pin 4) ON OFF
Timer 1 (pin 3) ON OFF
Timer 2 (pin 2) ON OFF
Timer 3 (pin 1) ON OFF
131
Page 150
Section 4-13
Analog Timer Unit Programming
4-13-3 Example Program Unit Configuration
The following table shows the word allocations for the Units in this example. Item IR word allocated to the Analog Timer Unit IR word allocated to the Input Unit IR word allocated to the Output Unit
Word IR 002 IR 000 IR 005
The Analog Timer Unit’s SV settings and external variable resistor control connections are shown below. Timer 0 1 2 3
132
Set value 0.6 s 3s 20 s 8 minutes
Range 0.1 to 1 s 1 to 10 s 10 to 60 s 1 to 10 minutes
Variable resistor control Internal Internal External External
Page 151
Section 4-13
Analog Timer Unit Programming Unit Settings and Wiring
The following diagram shows the switch settings and wiring connections required to achieve the Unit configuration shown above.
The settings on these two variable resistor controls are valid because timers 0 and 1 are set for internal SV settings. Use the screwdriver included with the Unit to set the variable resistor. The settings on these two variable resistor controls are not valid because timers 2 and 3 are set for external SV settings.
The timer range settings are as follows: Timer 0:
Timer 1:
Timer 2:
Timer 3:
0.1 to 1 second
1 to 10 seconds 10 to 60 seconds 1 to 10 minutes
Pin 8
Pin 7
Pin 6
Pin 5
Pin 4
Pin 3
Pin 2
Pin 1
OFF
OFF
ON
OFF
OFF
ON
ON
ON
The internal/external SV settings are as follows: Timer 0
Timer 1
Timer 2
Timer 3
Pin 4
Pin 3
Pin 2
Pin 1
Internal
Internal
External
External
ON
ON
OFF
OFF
Do not connect anything to these connectors. Timers 0 and 1 are set for internal SV settings, so the variable resistor controls at the top of the Unit are used to set their SVs.
External SV Settings (0 to 20 KΩ) Connect variable resistor for timers 2 and 3 to these connectors. Refer to the Analog Timer Unit’s Operation Manual for details on these settings.
133
Page 152
Section 4-13
Analog Timer Unit Programming Ladder Program
The following diagram shows the example ladder program. 1, 2, 3...
1. Output IR 00500 will go ON about 0.6 s (T0) after input IR 00002 goes ON. 2. Output IR 00501 will go ON about 3 s (T1) after input IR 00003 goes ON. 3. Output IR 00502 will go ON about 20 s (T2) after input IR 00004 goes ON and IR 00503 will go ON about 8 minutes (T3) after input IR 00004 goes ON. 4. Timers 2 and 3 are stopped by input IR 00005. Timer Stop Bit
00005 Timer 0 Completion Flag 00206
T2 Timers 2 and 3 stop operating when the emergency stop input goes ON.
00207
T3
Timer 0 Set Bit 00002 00200
T0
00208 00500 Timer 0 Completion Flag
Timer 1 Set Bit
Timer 0 (00200) starts operating and the Unit’s SET indicator lights when IR 00002 goes ON. When the time set on the internal volume control elapses, the Completion Flag (00208) goes ON and the Unit’s TIME UP indicator lights. Output IR 00500 goes ON at the same time.
00003 00201
T1
00209 00501 Timer 1 Completion Flag
Timer 2 Set Bit
Timer 1 (00201) starts operating and the Unit’s SET indicator lights when IR 00003 goes ON. When the time set on the internal variable resistor control elapses, the Completion Flag (00209) goes ON and the Unit’s TIME UP indicator lights. Output IR 00501 goes ON at the same time.
00004 00202
T2 Timer 2 (00202) and timer 3 (00203) start operating and the Unit’s SET indicator lights when IR 00004 goes ON.
00203
00210 00502 Timer 2 Completion Flag
00211 00503 Timer 3 Completion Flag
134
T3 When the time set on the external variable resistor control elapses, the Completion Flag (00210) goes ON and the Unit’s TIME UP indicator lights. Output IR 00502 goes ON at the same time. When the time set on the external variable resistor control elapses, the Completion Flag (00211) goes ON and the Unit’s TIME UP indicator lights. Output IR 00503 goes ON at the same time.
Page 153
SECTION 5 Instruction Set The C200HX/HG/HE PCs have large programming instruction sets that allow for easy programming of complicated control processes. This section explains instructions individually and provides the ladder diagram symbol, data areas, and flags used with each. The C200HX/HG/HS PCs can process more than 100 instructions that require function codes, but only 100 function codes (00 to 99) are available. Some instructions, called expansion instructions, do not have fixed function codes and must be assigned function codes from the 18 function codes set aside for expansion instructions before they can be used. The many instructions provided by the C200HX/HG/HE PCs are organized in the following subsections by instruction group. These groups include Ladder Diagram Instructions, Bit Control Instructions, Timer and Counter Instructions, Data Shifting Instructions, Data Movement Instructions, Data Comparison Instructions, Data Conversion Instructions, BCD Calculation Instructions, Binary Calculation Instructions, Logic Instructions, Subroutines, Special Instructions, Network Instructions, Serial Communications Instructions, Advanced I/O Instructions, and Special I/O Unit Instructions. Some instructions, such as Timer and Counter instructions, are used to control execution of other instructions, e.g., a TIM Completion Flag might be used to turn ON a bit when the time period set for the timer has expired. Although these other instructions are often used to control output bits through the Output instruction, they can be used to control execution of other instructions as well. The Output instructions used in examples in this manual can therefore generally be replaced by other instructions to modify the program for specific applications other than controlling output bits directly. 5-1 5-2 5-3 5-4 5-5 5-6 5-7
5-8
5-9
5-10 5-11 5-12 5-13 5-14
5-15
Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Instruction Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Data Areas, Definer Values, and Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Differentiated Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Expansion Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Coding Right-hand Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Instruction Set Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7-1 Function Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7-2 Alphabetic List by Mnemonic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ladder Diagram Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8-1 LOAD, LOAD NOT, AND, AND NOT, OR, and OR NOT . . . . . . . . . . . . . . . . . . . . . . . 5-8-2 AND LOAD and OR LOAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bit Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-9-1 OUTPUT and OUTPUT NOT – OUT and OUT NOT . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-9-2 DIFFERENTIATE UP and DOWN – DIFU(13) and DIFD(14) . . . . . . . . . . . . . . . . . . . . 5-9-3 SET and RESET – SET and RSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-9-4 KEEP – KEEP(11) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . INTERLOCK and INTERLOCK CLEAR – IL(02) and ILC(03) . . . . . . . . . . . . . . . . . . . . . . . . . . . JUMP and JUMP END – JMP(04) and JME(05) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . END – END(01) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . NO OPERATION – NOP(00) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Timer and Counter Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14-1 TIMER – TIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14-2 HIGH-SPEED TIMER – TIMH(15) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14-3 TOTALIZING TIMER – TTIM(87) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14-4 COUNTER – CNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14-5 REVERSIBLE COUNTER – CNTR(12) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Data Shifting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15-1 SHIFT REGISTER – SFT(10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15-2 REVERSIBLE SHIFT REGISTER – SFTR(84) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15-3 ARITHMETIC SHIFT LEFT – ASL(25) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15-4 ARITHMETIC SHIFT RIGHT – ASR(26) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15-5 ROTATE LEFT – ROL(27) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15-6 ROTATE RIGHT – ROR(28) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15-7 ONE DIGIT SHIFT LEFT – SLD(74) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15-8 ONE DIGIT SHIFT RIGHT – SRD(75) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15-9 WORD SHIFT – WSFT(16) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15-10 ASYNCHRONOUS SHIFT REGISTER – ASFT(17) . . . . . . . . . . . . . . . . . . . . . . . . . . . .
138 138 138 140 141 142 145 145 145 149 149 150 150 150 151 153 154 155 157 158 158 158 159 164 165 166 169 171 171 173 175 175 176 176 177 177 178 178
135