CPM2A_PROGRAMMING MANUAL (W353-E1-2) (986750), страница 63
Текст из файла (страница 63)
If the executioncondition has not changed or has changed from ON to OFF, the PV of CNT willnot be changed. The Completion Flag for a counter is turned ON when the PVreaches zero and will remain ON until the counter is reset.CNT is reset with a reset input, R. When R goes from OFF to ON, the PV is resetto SV. The PV will not be decremented while R is ON.
Counting down from SV willbegin again when R goes OFF. The PV for CNT will not be reset in interlockedprogram sections or by power interruptions.Changes in execution conditions, the Completion Flag, and the PV are illustrated below. PV line height is meant only to indicate changes in the PV.Execution conditionon count pulse (CP)ONExecution conditionon reset (R)ONOFFOFFONCompletion FlagOFFSVSVPV0002SV – 1SV – 200010000364Section 7-15Timer and Counter InstructionsPrecautionsProgram execution will continue even if a non-BCD SV is used, but the SV willnot be correct.FlagsER:ExampleIn the following example, CNT is used to create extended timers by counting SRarea clock pulse bits.CNT 001 counts the number of times the 1-second clock pulse bit (SR 25502)goes from OFF to ON.
Here again, IR 00000 is used to control the times whenCNT is operating.Because in this example the SV for CNT 001 is 700, the Completion Flag forCNT 002 turns ON when 1 second x 700 times, or 11 minutes and 40 secondshave expired. This would result in IR 20002 being turned ON.Indirectly addressed DM word is non-existent. (Content of *DM word isnot BCD, or the DM area boundary has been exceeded.)00000 25502AddressCPCNT00100001R#0700CNT 001Instruction00000000010000200003LDANDLD NOTCNT0000400005LDOUT20002! CautionOperands#CNT000002550200001001070000120002The shorter clock pulses will not necessarily produce accurate timers becausetheir short ON times might not be read accurately during longer cycles. In particular, the 0.02-second and 0.1-second clock pulses should not be used to createtimers with CNT instructions.7-15-6 REVERSIBLE COUNTER – CNTR(12)Definer ValuesN: TC numberLadder Symbol#IIDIRCNTR(12)NOperand Data AreasSVSV: Set value (word, BCD)IR, SR, AR, DM, HR, LR, #LimitationsEach TC number can be used as the definer in only one TIMER or COUNTERinstruction.
TC numbers run from 000 through 255 in the CPM2A/CPM2C PCsand from 000 through 127 in the CPM1/CPM1A/SRM1(-V2) PCs.DescriptionThe CNTR(12) is a reversible, up/down circular counter, i.e., it is used to countbetween zero and SV according to changes in two execution conditions, those inthe increment input (II) and those in the decrement input (DI).The present value (PV) will be incremented by one whenever CNTR(12) isexecuted with an ON execution condition for II and the last execution conditionfor II was OFF.
The present value (PV) will be decremented by one wheneverCNTR(12) is executed with an ON execution condition for DI and the last execution condition for DI was OFF. If OFF to ON changes have occurred in both II andDI since the last execution, the PV will not be changed.365Section 7-15Timer and Counter InstructionsIf the execution conditions have not changed or have changed from ON to OFFfor both II and DI, the PV of CNT will not be changed.When decremented from 0000, the present value is set to SV and the Completion Flag is turned ON until the PV is decremented again.
When incrementedpast the SV, the PV is set to 0000 and the Completion Flag is turned ON until thePV is incremented again.CNTR(12) is reset with a reset input, R. When R goes from OFF to ON, the PV isreset to zero. The PV will not be incremented or decremented while R is ON.Counting will begin again when R goes OFF. The PV for CNTR(12) will not bereset in interlocked program sections or by the effects of power interruptions.Changes in II and DI execution conditions, the Completion Flag, and the PV areillustrated below starting from part way through CNTR(12) operation (i.e., whenreset, counting begins from zero).
PV line height is meant to indicate changes inthe PV only.Execution conditionon increment (II)ONExecution conditionon decrement (DI)ONOFFOFFONCompletion FlagOFFSVPVSVSV – 1SV – 10001SV – 2SV – 200000000PrecautionsProgram execution will continue even if a non-BCD SV is used, but the SV willnot be correct.FlagsER:Indirectly addressed DM word is non-existent.
(Content of *DM word isnot BCD, or the DM area boundary has been exceeded.)7-15-7 REGISTER COMPARISON TABLE – CTBL(63)Ladder SymbolsOperand Data AreasP: Port specifierCTBL(63)@CTBL(63)PPCCTBTB000C: Control data000 to 003TB: First comparison table wordIR, SR, AR, DM, HR, LRThis instruction is not supported by SRM1(-V2) PCs.LimitationsThe first and last comparison table words must be in the same data area. (Thelength of the comparison table varies according to the settings.)P must be 000 and C must be between 000 and 003.DescriptionWhen the execution condition is OFF, CTBL(63) is not executed. When theexecution condition is ON, CTBL(63) registers a comparison table for use withthe high-speed counter PV.
Depending on the value of C, comparison with thehigh-speed counter PV can begin immediately or it can be started separatelywith INI(61).366Section 7-15Timer and Counter InstructionsThe port specifier (P) specifies the high-speed counter that will be used in thecomparison. Always set P to 000.The function of CTBL(63) is determined by the control data, C, as shown in thefollowing table.
These functions are described after the table.CCTBL(63) function000Registers a target value comparison table and starts comparison.001Registers a range comparison table and starts comparison.002Registers a target value comparison table. Start comparison with INI(61).003Registers a range comparison table. Start comparison with INI(61).When the PV agrees with a target value or falls within a specified range, the specified subroutine is called and executed.
Refer to 2-3-5 High-speed Counter Interrupts for more details on table comparison.If the high-speed counter is enabled in the PC Setup (DM 6642), it will begincounting from zero when the CPM2A/CPM2C begins operation. The PV will notbe compared to the comparison table until the table is registered and comparison is initiated with INI(61) or CTBL(63). Comparison can be stopped andstarted, or the PV can be reset with INI(61).Common Characteristicsof Target Value andRange Comparisons1, 2, 3...The operation of a target value comparison is different from a range comparison,but the two functions share some common characteristics.1. Subroutine numbers 000 to 049 can be used and the same subroutine number can be used more than once in the table.2. An undefined subroutine number or FFFF can be set for the subroutinenumber if interrupt processing is not required.3.
Comparison can be stopped with INI(61). A registered table is valid until PCoperation stops or a new comparison table is registered.4. CTBL(62) cannot be executed if the high-speed counter is disabled in thePC Setup (DM 6642). (An error will occur if CTBL(63) is executed when thehigh-speed counter is disabled.)Target Value ComparisonA target value comparison table contains up to sixteen target values. A subroutine number is also registered for each target value. The corresponding subroutine is called and executed when the PV matches a target value. (When interruptprocessing is not required, an undefined subroutine number may be entered.)• In the CPM1/CPM1A, target value comparisons are performed one item at atime in order of the comparison table.
When the PV reaches the first target value in the table, the interrupt subroutine is executed and comparison continuesto the next value in the table. When processing has been completed for the lasttarget value in the table, comparison returns to the first value in the table andthe process is repeated.• In the CPM2A/CPM2C, the PV is compared to all of the target values in thetable each time CTBL(63) is executed.
When the PV matches a target valuethe corresponding subroutine is called and executed.The following diagram shows the structure of a target value comparison table.Target values must be unique; an error will occur if a target value appears in thetable more than once.TBTB+1TB+2TB+3Number of target values (0001 to 0016, BCD)Target value #1, lower 4 digits (BCD)Target value #1, upper 4 digits (BCD)Subroutine number for #1 (See note.)One targetvalue setting367Section 7-15Timer and Counter InstructionsNote The subroutine number can be F000 to F049 to activate the subroutine whendecrementing and can be 0000 to 0049 to activate the subroutine when incrementing.
An error will occur if the high-speed counter is set to increment modebut a decrementing subroutine number (F000 to F049) is specified.Range ComparisonA range comparison table contains 8 ranges which are defined by an 8-digit lower limit and an 8-digit upper limit, as well as their corresponding subroutine numbers. The comparison is performed once each cycle at the end of program execution and can be performed during program execution with INI(61).When the PV falls within a given range the corresponding subroutine is calledand executed. (When interrupt processing is not required, an undefined subroutine number may be entered.) Ranges can overlap, so the PV can fall withinmore than one range; in the PV is within two or more ranges, the subroutine forthe first of the ranges will be executed.The following diagram shows the structure of a range comparison table.
Alwaysset 8 ranges. If fewer than 8 ranges are needed, set the remaining subroutinenumbers to FFFF.NoteFlagsTBTB+1TB+2TB+3TB+4Lower limit #1, lower 4 digits (BCD)Lower limit #1, upper 4 digits (BCD)Upper limit #1, lower 4 digits (BCD)Upper limit #1, upper 4 digits (BCD)Subroutine number (See note 2.)First range settingTB+35TB+36TB+37TB+38TB+39Lower limit #8, lower 4 digits (BCD)Lower limit #8, upper 4 digits (BCD)Upper limit #8, lower 4 digits (BCD)Upper limit #8, upper 4 digits (BCD)Subroutine number (See note 2.)Eighth range setting1. Each range’s lower limit must be less than its upper limit. An error will occur ifthe lower limit is greater than the upper limit.2.