CPM2A_PROGRAMMING MANUAL (W353-E1-2) (986750), страница 11
Текст из файла (страница 11)
Input points not used for counter inputs can be used as ordinary inputs.2. When not used for the counter PV storage destination, these words can beused as ordinary IR words.3. SR 25200 is read once each cycle. Up to one cycle may be required for areset to occur on the leading edge of phase Z.The following table shows the relationships between the high-speed counterand the CPM2A/CPM2C’s other functions.40SectionCPM2A/CPM2C High-speed CountersFunction2-2Interval timer interruptsSynchronized pulse controlCannot be used simultaneously.Interrupt inputsCan be used simultaneously.Interval timer interruptsCan be used simultaneously.High-speed counters---Interrupt inputs (counter mode)Can be used simultaneously.Pulse outputsCan be used simultaneously.Quick-response inputsCan be used simultaneously.Input time constantSee note.ClockCan be used simultaneously.Note When inputs 00000 to 00002 are set for use as a high-speed counter, the inputtime constants for the relevant inputs are disabled.
The input time constants remain in effect, however, for the values for refreshing the relevant input relayarea.Operation ExampleSelect the input mode and resetmethod.Input mode: Differential phase input, pulse + direction input, up/down input,or incrementReset method: Phase-Z + software reset, or software resetNo interrupts (Read high-speed counter PV, or read range comparison results)Select the interrupts to be used.Target value comparison interruptsRange comparison interruptsWire the inputs.Input numbers: 00000, 00001, 00002High-speed counter settingPC Setup (DM 6642)Input mode: Differential phase input, pulse + direction input, up/down input,or incrementReset method: Phase-Z + software reset, or software resetCTBL(63): Register comparison table, start comparisonCreate a ladder diagram program.INI(61): Change PV, start comparisonPRV(62): Read high-speed counter PV, read high-speed counter comparisonstatus, read range comparison resultsSBN(92) and RET(93): Create interrupt subroutine program(when count-check interrupts are used)41SectionCPM2A/CPM2C High-speed CountersPC SetupHigh-speedcounter functionEncoderinputsInput mode2-2DM 6642, bits 08 to 15Count-check interruptgenerated.CountDifferential phase inputLadder diagram programPulse + direction inputUp/down inputCTBL(63)Increment inputREGISTER COMPARISON TABLE instructionSpecified subroutine executed(when count-check interrupts areused).SBN(92)Register comparisontableStart comparisonPC SetupDM 6642, bits00 to 03INI(61)Every scanCounter PVMODE CONTROLinstructionChange PVStart/stopcomparisonRET(93)Each timePRV(62)SR 249 SR 248HIGH-SPEED COUNTERPV READ instructionRead PVRead comparison statusRange comparisonresultsAR 1100 to AR 1107Read range comparison resultsSelecting the Input Mode and Reset MethodInput ModeSelect the input mode for the high-speed counter according to the signal type.Differential Phase Input ModeIn the differential phase input mode, the count is incremented or decrementedaccording to two differential phase signals with a multiplication of 4 (phase A andphase B).Maximum frequency: 5 kHzONPhase AOFFONPhase BOFFCountNms → Frequency =1,000Nx442SectionCPM2A/CPM2C High-speed Counters2-2Pulse + Direction Input ModeIn the pulse + direction input mode, pulse signals and direction signals are input,and the count is incremented or decremented according to the direction signalstatus.Maximum frequency: 20 kHzONPulse inputsOFFONDirectioninputsOFFCount1,000Nms → Frequency =NUp/Down Pulse Input ModeIn the up/down pulse input mode, CW signals (up pulses) and CCW signals(down pulses) are input, and the count is incremented or decremented accordingly.Maximum frequency: 20 kHzONCW inputsOFFONCCW inputsOFFCountIncrementedNms → Frequency =Decremented1,000NIncrement ModeIn the increment mode, pulse signals are input and the count is incremented witheach pulse.
IR 00001 can be used as an ordinary input.Maximum frequency: 20 kHzONPulse inputsOFFCountNms → Frequency =1,000NWhen the differential phase input mode is used, the inputs must be 4X differential phase inputs. When an encoder is connected in this mode, the number ofcounts per revolution will be four times the encoder resolution. When selectingan encoder take into account the relationship with the number of counts that arepossible.Count ValuesThe range of numbers counted by the high-speed counter are in linear mode43SectionCPM2A/CPM2C High-speed Counters2-2only.
If the count is outside of the permissible range, an overflow or underflow willresult. The PV will become 0FFFFFFF if an overflow occurs, or FFFFFFFF if anunderflow occurs, and the comparison will be stopped.Differential phase inputmodePulse + direction inputmodeOverflow (0FFFFFFF)Underflow (FFFFFFFF)Up/down pulse inputmodeIncrement modeOverflow (0FFFFFFF)To restart the count following an overflow or underflow, reset the PV. (The PV isautomatically reset whenever operation is started or stopped.)Reset MethodEither of the following two methods can be selected for resetting the counter PVto 0.Phase-Z Signal (Reset Input) + Software ResetThe PV is reset when a phase-Z signal (i.e., a reset input) turns ON while theHigh-speed Counter Reset Flag (25200) is ON.1 scanPhase ZResetResetNot resetResetNot resetSoftware ResetThe PV is reset when the High-speed Counter Reset Flag (25200) turns ON.1 scanResetNot resetNot resetNot resetThe High-speed Counter Reset Flag (25200) is refreshed with every scan, so itmust remain ON for at least one cycle time to be certain it is read.Even when the PV is reset, the comparison table registration status, the comparison execution status, and the range comparison results are all retained just asthey were before the PV reset.
(If a comparison was underway prior to the PVreset, that comparison will be continued with no change following the reset.)Following the reset, the High-speed Counter Reset Flag (25200) must be turnedOFF in order to be able to execute the next reset. To be certain that it is turnedOFF, it must be remain OFF for at least one cycle time.Selecting the Interrupts to be UsedHigh-speed CounterInterrupts44High-speed counter interrupts use a comparison table and perform a countcheck by either of the methods described below (i.e., target value comparison orrange comparison).
If the conditions are satisfied, then an interrupt is generated.For details regarding interrupt priorities, refer to Order of Priority for Interruptsunder 2-1 Interrupts.SectionCPM2A/CPM2C High-speed Counters2-2If an interrupt is generated during execution of one of the high-speed countercontrol instructions, i.e., CTBL(63), INI(61), or PRV(62), these instructions willnot be executed within the interrupt program.Target Value Comparison InterruptsUp to 16 combinations of comparison conditions (target value and count direction) and interrupt subroutine numbers can be registered in the comparisontable.
The specified subroutine is executed when the counter PV matches a target value in the comparison table.PVComparison tableTarget value: 5,000Count direction: IncrementSubroutine number: 10IncrementdirectionDecrementdirectionTarget value: 1,000Count direction: IncrementSubroutine number: 8IncrementdirectionTarget value: 3,000Count direction: DecrementSubroutine number: 9TimeInterruptSubroutine 8executedInterruptSubroutine 10executedInterruptSubroutine 9executedThe relationship between the target value comparison count check and the comparison table is different for the CPM1/CPM1A. Refer to the individual manualsfor details.It is not possible to specify more than one comparison direction condition for thesame target value in the comparison table.Either target value comparison or range comparison can be used for high-speedcounter interrupts.Range Comparison InterruptsUp to eight combinations of comparison conditions (upper limit and lower limit)and interrupt subroutine numbers can be registered in the comparison table.The specified subroutine is executed once when the counter PV is greater thanor equal to the lower limit and less than or equal to the upper limit in the comparison table.Comparison tablePVLower limit: 1,000Upper limit: 4,000Subroutine number: 10Lower limit: 3,000Upper limit: 5,000Subroutine number: 9TimeInterruptSubroutine 10executedInterruptInterruptInterruptSubroutine 9 Subroutine 9 Subroutine 10executedexecutedexecutedIf two or more comparison conditions are satisfied simultaneously (in the samecycle), the interrupt for the condition closest to the beginning of the comparisontable will be executed.45SectionCPM2A/CPM2C High-speed Counters2-2Either target value comparison or range comparison can be used for high-speedcounter interrupts.If an interrupt is generated during execution of one of the high-speed countercontrol instructions, i.e., CTBL(63), INI(61), or PRV(62), these instructions willnot be executed within the interrupt program.If an interrupt is generated while an instruction controlling the high-speed counter is being executed in the normal program area, the CTBL(63), INI(61), andPRV(62), instructions will not be executed within the interrupt program.
This situation can be avoided by means of the following programming.Method 1Method 2Prohibit interrupts in thenormal program area whileexecuting the instruction.In the normal program area,re-execute the instructionthat could not be executed.Normal program areaInterrupt program areaInterrupt processing subroutines are defined by SBN(92) and RET(93), just likeordinary subroutines.An SBS UNDEFD error will be generated during the program check while an interrupt processing subroutine is being defined, but execution will be normal.Wiring InputsWire the inputs as shown in the following illustrations, according to the inputmode and the reset method.CPM2A InputsDifferential Phase Input ModeUp/Down Pulse Input Mode00000: CW input00001: CCW input00002: Reset input00000: Phase-A input00001: Phase-B input00002: Phase-Z inputPulse + Direction Input Mode00000: Pulse input00001: Direction input00002: Reset input46Increment Mode00000: Pulse input00002: Reset inputSectionCPM2A/CPM2C High-speed Counters2-2CPM2C InputsDifferential Phase Input ModeInput terminalsInput connector00002: Phase-Z input00001: Phase-B input00000: Phase-A input00002: Phase-Z input00001: Phase-B input00000: Phase-A inputUp/Down Pulse Input ModeInput terminalsInput connector00002: Reset input00001: CCW input00000: CW input00002: Reset input00001: CCW input00000: CW inputPulse + Direction Input ModeInput terminalsInput connector00002: Reset input00001: Direction input00000: Pulse input00002: Reset input00001: Direction input00000: Pulse input47SectionCPM2A/CPM2C High-speed Counters2-2Increment ModeInput terminalsInput connector00002: Reset input00000: Pulse input00002: Reset input00000: Pulse inputWhen phase-Z and reset inputs are not used, 00002 can be used as an ordinaryinput.PC SetupSet the PC Setup areas related to the high-speed counter as follows:WordDM 6642High-speed counter usageDM 6642, bits 08 to 15Input modeDM 6642, bits 00 to 03Reset method(Use/not use 00002 as ordinary input)DM 6642, bits 04 to 07BitsFunctionSetting00 to 03High-speed counter input mode setting0, 1, 2, or 404 to 070: Differential phase input 5 kHz1: Pulse + direction input 20 kHz2: Up/down input20 kHz4: Increment20 kHzHigh-speed counter reset method setting0 or 108 to 150: Phase-Z signal + software reset1: Software resetHigh-speed counter usage setting0100: Do not use.01: Use as high-speed counter02: Use as pulse synchronization control(10 Hz to 500 Hz)03: Use as pulse synchronization control(20 Hz to 1 kHz)04: Use as pulse synchronization control(300 Hz to 20 kHz)The new settings for the System Setup go into effect when operation begins(when PROGRAM mode is changed to MONITOR or RUN mode), or when theCPM2A/CPM2C’s power is turned ON.48SectionCPM2A/CPM2C High-speed CountersLadder DiagramProgramming2-2The following table shows the instructions related to high-speed counter control.Instruction(@)CTBL(63)Control(@)INI(61)OperationRegister target valuecomparison tableRegister rangecomparison tableRegister target valuecomparison table andstart comparisonRegisters target value comparison table.Register rangecomparison table andstart comparisonRegisters range comparison table andstarts comparison.Registers range comparison table.Registers target value comparison tableand starts comparison.Start comparisonStarts comparison with registeredcomparison table.Stop comparisonStops comparison.Change PVChanges the high-speed counter PV.Read PVReads the high-speed counter PV.Read statusReads the high-speed counter status.Read range comparison Reads range comparison result.resultMask all interruptsProhibits all interrupts, including interruptinputs, interval timer interrupts,high-speed counters, etc.(@)PRV(62)(@)INT(89)Unmask all interruptsPermits all interrupts, including interruptinputs, interval timer interrupts,high-speed counters, etc.The following table shows the data areas related to high-speed counter control.Word248249Bits25200 to 1500 to 1500AR1100 to 070809NameHigh-speed counter PVContentsReads high-speed counterPV.High-speed counter resetWhen this bit turns ON, asoftware reset is triggeredfor the high-speed counter.High-speed counter rangecomparison resultsHigh-speed countercomparisonHigh-speed counter PVoverflow/underflowON: Condition satisfiedOFF: Condition not satisfiedON: Comparison in progressOFF: Comparison stoppedON: Overflow/underflowOFF: NormalRegister Target Value Comparison TableRegister Target Value Comparison Table and Start ComparisonThese functions register a comparison table to the CPM2A/CPM2C for the purpose of count checking in target value comparison.