DriverLINX

Digital I/O Programming Guide

1

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 Digital I/O Programming Guide  Copyright 1996 - 1998, Scientific Software Tools, Inc. All rights reserved. Fourth Printing. SST 07-0698-1

LabOBJX, SSTNET and DriverLINX 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.

2

Contents
Preface 5
Software License and Software Disclaimer of Warranty............................................................5 About DriverLINX.....................................................................................................................7 About This Programming Guide ................................................................................................7 Conventions Used in This Manual .............................................................................................9

Why Use a Digital I/O Device Driver

11

Using Direct Hardware I/O ......................................................................................................11 Advantages of Device Drivers..................................................................................................11

Introducing DriverLINX

13

About DriverLINX...................................................................................................................13 DriverLINX Hardware Model..................................................................................................13 DriverLINX Driver ....................................................................................................13 Logical Devices .........................................................................................................13 Logical Subsystems....................................................................................................14 Logical Channels........................................................................................................14 DriverLINX Programming Model............................................................................................14 Logical Device Descriptors........................................................................................15 Service Requests ........................................................................................................15 C/C++ Interface .........................................................................................................16 Control Interface ........................................................................................................16 Summary ..................................................................................................................................16

Digital I/O and DriverLINX

17

Digital I/O Hardware Description ............................................................................................17 Mapping Logical Channels to Digital Hardware Channels ......................................................18 Properties of Logical Channels ..................................................................................18 Combining or Splitting Logical Channels ..................................................................19 Implementation Notes ................................................................................................20

Configuring Digital I/O Hardware

22

Using the DriverLINX Control Panel.......................................................................................22 The Device Property Page .........................................................................................23 The Digital Input Property Page ................................................................................24 The Digital Output Property Page..............................................................................27 Using DriverLINX to Dynamically Configure Ports................................................................28

DriverLINX Digital I/O Programming Guide

Contents  3

.......................................................................................... 30 Properties Common to All Service Requests ............................................................................................................................................. 41 Reading or Writing a Single Value...................................................................................................... 33 Opening and Closing a DriverLINX Device Driver ................................................................................................................................................................. 43 Reading or Writing Specific Digital Bits............ 31 Specifying Digital I/O Channels in a Service Request .. 31 Events for Digital I/O....................................................................... 36 Initializing the Device ....................... 46 Rapidly Transferring a Block of Digital Data ......... 37 Initializing a Digital Subsystem................... 33 Interfacing to DriverLINX .............................................................. 32 Specifying Data Buffers in a Service Request......................................... 30 Using Events to Control Service Requests ....................................................................................................................... 39 Determining the Digital Port Configuration ........... 40 Configuring a Digital Port at Run Time ............................................................................................................................................................................................. 53 Glossary of Terms Index 61 67 4  Contents DriverLINX Digital I/O Programming Guide ......................................................................................................Programming Digital I/O with DriverLINX 29 DriverLINX Digital I/O Operations ............................................................... 29 Using DriverLINX’s Service Requests....... 49 Performing Background Digital I/O ........ 35 Configuring a Logical Device ...............................................................................................................................................................................................................................

Licensee may not distribute copies. Term. including software that has been modified. Inc. if any) that are part of this product to Scientific Software Tools. binders or other containers. Inc. Scientific Software Tools. and a valuable trade secret. All modifications. DriverLINX Digital I/O Programming Guide Preface  5 . of the modified. This License will terminate automatically without notice from Scientific Software Tools. The Licensee may not network the software or use it on more than one computer or computer terminal at the same time. adaptations. If Licensee does not agree to the terms of this Agreement. Inc. Promptly return the unopened diskette package and the other items (including written materials. the Licensee. Inc. adapted or merged software or accompanying written materials to others. Licensee understands and agrees that the software is the proprietary and confidential property of Scientific Software Tools. Inc. This Agreement constitutes the complete Agreement between Licensee and Scientific Software Tools. The Licensee agrees upon such termination to return or destroy the written materials and all copies of the software. and merged portions of the software constitute the software licensed to the Licensee. Inc. authorizes the original purchaser only (Licensee) to either (a) make one copy of the software solely for backup or archival purposes. including electronic transfer of copies. The Licensee may terminate the agreement by returning or destroying the program and documentation and all copies thereof. and Scientific Software Tools. Trade Secret. for a full refund. decompile or disassemble any part of the software. Licensee agrees to use the software only for the intended use under this License. and hardware. The Licensee may not modify or translate the program or related documentation without the prior written consent of Scientific Software Tools. Inc. License. and is protected by both United States copyright laws and international treaty provisions. Copy Restrictions. Unauthorized copying of the software. No refunds will be given for products that have opened disk packages or missing components. The software and documentation is owned by Scientific Software Tools. By opening this sealed diskette package. or included with other software. merged. or (b) transfer the software to a single hard disk only. Licensing Agreement Copyright.Preface Software License and Software Disclaimer of Warranty This is a legal document which is an agreement between you. The written materials accompanying the software may not be duplicated or copied for any reason. transfer or lease the software to any third parties. This License is effective until terminated. Inc. grants the Licensee only a non-exclusive right to use the serialized copy of the software on a single terminal connected to a single computer. Scientific Software Tools. and the terms and conditions of this agreement apply to same. or of the written materials is expressly forbidden. and shall not disclose the software or its contents to any third party. do not open the diskette package. disclosure or use contrary to the terms of the License. Inc. if Licensee fails to comply with any term or condition of this License. Licensee agrees to become bound by the terms of this Agreement. Licensee agrees not to reverse engineer. which include the Software License and Software Disclaimer of Warranty. Licensee agrees to take all reasonable steps to protect Scientific Software Tools’ software from theft. Licensee may not rent.

THE ABOVE LIMITATIONS MAY NOT APPLY TO LICENSEE. Inc. reliability. provided the licensee previously sent in the limited warranty registration card to Scientific Software Tools. at Scientific Software Tools’ option. LOSS OF BUSINESS INFORMATION AND THE LIKE) ARISING 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. agents or employees. INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. or make any representations regarding the use. INDIRECT. Except as specifically set forth herein. accuracy. or can furnish proof of the purchase of the program. WITH RESPECT TO THE SOFTWARE. of the software or written materials in terms of correctness. Inc. abuse.Limited Warranty Scientific Software Tools. THE ACCOMPANYING WRITTEN MATERIALS. OR LIMITATIONS ON DURATION OF AN IMPLIED WARRANTY. Scientific Software Tools’ entire liability and the Licensee’s exclusive remedy shall be. the software and accompanying written materials (including instructions for use) are provided “as is” without warranty of any kind. The entire risk as to the results and performance of the software is assumed by Licensee and not by Scientific Software Tools. or misapplication. the item may be returned within the warranty period to Scientific Software Tools for a replacement without charge. Any replacement will be warranted for the remainder of the original warranty period.. NOR ANYONE ELSE WHO HAS BEEN INVOLVED IN THE CREATION. or its distributors. Inc. PRODUCTION. In the event of a defect in material or workmanship. warrants that the software will perform substantially in accordance with the written materials and that the program disk. AND ANY ACCOMPANYING HARDWARE. either (a) return of the price paid or (b) repair or replacement of the software or accompanying materials. SALE OR DELIVERY OF THIS PRODUCT SHALL BE LIABLE FOR ANY DIRECT. instructional manuals and reference materials are free from defects in materials and workmanship under normal use for 90 days from the date of receipt. or otherwise. Further. Scientific Software Tools. INC. EITHER EXPRESS OR IMPLIED. This remedy is void if failure has resulted from accident. BUSINESS INTERRUPTION. CONSEQUENTIAL. does not warrant. OR INCIDENTAL DAMAGES (INCLUDING DAMAGES FOR LOSS OF BUSINESS PROFITS. Inc. Remedy. currentness. or the results of the use. 6  Preface DriverLINX Digital I/O Programming Guide . BECAUSE SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES. NEITHER SCIENTIFIC SOFTWARE TOOLS. guarantee. All express or implied warranties of the software and related materials are limited to 90 days. THERE ARE NO OTHER WARRANTIES. EXCEPT AS SET FORTH HEREIN. This agreement is governed by the laws of the Commonwealth of Pennsylvania.

please see the hardware manuals that accompanied your board and the DriverLINX 4. Digital I/O and DriverLINX Describes how DriverLINX’s hardware model supports digital I/O boards. please see the DriverLINX Technical Reference Manual. For additional help programming your board. Introducing DriverLINX Presents a quick overview of DriverLINX’s hardware and programming model.About DriverLINX Welcome to DriverLINX for Microsoft Windows. DriverLINX Digital I/O Programming Guide Preface  7 . please examine the source code examples on the Distribution Disks. the high-performance realtime data-acquisition device drivers for Windows application development.    For help installing and configuring your hardware and DriverLINX. DriverLINX is a language. For more information on the DriverLINX API. 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 for your version of Windows.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 digital I/O operations with your hardware.and hardware-independent application programming interface designed to support hardware manufacturers’ high-speed analog and digital data-acquisition boards in Windows. DriverLINX is a multiuser and multitasking data acquisition resource manager providing more than 100 services for foreground and background data acquisition tasks. This manual is divided into the following chapters: Why Use a Digital I/O Device Driver Brief discussion of why modern operating systems require device drivers.

Configuring Digital I/O Hardware Using the DriverLINX Control Panel to configure digital I/O boards. Programming Digital I/O with DriverLINX Using DriverLINX for digital I/O tasks. 8  Preface DriverLINX Digital I/O Programming Guide .

DriverLINX indicates the exported function name of the device driver DLL while DriverLINX indicates the product as a whole. Numbered lists indicate a step-by-step procedure. DriverLINX Application Programming Interface identifiers.  Tables Tables of information are bounded by a box with a double line. DriverLINX Digital I/O Programming Guide Preface  9 . Italics are used for emphasis. and Dialog Box names are italicized when mentioned in the text.Conventions Used in This Manual The following notational conventions are used in this manual:        Code Itemized lists are identified by a round bullet (). DriverLINX Application Programming Interface and Windows macro and function names are set in bold when mentioned in the text. Source code and data structure examples are displayed in Courier typeface and bounded by a box with a single line. menu items. Concept  Important concepts and notes are printed in the left margin.

C/C++ developers could use these same techniques for most ports despite Microsoft’s strong recommendation against doing so. resource sharing of a single physical device among multiple applications and/or threads. DLLs. With the arrival of Windows NT. In Win32 applications hardware I/O instructions generate a “privileged instruction exception” and terminate the offending app. Advantages of Device Drivers Using device drivers to control hardware offers an application in a modern multitasking. To perform user-level I/O in Windows NT and future versions of Windows 95. but they quickly discovered they could replace the missing statements with calls to simple DLLs. and efficient and required a minimal learning curve.Why Use a Digital I/O Device Driver Using Direct Hardware I/O Most digital I/O ports are very simple devices to program.x. The application advantages of the device driver model are   hardware-independent access to boards belonging to a class of devices. Under Windows 3. multithreaded operating system several advantages and one major disadvantage. the operating system requires that applications communicate with the hardware using a device driver. however. Hardware I/O in DOS and Win16 apps may appear to execute. and services. but the CPU never actually executes the I/O instructions. DriverLINX Digital I/O Programming Guide Why Use a Digital I/O Device Driver  11 . direct hardware I/O in user applications is not physically possible. Visual Basic programmers. found that Microsoft had removed all direct I/O statements from the language. most engineers 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. For years. Modern device drivers are effectively trusted operating system extensions that have more privileges than ordinary user-mode applications. This was simple. fast.

and the hardware. such as acquiring a million data samples in one request. for use in a multitasking system. 12  Why Use a Digital I/O Device Driver DriverLINX Digital I/O Programming Guide . For this reason.  resource arbitration when multiple device users contend for the same hardware resources. the overhead is negligible. The main disadvantage of the device driver model is the extra overhead the system requires to communicate device requests between the application. developers must often redesign the protocols and algorithms that worked well in a single-tasking OS. the device driver. such as DOS. the time penalty is significant. and system security either at the logical level of authorized device users or at the physical level of preventing misuse of a device. such as Windows NT. but for acquiring one sample using a million separate requests. For device requests.

I/O address. This chapter briefly surveys the DriverLINX hardware and programming model. You can program each product using different “Service Requests” for each overlapping data-acquisition task.x. Logical Devices A single DriverLINX driver can support multiple boards from its list of supported models. During configuration. Many samples won't work with digital I/O devices. high-performance. DriverLINX is a language and hardware-independent. DriverLINX supports an abstract hardware model for generalized data-acquisition hardware that includes analog and digital I/O as well as counter/timer functions. you assign each physical device a Logical Device number that you use to identify a particular board to DriverLINX. DriverLINX Digital I/O Programming Guide Introducing DriverLINX  13 . DriverLINX Hardware Model DriverLINX Driver Each DriverLINX driver supports one or more models of a device series in a manufacturer’s product line.Introducing DriverLINX About DriverLINX The DriverLINX Distribution Disks contain many sample programs for a variety of hardware devices. and hardware resources of a Logical Device by consulting DriverLINX’s Logical Device Descriptor. You can control multiple products from different series by opening several DriverLINX drivers. At run time. data-acquisition device driver for 16 and 32-bit Windows 3. Windows 95 and Windows NT. Welcome to DriverLINX for Microsoft Windows. board-independent specification for the abstract DriverLINX hardware model. applications can determine the manufacturer. model name. this guide will ease your learning curve by focusing on just the digital I/O subsystem programming model. The DriverLINX Technical Reference Manual included with the DriverLINX package is the complete. real-time. Whether or not you’re familiar with DriverLINX programming.

DriverLINX may use multiple Logical Channel numbers to access a group of hardware channels using different data widths. Specify your task by filling the fields of a data structure known as the Service Request. uses a board-independent data structure approach to specifying the parameters for a data-acquisition task. Logical Channels The subsystems. To notify an application of the progress or error conditions detected during a dataacquisition task. except DEVICE. DriverLINX records the number of Logical Channels and their capabilities in the Logical Device Descriptor. multiplexers. but. DriverLINX Programming Model Programming DriverLINX for data-acquisition tasks differs from the approach you may have used previously. simple three-step protocol: 1. All data-acquisition tasks in DriverLINX use the same. you can use that knowledge to program any other supported device. DriverLINX sends the application a series of messages just as Windows sends messages to an app’s message loop. DO (Digital Output)—the digital output ports and associated hardware. for some boards. This feature allows an app to 14  Introducing DriverLINX DriverLINX Digital I/O Programming Guide . 3. and associated hardware.       DEVICE—the physical hardware considered as a whole. consist of one or more data channels known as Logical Channels. CT (Counter/Timer)—the counter/timer channels and associated hardware. The power of the Service Request approach is that you use the same structure for all data-acquisition tasks on any supported hardware. AI (Analog Input)—the A/D converters. AO (Analog Output)—the D/A converters and associated hardware. 2. DI (Digital Input)—the digital input ports and associated hardware. Once you understand how to program one type of device. Pass the Service Request to DriverLINX which setups the hardware and acquires the data for you. DriverLINX’s Logical Device Descriptor contains properties specifying which Logical Subsystems are available for a particular device. Decide how you want to acquire data. Most vendors’ data-acquisition packages consist of thick documents describing hundreds of hardware-specific calls to configure and program a data-acquisition board.Logical Subsystems DriverLINX treats all data-acquisition devices uniformly as abstract hardware consisting of seven possible subsystems. Usually a Logical Channel corresponds to one hardware channel. DriverLINX. in contrast.

The LDD contains information about number and types of data channels on the board. however. Service Requests The DriverLINX Technical Reference Manual defines the DriverLINX Specification for all data-acquisition boards. Logical Device Descriptors DriverLINX doesn’t require that applications reference or use the LDD to program dataacquisition tasks. For writing hardware-independent applications. As much as is possible.overlap data processing with data acquisition and easily synchronize the two activities. see the DriverLINX Technical Reference Manual. This is the data structure. DriverLINX supports running multiple. Most data-acquisition drivers manage a hardware board exclusively for one application. Using DriverLINX for a specific board requires learning just the supported properties for the board. DriverLINX treats all data-acquisition tasks as similar using the same concepts and properties to define each possible task. you may need to know the hardware specifications of the board your program is controlling. For more information. DriverLINX Digital I/O Programming Guide Introducing DriverLINX  15 . 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. DriverLINX makes this information available to your program with another device-independent data structure known as the Logical Device Descriptor (LDD). Events Group—specifies how DriverLINX should time or pace data acquisition. the allowed operating modes and commands. If your hardware board has the necessary features. The most important DriverLINX concept to understand is the Service Request. The key to learning how to specify a Service Request is first learning the major groups of a Service Request. Results Group—DriverLINX uses these properties to return result codes and single data values. manages the subsystems of a hardware board as a shared resource that multiple applications or threads can share. independent tasks concurrently on one board. and then learning the properties for each group. You can fill out Service Requests either interactively using the Edit Service Request Dialog Box in DriverLINX or programmatically by assigning values to the required properties in each group. and when it should end. DriverLINX. or form. that you use to specify all data-acquisition tasks. Select Group—specifies the Logical Channels to acquire and the number and length of data buffers to acquire. when DriverLINX should start acquisition. and many other details.

Event. After setting up the Service Request. Create an instance of the data structure. Assign the proper values to the needed properties for your task. pass the address of the Service Request to DriverLINX for execution. Control Interface If you’re using the Visual Basic custom control (VBX) or ActiveX (OLE or OCX) version of DriverLINX. Developers program dataacquisition tasks by setting up the properties in the Request.C/C++ Interface If you’re using C/C++. Then tell DriverLINX to execute the Service Request by calling the Refresh method for the control. 16  Introducing DriverLINX DriverLINX Digital I/O Programming Guide . and then assign the proper values to each needed property in the groups. abstract model of data-acquisition hardware consisting of seven possible Logical Subsystems. the Service Request is an instance of the control on your form or dialog. and Select Groups of a Service Request. Each Logical Subsystem treats data-acquisition tasks as conceptually similar. the Service Request is a C data structure type definition. The DriverLINX Technical Reference Manual defines the DriverLINX Specification for all data-acquisition boards. Using DriverLINX for a particular board requires learning the supported properties for the hardware. Summary DriverLINX provides a hardware-independent. set all fields to zero.

or as two 4-bit ports (Port Cu and Cl). For more information. The 24 digital lines are programmable in two groups of 12 Group A—Port A and Port Cu Group B—Port B and Port Cl The Intel 8255 chip has three operational modes Basic (Mode 0)—supports simple input or output without control and status signals.Digital I/O and DriverLINX Digital I/O Hardware Description Most digital I/O boards either use or emulate one or more Intel 8255 Programmable Peripheral Interface chips. B. only support the Basic mode (Mode 0). Strobed (Mode 1)—supports input or output for Group A and B using Port C for control and status signals. and the fourth location addresses a hardware control port. see the Intel 8255A Programmable Peripheral Interface data sheet and your digital I/O hardware User’s Guide. Outputs are latched and inputs are not latched. Port C—configurable as an 8-bit data output latch/buffer. and C. This chip contains 24 digital I/O lines configured as 3 individual ports         Port A—configurable as either an 8-bit data output latch/buffer or an 8bit data input latch. The 8-bit inputs and outputs are latched. DriverLINX Digital I/O Programming Guide Digital I/O and DriverLINX  17 . Many 8255 emulations. Bidirectional (Mode 2)—supports bidirectional input and output only for Group A using 5 lines of Port C for control and status bits. an 8-bit data input buffer. Each 8255 chip occupies 4 consecutive I/O addresses. The first three locations address Ports A. Port B—configurable as either an 8-bit data output latch/buffer or an 8bit data input buffer. however. The 8-bit inputs and outputs are latched.

Mapping Logical Channels to Digital Hardware Channels DriverLINX maps the hardware’s digital I/O channels to consecutive Logical Channels. but a few boards fix the channels as input or output. The programmable channels and hardware for most fixed digital channels allow applications to read back the last value written to an output channel (rw). The following table indicates if a Logical Channel is programmable (RW) or fixed (r or rw). If the hardware doesn’t support this feature. I or O for fixed channels. C for programmable channels. DriverLINX emulates output channel readback in software. Logical Channel PIO-12 PIO-24 PCI-PIO24 PIO-96 PCI-PIO96 PIO-SSR-24 PIO-SSR-48 PIO-SSR-120 PIO-HV Intel 8255 PIO-32IN PIO-32IO PIO-32OUT PDISO-8 REL-16 0 A A A A A A A A O A I I O O O 1 B B B B B B B B I B I I O I O 2 C C C C C C C C S C I O O 3 4 5 6 7 8 9 10 11 12 13 14 A A B B C C A A B B C C A A B B C C A A B B C C A B C A B C A B C I O O Properties of Logical Channels Most digital I/O boards allow applications to program a channel as either input or output. B. and S for switch-selected channels) and Logical Channels. The following table shows the correspondence between the hardware channels (designated as A. Logical Channel PIO-12 PIO-24 PCI-PIO24 PIO-96 0 R W R W R W R 1 R W R W R W R 2 R W R W R W R 3 4 5 6 7 8 9 10 11 12 13 14 R R R R R R R R R 18  Digital I/O and DriverLINX DriverLINX Digital I/O Programming Guide .

applications can address individual bits on the digital I/O board or read and write multiple channels with a single operation. To use the Logical Channel addressing extensions. For instance. See “Reading or Writing Specific Digital Bits” on page 46. form a 16-bit Logical Channel address by combining the channel number of an addressable unit with a size field as follows: 0 15 MSB Size Code 14 13 12 11 10 9 8 Channel Number 7 6 5 4 3 2 1 0 LSB DriverLINX Digital I/O Programming Guide Digital I/O and DriverLINX  19 . DriverLINX supports a software extension to Logical Channel addressing that allows applications to combine adjacent Logical Channels into a single channel or split a Logical Channel into smaller addressable parts.W PCI-PIO96 PIO-SSR-24 PIO-SSR-48 PIO-SSR-120 PIO-HV Intel 8255 PIO-32IN PIO-32IO PIO-32OUT PDISO-8 REL-16 R W R W R W R W R W R W r r rw rw rw W R W R W R W R W R W R W r r rw r rw W R W R W R W R W R W R W r rw rw W R W W R W W R W W R W W R W W R W W R W W R W W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W R W r rw rw Combining or Splitting Logical Channels DriverLINX also supports bitlevel I/O using masks.

23 0... Note that extended Logical Channels may not map to consecutive physical channels.11 0. For most boards..2 1000.8203 12288. For buffered interrupt transfers.200B 3000.20481 Address (hex) 0.. DriverLINX will map extended Logical Channels to consecutive I/O ports even if the physical port addresses aren’t consecutive. an Intel 8255 with three 8-bit ports would have the following channel addresses for each size code: Unit native bit half nibble nibble byte word Channels 0.2 4096.1017 2000..4119 8192.. For instance.5001 Implementation Notes   For extended Logical Channel addressing of unit sizes less than the native size..2 0. When using extended Logical Channel addressing.. Because DriverLINX uses the CPU’s block I/O instructions for polled.. DriverLINX only allows Logical Channel addressing at unit sizes equal or larger than the native size..5 0.... this is the same as an 8-bit byte..12293 16384. DriverLINX groups digital bits in units defined by the size code and then assigns consecutive channel numbers starting from zero.16386 20480.. block I/O transfers. DriverLINX requires transfers to use native addressing or larger sizes. DriverLINX only supports single-value transfers.4002 5000.2 0..3005 4000. some bytes won’t represent I/O ports. For block I/O transfers.  20  Digital I/O and DriverLINX DriverLINX Digital I/O Programming Guide .The following table specifies the 3-bit size codes: Size Code 0 1 2 3 4 5 6 7 Unit native bit half nibble nibble byte word dword qword Bits varies with hardware 1 2 4 8 16 32 64 “Native” units refer to the hardware-defined digital channel size.1 Address (dec) 0...

DriverLINX Digital I/O Programming Guide Digital I/O and DriverLINX  21 . you may not be able to address all hardware ports if the number of available digital I/O lines is not an integral multiple of the size unit. When using size codes larger than the native addressing unit.

This may be useful if you connect your hardware’s outputs to external devices that expect high logic signals. The DriverLINX Configuration Panel displays a tree list of all the installed DriverLINX drivers on your system and the configured Logical Devices under each driver. use the DriverLINX icon in the Windows Control Panel application. You can also instruct DriverLINX to initialize the hardware into a custom configuration of input and output ports and default output values. its base I/O address. and the interrupt channel you’ve assigned to the board. if it has one. 22  Configuring Digital I/O Hardware DriverLINX Digital I/O Programming Guide . please read the manufacturer’s hardware manual or see the DriverLINX 4. Use the Configuration Panel to tell DriverLINX the model of the board you’ve installed.Configuring Digital I/O Hardware Using the DriverLINX Control Panel Windows NT’s security features require that users installing or configuring device drivers log on under an administrative account. as their starting state. rather than the default low logic signals. To configure a Logical Device. If you need assistance in installing your hardware or using the DriverLINX Control Panel.0 Installation and Configuration Guide.

“Intel 8255”. DriverLINX Digital I/O Programming Guide Configuring Digital I/O Hardware  23 . Select and complete each property page to configure the Logical Device. Address—enter the base I/O address that you set on the board’s jumpers or dip switch. Pushing the Setup… button on the DriverLINX Configuration Panel displays a Configure DriverLINX Device dialog box for configuring the selected Logical Device.Your applications can also program DriverLINX to display the Configure DriverLINX Device dialog at run-time (see “Configuring a Logical Device” on page 36). DriverLINX may not use any detection protocols so this switch may have no effect. The Device Property Page To successfully configure your hardware. will work with most digital boards that use an 8bit ISA interface. You may need to disable detection if your hardware has malfunctioning I/O ports that you’re not using or if the hardware testing algorithms interfere with permanently attached equipment. this instructs DriverLINX to attempt to detect and test the installed hardware during driver loading. enter the following required fields on the Device page:    Model—select the model name that matches the installed board. The selection. For simple digital I/O boards. The following fields should usually be left with their default values: Detect—when checked. This address must not conflict with any other device in your system. The tabbed dialog box has a page for each Logical Subsystem that your board supports.

At run time. Calibrate—when checked. The Digital Input Property Page The Configuration properties have no effect if you’re hardware has a fixed configuration. DriverLINX configures and initializes all Logical Channels when the operating system loads the kernel mode device driver. Interrupt—specifies the interrupt channel you’ve assigned to your hardware. At this point. you may either select OK and accept default initialization or advance to the Digital Input and Digital Output Property Pages. If other applications are sharing the device. DriverLINX will reconfigure and reinitialize the hardware. If you’re not using interrupts. the hardware effects of a Device Initialization operation depend on the number of times apps have concurrently opened the DriverLINX device driver. DriverLINX ignores DriverLINX Digital I/O Programming Guide . Most digital I/O boards don’t use DMA.   If one application has opened the device. and to modify DriverLINX’s default hardware initialization. DriverLINX does not change the hardware configuration or initialization status. see “Statically Initialize Digital Output Ports” on page 27. This page allows you to assign an interrupt channel to your board. usually at boot time. DMA level—specifies the DMA channel you’ve assigned to your hardware. Statically Configure Digital Ports To initialize output ports with user-defined values. DriverLINX disables options not supported by your hardware. By default DriverLINX automatically configures all channels as inputs to emulate the power off/on behavior of 8255 chips. DriverLINX performs hardware calibration if the device supports this feature. select “none”. you may do so with the following properties:  24  Configuring Digital I/O Hardware Setup—tells DriverLINX to configure the Logical Channel selected in the Channels list box as input (1) or output (0). If you wish to initialize one or more configurable channels as outputs when the DriverLINX driver loads. Many digital I/O boards based on Intel 8255-style chips support reconfiguring the digital channels as either inputs or outputs (see “Properties of Logical Channels” on page 18 for a table listing boards with configurable or static ports). if it supports interrupts. Enter the selections for the following fields:    Channels—shows the available Logical Channels for digital input and selects the Logical Channel for the Configuration properties. This switch has no effect for digital I/O boards.

this property if Initialize isn’t checked. Certain Logical Channels on some boards support additional configuration values (see “Definition of Configuration Values” on page 25). 

Initialize—when checked, this property indicates that DriverLINX should automatically configure this channel as specified in the Setup property. If unchecked, DriverLINX ignores the value of the Setup property.

To configure the ports at run time, see “Configuring a Digital Port at Run Time” on page 41.

Configuration Example
To configure Logical Channel 2 as an output port, perform the following steps: 1. 2. 3. Select “2 (bits 0-7)” in the Channels list box. Enter “0” in the Configuration Setup edit box. Click the Initialize check box.

Repeat steps 1 to 3 for every Logical Channel that requires user-defined configuration. After completing all Property Pages, press OK to save your configuration.

Definition of Configuration Values
Digital I/O boards that use the Intel 8255 design support 8-bit (byte) channels in groups of 3. You can program the first two channels as either all inputs or all outputs, but you can program each half (4 bits, or a nibble) of the third channel in a group separately as input or output. Bit 0 encodes the port direction (input or output). Bits 3 and 4 encode the Group mode. Bits 1 and 2 are unused for Ports A and B. The Intel 8255-based digital boards often support three modes of operation—basic I/O (Mode 0), strobed I/O with handshaking (Mode 1), and bidirectional I/O (Mode 2). The 8255 supports all three modes for Group A (Ports A and Cu) and the first two modes for Group B (Ports B and Cl). To use these options, encode the mode and port direction in the Configuration Setup property for the Logical Channel corresponding to Ports A or B.

Bit 4
0 0 0 0 1 1

Bit 3
0 0 1 1 0 0

Bit 2
x x x x x x

Bit 1
x x x x x x

Bit 0
0 1 0 1 0 1

Meaning
Mode 0, output port Mode 0, input port Mode 1, output port Mode 1, input port Mode 2, output port Mode 2, input port

The following boards and Logical Channels support Modes.

Model
PIO-12 PCI-PIO24

Logical Channels
0, 1 0, 1

DriverLINX Digital I/O Programming Guide

Configuring Digital I/O Hardware  25

PIO-96 Intel 8255 DASCard-PIO12

0, 1, 3, 4, 6, 7, 9, 10 0, 1 0, 1

Nibble programming of Port C is only available using static configuration.

Port C of an 8255 chip doesn’t support modes, but it does support nibble programming of the I/O direction. To setup the third channel in each group of 3, use the following definition for the Configuration Setup property:

Bit 2
0 0 1 1 1 1

Bit 1
x x 0 0 1 1

Bit 0
0 1 0 1 0 1

Meaning
All 8 bits are output. All 8 bits are input. All 8 bits are output. Low 4 bits are input. High 4 bits are output. Low 4 bits are output. High 4 bits are input. All 8 bits are input.

The following boards and Logical Channels support nibble programming:

Model
PIO-12 PIO-24 PCI-PIO24 PIO-96 PCI-PIO96 PIO-SSR-24 PIO-SSR-48 PIO-SSR-120 Intel 8255 DASCard-PIO12

Logical Channels
2 2 2 2, 5, 8, 11 2, 5, 8, 11 2 2, 5 2, 5, 8, 11, 14 2 2

Note: Some special considerations apply when transfer data to or from a port with one nibble configured for input and the other for output. 



When writing data, DriverLINX ignores the nibble data for the input nibble. When reading data, DriverLINX returns both nibbles. The input nibble has new input data while the output nibble has the last data written.

As an alternative, DriverLINX allows applications to explicitly specify masks or access subdivisions of a port. See “Reading or Writing Specific Digital Bits” on page 46 or “Combining or Splitting Logical Channels” on page 19.

26  Configuring Digital I/O Hardware

DriverLINX Digital I/O Programming Guide

The Digital Output Property Page

This page allows you to define output values for initializing the ports, and it allows you to define interrupt resources if you didn’t define them on the Digital Input Property Page. By default DriverLINX sets output values to zero. To change the defaults, modify the following fields: 

 

Channels—shows the available Logical Channels for digital output and selects the Logical Channel for the Initialization properties. Value—specifies the output value DriverLINX uses to initialize the port selected in the Channels list box. DriverLINX ignores this property if Initialize isn’t checked. Initialize—when checked, this property indicates that DriverLINX should automatically initialize this channel as specified in the Value property.

If you specify an initialization value for an input port, DriverLINX ignores the initialization value. However, if you dynamically reconfigure an input port for output, DriverLINX will write the initialization value, or the last output value if previously reconfigured, to the output port. DriverLINX configures and initializes all Logical Channels when the operating system loads the kernel mode device driver, usually at boot time. At run time, the hardware effects of a Device Initialization operation depend on the number of times apps have concurrently opened the DriverLINX device driver. 



If one application has opened the device, DriverLINX will reconfigure and reinitialize the hardware. If other applications are sharing the device, DriverLINX does not change the hardware configuration or initialization status.

Statically Initialize Digital Output Ports
To initialize Logical Channel 2 with all bits at logic high, perform the following steps: 1. 2. 3. Select “2 (bits 0-7)” in the Channels list box. Enter “255” (Dec) or “0xFF” (Hex) in the Initialization Value edit box. Click the Initialize check box.

DriverLINX Digital I/O Programming Guide

Configuring Digital I/O Hardware  27

Digital I/O ports based on 8255 chips automatically reset the states of all I/O lines when software reprograms the chip. 28  Configuring Digital I/O Hardware DriverLINX Digital I/O Programming Guide . Note that dynamic reconfiguration of a digital I/O port has some potential limitations. or glitch. press OK to save your configuration. After completing all Property Pages. Using DriverLINX to Dynamically Configure Ports DriverLINX lets you dynamically reconfigure digital I/O ports at run time using the a “Digital Setup Event”.Repeat steps 1 to 3 for every Logical Channel that requires user-defined initialization. DriverLINX quickly tries to re-establish the initialization or last values written to the output ports. but the reprogramming process may cause the outputs to transiently change state. See “Configuring a Digital Port at Run Time” on page 41.

the DriverLINX API also supports the following digital I/O operations:  Dynamic port configuration—DriverLINX dynamically reconfigures a programmable digital I/O port as input or output or changes the DriverLINX Digital I/O Programming Guide Programming Digital I/O with DriverLINX  29 . See “Initializing the Device” on page 37. VBX. and close drivers for specific boards. After providing background information about using Service Requests for digital I/O operations. select. this chapter presents DriverLINX procedures in C/C++ and Visual Basic for the following digital I/O operations:        Connecting to a device—DriverLINX requires applications to open.Programming Digital I/O with DriverLINX DriverLINX Digital I/O Operations The DriverLINX API is available as a C/C++. See “Interfacing to DriverLINX” on page 33. Single value I/O—DriverLINX synchronously reads or writes a single value to an I/O port. Device initialization—DriverLINX initializes all subsystems on a board. See “Configuring a Logical Device” on page 36. Configuring a device—DriverLINX allows your application to display the Configure DriverLINX Device dialog box for users. specified subsystem. See “Rapidly Transferring a Block of Digital Data” on page 49. single value I/O—DriverLINX synchronously reads or writes only the selected bits of an I/O port. or ActiveX interface. This chapter describes how to control your digital I/O board using the DriverLINX API. See “Opening and Closing a DriverLINX Device Driver” on page 35. If the board has the necessary hardware. Masked. Block transfer on an I/O port—DriverLINX synchronously transfers a block of data to or from an I/O port. See “Reading or Writing a Single Value” on page 43. See “Reading or Writing Specific Digital Bits” on page 46. See “Initializing a Digital Subsystem” on page 39. Subsystem initialization—DriverLINX initializes a single.

“Determining the Digital Port Configuration” on page 40. however. See “Statically Configure Digital Ports” on page 24. the principles of setting up a Service Request are the same. Both DriverLINX and the host application run concurrently. Whatever language you’re using. the Service Request is a data structure defined in the include file. If you’re using C/C++. Buffered I/O operations. Using DriverLINX’s Service Requests All digital I/O operations use the Service Request to pass your task specification to DriverLINX.hardware’s operating mode. are asynchronous. although the syntax varies slightly with each language. Most digital I/O operations are synchronous. This manual will use the Service Request terminology displayed in the Edit Service Request Dialog box. the Service Request is an instance of the control with member variables that you setup.h”. Properties Common to All Service Requests All Service Requests require that the application define the following properties:   Device—specifies the Logical Device number of a configured device as the target of this Service Request. and “Configuring a Digital Port at Run Time” on page 41. See the DriverLINX Technical Reference Manual or the example programs for the language-specific syntax. DriverLINX can support asynchronous mode only if   the digital I/O board supports interrupts you have configured the board to use an available interrupt. DriverLINX initiates the I/O operation and then immediately returns control back to the calling application. If you’re using the ActiveX (OCX) control to program DriverLINX. See “Performing Background Digital I/O” on page 53.  Buffered I/O on one or more ports—DriverLINX asynchronously transfers values between data buffers and one or more I/O ports. 30  Programming Digital I/O with DriverLINX DriverLINX Digital I/O Programming Guide . “drvlinx. Subsystem—specifies the primary Logical Subsystem that is the target of this Service Request. DriverLINX doesn’t return control back to the calling application until the I/O transfer has completed.

and task your application intends to perform. The DriverLINX Technical Reference Manual defines an extensive set of possible events for a wide variety of hardware and data-acquisition protocols. operation.  Mode—suggests the hardware technique (Other.    Timing—specifies the timing. Stop—specifies when DriverLINX stops acquiring data for this Service Request. Interrupt. To allow applications to handle hardware-dependent features. uses only a few of the defined events. Using Events to Control Service Requests A few Service Request operations don’t use events. A DriverLINX driver for a specific manufacturer’s product. however. or they support only a subset of the event’s parameters. start. The example Service Request above defines a synchronous (polled) digital read of one sample (no timing event) on Logical Device 0 that starts immediately (on software Command) and ends when DriverLINX reads all.. Events for Digital I/O DriverLINX’s digital I/O operations only use the following events:  DriverLINX Digital I/O Programming Guide None—indicates that the event is unspecified and unneeded. Programming Digital I/O with DriverLINX  31 . i. DriverLINX uses the concept of an “event” to logically control the processing of a Service Request task. DMA) that DriverLINX should use for this Service Request. DriverLINX requires your application to specify an event for three event classes. or pacing. Start—specifies when DriverLINX starts acquiring data for this Service Request. Operation—specifies the primary command to execute for this Service Request. one. Some hardware boards. The DriverLINX Technical Reference Manual describes the Logical Device Descriptor. DriverLINX publishes board-specific information for applications in the Logical Device Descriptor. or stop event whenever logical. don’t support events that are common to the majority of similar products. For all tasks. sample (on Terminal count). The additional Service Request groups and properties depend on the selected subsystem. DriverLINX tries to define events as hardware independent and to allow each event to be used as a timing. Polled. however.e. clock DriverLINX uses to acquire a series of samples during processing a Service Request.

Digital—specifies a digital input channel to read and a masked set of bits to compare to a pattern. Mode Other Polled Timing None Digital Setup None Start None None Command Digital Command Digital Stop None None Terminal count Command Digital Terminal count Interrupt Rate Digital Specifying Digital I/O Channels in a Service Request Most Service Request operations require your application to specify one or more Logical Channels for reading or writing.     Digital Setup—specifies how to configure a programmable digital channel. Depending on the task and operation. Command—indicates that the Service Request starts or stops on software command. 32  Programming Digital I/O with DriverLINX DriverLINX Digital I/O Programming Guide . or a random list of Logical Channels. Terminal count—indicates that the Service Request completes when the hardware has transferred all samples into or out of the data buffers. or stop event. start. The following table defines the events DriverLINX allows for each event class and mode. a consecutive range of Logical Channels (Start/Stop). Use as a timing. your application can specify a single Logical Channel. Rate—specifies the operating parameters for an internal or external hardware clock.

applications must incorporate the DriverLINX API into their code.DriverLINX simulates simultaneous digital I/O transfers using a fast software loop. Interfacing to DriverLINX To use DriverLINX. VBX—16-bit Visual Basic Custom Control that supports the Visual Basic 1. DriverLINX Digital I/O Programming Guide Programming Digital I/O with DriverLINX  33 . The Simultaneous property tells DriverLINX to transfer either one channel (unchecked or false) or all channels (checked or true) at each interrupt. When specifying more than one Logical Channel. Specifying Data Buffers in a Service Request DriverLINX can transfer multiple samples in one Service Request by using data buffers. For buffered interrupt operations.   C/C++—a data structure and function call API available for both 16and 32-bit C/C++ applications. applications can specify one Logical Channel and one buffer as long as 128 KB. applications can specify multiple Logical Channels and up to 255 fixed-length buffers of arbitrary size. Some C/C++ compilers and 16bit Delphi 1. To transfer only a single value in a Service Request. The DriverLINX API supports multiple languages as well as both Win16 and Win32 application development. DriverLINX can transfer one Logical Channel at each interrupt or transfer all specified Logical Channels at each interrupt. all Logical Channels must specify the same size addressable unit.   For untimed I/O transfers using fast CPU block I/O instructions. see “Reading or Writing a Single Value” on page 43. control standard.0. Applications can then control multiple DriverLINX drivers and multiple Logical Devices using DriverLINX’s API. DriverLINX supports three different language interfaces. or higher.0 can also use this interface. such as native or byte. For timed I/O transfers using external interrupts.

DRVLNX32. You may also want to add symbolic constant definitions to your project. Add the following import library to your project or linker’s list of libraries. Add the following C header files in your program after including the standard Windows definitions: /* DriverLINX API */ /* DriverLINX error codes and macros */ /* OEM-specific vendor and model codes */ #include “drvlinx.h” 2.    DRVLNXVB. DRVLNXVB.0. The name of the 16-bit control is DLXOCX16.OCX. 34  Programming Digital I/O with DriverLINX DriverLINX Digital I/O Programming Guide . and most new language tools support 32-bit ActiveX controls. you’ll have to rename them to the above library names. use a library file format that is not compatible with Microsoft’s format. 1. The DriverLINX language interfaces bind to either “DrvLNX16.LIB for 32-bit applications. DRVLNX16. You may also want to add the following files to your project to define symbolic names for the DriverLINX constants.BAS DLCODES. for 16-bit applications.OCX. Win 95. add the file. ActiveX—or OLE 2. see the instructions for your compiler. Delphi 2. Look on the DriverLINX Distribution Disks or SST’s Web site to see if files exist for your compiler.h” #include “dlcodes. such as Borland C/C++.and 32-bit interfaces. A specific DriverLINX driver may not be available on all platforms. Visual Basic 4.BAS ActiveX Control To add the ActiveX Custom Control (OCX) to your project.VBX to your project. or Win NT as long as you have installed the correct version of DriverLINX for your hardware and operating system. These DLLs are operating system independent and allow you to run your binary application on either Win 3. Interface with the Custom Control Visual Basic Custom Control To use the Visual Basic Custom Control (VBX).BAS PIOCODES.0.x.h” #include “kmbpio. If not present. If present.LIB   Note that some compiler tools.0. Please consult your compiler vendor’s documentation for assistance. while the 32-bit control is DLXOCX32. most compilers provide a tool to create a linking library given a DLL.0 Custom Control (OCX) in both 16. Please check DLAPI subdirectory where you installed DriverLINX for library files compatible with your compiler.DLL” or “DrvLNX32. Microsoft Visual C++ 4. Interface with C/C++ To use the C/C++ interface.DLL”.

DriverLINX will display the Open DriverLINX dialog requesting the user to select a driver to open. In this case. Parameter hWnd Name Type/Description HWND Specifies one of the caller’s Window handles.Opening and Closing a DriverLINX Device Driver To communicate with a physical device. DriverLINX displays the Open DriverLINX dialog box. applications can either specify the name of a specific driver or they can supply a blank name. This function returns an “instance handle” that the application can use to identify the DriverLINX driver for the SelectDriverLINX and CloseDriverLINX function calls. With DriverLINX. call the following function: HINSTANCE DLLAPI OpenDriverLINX (const HWND hWnd. Applications should close the device driver when they no longer need its services. If NULL. Closing a DriverLINX driver stops all active tasks and unloads it from memory. call the following function: VOID DLLAPI CloseDriverLINX (const HINSTANCE hDLL). Close a Driver in C/C++ To stop all active tasks and unload a DriverLINX driver. LPCSTR Specifies the name of the DriverLINX driver to load. LPCSTR name). Open a Driver in C/C++ To load and prepare a DriverLINX driver for application use. Parameter hDLL Type/Description HINSTANCE Specifies the instance handle returned by an OpenDriverLINX call. Open a Driver with the Custom Control To load and prepare a DriverLINX driver for application use with either the VBX or OCX control. or if the app specifies an unknown name. applications must first open a device driver. simply set the Req_DLL_name property to the name of the desired driver. DriverLINX Digital I/O Programming Guide Programming Digital I/O with DriverLINX  35 .

Close a Driver with the Custom Control To stop all active tasks and unload a DriverLINX driver. if you want your application to manage device configuration. setup the Service Request Group as follows: Device <Logical Device> Subsystem DEVICE Mode OTHER Operation CONFIGURE The other properties of a Service Request are unused and should be set to zero. However. 36  Programming Digital I/O with DriverLINX DriverLINX Digital I/O Programming Guide . Users should normally configure Logical Devices using the DriverLINX Control Panel (see “Configuring Digital I/O Hardware” on page 22). To configure a device. Configuring a Logical Device Changing a device’s configuration has no effect until after you reboot the OS. simply set the Req_DLL_name property to a null string. the app can pop up the Configure DriverLINX Device dialog box after opening a Logical Driver.

If another process is executing a Service Request on the device.  If the application is the only process using the device. UINT Device) { memset(pSR. pSR->operation = CONFIGURE.   DriverLINX Digital I/O Programming Guide Programming Digital I/O with DriverLINX  37 . pSR->device = Device.Req_mode = DL_OTHER . If you don’t define initialization values for output ports.Refresh End With End Sub Initializing the Device Device initialization is the first step. if (DriverLINX(pSR) != NoErr) { result = pSR->result. that all applications should perform. DriverLINX writes zeros to output ports when the driver first loads and the last known output value at any other Device Initialization.Req_subsystem = DL_DEVICE .Req_op = DL_CONFIGURE . If multiple processes are sharing the device. Device initialization cancels all active Service Requests on the device that the current process started and does a software reset of all subsystems. UINT result = NoErr. Because DriverLINX supports sharing hardware devices among multiple processes. DriverLINX does not reconfigure or reinitialize the hardware state.Configure a Device Using C/C++ //********************************************** // Use this procedure to configure the hardware //********************************************** UINT ConfigDevice (LPServiceRequest pSR. Dev As Integer) With dl . pSR->subsystem = DEVICE. pSR->mode = OTHER. DriverLINX reconfigures and reinitializes the hardware to the user-defined state. // Display error message pSR->operation = MESSAGEBOX. } Configure a Device Using Visual Basic 'Use this procedure to configure the hardware Sub ConfigDevice(dl As Control.Req_device = Dev . DL_SetServiceRequestSize(*pSR). sizeof(DL_SERVICEREQUEST)). 0. DriverLINX(pSR). } return result. DriverLINX returns a Device Busy error to app requesting initialization. the additional effects of device initialization vary. after loading a DriverLINX driver.

To initialize a device. setup the Service Request Group as follows: Device <Logical Device> Subsystem DEVICE Mode OTHER Operation INITIALIZE The other properties of a Service Request are unused and should be set to zero. 38  Programming Digital I/O with DriverLINX DriverLINX Digital I/O Programming Guide .

// Display error message pSR->operation = MESSAGEBOX.h" #include "dlcodes. DL_SetServiceRequestSize(*pSR). 0. pSR->device = Device.h> #include "drvlinx. DriverLINX(pSR). pSR->operation = INITIALIZE. pSR->subsystem = DEVICE.h" //********************************************** // Use this procedure to initialize the hardware //********************************************** UINT InitDevice (LPServiceRequest pSR. } return result. } Initialize the Device Using Visual Basic 'Use this procedure to initialize the hardware Sub InitDevice(dl As Control. UINT Device) { memset(pSR. if (DriverLINX(pSR) != NoErr) { result = pSR->result. Dev As Integer) With dl . UINT result = NoErr. pSR->mode = OTHER.Req_subsystem = DL_DEVICE . Usually applications don’t need to call this service.Refresh End With End Sub Initializing a Digital Subsystem Applications may perform a subsystem initialization at any time to abort all outstanding Service Requests owned by the calling process.Req_device = Dev . sizeof(DL_SERVICEREQUEST)). To initialize a subsystem.Req_mode = DL_OTHER .Initialize the Device Using C/C++ #include <windows. setup the Service Request Group as follows: DriverLINX Digital I/O Programming Guide Programming Digital I/O with DriverLINX  39 .Req_op = DL_INITIALIZE .

// Display error message pSR->operation = MESSAGEBOX.Device <Logical Device> Subsystem <Logical Subsystem> Mode OTHER Operation INITIALIZE The other properties of a Service Request are unused and should be set to zero. UINT Device) { memset(pSR. sizeof(DL_SERVICEREQUEST)). the Logical Channel is an input port. pSR->mode = OTHER.Req_mode = DL_OTHER .Refresh End With End Sub Determining the Digital Port Configuration Most digital I/O boards support reconfiguration of digital ports as inputs or outputs. 3. 2. If write fails. Write data value to Logical Channel. } Initialize a Subsystem Using Visual Basic 'Use this procedure to initialize a subsystem Sub InitDigitalInput(dl As Control. 40  Programming Digital I/O with DriverLINX DriverLINX Digital I/O Programming Guide . DriverLINX(pSR). DL_SetServiceRequestSize(*pSR). UINT result = NoErr. 0. Applications can detect at run time how DriverLINX or other applications have configured the Logical Channels using the following simple algorithm: For each Logical Channel of a device. pSR->device = Device.Req_subsystem = DL_DI . pSR->subsystem = DI. This algorithm won’t disturb the current state of any Logical Channel. Read Logical Channel data value. the Logical Channel is an output port. } return result. Dev As Integer) With dl .Req_op = DL_INITIALIZE . if (DriverLINX(pSR) != NoErr) { result = pSR->result. 1. Initialize a Subsystem Using C/C++ //********************************************** // Use this procedure to initialize a subsystem //********************************************** UINT InitDigitalInput (LPServiceRequest pSR.Req_device = Dev . If write succeeds. pSR->operation = INITIALIZE.

chan). UINT nChan) { UINT chan.1 ' In order not to change the current data of each channel. ++chan) { // In order not to change the current data of each channel. ' which may be written by other programs. break. Detect Port Configuration Using Visual Basic Sub DetectPortConfig(dl) Dim chan%. setup the Service Request as follows: Device Subsystem Mode Operation DriverLINX Digital I/O Programming Guide Programming Digital I/O with DriverLINX  41 . // which may be written by other programs. default: DriverLINXSR1->operation = MESSAGEBOX. case InvalidOpErr: IOConfig[chan] = 1.IOConfig(chan) = 0 ElseIf dl. chan) WriteChannel DriverLINXSR1.Res_result = DL_InvalidOpErr Then PIO. // if a channel has an error when executing a write operation // then we know this channel is configured as an input channel // otherwise it is configured as an output channel switch (DriverLINXSR1->result) { case NoErr: IOConfig[chan] = 0.nChan . chan. Data 'if a channel has an error when executing a write operation 'then we know this channel is configured as an input channel 'otherwise it is configured as an output channel If dl. break. chan. read it first then ' write it back Data = ReadChannel(DriverLINXSR1. for (chan = 0. Some digital I/O boards support dynamically reconfiguring ports as either input or output at run time.Detect Port Configuration Using C/C++ UINT IOConfig[NCHAN]. void DetectPortConfig (LPServiceRequest DriverLIXNSR1. see “Read or Write a Single Value Using C/C++” on page 44. ReadChannel and WriteChannel.IOConfig(chan) = 1 Else dl. read it first then // write it back data = ReadChannel(DriverLINXSR1.Res_result = DL_NoErr Then PIO. WriteChannel(DriverLINXSR1. Data% For chan = 0 To PIO. data). see “Read or Write a Single Value Using Visual Basic” on page 45. chan < nChan. DriverLINX(DriverLINXSR1). To change a port’s configuration.Refresh End If Next End Sub For the subroutines. Configuring a Digital Port at Run Time See “Configuring Digital I/O Hardware” on page 22 to statically configure ports.Req_op = DL_MESSAGEBOX 'Show Error Message dl. BYTE data. // show error message } // switch } // for } For the subroutines. ReadChannel and WriteChannel.

42  Programming Digital I/O with DriverLINX DriverLINX Digital I/O Programming Guide . set the subsystem to digital output. see the DriverLINX Technical Reference Manual. If the port doesn’t support dynamic reconfiguration. but any equipment attached to the ports may respond to transient changes on the outputs. The Logical Channel in the Digital Setup Event specifies the channel you want to reconfigure. Note that reconfiguring Intel 8255 PPI chips will reinitialize the values on the other output ports of the chip.<Logical Device> Digital Input or Digital Output OTHER CONFIGURE And specify a Digital Setup Event for the timing event as follows: Channel <Logical Channel> Mode DIO_BASIC or DIO_STROBED or DIO_BIDIRECTIONAL For a list of error codes. set the subsystem to digital input. or glitches. To configure as an input channel. To configure as an output channel. If the port you’re configuring is already an input. DriverLINX will return an error code for “Operation Not Supported”. DriverLINX will rewrite the last known output values to the ports. DriverLINX reports no error.

diSetup. } Configure a Port Using Visual Basic 'Use this procedure to configure a specific channel 'either as an input channel or as an output channel 'at runtime Sub InitDIOPort(dl As Control. } return result.channel = chan. pSR->timing.Evt_Tim_dioMode = DL_DIO_BASIC .u.Sel_chan_N = 0 . pSR->subsystem = subsys.Evt_Tim_dioChannel = chan . pSR->timing. 0. DL_SetServiceRequestSize(*pSR).Req_op = DL_CONFIGURE . pSR->device = Device.typeEvent = DIOSETUP.Evt_Str_type = DL_NULLEVENT . if (DriverLINX(pSR) != NoErr) { result = pSR->result. DriverLINX Digital I/O Programming Guide Programming Digital I/O with DriverLINX  43 . UINT Device. UINT chan) { memset(pSR.Evt_Tim_type = DL_DIOSETUP . sizeof(DL_SERVICEREQUEST)).Req_subsystem = subsys . pSR->operation = CONFIGURE.mode = DIO_BASIC. // Display error message pSR->operation = MESSAGEBOX.u. DriverLINX(pSR). pSR->mode = OTHER. ByVal chan As Integer) With dl .diSetup.Req_mode = DL_OTHER . subsys As Integer.Refresh End With End Sub Reading or Writing a Single Value Applications can read or write a single value for a digital I/O port using DriverLINX’s extended Logical Channel addressing.Configure a Port Using C/C++ //*************************************************** // Use this procedure to configure a specific channel // either as an input channel or as an output channel // at runtime //*************************************************** UINT InitDIOPort (LPServiceRequest pSR. See “Combining or Splitting Logical Channels” on page 19. pSR->timing. UINT result = NoErr. SubSystems subsys.Evt_Stp_type = DL_NULLEVENT .

Read or Write a Single Value Using C/C++ Write a Single Value 44  Programming Digital I/O with DriverLINX DriverLINX Digital I/O Programming Guide . Select Channels Setup the Select Group Channels as follows: Number of channels 1 Start Channel <Logical Channel> Format native Select Buffers Single-value transfers use ioValue property in the Service Request instead of a buffer to hold the data. For output. Start on Command and stop on Terminal Count tells DriverLINX to transfer the data once. Set the number of Buffers to zero.To transfer a single value. For input. read the input from the ioValue property after executing the Service Request. setup the Service Request Group as follows: Device <Logical Device> Subsystem <Logical Subsystem> Mode POLLED Operation START Setup the Events Group as follows: Timing None Start None or Command Stop None or Terminal count For a Start Event. assign the output value to the ioValue property in the Results Group. None or Command are equivalent as are None or Terminal Count for a Stop Event.

DriverLINX(pSR). DWORD Value) { memset(pSR. sizeof(DL_SERVICEREQUEST)).chanGain[0]. pSR->channels. sizeof(DL_SERVICEREQUEST)).u. pSR->mode = POLLED. // Display error message pSR->operation = MESSAGEBOX. DL_SetServiceRequestSize(*pSR).channel = Channel. if (DriverLINX(pSR) != NoErr) { result = pSR->result. pSR->channels. UINT Device. UINT Channel. pSR->mode = POLLED. pSR->subsystem = DI. UINT Channel) { memset(pSR. UINT result = NoErr. return (DWORD)-1. 0. DL_SetServiceRequestSize(*pSR).//******************************************* // Use this procedure to write a single value // to a specific channel //******************************************* UINT WriteChannel (LPServiceRequest pSR. pSR->channels. UINT Device. pSR->status. pSR->channels.ioValue = Value.nChannels = 1. pSR->status. pSR->subsystem = DO. pSR->operation = START.u. 0.channel = Channel. DriverLINX(pSR). pSR->device = Device. if (DriverLINX(pSR) != NoErr) { // Display error message pSR->operation = MESSAGEBOX. } Read or Write a Single Value Using Visual Basic Write a Single Value DriverLINX Digital I/O Programming Guide Programming Digital I/O with DriverLINX  45 . } return pSR->status. pSR->device = Device.typeStatus = IOVALUE. } Read a Single Value //************************************* // Use this procedure to read one value // from a specific channel //************************************* DWORD ReadChannel (LPServiceRequest pSR.ioValue. pSR->operation = START.nChannels = 1. } return result.chanGain[0].

Refresh End With End Sub Read a Single Value 'Use this procedure read one sample 'from a specific channel Function ReadChannel(dl As Control.Sel_chan_format = DL_tNATIVE .Res_Sta_ioValue End If ReadChannel = DIValue End Function Reading or Writing Specific Digital Bits Applications can write specific bits to a digital I/O port using a Digital Event to supply a bit mask.Req_mode = DL_POLLED .Req_op = DL_START Evt_Tim_type = DL_NULLEVENT .Evt_Stp_type = DL_NULLEVENT .Res_Sta_ioValue = Value .Evt_Str_type = DL_NULLEVENT .Sel_chan_N = 1 . 46  Programming Digital I/O with DriverLINX DriverLINX Digital I/O Programming Guide .Req_op = DL_START .Evt_Str_type = DL_NULLEVENT . Channel As Integer.Sel_chan_start = Channel .Req_subsystem = DL_DI . Use this technique to set single bits in an output port or to share an output port between threads or processes. Channel As Integer) As Integer ' Setup for polled digital input of 1 sample Dim DIValue As Long With dl .Req_subsystem = DL_DO .Req_mode = DL_POLLED .Sel_buf_N = 0 .Evt_Tim_type = DL_NULLEVENT .'Use this procedure to write one sample 'to a specific channel Sub WriteChannel(dl As Control.Sel_chan_start = Channel . ByVal Value As Integer) Dim Res% With dl .Refresh End With If dl.Res_result = DL_NoErr Then DIValue = dl.Sel_chan_N = 1 .Sel_chan_format = DL_tNATIVE .Evt_Stp_type = DL_NULLEVENT .Sel_buf_N = 0 .

Setting up masked I/O is similar to single value transfers. Start Event Setup the Digital Event as follows: Channel <Logical Channel> Mask <bit mask> Match <unused> Pattern <unused> DriverLINX composes the new output value for the port as new value = (old value AND NOT Mask) OR (user value AND Mask). First. Select Channels Setup the Select Group Channels as follows: Number of channels 1 Start Channel <Logical Channel> Format native DriverLINX Digital I/O Programming Guide Programming Digital I/O with DriverLINX  47 . setup the Service Request Group as follows: Device <Logical Device> Subsystem <Logical Subsystem> Mode POLLED Operation START Setup the Events Group as follows: Timing None Start Digital Stop None or Terminal count For a Stop Event. None or Terminal Count are equivalent.

read the input from the ioValue property after executing the Service Request.Select Buffers Single-value transfers use ioValue property in the Service Request instead of a buffer to hold the data. 48  Programming Digital I/O with DriverLINX DriverLINX Digital I/O Programming Guide . For input. For output. assign the value to write to the ioValue property in the Results Group. Set the number of Buffers to zero.

pSR->channels. ByVal Value As Integer.Evt_Tim_type = DL_NULLEVENT . pSR->start. } Write a Masked Value Using Visual Basic Sub WriteBits(dl As Control. pSR->start. pSR->start.Evt_Str_diMask = Mask .Pattern = 0. pSR->status. sizeof(DL_SERVICEREQUEST)). pSR->mode = POLLED.diEvent. UINT Channel.channel = Channel.Req_mode = DL_POLLED . UINT Device. pSR->status.chanGain[0]. pSR->subsystem = DO. pSR->channels. } return result.u.diEvent. pSR->start.u.u.Req_op = DL_START .nChannels = 1. UINT Mask) { memset(pSR.typeEvent = DIEVENT. DL_SetServiceRequestSize(*pSR).u. DriverLINX(pSR).Write a Masked Value Using C/C++ //***************************************************** // Use this procedure to read one value from a specific // channel //***************************************************** UINT WriteBits (LPServiceRequest pSR.ioValue = Value.Evt_Str_type = DL_DIEVENT . UINT Value.u.Res_Sta_ioValue = Value .Mask = Mask.Refresh End With End Sub Rapidly Transferring a Block of Digital Data DriverLINX Digital I/O Programming Guide Programming Digital I/O with DriverLINX  49 .channel = channel.Sel_buf_N = 0 .Match = FALSE. pSR->start. UINT result = NoErr.typeStatus = IOVALUE.Sel_chan_start = Channel . ByVal Mask As Integer) Dim Res% ' Setup for polled digital output of 1 sample With dl . 0.Sel_chan_format = DL_tNATIVE .Req_subsystem = DL_DO . pSR->device = Device.Evt_Str_diPattern = 0 .Sel_chan_N = 1 .Evt_Stp_type = DL_NULLEVENT . Channel As Integer.Evt_Str_diMatch = DL_NotEquals .Evt_Str_diChannel = Channel .diEvent.diEvent. if (DriverLINX(pSR) != NoErr) { result = pSR->result. pSR->operation = START. // Display error message pSR->operation = MESSAGEBOX.

None or Command are equivalent as are None or Terminal Count for a Stop Event. To transfer a buffer.Applications can rapidly transfer a single data buffer of values to or from an I/O port using the computer’s block I/O hardware instructions. setup the Service Request Group as follows: Device <Logical Device> Subsystem <Logical Subsystem> Mode POLLED Operation START Setup the Events Group as follows: Timing None Start None or Command Stop None or Terminal count For a Start Event. Start on Command and stop on Terminal Count tells DriverLINX to transfer the data in buffer once. Read or Write a Single Buffer Using C/C++ Read One Buffer 50  Programming Digital I/O with DriverLINX DriverLINX Digital I/O Programming Guide . Select Channels Setup the Select Group Channels as follows: Number of channels 1 Start Channel <Logical Channel> Format native Select Buffers Set the number of Buffers to one and the BufferSize to the number of bytes to transfer.

nChannels = 1. PVOID Buffer.chanGain[0]. pSR->subsystem = DI. UINT Channel. sizeof(DL_SERVICEREQUEST)). UINT result = NoErr. } Write One Buffer DriverLINX Digital I/O Programming Guide Programming Digital I/O with DriverLINX  51 . if (DriverLINX(pSR) != NoErr) { result = pSR->result. pSR->device = Device. pSR->lpBuffers->BufferAddr[0] = Buffer. pSR->operation = START. pSR->channels. pSR->channels.//********************************** // Use this procedure to read a data // array from a specific channel //********************************** UINT ReadChannelBuff (LPServiceRequest pSR. // Display error message pSR->operation = MESSAGEBOX. } return result. BufAllocErr). pSR->lpBuffers->bufferSize = Length. DWORD Length) { memset(pSR. pSR->mode = POLLED. DriverLINX(pSR). pSR->lpBuffers->nBuffers = 1. DL_SetServiceRequestSize(*pSR). 0.channel = Channel. pSR->lpBuffers = (LPBUFFLIST)malloc(DL_BufferListBytes(1)). if (!pSR->lpBuffers) return Error(Abort. UINT Device.

} Read or Write a Single Buffer Using Visual Basic Read One Buffer 'Use this procedure to read one buffer from a 'specific channel. if (DriverLINX(pSR) != NoErr) { result = pSR->result. DriverLINX(pSR).Buf_0(i) Next i End If End Sub Write One Buffer 52  Programming Digital I/O with DriverLINX DriverLINX Digital I/O Programming Guide .Evt_Stp_type = DL_NULLEVENT .Evt_Str_type = DL_NULLEVENT .Sel_chan_format = DL_tNATIVE . Length As Integer) ' Setup for polled digital input Dim i% With dl . pSR->operation = START. Sub ReadChannelBuff(dl As Control. UINT result = NoErr.Refresh End With If dl.1 Buffer(i) = dl.Sel_chan_N = 1 . UINT Channel.Res_result = DL_NoErr Then For i = 0 To Length . } return result. PVOID Buffer. pSR->device = Device.chanGain[0].Req_mode = DL_POLLED .nChannels = 1. pSR->channels. DWORD Length) { memset(pSR. pSR->subsystem = DO. pSR->lpBuffers->bufferSize = Length.Sel_buf_samples = Length . UINT Device.//*********************************** // Use this procedure to write a data // array to a specific channel //*********************************** UINT WriteChanBuf (LPServiceRequest pSR. pSR->channels. // Display error message pSR->operation = MESSAGEBOX.channel = Channel. Buffer() As Integer. sizeof(DL_SERVICEREQUEST)).Req_subsystem = DL_DI . if (!pSR->lpBuffers) return Error(Abort. pSR->lpBuffers = (LPBUFFLIST)malloc(DL_BufferListBytes(1)).Evt_Tim_type = DL_NULLEVENT . DL_SetServiceRequestSize(*pSR).Sel_buf_N = 1 . pSR->lpBuffers->nBuffers = 1. Channel As Integer.Req_op = DL_START .Sel_chan_start = Channel . pSR->lpBuffers->BufferAddr[0] = Buffer. pSR->mode = POLLED. 0. BufAllocErr).

Sel_buf_samples = Length For i = 0 To Length .Req_subsystem = DL_DO .Sel_buf_N = 1 . The application can optionally start or stop background I/O at the occurrence of a digital trigger.Sel_chan_N = 1 . Channel As Integer.Refresh End With End Sub Performing Background Digital I/O DriverLINX can transfer I/O data in the background if the digital hardware supports an external interrupt to time or clock the data transfers.Evt_Str_type = DL_NULLEVENT .'Use this procedure write an integer data 'array to a specific channel Sub WriteChanBuf(dl As Control. To transfer a buffer in the background. Buffer() As Integer. setup the Service Request Group as follows: Device <Logical Device> Subsystem <Logical Subsystem> Mode INTERRUPT Operation START DriverLINX Digital I/O Programming Guide Programming Digital I/O with DriverLINX  53 . Length As Integer) Dim i% With dl .Sel_chan_start = Channel .Evt_Tim_type = DL_NULLEVENT .1 .Req_mode = DL_POLLED .Evt_Stp_type = DL_NULLEVENT .Req_op = DL_START .Buf_0(i) = Buffer(i) Next I .Sel_chan_format = DL_tNATIVE .

This specifies that a rising edge at any input will trigger the interrupt. symbolic Logical Channel.   As an alternative to a Digital Timing Event. DriverLINX will acquire data until the application resets the Service Request’s Operation property to Stop and resubmits the Service Request to DriverLINX. With a Stop Command. Set the Match and Pattern properties to “not equal zero”. You can enable (1) or disable (0) individual interrupt input lines by setting the corresponding bit in the Mask property. logically combines (logical OR operation) the C0 and C3 inputs of every Port C on the board to trigger an interrupt.Setup the Events Group as follows: Timing Digital or Rate Start Command or Digital Stop Command or Digital or Terminal count Timing Event Use a Digital Timing Event to tell DriverLINX which hardware input source to use for the interrupt. DI_EXTCLK. Most boards only support one external interrupt line so use a value of 1. and the MSB specifies the C3 input of the highest Logical Channel. DriverLINX automatically replaces this value with the correct hardware channel when the app sends the Service Request to DriverLINX. after DriverLINX finishes processing the last buffer. you can specify a Rate Event that uses a Rate Generator with an external clock. The LSB specifies the C0 input of the lowest Logical Channel. This option is for compatibility with other data-acquisition devices that support pacing clocks. To start or stop data transfer on software command. Start and Stop Events DriverLINX can optionally post “buffer filled” messages to the application as DriverLINX completes processing each buffer. 54  Programming Digital I/O with DriverLINX DriverLINX Digital I/O Programming Guide . If you use a Stop Command or Digital Event. either specify the Logical Channel DriverLINX has assigned as the external interrupt input line (for an N-channel digital input board. it will automatically start transferring data again from the first buffer. Setup the Digital Event as follows: Channel <external interrupt channel> Mask <input lines to test> Match FALSE or “not equal” Pattern 0  For the Channel. this is usually Logical Channel N) or use a hardwareindependent. Other values for these properties will generate an error. This option is logically equivalent to specifying the above Digital Event with a Mask value of 1. The MetraByte PIO-SSR Series. use Command Events for the Start or Stop Event. however. Use the Mask property to indicate which line(s) to enable for interrupts.

If DriverLINX detects the start trigger.“not equal” or 1 . At each interrupt. Setup a Digital Event as follows: Channel <Logical Channel> Mask <input lines to test> Match 0 . Use the Match property to select how DriverLINX tests for a digital trigger. To start or stop data transfer when a certain condition occurs on a digital input channel. but it will send a message to the application each time it detects the stop event. Note that a digital input may change value between the time when DriverLINX reads the Logical Channel for a trigger test and reads a channel for data input. if the stop delay property has the maximum count.DriverLINX can optionally post “start trigger” and “stop trigger” messages to the application. specify the Logical Channel for any digital input port. DriverLINX won’t trigger the event until it has counted the number of additional interrupts the app specified in the delay property. See the DriverLINX Technical Reference Manual for more information about messages.“equal” Pattern <pattern to match>     For the Channel property. DriverLINX will terminate acquisition either when the digital input value satisfies the digital trigger condition or when the application sends a stop operation. After processing one sample or scan. Use the Mask property to select which input bits to test as a digital trigger. If the delay property of a Digital Event is not zero. Match Value 0 1 Trigger Test Channel AND Mask  Pattern Channel AND Mask = Pattern With a Stop Digital Event. it starts processing the data buffers immediately. DriverLINX supports two types of digital triggers tests based on the value of the Match property. As a special case. DriverLINX treats this event as “stop on command”. if found. stops processing data immediately. and. Select Channels Setup the Select Group Channels for 1 Logical Channel: Number of channels 1 Start Channel <Logical Channel> Format native DriverLINX Digital I/O Programming Guide Programming Digital I/O with DriverLINX  55 . DriverLINX tests for the stop trigger event. DriverLINX tests the requested Logical Channel for the trigger event. Use the Pattern property to specify the bits DriverLINX uses for comparison. use a Digital Event for the Start or Stop Event.

Setup the Select Group Channels for a consecutive range of channels: Number of channels 2 Start Channel <Logical Channel> Stop Channel <Logical Channel> Format native Specify the number of channels as 2. not the number of channels in the consecutive sequence. If the starting channel is greater than the stopping channel. 56  Programming Digital I/O with DriverLINX DriverLINX Digital I/O Programming Guide . Select Buffers Set the number of Buffers between 1 and 255 and the BufferSize to the number of bytes to transfer. Buffers must contain an integral multiple of the number of channels. DriverLINX scans all channels between the starting and stopping channel. Most digital I/O hardware doesn’t support true simultaneous transfers. but all channels must have the same size attribute. so DriverLINX rapidly reads each channel in a loop. the channel sequence wraps around at the highest Logical Channel and continues from zero. DriverLINX can transfer one Logical Channel at each interrupt or transfer all the specified Logical Channels (a scan) at each interrupt. Setup the Select Group Channels for a random channel list: Number of channels <size of list> Channeli <Logical Channel> Gaini 0 Format native You may use extended Logical Channel addressing. The Simultaneous property tells DriverLINX to transfer either one channel (unchecked or false) or all channels (checked or true) at each interrupt.

pSR->stop. // Display error message pSR->operation = MESSAGEBOX. DL_SetServiceRequestSize(*pSR).typeEvent = COMMAND. pSR->timing.typeEvent = DIEVENT. 0. pSR->lpBuffers->BufferAddr[0] = Buffer.Read or Write a Background Buffer Using C/C++ Read Buffers //********************************** // Use this procedure to read a data // array from a specific channel // in the background //********************************** UINT ReadChannelBuffBkg (LPServiceRequest pSR. pSR->timing.chanGain[0].channel = Channel.u. BufAllocErr). UINT Channel. pSR->channels. pSR->device = Device.match = FALSE.pattern = 0.typeEvent = TCEVENT.u. pSR->start. DriverLINX(pSR).u.channel = DI_EXTCLK. DWORD Length) { memset(pSR. if (!pSR->lpBuffers) return Error(Abort. } DriverLINX Digital I/O Programming Guide Programming Digital I/O with DriverLINX  57 . pSR->timing. } return result. pSR->timing.diEvent.diEvent.diEvent. PVOID Buffer. pSR->operation = START.diEvent.nChannels = 1. UINT result = NoErr.u. pSR->lpBuffers->nBuffers = 1.mask = 1. pSR->mode = INTERRUPT. pSR->lpBuffers = (LPBUFFLIST)malloc(DL_BufferListBytes(1)). sizeof(DL_SERVICEREQUEST)). pSR->subsystem = DI. pSR->lpBuffers->bufferSize = Length. pSR->channels. UINT Device. if (DriverLINX(pSR) != NoErr) { result = pSR->result. /* Setup external interrupt as timing clock */ pSR->timing.

pSR->timing.u. pSR->stop.mask = 1. pSR->lpBuffers = (LPBUFFLIST)malloc(DL_BufferListBytes(1)). pSR->device = Device. if (DriverLINX(pSR) != NoErr) { result = pSR->result. pSR->lpBuffers->BufferAddr[0] = Buffer. pSR->channels. pSR->lpBuffers->nBuffers = 1. DL_SetServiceRequestSize(*pSR).diEvent. PVOID Buffer. UINT Channel.Write Buffers //*********************************** // Use this procedure to write a data // array to a specific channel // in the background //*********************************** UINT WriteChannelBuffBkg (LPServiceRequest pSR. /* Setup external interrupt as timing clock */ pSR->timing. UINT result = NoErr. pSR->operation = START.pattern = 0.u.channel = DI_EXTCLK. 0. // Display error message pSR->operation = MESSAGEBOX.typeEvent = DIEVENT.nChannels = 1. pSR->timing. pSR->lpBuffers->bufferSize = Length. } return result. pSR->channels. pSR->subsystem = DO.match = FALSE.chanGain[0]. BufAllocErr). pSR->timing. DriverLINX(pSR). pSR->mode = INTERRUPT.diEvent. if (!pSR->lpBuffers) return Error(Abort.u. pSR->start.channel = Channel.u. pSR->timing. } 58  Programming Digital I/O with DriverLINX DriverLINX Digital I/O Programming Guide . UINT Device.typeEvent = COMMAND.diEvent. DWORD Length) { memset(pSR.typeEvent = TCEVENT. sizeof(DL_SERVICEREQUEST)).diEvent.

Length As Integer) With dl .Evt_Str_type = DL_COMMAND .Evt_Tim_type = DL_DIEVENT . device As Integer. Channel As Integer.Req_op = DL_START ' Setup external interrupt as timing clock .Sel_buf_samples = Length .Sel_chan_format = DL_tNATIVE .Evt_Stp_type = DL_TCEVENT .Evt_Tim_diMask = 1 . bufIndex As Integer) .Req_mode = DL_INTERRUPT . mode As Integer.Sel_chan_start = Channel .VBArrayBufferXfer(0.Sel_chan_N = 1 . subsystem As Integer.Sel_buf_N = 1 .Refresh End With End Sub Sub DriverLINXSR1_BufferFilled(task As Integer.Evt_Tim_diChannel = DL_DI_EXTCLK .Req_subsystem = DL_DI .Evt_Tim_diMatch = DL_NotEquals . DL_BufferToVBArray) End Sub DriverLINX Digital I/O Programming Guide Programming Digital I/O with DriverLINX  59 .Read or Write a Background Buffer Using Visual Basic Read Buffers ' Use this procedure to read a data ' array from a specific channel ' in the background Sub ReadChannelBuffBkg (dl As Control. Buffer.Evt_Tim_diPattern = 0 .Sel_buf_notify = DL_NOTIFY .

Evt_Tim_diPattern = 0 . Channel As Integer.VBArrayBufferXfer(0.Evt_Stp_type = DL_TCEVENT .Evt_Tim_diChannel = DL_DI_EXTCLK .Sel_chan_format = DL_tNATIVE .Sel_buf_notify = DL_NOTIFY .Sel_chan_start = Channel .Evt_Tim_type = DL_DIEVENT .Evt_Str_type = DL_COMMAND . Buffer.Refresh End With Sub DriverLINXSR1_BufferFilled(task As Integer. mode As Integer.Req_mode = DL_INTERRUPT .Sel_buf_N = 1 .Req_subsystem = DL_DO .Sel_chan_N = 1 .Sel_buf_samples = Length . DL_VBArrayToBuffer) End Sub 60  Programming Digital I/O with DriverLINX DriverLINX Digital I/O Programming Guide . Length As Integer) With dl .Evt_Tim_diMask = 1 . bufIndex As Integer) . device As Integer.Reqoperation = DL_START ' Setup external interrupt as timing clock .Write Buffers ' Use this procedure to write a data ' array to a specific channel ' in the background Sub WriteChannelBuffBkg (dl As Control. subsystem As Integer. Buffer As Integer.Evt_Tim_diMatch = DL_NotEquals .

DriverLINX Digital I/O Programming Guide Glossary of Terms  61 . Kernel Mode The privileged mode in which the operating system runs system software such as device drivers. DMA Direct Memory Access provides a direct device to memory hardware channel that doesn’t require software overhead to transfer acquired data. API Application Programming Interface—the properties and methods used to communicate with a software service. Kernel mode software has complete access to memory and hardware resources. Logical Channel A DriverLINX-assigned number for a data channel of a Logical Subsystem. ActiveX controls were formerly called OCX controls.Glossary of Terms ActiveX Component software object using Microsoft’s Component Object Model specification for 16. Logical Device A user-assigned number that a DriverLINX driver uses to designate an installed hardware device. COM Component Object Model is a specification of a binary standard for reusable software objects.and 32-bit controls.

Logical Subsystem A set of related hardware resources on a data-acquisition device. OCX OLE Custom Controls are now called ActiveX custom controls. digital input. nibble A nibble is 4 bits or ½ byte. and hardware.0 also support VBX controls. Service Request A DriverLINX data structure that completely specifies the parameters for all dataacquisition tasks. VBX Component software object using the 16-bit Visual Basic Custom Control specification.Logical Device Descriptor A DriverLINX data structure that contains hardware specifications for a Logical Device. User Mode The mode in which the operating system runs user applications. User mode software has restricted access to memory. 62  Glossary of Terms DriverLINX Digital I/O Programming Guide . digital output. and counter/timer. OLE Object Linking and Embedding is an older term for Microsoft's ActiveX technology. Many 16-bit C/C++ compilers and Delphi 1. analog input. DriverLINX abstractly characterizes all data-acquisition devices as consisting of seven possible subsystems—device. other processes. analog output.

46–47. 25 DI 14. 44. 24–26. 27 Initialize 25.Index Configuration Example 25 Configuration Setup 25–26 Configuration Values 25 Configure digital ports 24. 28. 53 B Background I/O 30. 32. 33–34 A ActiveX 16. 29–31 Digital Input Property Page 24. 23. 41 Model 13–14. 27 Channels 24. 30 Configure DriverLINX Device dialog box 23. 27 Configuration Setup 25–26 Initialize 25. 43–46. 54 Configuration base address 22–23 custom 22 DriverLINX Control Panel 8. 24. 41 detection protocols 23 DEVICE 14. 22. 29–31. 41. 32. 30 Open DriverLINX 35 Digital Event 32 Digital I/O events 31 Digital I/O hardware 8. 43–46. 22 advantages 11 disadvantages 12 Device initialization 24. 51–52. 36 Edit Service Request 15. 27 CloseDriverLINX 35 Command Event 31–32. 57–59 Control Interface 16 CT 14 custom configuration 22 1 16-bit 33 D DASCard-PIO12 26 Data Buffers Specifying 33 default hardware initialization 24 Delphi 33 Detect 23. 31. 32 Setup 23. 57–59 DI_EXTCLK 54. 27 Interrupt 24. 54. 36. 45–46. 43–46. 52–59 Digital Output Property Page 27 Channels 24. 27 Value 27. 56 Digital I/O operations 7. 40. 42 3 32-bit 13. 36–39 device drivers 7–11. 54 DriverLINX Digital I/O Programming Guide Index  63 . 27. 29–30. 42. 53 base I/O address 22–23 Block I/O transfers 20 Block transfer 29 Buffered I/O 30 Buffered interrupt transfers 20 C C/C++ Interface 16. 34 Calibrate 24 channel size 20 Channels 24. 17. 22. 36 interrupt channel 22. 57–59 dialog box Configure DriverLINX Device 23. 44. 50. 36 Configuring a device 29 Configuring DriverLINX administrative account 22 Connecting to a device 29 Constant DI_EXTCLOCK 54. 34 Address 23 administrative account 22 AI 14 AO 14 asynchronous 30 Asynchronous I/O 30. 49–50. 49 Digital Setup Event 28. 37 Device Property Page 23 Address 23 Calibrate 24 Detect 23.

33 Logical Channels 14–15.OCX 34 DLXOCX32. 22–23 base 22–23 I/O addresses 17 I/O hardware calibration 24 description 17 detecting 23. 47. 57–59 DO 6. 36. 44. 54. 15–16. 52–53. 42 drvlinx.OCX 34 DMA 24. 40. 49. 53 block 29.DLL 34 DRVLNXVB. 32–33. 36–39 DI 14. 34. 49 buffered 30 masked I/O 29. 22 DriverLINX Control Panel 8.direct hardware I/O 11 Direct Memory Access 24. 53 Logical Device Descriptor 13–15. 45–46. 27 Digital Output Property Page 27 DriverLINX Distribution Disks 13. 54 Digital Setup 28. 24–27. 52–53. 40.h 30. 35 programming model 7–14 Serivce Requests 13. 29. 44. 56 Logical Device 13–15. 33. 22. 44. 50. 22–23. 38. 42.BAS 34 dlcodes. 40. 45–46 WriteChannelBuffBkg 58–60 G Group A 17. 30 Event Digital 32 Events Command 31–32. 46 masked single value 29 overlapped 30. 37.h 34. 47. 33 I/O transfer asynchronous 30 background 30. 50. 42 None 31–32. 53 single value 29. 45–46 ReadChannelBuff 51–52 ReadChannelBuffBkg 57. 39 DLXOCX16. 50 Rate 32. 16 Opening 29. 44. 14. 41 initialization 24 I/O instructions 11. 39 DriverLINX 4.VBX 34 Dynamic port configuration 29 Types for digital I/O 31 Events Group 15. 39 DrvLNX16. 45–46. 34 DLCODES. 14. 47. 58–60 DOS 11–12 DriverLINX AI 14 AO 14 CT 14 DEVICE 14. 20. 54 Terminal count 31–32. 47. 15. 54 F Functions CloseDriverLINX 35 ConfigDevice 37 DetectPortConfig 41 InitDevice 39 InitDigitalInput 40 InitDIOPort 43 OpenDriverLINX 35 ReadChannel 41. 36 Device Property Page 23 Digital Input Property Page 24. 25 H hardware I/O direct 11 hardware model 7–13 hardware testing algorithms 23 HINSTANCE 35 I I/O address 13.BAS 34 DRVLNXVBX. 45–46.DLL 34 DrvLNX32. 32. 50. 58–60 hardware model 7–13 Interfacing 29. 18–20. 59 SelectDriverLINX 35 WriteBits 49 WriteChanBuf 52–53 WriteChannel 41. 31 DO 6. 31 Logical Subsystems 14. 49. 30–31.0 Installation and Configuration Guide 7. 34 DriverLINX Technical Reference Manual 7–13. 50. 29–31. 43 E Edit Service Request Dialog Box 15. 31 Distribution Disks 7–13. 44. 54 64  Index DriverLINX Digital I/O Programming Guide . 51–52. 25 Group B 17.

41 masked I/O 29. 47. 32 interrupt channel 22. 47. 43. 44. 25 Port A 17 Port B 17 Port C 17. 57–59 DO 6. 14. 54 Reconfiguring 42 Intel 8255A Programmable Peripheral Interface 17 Interface C/C++ 16. 25 Operational modes 17. 30. 45–46. 40.BAS 34 kmbpio. 44. 51–52. 26. 27. 26 PIO-SSR-24 18. 39–41. 33. 50. 18–20. 42 Group A 17. 54 Interrupt I/O 30. 25 PIO-24 18. 29–31. 34 Control 16 Interfacing to DriverLINX 29. 27 Initialize digital output ports 24. 33 Interrupt 24. 40. 25–26 None Event 31–32. 31 LDD 15 Logical Driver Connecting 29. 48 Implementation notes 20 Initialize 25. 45. 46 Masked. 26 PIO-32IN 18–19 PIO-32IO 18–19 PIO-32OUT 18–19 PIO-96 18. 45–46. 23. 47. 49. 53 ioValue property 44–46. 40. 56 Combining or splitting 19 Mapping to hardware channels 18 N Native 20. 36. 24–27. 31. 49 Determining configuration 30.h 34 L LDD 15 library files 34 License software 5 Logical Channel block I/O 29. 33 block 20 buffered 20 interrupt 20 single value 20. 44. 36. single value I/O 29 Method Refresh 16 MetraByte DASCard-PIO12 26 PDISO-8 18–19 PIO-12 18. 16 LPServiceRequest 37. 32. 22–23. 42. 23–26. 26 PIO-SSR-48 18. 54. 49. 56 notes 20 Logical Channels 14–15. 33. 32–33. 24. 43 reconfiguring 42 Logical Channel addressing 19–20. 22. 51–52. 58–60 initialization 39 Initializing 29. 39 Logical Subsystems 14. 25 Group B 17. 29. 41. 28. 38. 52–53. 43. 24 Logical Device 13–15. 25 multiple processes 37 multitasking 7–12 K Kernel Mode 24. 50 DriverLINX Digital I/O Programming Guide Index  65 . 37 Initializing 29.starting and stopping 54–55 synchronous 30–31 timed or paced 33 untimed 33 I/O transfers 20. 53 Model 13–14. 50. 26 REL-16 18–19 Mode 31. 44. 55–56 nibble 20. 44. 29. 27 KMBPIO. 40 Dynamic configuration 25. 27 Intel 8255 17–19. 35 Logical Subsystem AI 14 AO 14 CT 14 DEVICE 14. 50. 37 Logical Device Descriptor 13–15. 57–58 M Mapping Logical Channels 18 Masked I/O transfer 29. 38. 26 PIO-HV 18–19 PIO-SSR-120 18–19. 40. 48–49 ISA 23 Properties 18. 46 Reading or writing 29. 47. 53 configuration 8. 36–39 DI 14. 36 configuring 29 connecting 29 initialization 24.

26 Port A 17 Port B 17 Port C 17. 41. 37. 53 P PDISO-8 18–19 PIO-12 18. 44.x 11. 29–30. 44. 53–54 Results Group 15. 50. 48 Value 27. 26 PIO-SSR-24 18. 53. 36. 43. 44. 36. 29. 39–41. 23. 50. 44. 54 Mode 31. 38–40. 26. 47. 39 programming model 7–14 Properties of Logical Channels 18. 30. 44. 36.Null Event 31–32. 50. 50. 34 OCX 16. 33 S Scientific Software Tools 5–6 security 12. 47. 33–35 Visual Basic 11. 23. 29. 50. 34 Win NT 11–13. 38. 46–47. 52–59 Sharing hardware 37 Single value I/O 29 single-value transfers 20. 50. 47. 44. 50. 50. 22 Select Group 15. 54–55 Subsystem 15–16. 54–55 Stop 31–32. 33. 34–35 ActiveX 16. 44. 48–49 Req_DLL_name 35–36 SelectDriverLINX 35 Service Request Common properties 30 Edit dialog box 15. 36. 50. 47. 34 OLE Custom Control 16. 49. 40. 34 ActiveX 16. 53 Timing Events 31–32. 44. 52. 54 Service Requests 13. 25 PIO-24 18. 39 Setup 23. 50 O Object Linking and Embedding 16. 55–56 Specifying data buffers 33 Specifying I/O channels 32 Start Events 31–32. 36. 24 Property ioValue 44–46. 44. 55–56 66  Index DriverLINX Digital I/O Programming Guide . 47. 38. 13. 54 threads 11. 46 Timing Events 31–32. 54–55 Stop Event 31–32. 29–30. 38. 44. 26 PIO-SSR-48 18. 30 Events 31 Events Group 15. 44. 38. 50. 47. 41. 29–30. 47. 34–35 Open DriverLINX dialog 35 OpenDriverLINX 35 Operation 31. 47. 48 Select Group 15. 33–35 W Web site 34 Win 3. 50. 43–46. 54 Refresh method 16 REL-16 18–19 Req_DLL_name property 35–36 Request Group 15. 29. 36. 44. 26 PIO-32IN 18–19 PIO-32IO 18–19 PIO-32OUT 18–19 PIO-96 18. 43–46. 37. 29–30. 22 Win32 11. 50. 32. 44. 49–50. 47. 15. 47. 41. 50. 53 Subsystem initialization 39 synchronous 30–31 T Terminal count Event 31–32. 50. 38–40. 24–26. 47. 59 VBX 16. 44. 34 administrative account 22 security 12. 36. 44. 34 Win 95 11. 30. 44. 53 resource arbitration 12 resource sharing 11 Results Group 15. 41. 53–54 operational modes 17 Overlapped I/O 30. 44. 28. 47. 54 process 28. 38. 44. 47. 39. 54 V R Rate Event 32. 47. 42. 54–55 Stop Events 31–32. 54–55 Subsystem 15–16. 44. 47. 44. 47. 40. 43–46. 48 Software License 5 Splitting Logical Channels 19 Start Event 31–32. 53 Operation 31. 13. 50. 45. 32. 37. 34 OLE 16. 40. 15. 50. 49 VBX 16. 39. 47. 29–31. 47. 41. 44. 16. 26 PIO-HV 18–19 PIO-SSR-120 18–19. 50. 44.

13 Windows 95 11.Windows 3.x 11. 13 Windows NT 11–13 DriverLINX Digital I/O Programming Guide Index  67 .