242
Timer and Counter Instructions
Section 5-16
Note
1.
Interval timer 0 cannot be used when a pulse output is being output by the
SPED(64) instruction.
2.
Interval timer 2 cannot be used when high-speed counter 0 operation has
been enabled in DM 6642 of the PC Setup.
Starting Interrupts
Set C1=000 to 002 to start timers 0 to 2 to activate a one-shot interrupt. Set
C1=003 to 005 to start scheduled interrupts using timers 0 to 2.
C2, which specifies the timer’s SV, can be a constant or the first of two words
containing the SV. The settings are slightly different depending on the method
used.
If C2 is a constant, it specifies the initial value of the decrementing counter
(BCD, 0000 to 9999). The decrementing time interval is 1 ms.
If C2 is a word address, C2 specifies the initial value of the decrementing
counter (BCD, 0000 to 9999), and C2+1 specifies the decrementing time
interval (BCD, 0005 to 0320) in units of 0.1 ms. The decrementing time inter-
val can thus be 0.5 to 32 ms.
C3 specifies subroutine number 0000 to 0255.
Note
The time required from interval timer start-up to time-up is:
(the content of C2)
×
(the content of C2+1)
×
0.1 ms
Reading Timer PVs
Set C1=006 to 008 to read the PVs of timers 0 to 2.
C2 specifies the first of two destination words that will receive the timer’s PV.
C2 will receive the number of times the decrementing counter has been dec-
remented (BCD, 0000 to 9999) and C2+1 will receive the decrementing time
interval (BCD in 0.1 ms units).
C3 specifies the destination word that will receive the time which has elapsed
since the last time the timer was decremented (BCD in 0.1 ms units).
(Must be equal to or less than the decrementing time interval set in C2+1.)
Note
The time that has elapsed since the timer was started is computed as follows:
(Content of C2
×
(Content of C2 + 1) + Content of C3)
×
0.1 ms
Stopping Timers
Set C1=010 to 012 to stop timers 0 to 2.
C2 and C3 have no function and should both be set to 000.
Flags
ER:
Interval timer 0 is started while a pulse output is operating.
(C1=000 only)
Interval timer 2 is started while the high-speed counter 0 is enabled
(C1=002 only)
Indirectly addressed EM/DM word is non-existent.
(Content of
*
EM/
*
DM word is not BCD, or the EM/DM area boundary
has been exceeded.)
A data area boundary has been exceeded.