Instruction manual
AMPDIO DRIVERS
Page 32
Also a low-to-high transition on the gate input causes the initial count value to be re-latched into the
counting element.
Two functions TCgetExtFreq and TCgetExtPeriod (see sections 6.4.9.1 and 6.4.9.2) are used to
program a timer/counter to provide a one-shot gate pulse of precise duration to a second
timer/counter. The second timer/counter has an external signal as its clock input. When the gate
pulse is over, the second timer/counter's counting stops, and its value is then read. A simple
calculation is then made to determine the number of external clock cycles received during the gate
period, and from this the external frequency and period can be estimated. An increasing sequence
of gate periods (6.5535 ms, 65.535 ms, 655.35 ms, 6.5535 s and 65.535 s) is tried until a
sufficiently accurate count (at least 1000 ticks) is read from the second timer/counter. On cards
without clock and gate connection registers, such as the PC214E, a fixed gate period of 6.5535 ms
is assumed.
Version 4.42 of DIO_TC.DLL provides another frequency measurement function
TCgetExtFreqRestricted (see section 6.4.9.3). This uses two timer/counter channels in the same
way as TCgetExtFreq, but the frequency is external frequency is measured by counting external
clock pulses over a specified period. The function also indicates whether the 16-bit counter used to
measure the frequency overflowed during the measurement period.
The timer/counter you specify in calls to TCgetExtFreq, TCgetExtPeriod and
TCgetExtFreqRestricted is the second timer/counter described above. In cards that support
programmable gate configuration, the counters will be configured automatically. For certain legacy
cards the user must set appropriate jumpers. To use Z1 counter 2 on the PC214E, the following
connections must be made:
1. Connect the external TTL signal to SK1 pin 36 with reference to GND on, say SK1 pin 56.
2. Remove jumper J4
3. Place jumper J2 in position 1 (10 MHz) for TCgetExtFreq or TCgetExtPeriod, or in position 2 (1
MHz) for TCgetExtFreqRestricted.
4. Link SK1 pin 54 (Z1 /OUT0 O/P) to SK1 pin 75 (Z1 GAT2 I/P)
3.1.6 Frequency Generation
In mode 3 the output of the timer/counter is a periodic square wave, whose frequency is the input
clock frequency divided by the programmed counter divide ratio (CDR). The function
TCgenerateFreq (see section 6.4.8.4) calculates the CDR required for a specific frequency on a
given timer/counter. Normally the function selects an appropriate input clock frequency but, since
the PC214E does not support software-programmable clock connections, the clock input must be
set as 1 MHz on the appropriate jumper. For the PC27E, the clock input is fixed at 4 MHz.
The function TCgeneratePulse (see section 6.4.8.6) is provided as a variant of TCgenerateFreq.
This uses mode 2 instead of mode 3, which results in a periodic negative-going pulse instead of a
square wave. The width of the pulse is the period of the input clock.
3.1.7 Frequency Multiplication
An extension of the frequency measurement and frequency generation capabilities described in
sections 3.1.5 and 3.1.6 above is to combine the two into a process that measures an external
frequency on one timer/counter; multiplies the frequency value by a given factor and generates this
new frequency on a second timer/counter. Function TCmultiplyFreq described in section 6.4.9.4
performs this operation. See sections 3.1.5 and 3.1.6 above for connection details.