Information in this document is subject to change without notice. The software
described is this document is furnished under a license agreement. The software may
be used or copied only in accordance with the terms of the agreement.
SCIENTIFIC SOFTWARE TOOLS, INC. SHALL NOT BE LIABLE FOR ANY
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES RELATED TO
THE USE OF THIS PRODUCT. THIS PRODUCT IS NOT DESIGNED WITH
COMPONENTS OF A LEVEL OF RELIABILITY SUITABLE FOR USE IN LIFE
SUPPORT OR CRITICAL APPLICATIONS.
This document may not, in whole or in part, be copied, photocopied, reproduced,
translated or reduced to any electronic medium or machine readable form without
prior written consent from Scientific Software Tools, Inc.
DriverLINX Counter/Timer Programming Guide
Copyright 1997-2001, Scientific Software Tools, Inc.
All rights reserved.
SST 08-0101-1
LabOBJX, DriverLINX, and SSTNET are registered trademarks and
DriverLINX/VB is a trademark of Scientific Software Tools, Inc.
Microsoft and Windows are registered trademarks and Visual C++ and Visual Basic
are trademarks of Microsoft Corporation.
Borland is a registered trademark and Borland C++ is a trademark of Borland
International, Inc.
All Keithley product names are trademarks or registered trademarks of Keithley
Instruments, Inc.
All other brand and product names are trademarks or registered trademarks of their
respective companies.
Contents
Preface 7
Software License and Software Disclaimer of Warranty...........................................................7
About DriverLINX.....................................................................................................................9
About This Programming Guide................................................................................................9
Conventions Used in This Manual...........................................................................................11
Why Use a Counter/Timer Device Driver 13
Using Direct Hardware I/O......................................................................................................13
Advantages of Device Drivers.................................................................................................13
Introducing DriverLINX 15
About DriverLINX...................................................................................................................15
Software License and Software Disclaimer of Warranty
This is a legal document which is an agreement between you, the Licensee, and Scientific S oftware Tools, Inc. By opening this
sealed diskette package, Licensee agrees to become bound by the terms of this Agreement, which include the Software License and
Software Disclaimer of Warranty.
This Agreement constitutes the complete Agreem ent between Licensee and Scientific Software Tools, Inc. If Licensee does not
agree to the terms of this Agreement, do not open the diskette pack age. Promptly return the unopened disk ette package and the other
items (including written materials , binders or other containers, and hardware, if any) t hat are part of this product to Scientific Software
Tools, Inc. for a full refund. No refunds will be given for products that have opened disk packages or missing components.
Licensing Agreement
Copyright. The software and documentation is owned by Scient ific Software Tools, Inc. and is prot ected by both United States
copyright laws and international treaty provisions. Scientific Software Tools, Inc. authorizes the original purchas er only (Licensee) to
either (a) make one copy of the software solely for backup or archival purposes, or (b) transfer the software to a single hard disk only.
The written materials accompanying the software may not be duplicated or copied for any reason.
Trade Secret. Licensee understands and agrees that the software is the proprietary and confidential property of Scientif ic Software
Tools, Inc. and a valuable trade sec ret. Licensee agrees t o use the software only for the intended use under t his License, and shall not
disclose the software or its contents to any third party.
Copy Restrictions. The Licensee may not modify or translate the program or relat ed documentation without the prior written
consent of Scientific Software Tools, Inc. All modifications, adaptations, and merged porti ons of the software constitute the s oftware
licensed to the Licensee, and the terms and conditions of this agreement apply t o same. Licensee may not distribute copies, i ncluding
electronic transfer of copies, of the modified, adapted or merged software or accompanying written materials to others. Licens ee agrees
not to reverse engineer, decompile or disassemble any part of the software.
Unauthorized copying of the software, including software that has been modif ied, merged, or included with other software, or of the
written materials is expressly forbidden. Licensee may not rent, transf er or lease the software to any third parties. Licensee agrees to
take all reasonable steps to protect Scientific Software Tools’ software from theft, disclosure or use contrary to the terms of the License.
License. Scientific Software Tools, Inc. grants the Licensee only a non-exclusive right t o use the serialized copy of the software on a
single terminal connected to a single computer. The Licensee may not network the software or use it on more than one computer or
computer terminal at the same time.
Term. This License is effective until terminated. This License will terminate automatically without notice from Scientific Software
Tools, Inc. if Licensee fails t o comply with any term or condition of this Lic ense. The Licensee agrees upon suc h terminat ion to return or
destroy the written materials and all copies of the software. The Licensee may terminat e the agreement by returning or destroying the
program and documentation and all copies thereof.
DriverLINX Counter/Timer User’s Guide Preface • 7
Limited Warranty
Scientific Software Tools, Inc. warrants that the software will perform substantially in accordance with the written materials and that
the program disk, instructional manuals and reference materials are free from defects in materials and workmanship under normal use for
90 days from the date of receipt. All express or implied warranties of the software and related materials are limited to 90 days.
Except as specifically set forth herein, t he software and accompanying writt en materials (including i nstructions for use) are provided
“as is” without warranty of any kind. Furt her, Scientific Software Tools, Inc. does not warrant, guarantee, or make any represent atio ns
regarding the use, or the results of the use, of the software or written materi als in terms of correctness, accuracy , reliability, c urrent ness,
or otherwise. The entire risk as to the results and performance of the software is assumed by Licensee and not by Scientific Software
Tools, Inc. or its distributors, agents or employees.
EXCEPT AS SET FORTH HEREIN, THERE ARE NO OT HER WARRANTIES, EITHE R EXPRESS OR IMPL IED, I NCLUDING BUT
NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH
RESPECT TO THE SOFTWARE, THE ACCOMPANYING WRITTEN M AT ERIALS, AND ANY ACCOMPANYING HARDWARE.
Remedy. Scientific Software Tools’ entire liability and the Lic ensee’s exclusive remedy shall be, at Scientific Software Tools’ opt ion,
either (a) return of the price paid or (b) repair or replacement of the software or ac companying materials. In the event of a defect in
material or workmanship, the item may be returned withi n the warranty period to Scientific Software Tools for a replacement without
charge, provided the licensee previously sent in the limited warranty registration card to Sc ientific Software Tools, Inc., or can furnish
proof of the purchase of the program. This remedy is void if failure has resulted from accident, abus e, or mis appl ication. Any replacement
will be warranted for the remainder of the original warranty period.
NEITHER SCIENTIFIC SOFTWARE TOOLS, INC. NOR ANYONE ELSE WHO HAS BEEN INVOLVED IN THE CREATION,
PRODUCTION, SALE OR DELIVERY OF THIS PRODUCT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTI AL,
OR INCIDENTAL DAMAGES (INCLUDING DAMAGE S FOR LOSS OF BUSINESS PROFITS, BUSINESS I NTERRUPTION, L OSS OF
BUSINESS INFORMATION AND THE L I KE) ARI SING OUT OF THE USE OF OR THE INABILITY TO USE SUCH PRODUCT EVEN IF
SCIENTIFIC SOFTWARE TOOLS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME
JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL
DAMAGES, OR LIMITATIONS ON DURATION OF AN IMPLIED WARRANTY , THE ABOVE LIMITATIONS MAY NOT APPLY TO
LICENSEE.
This agreement is governed by the laws of the Commonwealth of Pennsylvania.
8 • Preface DriverLINX Counter/Timer User’s Guide
About DriverLINX
Welcome to DriverLINX for Microsoft Windows, the high-performance real-
time data-acquisition device drivers for Windo ws application development.
DriverLINX is a language- and hardware-independent application-programming
interface designed to support hardware manufacturers’ high-speed analog, digital,
and counter/timer data-acquisition boards in Windows. DriverLINX is a multi-user
and multitasking data-acquisition resource manager providing more than 100
services for foreground and background data acquisition tasks.
Included with your DriverLINX package are the following items:
•The DriverLINX DLLs and drivers supporting your data-acquisition
hardware
•Learn DriverLINX, an interactive learning and demonstration program
for DriverLINX that includes a Digital Storage Oscilloscope
• Source code for the sample programs
• The DriverLINX Application Programming Interface files for your
compiler
• DriverLINX On-line Help System
• DriverLINX 4.0 Installation and Configuration Guide
• DriverLINX Technical Reference Manual
• Supplemental Documentation on DriverLINX and your data acquisition
hardware
About This Programming Guide
The purpose of this manual is to help you quickly learn to program DriverLINX for
counter/ti mer operat i ons with your hardware.
• For help installing and configuring your hardware and DriverLINX,
please see the hardware manuals that accompanied your board and the
DriverLINX 4.0 Installation and Configuration Guide for your version
of Windows.
• For more information on the DriverLINX API, please see the on-line
DriverLINX Technical Reference Manual.
• For additional help programming your board, please exa mine the
source code examples on the Distribution Disks.
This manual is divided into the following chapters:
Why Use a Counter/Timer Device Driver
Brief discussion of why modern operating systems require device drivers.
Introducing DriverLINX
Presents a quick overview of DriverLINX’s hardware and programming model.
Counter/Timers and DriverLINX
Describes how DriverLINX’s hardware model supports counter/timer boards.
DriverLINX Counter/Timer User’s Guide Preface • 9
Programming Counter/Timers with DriverLINX
Explains how to program counter/timer tasks.
Using Task-Oriented Functions
Describes counter/timer functions that DriverLINX defines with a task orientation
rather than a hardware orientation.
Hardware Reference
Describes Intel 8254, KPCI-3140 and Am9513 operating modes and how they map
onto the DriverLINX programming model.
Most counter/timer devices are simple devices to program. For years most
application developers wrote directly to the I/O hardware using the CPU’s I/O
instructions (inp and outp) or using Peek and Poke statements in Basic. This was
simple, fast, and efficient and required a minimal learning curve.
Under Windows 3.x, C/C++ developers could use these same techniques for most
ports despite Microsoft’s strong recommendation against doing so. Visual Basic
programmers, however, found that Microsoft had removed all direct I/O statements
from the language, but they quickly discovered they could replace the missing
statements with calls to simple DLLs.
With the arrival of Windows NT, direct hardware I/O in user applicatio ns is not
physically possible. Hardware I/O in DOS and Win16 apps may appear to execute,
but the CPU never actually executes the I/O instructions. In Win32 apps hardware
I/O instructions generate a “privileged instruction exception” and terminate the
offending app.
To perform user-level I/O in Windows NT and future versions of Windows 95, the
operating system requires that applications communicate with the hardware using a
device driver. Modern device drivers are effectively trusted operating system
extensions that have more privileges than ordinary user-mode applications, DLLs,
and services.
Advantages of Device Drivers
Using device drivers to control hardware offers an application in a modern
multitasking, multithreaded operating system several advantages and one major
disadvantage. The application advantages of the device driver model are
• hardware-independent access to boards belonging to a class of devices,
• resource sharing of a single physical device among multiple
applications and/or threads,
DriverLINX Counter/Timer User’s Guide Why Use a Counter/Timer Device Driver • 13
• resource arbitration when multiple device users contend for the same
hardware resources, and
• system security either at the logical level of authorized device users or
at the physical level of preventing misuse of a device.
The main disadvantage of the device driver model is the extra overhead the system
requires to communicate device requests between the application, the device driver,
and the hardware. For device requests, such as acquiring a million data samples
in one request, the overhead is negligible, but for acquiring one sample using a
million separate requests, the time penalty is significant. For this reason,
developers must often redesign the protocols and algorithms that worked well in a
single-tasking OS, such as DOS, for use in a multitasking system, such as Windows
NT.
14 • Why Use a Counter/Timer Device Driver DriverLINX Counter/Timer User’s Guide
Introducing DriverLINX
About DriverLINX
The DriverLINX Distribution
Disks contain many sample
programs for a variety of
hardware devices. Many
samples will not work with
counter/timer devices.
Welcome to DriverLINX for Microsoft Windows. DriverLINX is a language and
hardware-independent, high-performance, real-time, data-acquisition device driver
for 16 and 32-bit Windows 3.x, Windows 95 and Windows NT. DriverLINX
supports an abstract hardware model for generalized data-acquisition hardware that
includes analog and digital I/O as well as counter/timer functions.
This chapter briefly surveys the DriverLINX hardware and programming model. The
on-line DriverLINX Technical Reference Manual included with the DriverLINX
package is the complete, board-independent specification for the abstract
DriverLINX hardware model. Whether or not you are familiar with DriverLINX
programming, this guide will ease your learning curve by focusing on just the
counter/timer subsystem programming model.
DriverLINX Hardware Model
DriverLINX Driver
Each DriverLINX driver supports one or more models of a device series in a
manufacturer’s product line. You can control multiple products from different series
by opening several DriverLINX drivers. You can program each product using
different “Service Requests” for each overlapping data-acquisition task.
Logical Devices
A single DriverLINX driver can support multiple boards from its list of supported
models. During configuration, you assign each physical device a Logical Device
number that you use to identify a particular board to DriverLINX. At run time,
applications can determine the manufacturer, model name, I/O address, and hardware
resources of a Logical Device by consulting DriverLINX’s Logical Device
Descriptor.
DriverLINX treats all data-acquisition devices uniformly as abstract hardware
consisting of seven possibl e subsystems.
• DEVICE—the physical hardware considered as a whole.
• AI (Analog Input)—the A/D converters, multiplexers, and associated
hardware.
• AO (Analog Output)—the D/A converters and associated hardware.
• DI (Digital Input)—the digital input ports and associated hardware.
• DO (Digital Output)—the digital output ports and associated hardware.
• CT (Counter/Timer)—the counter/timer channels and associated
hardware.
DriverLINX’s Logical Device Descriptor contains properties specifying which
Logical Subsystems are available for a particular device. Counter/timer boards
always support the DEVICE and CT subsystems, and some boards support
additional subsystems, such as DI and DO.
Logical Channels
The subsystems, except DEVICE, consist of one or more data channels known as
Logical Channels. Usually a Logical Channel corresponds to one hardware channel,
but, for some boards, DriverLINX may use multiple Logical Cha nnel numbers to
access a group of hardware channels using different data widths. DriverLINX
records the number of Logical Channels and their capabilities in the Logical Device
Descriptor.
DriverLINX Programming Model
Programming DriverLINX for data-acquisition tasks differs from the approach you
may have used previously. Most vendors’ data-acquisition packages consist of thick
documents describing hundreds of hardware-specific calls to configure and program
a data-acquisition board. DriverLINX, in contrast, uses a board-independent list of
properties to specify the parameters for a data-acquisition t a sk.
All data-acquisition tasks in DriverLINX use the same, simple three-step protocol:
1. Decide how you want to acquire data.
2. Specify your task by setting the properties of an object or data structure
known as the Service Request.
3. Pass the Service Request to DriverLINX, which sets up the hardware
and acquires the data for you.
The power of the Service Request approach is that you use the same structure for all
data-acquisition tasks on any supported hardware. Once you understand how to
program one type of device, you can use that knowledge to program any other
supported device.
To notify an application of the progress or error conditions detected during a dataacquisition task, DriverLINX sends the application a series of messages just as
Windows sends messages to an application’s message loop. This feature allows an
application to overlap data processing with data acquisition and easil y synchronize
the two activities.
Most data-acquisition drivers manage a hardware board exclusively for one
application. DriverLINX, however, manages the subsystems of a hardware board as
a shared resource that multiple applications or threads can share. If your hardware
board has the necessary features, DriverLINX supports running multiple,
independent tasks concurrently on one board.
Logical Device Descriptors
DriverLINX does not require
that applications reference or
use the LDD to program
data-acquisition tasks.
The on-line DriverLINX
Technical Reference Manual
defines the DriverLINX
Specification for all dataacquisition boards.
Using DriverLINX for a
specific board requires
learning just the supported
properties for the board.
For writing hardware-independe nt applications, you may need to know the hardware
specifications of the board your program is controlling. DriverLINX ma kes this
information available to your program with another device-independent data
structure known as the Logical Device Descriptor (LDD). The LDD contains
information about number and types of data channels on the board, the allowed
operating modes and commands, and many other details. For more information, see
the on-line DriverLINX Technical Reference Manual.
Service Requests
The most important DriverLINX concept to understand is the Service Request. This
is the object, data structure, or form that you use to specify all data-acquisition tasks.
As much as is possible, DriverLINX treats all data-acquisition tasks as similar
using the same concepts and properties to define each possible task.
The key to learning how to specify a Service Request is first learning the major
groups of a Service Request, and then learning the properties for each group.
A Service Request consists of four major property groups:
• Request Group—specifies the target Logical Device and Logical
Subsystem of a task and the data-acquisition mode and operation to
perform.
• Events Group—specifies how DriverLINX should time or pace data
acquisition, when DriverLINX should start acquisition, and when it
should end.
• Select Group—specifies the Logical Channels to acquire and the
number and length of data buffers to acquire.
• Results Group—DriverLINX uses these properties to return result
codes and single data values.
You can fill out Service Requests either interactively using the Edit Service Request
Property page in DriverLINX or programmatically by assigning values to the
required properties in each group.
If you are using C/C++, the Service Request is a C data struc ture type definition.
Create an instance of the data structure, set all fields to zero, and then assign the
proper values to each needed property in the groups. After setting up the Service
Request, pass the address of the Service Request to DriverLINX for execution.
DriverLINX will report information about the task back to t he app lication using
Windows messa ges.
Control Interface
If you are using the Visual Basic custom control (VBX) or ActiveX (OLE or OCX)
version of DriverLINX, the Service Request is an instance of the control o bject on
your form or dialog. Assign the proper values to the needed properties for your task.
Then tell DriverLINX to execute the Service Request by calling the Refresh method
for the control. DriverLINX will report information about the task back to the
application using control events.
DriverLINX provides a hardware-independent, abstract model of data-acquisition
hardware co nsisting of seven possible Logical Subsystems. Each Logica l Subsystem
treats data-acquisition tasks as conceptually similar. Develo pers program dataacquisition tasks by setting up the proper ties in the Request, Event, and Select
Groups of a Service Request.
The on-line DriverLINX Technical Reference Manual def ines the DriverLINX
Specification for all data-acquisition boards. Using DriverLINX for a particular
board requires learning the supported properties for the hardware.
Most counter/timer boards use either the Intel 8254 Programmable Interval Timer or
the AMD Am9513 System Timing Controller. The Intel 8254 is a much simpler
device than the Am9513 chip, and the 8254 has limited capabilities without external
circuitry and connections. Most vendors use the 8254 for clock generation on dataacquisition devices, but, for stand-alone counter/timer devices, the y usually use the
more complex Am9513 chip or proprietary chips as in the Keithley KPCI-3140 (and
the compatible KPCI-3100 Series).
The DriverLINX Counter/Timer programming model supports diverse hardware
using a common programming model. Although the programming model is common,
developers should understand the inherent hardware differences among counter/timer
chips if they need to write applications to support different counter/timers. The
following sections present an overview of hardware features of these chips.
Intel 8254
The Intel 8254 provides three 16-bit timing channels per chip that support six pulse
and frequency generation modes. The Intel 8254 is capable of simple event counting,
rate and square wave generation, one-shot, and strobe applications.
The following table describes the six operation modes and variations of the Intel
8254 counter/timer chip. For a detailed description of these modes, see “8254
Operating Modes” on page 113.
DriverLINX Counter/Timer User’s Guide Counter/Timers and DriverLINX • 19
Without external circuitry, however, the Intel 8254 does not support selectable clock
sources, gating control, or output polarity. The effect of the gate input on counting is
a function of the selected mode. The 8254 has no built-in frequency prescaler and
only counts in binary.
For more information, see the Intel 8254 Programmable Interval Timer data sheet
and your counter/timer hardware User’s Guide.
KPCI-3140 Counter/Timer Chip
The counter/timer chip in the Keithley KPCI-3140 and KPCI-3100 Series provides
four 16-bit timing channels per chip that support 3 pulse and frequency generation
modes. In addition, the chip has two 24-bit counters but the onl y counter/ti mer
function they can perform is to pace interrupt mode tasks.
The following table describes the three operation modes of the KPCI-3140
counter/timer chip. For a detailed description of these modes, see “KPCI-3140
Operating Modes” on page 116.
Table 2 Designations for KPCI-3140 Counter/Timer Modes
Am9513
The Am9513 provides five 16-bit timing channels per chip that support 19 pulse and
frequency generation modes. In addition, the Am9513 supports a variety of software
options to electronically interconnect counter channels and to program outputs. The
Am9513 allows software to select 16 counting sources and 5 output modes
independent of the chip’s operating mode. This chip has five built-in frequency
prescalers and can count in either binary or binary coded decimal (BCD) modes.
When using the prescalers in binary mode, each counter channel has an effective
dynamic range of 32-bits.
The following table describes the 19 operation modes of the Am9513 and AMD’s
letter designation for each mode. For a detailed description of these modes, see
“Am9513 Operating Modes” on page 117.
Mode Description
A Software triggered Strobe with no hardware gating
B Software triggered Stro b e with level gating
C Hardware triggered Stro b e
D RateGenerator with no hardware gating
E Rate Generator with level gating
F Non-retriggerable One-Shot
G Software triggered delayed Pulse one-shot
H Software triggered delayed Pulse one-shot with hardware gating
20 • Counter/Timers and DriverLINX DriverLINX Counter/Timer User’s Guide
Mode Description
I Hardware triggered delayed Pulse strobe
J Variable Duty Cycle rate generator with no hardware gating
K Variable Duty Cycle rate generator with level gating
L Hardware triggered delayed Pulse one-shot
N Software triggered Strobe with level gating and hardware retriggering
O Software triggered Strobe with edge gating and hardware retriggering
Q Rate Generator with synchronization
R Retriggerable One-Shot
S Delayed Pulse one-shot with level-selected reloading
V
X Rate Generator with edge gating
Table 3 Letter Designations for Am9513 Counter/Timer Modes
Frequency -Shift Keying
Each Am9513 chip occupies 2 consecutive I/O addresses. The first location
addresses a control port and the second a data port.
The Am9513 can be a complex chip to learn, program, and use because of its rich
feature set. For detailed hardware information, consult Advanced Micro Devices’
Am9513A/Am9513 System Timing Controller Technical Manual and your
counter/timer hardware user’s guide.
DriverLINX Counter/Timer Model
Figure 1 DriverLINX Counter/Timer Model
DriverLINX abstracts all counter/timer hardware chips as an array of three terminal
devices. The terminals of an individual counter/timer are
• Clock—the source input for dividing down to a lower frequency or for
counting external events.
• Gate—the control input for triggerin g, re-triggeri ng, or gating the
counter/timer operation.
• Output—the counter/timer output frequency, pulse, or stro be.
DriverLINX associates with each counter/timer channel four operating properties.
The properties are
• Mode—defines the operational task for the counter/timer channel.
• Period—defines the cycle period or divisor for the counter/timer
channel.
DriverLINX Counter/Timer User’s Guide Counter/Timers and DriverLINX • 21
• OnCount—defines high duration of the period for asymmetrical output
trains or pulses.
• Pulses—defines the number of periods to generate.
22 • Counter/Timers and DriverLINX DriverLINX Counter/Timer User’s Guide
Capabilities of DriverLINX’s
f
counter/timer subsystem
depend on the hardware
eatures of your board.
By selecting values for these seven properties and, where necessary, making the
appropriate connections between counters, applications can program DriverLINX to
execute one of the counter/timer’s basic operating modes or the following
counter/timer operations and tasks:
• Event counting—16-, 32-, and 64-bit counters for signals at the Clock
input.
• Frequency measurement—16- and 32-bit frequency measurement.
• Interval measurement—Measure time between two consecutive
pulses at a single input or two pulses at separate inputs.
• Period and pulse width measurement—Measure duration of each
cycle or half cycle.
• Pulse generation—Generate a variety of one-shot pulses and strobes.
• Frequency generation—Generate periodic pulse trains, variable duty
cycle waveforms, square waves, or input-modulated waveforms.
Applications may program and operate counter/timers independently, or they may
configure the operating mode for several counter/timers and start or stop them
synchronously. For hardware boards that support interrupts, applications may
program a list of timers whose current value DriverLINX will read into a buffer on
each interrupt.
The following tables show the legal values for the Clock, Gate, Output, and Mode
fields of a DriverLINX logical counter channel. Note that the capabilities of the Intel
8254 are a subset of the Am9513’s capabilities.
Clocks
The Clock property specifies the source input for the abstract counter/timer of a
Logical Channel.
Clock Description Intel 8254 KPCI-3140 Am9513
Internal1..
Internal5
Source1..
Source5
Gate1..
Gate5
External External clock frequency
ExternalPE External clock frequency
ExternalNE Ext ernal clock frequency
TCNm1 Use channel N-1 terminal
Table 4 Allowed Values for Rate Event Clock Property
Internal clock frequency
prescaled at 1 of 5 taps
Use channel 1..5 source
(clock) input
Use channel 1..5 gate input no no yes
(usually positive edge)
(positive edge clocking)
(negative edge clocking)
count output
yes
(Internal1
only)
no no yes
yes yes yes
yes yes yes
no yes yes
no yes yes
yes (Internal1
only)
yes
DriverLINX Counter/Timer User’s Guide Counter/Timers and DriverLINX • 23
• For the Am9513-based counter/timers, you may also request that the
clock input use the negative-going edge of the clock input rather than
the positive edge.
• Internal1 always designates the onboard hardware clock.
Internal2..Internal5 designate lower frequency taps of the master clock
if the hardware supports this capability.
• If the application uses an Internal1 clock with a Period value greater
than the hardware counter/timer supports, DriverLINX will
automatically select available hardware prescalers to obtain the closest
value to the requested Period.
Gates
The Gate property selects how the abstract counter/timer uses the gate input of a
Logical Channel. Generally, this input gates the counting or measuring process or
triggers the counter/timer operation.
count output N-1
Positive edge at gate input N modes 1,5 modes 0,1 yes
modes 0,2-4 mode 2 yes
no no yes
no no yes
no no yes
Table 5Allowed Values for Rate Event Gate Property
*Some boards provide off-chip hardware that can disable the 8254’s gate.
24 • Counter/Timers and DriverLINX DriverLINX Counter/Timer User’s Guide
Outputs
The Output property programs the polarity and duty cycle of the abstract
counter/timer’s output port.
Output Description Intel 8254 KPCI-3140 Am9513
Default Depends on operation (see
“Counter Output” on page
55)
LoToggled Start low; toggle at TC yes yes yes
LoActive Active low pulse at TC yes yes yes
LoZ Inactive low impedance
output
Toggled Toggle at TC yes no yes
HiToggled S tart high; toggle at TC yes yes yes
HiActive Active high pulse at TC no yes yes
HiZ Inactive high impedance
output
Table 6 Allowed Values for Rate Event Output Property
DriverLINX automatically selects an output type if the application requests Default.
Depending on hardware capabilities, DriverLINX chooses the output option based on
the requested Mode. The Intel 8254 allows only one output mode, which depends on
the operation.
yes yes yes
no no yes
no no yes
Modes
The Mode property selects the type of rate generator or task the abstract
counter/timer will perform. Mode values fall into two gener a l gro ups—pulse and
wavefor m generators and measurement tasks. Note that the generator modes (e.g.,
RateGen, SqWave, etc.) program a single Logical Channel of an abstract
counter/timer while the measurement modes (e.g., Frequency, Interval, etc.) may
program multiple Logical Channels.
generator
BurstGen Burst rate generator no no no
Divider Frequency divider no yes yes
Freq Frequency counter yes yes yes
Interval Interval timer yes no yes
Count Event counter yes yes yes
PulseWd Pulse width measurement yes yes yes
SplitClk Split frequency rate
generator
yes yes yes
no no no
DriverLINX Counter/Timer User’s Guide Counter/Timers and DriverLINX • 25
Generator Description Intel 8254 KPCI-3140 Am9513
FskGen Frequency-shift keying no no yes
PulseGen Pulse generator no yes yes
Retrig
RateGen
Retrig
SqWave
Count32 32-bit event counter no yes yes
Count64 64-bit event counter no yes yes
Freq32 32-bit frequency counter no yes yes
FreqRatio Frequency ratio counter no no no
OneShot One-shot pulse or strobe yes yes yes
Retrig
OneShot
Table 7 Allowed Values for Rate Event Mode Property
Retriggerable rate generator no no yes
Retriggerable square wave
generator
Retriggerable one-shot pulse
or strobe
no no yes
yes no yes
• Some of the above mode field options, e.g., BurstGen, specify features
that require external connections, which some vendors have prewired
into their products.
• Other options, such as frequency measurement modes, require external
user connections between counter/timer terminals.
DriverLINX Task Model
To manage a user application’s data-acquisition requests, DriverLINX creates tasks.
A DriverLINX task consists of the set of hardware and system resources and the
board-specific protocols required to execute the data-acquisition request.
Applications can start tasks, monitor tasks, and stop tasks by submitting Service
Requests to DriverLINX.
Hardware Sharing
DriverLINX allows multiple applications to share a data-acquisition device or allows
multiple tasks to run on a device if the hardware can support concurrent operations.
To support hardware sharing and concurrency, DriverLINX assigns resources to each
task and then compares the resource requirements of a new task with the in-use
resources of all current tasks. If the new requirements do not conflict with the current
in-use resources, DriverLINX updates the in-use resources and starts the task.
Otherwise, DriverLINX rejects the newly requested task.
Creating Tasks
User applications create data-acquisition tasks by setting the properties of a Service
Request to values that specify the task. Then the application submits the Service
Request to DriverLINX, which transforms each Service Request into a procedure for
performing the task on the requested hardware subsystem. To execute a new task,
DriverLINX performs the following steps for each Service Request:
26 • Counter/Timers and DriverLINX DriverLINX Counter/Timer User’s Guide
A Start operation fills in the
Applications may also check the status of a task or terminate a task by modifying the
taskId property. DriverLINX
uses the taskId to determine
to which task a Status or Stop
operation applies.
1. Audit the Service Request fields to determine if the hardware can
perform the task.
2. Request necessary hardware and system resources to perform task.
3. Con vert the Service Request into the hardware parameters and
protocols to perform the task.
4. Execute the task on the hardware.
5. Notify application of any requested task events as they occur.
6. Wait for the task to complete.
7. Release requested hardware and system resource used by the task.
If DriverLINX detects any errors in the Service Request or in the hardware during
the task, it aborts the task and returns an error code to the application. If the
application requests hardware resources that are already in use by another thread or
process, DriverLINX also stops the task and notifies the application.
Monitoring and Stopping Tasks
operation property of the Service Request used to create the task and resubmitting it
to DriverLINX. To check status, change the operation property to “status”. To
terminate a task, change the operation property to “stop”.
DriverLINX Events
Applications can request that DriverLINX notify the application of significant events
during execution of a task. By designing a data-acquisition task to use events, an
application can overlap data processing with data collection. Events allow the
application to coordinate these two activities without t he overhead associated with
polling for the status of the data collection task and without the scheduling pr oblem
of coordinating data processing with partial data collection.
DriverLINX posts events to an application through t he Windows messaging
mechanism. DriverLINX supports the following messages:
Message Description Posted
ServiceStart Task is starting Default. Can disable.
ServiceDone Task is complete Default. Can disable.
BufferFilled Buffer processing complete Can enable.
DataLost Data over/underrun Always reported.
TimerTic Timer interrupt occurred Non-buffered CT task.
StartEvent Start event detected Can enable.
StopEvent Stop event detected Can enable.
CriticalError Hardware error Always reported.
Table 8 DriverLINX Messages
DriverLINX Counter/Timer User’s Guide Counter/Timers and DriverLINX • 27
The most useful events for applications are ServiceDone, BufferFilled, and DataLost.
• The ServiceDone event notifies the application that DriverLINX
terminated the task. Tasks may end because the application stopped it,
the stop event condition in a Service Request was satisfied, or
DriverLINX detected a run-time error and stopped the task.
• The BufferFilled event notifies the application that DriverLINX has
read or written the current buffer. Applications can use this message
with multiple data buffers to eliminate polling the driver for the status
of the task and to overlap data processing with data acquisition.
• The DataLost event notifies the application that DriverLINX detected
that the hardware was filling or emptying buffers faster than the
application or driver could process the buffers.
The other DriverLINX events are useful for special cases.
• The ServiceStart event notifies the application that DriverLINX is
starting the task. An application might use this event to provid e visual
feedback to the user interface that the task is starting.
• The TimerTic event notifies the application that DriverLINX has
processed a clock interrupt. DriverLINX only reports this event for the
counter/timer subsystem when the task is not using data buffers.
• The StartEvent notifies the application that DriverLINX detected that
the logical condition the application specified in the Service Request’ s
Start Event is true. DriverLINX can only report this event if the
hardware generates an interrupt associated with the Start Event.
• The StopEvent notifies the application that DriverLINX detected that
the logical condition the application specified in the Service Request’ s
Stop Event is true. DriverLINX can only report this event if the
hardware generates an interrupt associated with the Stop Event.
• The CriticalError event notifies the application that DriverLINX
detected an unexpected critical error other than DataLost. This usually
indicates either the hardware or software is malfunctioning and needs
repair or re-configuration.
DriverLINX Operations
For most counter/timer hardware, applications can select one of five operations for a
task. The basic counter/timer task operations are
• Initialize—resets the counter/timer subsystem software and/or
hardware.
• Configure—set up a counter/timer for a task, but do not start the task.
• Start—set up and arm a counter/timer for a task. The Gate, Clock, and
Mode properties determine when the hardware starts counting.
• Status—return the current counter/timer count value and status to the
application.
• Stop—disarm the counter/timer task and make the task resources
available for new tasks.
The Initialize, Configure, and Start operations all create a DriverLINX task. The task
that DriverLINX creates for the first two operations exists only briefly during the
28 • Counter/Timers and DriverLINX DriverLINX Counter/Timer User’s Guide
application’s function call to DriverLINX. For a Start operation, however,
operation to read the current count value of a counter/timer. The counter/timer
DriverLINX creates a task that may exist indefinitely until the application explicitly
ends the task with a Stop operation or DriverLINX ends the task because the Stop
Event has become true.
DriverLINX Modes
For most counter/timer hardware, DriverLINX supports three task modes, OTHER,
POLLED and INTERRUPT.
• When an application uses OTHER mode, DriverLINX initializes the
subsystem or configures a Logical Channel without starting the
counter.
• When an application uses POLLED mode, DriverLINX starts the
counter/timer hardware running, but it does not automatically report
any status information about the task to the application.
• When an application uses INTERRUPT mode, DriverLINX starts the
counter/timer hardware running with a hard wa re interrupt enabled. At
each interrupt, DriverLINX either sends a TimerTic event to the
application or saves the current count of the requested counter/timers
into a data buffer.
For other subsystems, polled
mode tasks start and stop
before DriverLINX returns
control to the application.
When using polled mode counter/timer operations, DriverLINX return s control to
the application after starting the counter/timer hardware. Applications must use the
Status
task will run until the application ends it with a Stop operation.
When using interrupt mode counter/timer operations, DriverLINX also returns
control to the application after starting the counter/timer hardware. However, if the
application specified data buffers in the Service Request, DriverLINX will
automatically read and store the current counter value(s) into the buffer. The
application may request that DriverLINX read the next Logical Cha nnel in the
Channel list at each interrupt or that DriverLINX read all Logical Channels at each
interrupt. If the application is not using buffers, then DriverLINX sends a TimerTic
event to the application at each interrupt.
Individual and Group Tasks
Applications can control individual counter/timer channels as separate task s or they
can synchronize the starting and stopping of multiple channels. To collect multiple
channels into a group, the application first performs Configure operations on each
channel in the group to set up the hardware. Then the application can start the
channels in the group by executing a Service Request with a Start operation that lists
the group’s channels in the Service Request’s channel list. By using a Stop operation
instead, the application can simultaneously stop all channels in the group. For more
information, see “Group Tasks” on page 38.
Mapping Logical Channels to Counter/Timer Hardware
Channels
DriverLINX maps the hardware’s counter/timer channels to consecutive Logical
Channels. The following table shows the correspondence between the hardware
channels and Logical Channels. Note that DriverLINX always uses zero-based
DriverLINX Counter/Timer User’s Guide Counter/Timers and DriverLINX • 29
numbering for Logical Channels while vendors often use one-based channel
numbering.
Table 9 Map of Logical Channels to Counter/Timer Hardware Channels
For other models, see the appropriate Using DriverLINX with your Hardware
manual.
Digital I/O Hardware
0 1 2 3 4 5 6 7 8 9
Software cannot read or
control the strobe lines for
digital inputs without external
connections.
The MetraByte counter/timer boards support one or more digital I/O ports. The
CTM-05/A board has one 8-bit digital input port with latch and one 8-bit digital
output port with latch. The CTM-10 board has two 8-bit digital input ports with
latches and two 8-bit digital output ports with latc hes. A strobe line input at each
input port controls whether the input data passes through the latch or is held by the
latch. There is no software control over this strobe line. For more infor mation, see
the CTM-10 and CTM-05/A User’s Guide.
These digital ports are physically independent of the counter/timers and do not have
any internal connections to the counter/timers. Also, the digital I/O ports do not
generate any hardware interrupts. Applications can read or write the digital ports
independently of the counter/timers. DriverLINX does support reading a digital input
port at each counter/timer interrupt to start or stop a counter/timer task.
The CTM Ser ies boards also have a digital input line that generates a hardware
interrupt. DriverLINX models this line as a special-purpose, 1-bit digital input
channel. Associated with the interrupt input line is another external input line t hat
enables or disables the interrupt input line. DriverLINX has no direct hardware
control over this gating line.
For other models, see the appropriate Using DriverLINX with your Hardware
manual for details on digital I/O features.
30 • Counter/Timers and DriverLINX DriverLINX Counter/Timer User’s Guide
Loading...
+ 104 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.