CPM2A_PROGRAMMING MANUAL (W353-E1-2) (986750), страница 14
Текст из файла (страница 14)
In this way, they start the count operation for interrupt inputs(counter mode) and they permit interrupts.Storing Set Values in Data AreasThe counter’s set values are stored in words 240, 241, 242, and 243.SR 240SV for interrupt input (count mode) 0: 0000 to FFFFSR 241SV for interrupt input (count mode) 1: 0000 to FFFFSR 242SV for interrupt input (count mode) 2: 0000 to FFFFSR 243SV for interrupt input (count mode) 3: 0000 to FFFF65SectionCPM2A/CPM2C High-speed Counters2-2Starting the Count Operation and Permitting InterruptsIncrementing Counter(@)INT(89)004Interrupt control designation (004: Refresh incrementing counter SV)000Fixed: 000C2Control data wordDecrementing Counter(@)INT(89)003Interrupt control designation (003: Refresh decrementing counter SV)000Fixed: 000C2Control data wordSpecify and store 0Specify interrupt input (counter mode) 3Specify interrupt input (counter mode) 2Specify interrupt input (counter mode) 1Specify interrupt input (counter mode) 00: Refresh SV1: Do not refresh SVNote When INT(89) is executed to mask interrupts during counter operation (interruptcontrol designation 000), counter operation will be stopped and the counter PVwill be reset.
To use the counter again, start the counter operation again as described above.Change PVThis function refreshes the counter’s present value (PV).(@)INT(89)P002C2Port specifier (100. 102, 102, 103: Interrupt inputs (counter mode) 0 to 3)Control designation (002: Change PV)Change PV data wordC2Change PV dataRegisters the PV data to be changed.0000 to FFFFRead PVThis function reads the counter’s present value (PV).Using an Instruction(@)PRV(62)P000DPort specifier (100. 102, 102, 103: Interrupt inputs (counter mode) 0 to 3)Control designation (000: Read PV)Word for storing PVD66Read PV dataThe PV that is read is stored here.0000 to FFFFSectionCPM2A/CPM2C High-speed Counters2-2Using Data AreasThe high-speed counter’s present value (PV) is stored in words SR 244 toSR 247 as shown below.SR 244PVInterrupt input (counter mode) 0SR 245PVInterrupt input (counter mode) 1SR 246PVInterrupt input (counter mode) 2SR 247PVInterrupt input (counter mode) 3Words SR 244 to SR 247 are refreshed with every scan, so there may be a discrepancy from the exact PV at any given time.Words SR 244 to SR 247 cannot be used as work word even when the interruptinputs (counter mode) are not used.When the PV is read by executing PRV(62), words 244 to 247 are refreshed withthe same timing.Mask/Unmask All InterruptsFor details regarding masking and unmasking all interrupts, refer to 2-1-1 Interrupt Inputs.Application ExampleExplanationIn this example, the PV is decremented every time input 00003 is turned ON, andDM 0000 is incremented by 1 by an interrupt subroutine every 100 times (64Hex) that input 00003 is turned ON.WiringThe following diagram shows input wiring in the CPM2A.Input deviceThe following diagram shows input wiring in the CPM2C.Input terminalsInput connectorInput deviceInput device67SectionCPM1/CPM1A Interrupt Functions2-3PC Setup15DM 662800001Specifies bit 00003 as an interrupt input (counter mode).
Inputs00004 to 00006 are used as ordinary inputs.ProgrammingON for 1 cycle at beginningof operationClears Increment Area (DM 0000).Decrement counter settingCounter SV: 64 Hex (100 times)Stores SV in word 240.(89)Starts counter with bit 00003 as interrupt input(counter mode).Refreshes counter SV (decrement counter).Always 000.Specifies bit 00003. (Others are masked.)Executed one time when count is up.2-3CPM1/CPM1A Interrupt FunctionsThis section explains the settings and methods for using the CPM1/CPM1A interrupt functions.2-3-1 Types of InterruptsThe CPM1/CPM1A has three types of interrupt processing, as outlined below.Input InterruptsCPM1/CPM1A PCs have two or four interrupt inputs. Interrupt processing isexecuted when one of these inputs is turned ON from an external source.Interval Timer InterruptsInterrupt processing is executed by an interval timer with a precision of 0.1 ms.High-speed Counter InterruptsThe 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 Priority68When an interrupt is generated, the specified interrupt processing routine isexecuted.
Interrupts have the following priority ranking.Input interrupts > Interval interrupts = High-speed counter interruptsWhen an interrupt with a higher priority is received during interrupt processing,the current processes will be stopped and the newly received interrupt will beprocessed 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.SectionCPM1/CPM1A Interrupt Functions2-3When two interrupts with equal priority are received at the same time, they areexecuted in the following order:Input interrupt 0 > Input interrupt 1 > Input interrupt 2 > Input interrupt 3Interval interrupts > High-speed counter interruptsInterrupt ProgramPrecautionsObserve the following precautions when using interrupt programs:1, 2, 3...High-speed CounterInstructions and Interrupts1.
A new interrupt can be defined within an interrupt program. Furthermore, aninterrupt 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 notwrite a SUBROUTINE DEFINE instruction, SBN(92), within an interrupt program.4. An interrupt program cannot be written within a subroutine program.
Do notwrite 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.The following instructions cannot be executed in an interrupt subroutine whenan instruction that controls high-speed counters is being executed in the mainprogram:INI(61), PRV(62), or CTBL(63)The following methods can be used to circumvent this limitation:Method 1All interrupt processing can be masked while the instruction is being executed.@INT(89)100000000INI(61)000000000@INT(89)200000000Method 2Execute the instruction again in the main program.1, 2, 3...1.
This is the program section from the main program:@PRV(62)000002DM 0000LR 0000CTBL(63)000000DM 0000RSET LR 000069SectionCPM1/CPM1A Interrupt Functions2-32. This is the program section from the interrupt subroutine:SBN(92) 00025313@CTBL(63)000000DM 000025503NoteLR00001. Define interrupt routines at the end of the main program with SBN(92) andRET(93) instructions, just like regular subroutines.2.
When defining an interrupt routine, a “SBS UNDEFD” error will occur duringthe program check operation, but the program will be executed normally.2-3-2 Input InterruptsThe 10-pt CPU Units (CPM1-10CDR- and CPM1A-10CDR-) have two interrupt inputs (00003 and 00004).The 20-, 30-, and 40-pt CPU Units (CPM1-20CDR-, CPM1A-20CDR-,CPM1-30CDR-(-V1), CPM1A-30CDR- and CPM1A-40CDR-) havefour interrupt inputs (00003 to 00006).There are two modes for input interrupts: input interrupt mode and countermode.CPM1 PCsNC24VDC70000030000400005000060000420- and 30-pt CPU Units(CPM1-20CDR- andCPM1-30CDR-(-V1))0000310-pt CPU Units(CPM1-10CDR-)SectionCPM1/CPM1A Interrupt Functions2-3CPM1A PCs20-, 30-, and 40-pt CPU Units(CPM1A-20CDR-,CPM1A-30CDR-, andCPM1A-40CDR-)10-pt CPU Units(CPM1A-10CDR-)CPU UnitInputCPM1-10CDR-CPM1A-10CD-Interruptnumber00003000040000300010000004CPM1-30CDR-(-V1)00003CPM1A-30CD-00004CPM1A-40CD-01CPM1-20CDR-CPM1A-20CD-Response timeInterrupt modeCounter mode0.3 ms max.1 kHz(Time until theinterruptprogram isexecuted.)0203Note If input interrupts are not used, use inputs 00003 to 00006 as regular inputs.Input Interrupt SettingsInputs 00003 to 00006 must be set as interrupt inputs in DM 6628 if they are tobe used for input interrupts in the CPM1/CPM1A.
Set the corresponding digit to 1if 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.WordDM 6628Setting0: Regular input (default setting)1: Interrupt input2: Quick-response inputBit 150DM 6628Setting for input 00006: Set to 1Setting for input 00005: Set to 1Setting for input 00004: Set to 1Setting for input 00003: Set to 1Interrupt SubroutinesInterrupts from inputs 00003 to 00006 are allocated interrupt numbers 00 to 03and call subroutines 000 to 003.
If the input interrupts aren’t being used, subroutines 000 to 003 can be used in regular subroutines.Input numberInput RefreshingInterrupt numberSubroutine number000030000000041001000052002000063003If input refreshing is not used, input signal status within the interrupt routine willnot be reliable. Depending on the input time constant, the input signals might notgo ON even if input refreshing is used.