Measurement TP ADAC-32 User Manual

the smart approach to instrumentation
IOtech, Inc.
25971 Cannon Road
Cleveland, OH 44146-1833
Phone: (440) 439-4091
Fax: (440) 439-4093
e-mail: sales@iotech.com
Internet: http://www.iotech.com
TempBook
Thermocouple & Voltage Measurement
TempBook/66-901,
p/n
© 1997 by IOtech, Inc. Released per EO# 1788R4, Nov. 2000
User’s Manual
3.0
Rev.
TempBook/66-901,
Part No.
Rev.
3.0

Warranty

Your IOtech warranty is as stated on the product warranty card. You may contact IOtech by phone, fax machine, or e-mail in regard to warranty-related issues.
Phone: (440) 439-4091, fax: (440) 439-4093, e-mail: sales@iotech.com
Limitation of Liability
IOtech cannot be held liable for any damages resulting from the use or misuse of this product.
Copyright and Trademark Notice
© ® ™ All IOtech documentation, software, and circuit boards are copyrighted with all rights reserved by
IOtech. No part of this product may be copied, reproduced or transmitted by any mechanical, photographic, electronic, or other method without prior written consent of IOtech, Inc. TempBook, TempView, DaqView, and related product names are trademarks of IOtech, Inc. Other product names are trademarks of their respective holders.
FCC Statement
IOtech devices emit radio frequency energy in levels compliant with Federal Communications Commission rules (Part 15) for Class A devices. The following booklet, prepared by the FCC, may be helpful: How To Identify and Resolve Radio-TV Interference Problems (stock no. 044-000-00345-4). The booklet is available from the US Government Printing Office, Washington, DC 20402
CE Notice
Many IOtech products now carry the CE marker to indicate they comply with safety and emissions standards as regulated by the European Community. Such products are shipped with a Declaration of Conformity stating which specifications and operating conditions apply.

Safety/Caution Notice

The TempBook contains no user-serviceable parts other than expressed in this manual; refer all service to qualified personnel. Perform system connections and all service (but not calibration) with the power off to the device serviced and to all connected equipment. Using this equipment in ways other than described in this manual can present serious safety hazards or cause equipment damage.
This warning symbol is used in this manual or on the equipment to warn of possible injury or death from electrical shock under noted conditions.
This caution symbol is used to warn of possible personal injury or equipment damage under noted conditions. Follow all safety standards of professional practice and recommendations in the manual.
This ESD caution symbol is used to urge proper handling of equipment or components sensitive to damage from electrostatic discharge. Handling guidelines include properly grounded mats and wrist straps, ESD bags and cartons, and related procedures.
Calibration Notice
IOtech products are factory-calibrated to published specifications, and associated trimpots have been sealed in the calibrated position. Re-calibration in the warranty period is the responsibility of the user and is covered under warranty at IOtech’s discretion.
Quality Notice
Certified to ISO 9001 standards since 1996, IOtech applies tests and procedures to assure the highest quality in all aspects of our products. Prior to shipment, we thoroughly test the products and review the documentation. In a spirit of continuous improvement, IOtech welcomes your suggestions.
© 1997 by IOtech, Inc.
TempBook/66-901,
Part No.
3.0 Printed in the United States of America
Rev.

How To Use This Manual

This manual explains the setup and operation of the TempBook data acquisition system. This manual is divided into a table of contents, 11 chapters, and 1 appendix as follows:
Chapter 1 - Introduction and Quick Start begins with an overview description and a listing of system
specifications. If you are generally familiar with this type of equipment, the Quick Start section shows how to hook up a simple system; however, most users will prefer the more detailed startup procedures in chapter 2.
Chapter 2 - Installation, Configuration, and Calibration describes panel switches, indicators,
connectors, hardware hookups, software installation, configuration, and calibration.
Chapter 3 - Using TempView (16-bit) explains the use and features of TempView. Screen prints
show you the pull-down menus, toolbars, charts, and parameter fields discussed in the text.
Chapter 4 - Using PostView discusses the independent PostView program. PostView allows you to
view waveforms recorded by TempView, after the acquisition.
Chapter 5 - Programmer’s Guide explains how to custom-program for your application. Various
concerns are discussed; e.g., a comparison of standard and enhanced APIs and language support.
Chapter 6 - Standard API Programming of the TempBook With C describes several example
programs using the standard API with the C language.
Chapter 7 - Software Calibration and Zero Compensation describes the commands and parameters
related to calibration and zero compensation. This chapter organizes and supplements related sections of the tbkCommand Reference chapter.
Chapter 8 - Thermocouple Measurement describes the commands and parameters related to
thermocouple measurement. This chapter organizes and supplements related sections of the tbkCommand Reference chapter.
Chapter 9 - tbkCommand Reference (Standard API) describes the commands and parameters of the
“standard” API including useful reference tables.
Chapter 10 - Programming Models for Enhanced API describes the fundamental building blocks for
TempBook data acquisition software. These programming blocks can then be arranged and filled with your parameters to make your system do as you please. Program excerpts illustrate the basic concepts and can often (with modifications) be used in your code.
Chapter 11 - daqCommand Reference (Enhanced API) describes the commands and parameters of
the “enhanced” API including useful reference tables.
Appendix A- Differential Measurement Configurations describes setups for “floating” and
“referenced” differential signal input connections.
CAUTION
CAUTION
CAUTIONCAUTION
Using this equipment in ways other than described in this manual can cause personal injury or equipment damage. Before setting up and using your equipment, you should read all documentation that covers your system. Pay special attention to cautions and warnings formatted like this one.
Software Reference Note: 16-bit PC users can use TempView out-of-the-box (see chapter 3) or program their
own application. Programmers using 16-bit API should refer to chapters 5 through 9. Chapters 6, 7, and 8 provide examples and explain how to perform common tasks with the standard API (16-bit) detailed in chapter 9. 32-bit PC users can program their own application. Programmers using 32-bit API should refer to chapters 5, 10, and 11; chapter 10 explains programming models for the enhanced API detailed in chapter 11.
TempBook User’s Manual,
11-14-00
i
1 Introduction and Quick Start
Overview------------------------------------------------------------------------------------------------------------------- 1-1 Description ---------------------------------------------------------------------------------------------------------------- 1-1 Available Accessories---------------------------------------------------------------------------------------------------- 1-2 Specifications-------------------------------------------------------------------------------------------------------------- 1-2 Quick Start----------------------------------------------------------------------------------------------------------------- 1-3
Signal Connection ----------------------------------------------------------------------------------------------- 1-3 PC Connection --------------------------------------------------------------------------------------------------- 1-3 Power Connection and Switch --------------------------------------------------------------------------------- 1-4 Software Installation -------------------------------------------------------------------------------------------- 1-4
2 Installation, Configuration, and Calibration
Inspection ------------------------------------------------------------------------------------------------------------------ 2-1 Panel Connectors and Indicators --------------------------------------------------------------------------------------- 2-1 Termination Card and I/O Connectors--------------------------------------------------------------------------------- 2-2 Internal Configuration---------------------------------------------------------------------------------------------------- 2-3
Watchdog Timer Enable/Disable (JP8) ----------------------------------------------------------------------- 2-3
Time Base Selection (JP9)-------------------------------------------------------------------------------------- 2-3 Hardware Installation ---------------------------------------------------------------------------------------------------- 2-3 Rechargeable Battery Module (DBK30A) ---------------------------------------------------------------------------- 2-4
Charging the Battery Modules --------------------------------------------------------------------------------- 2-4
Battery Module Connection------------------------------------------------------------------------------------ 2-5 Parallel Port Capabilities ------------------------------------------------------------------------------------------------ 2-5 TempBook Configuration Under Windows 95/98 ------------------------------------------------------------------- 2-6 Connection Troubleshooting (Windows 95/98) ---------------------------------------------------------------------- 2-8 Calibration of TempBook------------------------------------------------------------------------------------------------ 2-8
Calibration Constants File Installation------------------------------------------------------------------------ 2-8
Hardware Calibration ------------------------------------------------------------------------------------------- 2-8

Table of Contents

3 Using TempView
Application Startup ------------------------------------------------------------------------------------------------------- 3-1 TempView Components ------------------------------------------------------------------------------------------------- 3-2
Analog Input Spreadsheet ----------------------------------------------------------------------------------------- 3-2
Counter/Timer Window-------------------------------------------------------------------------------------------- 3-4
Digital I/O Window ------------------------------------------------------------------------------------------------ 3-4 Charts and the Spreadsheet's "Reading" column --------------------------------------------------------------------- 3-4 TempView Menu Items-------------------------------------------------------------------------------------------------- 3-5
File ------------------------------------------------------------------------------------------------------------------- 3-5
Edit ------------------------------------------------------------------------------------------------------------------- 3-5
Select Device -------------------------------------------------------------------------------------------------------- 3-6
Window -------------------------------------------------------------------------------------------------------------- 3-6
Acquisition ---------------------------------------------------------------------------------------------------------- 3-6
Charts ---------------------------------------------------------------------------------------------------------------- 3-6
4 Using PostView
Introduction---------------------------------------------------------------------------------------------------------------- 4-1 PostView Toolbar Items ------------------------------------------------------------------------------------------------- 4-2 PostView Menu Items---------------------------------------------------------------------------------------------------- 4-3 PostView Time Base -------------------------------------------------------------------------------------------------- 4-4 Data File Accessibility -------------------------------------------------------------------------------------------------- 4-4
Acquisition Configuration -------------------------------------------------------------------------------- 3-3
ii
11-14-00
TempBook User’s Manual
5 Programmer’s Guide
A Programmer’s View of TempBook Operations -------------------------------------------------------------------- 5-1 Driver Options ------------------------------------------------------------------------------------------------------------ 5-3
Standard API (tbk…)-------------------------------------------------------------------------------------------- 5-3 Enhanced API (daq…) ------------------------------------------------------------------------------------------ 5-3 Language Support ----------------------------------------------------------------------------------------------- 5-3
6 Standard API Programming of the TempBook With C
Accessing TempBook from a Windows Program -------------------------------------------------------------------- 6-1 Accessing TempBook from a C for Windows Program ------------------------------------------------------------- 6-1 High-Level Analog Input ------------------------------------------------------------------------------------------------ 6-1 Low-Level Analog Input ------------------------------------------------------------------------------------------------ 6-2 Analog Input in the Background---------------------------------------------------------------------------------------- 6-2 General Purpose Digital I/O Functions -------------------------------------------------------------------------------- 6-4 High-Speed Digital Input ------------------------------------------------------------------------------------------------ 6-4 Counter/Timer Functions ------------------------------------------------------------------------------------------------ 6-5 High-Level Thermocouple Data Acquisition ------------------------------------------------------------------------- 6-6 Thermocouple Linearization -------------------------------------------------------------------------------------------- 6-7 Sample Programs --------------------------------------------------------------------------------------------------------- 6-8
High-Level Analog Input --------------------------------------------------------------------------------------- 6-8 Low-Level Analog Input---------------------------------------------------------------------------------------- 6-9 Analog Input in the Background------------------------------------------------------------------------------6-10 General Purpose Digital I/O----------------------------------------------------------------------------------- 6-11 High-Speed Digital Input-------------------------------------------------------------------------------------- 6-12 Counter Timer Functions -------------------------------------------------------------------------------------- 6-13 High-Level Thermocouple Measurement ------------------------------------------------------------------- 6-14 Low-Level Thermocouple Linearization -------------------------------------------------------------------- 6-15
Command Summary, C Language (Windows) ---------------------------------------------------------------------- 6-17
7 Software Calibration and Zero Compensation
Software Calibration ----------------------------------------------------------------------------------------------------- 7-1
Initializing the Calibration Constants ------------------------------------------------------------------------- 7-1 Calibration Setup and Conversion----------------------------------------------------------------------------- 7-2 Calibration Example--------------------------------------------------------------------------------------------- 7-2
Zero Compensation------------------------------------------------------------------------------------------------------- 7-3
Zero Compensation Example ---------------------------------------------------------------------------------- 7-4 Automatic Zero Compensation -------------------------------------------------------------------------------- 7-5
8 Thermocouple Measurement
Low-Level Thermocouple Data Conversion Functions ------------------------------------------------------------- 8-1 High-Level Thermocouple Measurement Functions----------------------------------------------------------------- 8-3
Single-Channel Measurement (tbkRdTemp)--------------------------------------------------------------- 8-3 Multiple Measurements from a Single Channel (tbkRdTempN) ---------------------------------------- 8-4 Multiple Channel Measurement (tbkRdTempScan) ----------------------------------------------------- 8-4 Multiple Measurements from Multiple Channels (tbkRdTempScanN) ------------------------------- 8-4
9 tbkCommand Reference (Standard API)
Overview------------------------------------------------------------------------------------------------------------------- 9-1 Commands in Alphabetical Order -------------------------------------------------------------------------------------- 9-2 API Reference Tables ---------------------------------------------------------------------------------------------------9-32
A/D Channel Descriptions------------------------------------------------------------------------------------- 9-32 A/D Gain Definitions------------------------------------------------------------------------------------------- 9-32 A/D Trigger Source Definitions ------------------------------------------------------------------------------ 9-32 Pretrigger Functions Trigger Source Definitions----------------------------------------------------------- 9-33 Thermocouple Types------------------------------------------------------------------------------------------- 9-33 API Error Codes - C Languages ------------------------------------------------------------------------------ 9-33 API Error Codes - QuickBASIC------------------------------------------------------------------------------ 9-34 API Error Codes - Turbo Pascal ------------------------------------------------------------------------------9-35 API Error Codes - Visual Basic ------------------------------------------------------------------------------9-36
TempBook User’s Manual,
11-14-00
iii
10 Enhanced API Programming Models (TempBook)
Overview------------------------------------------------------------------------------------------------------------------ 10-1 Data Acquisition Environment----------------------------------------------------------------------------------------- 10-1
Application Programming Interface (API) ------------------------------------------------------------------10-1 Enhanced vs Standard API ------------------------------------------------------------------------------------ 10-1 Hardware Capabilities and Constraints ---------------------------------------------------------------------- 10-1 Signal Environment -------------------------------------------------------------------------------------------- 10-2
Basic Models -------------------------------------------------------------------------------------------------------------10-2
Initialization and Error Handling ----------------------------------------------------------------------------- 10-3 Foreground Acquisition with One-Step Commands ------------------------------------------------------- 10-5 Temperature Acquisition Using One-Step Commands ---------------------------------------------------- 10-7 Counted Acquisition Using Linear Buffers ----------------------------------------------------------------- 10-9 Indefinite Acquisition, Direct-To-Disk Using Circular Buffers---------------------------------------- 10-11 Multiple Hardware Scans, Software Triggering ---------------------------------------------------------- 10-14 Background Acquisition ------------------------------------------------------------------------------------- 10-16 Temperature Acquisition Using TC Conversion Functions--------------------------------------------- 10-18 Double Buffering --------------------------------------------------------------------------------------------- 10-21 Direct-To-Disk Transfers ------------------------------------------------------------------------------------ 10-23 Transfers With Driver-Allocated Buffers------------------------------------------------------------------ 10-26
Summary Guide of Selected Enhanced API Functions----------------------------------------------------------- 10-28
11 daqCommand Reference (Enhanced API)
Overview------------------------------------------------------------------------------------------------------------------ 11-1 Commands in Alphabetical Order ------------------------------------------------------------------------------------- 11-2 API Reference Tables ------------------------------------------------------------------------------------------------- 11-35
Daq Device Property Definitions --------------------------------------------------------------------------- 11-36 Event-Handling Definitions --------------------------------------------------------------------------------- 11-36 Hardware Information Definitions ------------------------------------------------------------------------- 11-36 ADC Trigger Source Definitions --------------------------------------------------------------------------- 11-37 ADC Miscellaneous Definitions---------------------------------------------------------------------------- 11-37 TempBook Definitions--------------------------------------------------------------------------------------- 11-38 General I/O Definitions -------------------------------------------------------------------------------------- 11-38 DaqTest Command Definitions ----------------------------------------------------------------------------- 11-38 Calibration Input Signal Sources --------------------------------------------------------------------------- 11-38 API Error Codes ---------------------------------------------------------------------------------------------- 11-39
Appendix -
Floating Differential------------------------------------------------------------------------------------------------------ A-1 Referenced Differential --------------------------------------------------------------------------------------------------A-1
Differential Measurement Configurations
iv
11-14-00
TempBook User’s Manual
Introduction and Quick Start

Overview

This chapter describes the TempBook in general terms including specifications. Also, a Quick Start can help you get a simple system up and running (chapter 2 has more detailed installation inst ructions).

Description

1
TempBook/66 Block Diagram
The TempBook/66 adds voltage and thermocouple measurement capability to notebook PCs for portable test applications. The TempBook also provides an effective alternative to plug-in boards for desktop PCs. The TempBook provides 12-bit, 100 kHz data acquisition and can support up to 800 Kbyte/s data transfer to a PC via an enhanced parallel port interface or PCMCIA link. The unit can also connect to a standard parallel port and transfer readings directly to disk at up to 100K readings/s. As an external module with the same footprint as a typical notebook PC, the TempBook can be attached directly under a notebook PC for portability.
The TempBook has a built-in analog capability that permits it to measure 8 channels in a differential mode or 16 channels in single-ended mode. Its on-board programmable-gain instrumentation amplifier can be set to gains of ×1, 2, 5, 10, 20, 50, 100 or 200 on a per channel basis. Its A/D converter scans selected channels at a constant 10 us/channel rate, minimizing the time skew between consecutive channels. The time between the start of each scan sequence can be programmed to start immediately or at intervals of up to 10 hours. The TempBook features a hardware-based digital/TTL trigger that minimizes trigger latency to less than 10 us. The TempBook can also be triggered from a command from the PC.
The TempBook/66 can be powered by an included AC adapter, a standard 12V car battery, any +9 to 20 VDC source, or an optional rechargeable nickel-cadmium battery module (DBK30A). This makes it ideal for field and remote data acquisition applications.
Software included with the TempBook includes TempView and PostView. TempView is a 16-bit Windows-based program that allows you to set up your acquisition and save acquired data directly to disk. The package also includes thermocouple linearization for direct readout of temperatures. PostView is a Windows-based post application waveform display application that permits you to display previously acquired data.
TempBook User’s Manual,
11-14-00
Introduction and Quick Start 1-1
In addition, the TempBook/66 includes DOS drivers for Quick Basic, C, and Pascal; Windows drivers for Visual Basic and C for Windows. Several graphically analysis and control software packages also support the TempBook/66. These include DASYLab, Snap-Master, LABTECH NOTEBOOK and LabVIEW.

Available Accessories

Additional accessories that can be ordered for the TempBook/66 include:
DBK35 PCMCIA interface card and cable
DBK30A Rechargeable battery module

Specifications

General Connector
user signals are connected vi a screw terminals on a removabl e screw-terminal card.
Thermocouple Types Input Ranges
Unipolar Bipolar
Analog Inputs
differential thermocouple inputs
Analog-to-Digital Converter
unsigned binary output format .
Cold Junction Sensor Output Input Impedance
channel basis in parallel with 100 pF
Input RC Filter -3dB Frequency
per channel basis
Gain Accuracy Maximum Input Voltage CMRR (Input Stage) Offset Offset Drift
Channel Sequencer Depth Speed Interval Between Scans
programmable
Gains Unipolar/Bipolar
basis.
Single-Ended/Differential
channels
Temperature
Thermocouple Accuracy (TempBook/66 @ 0 to 50°C)
Type Min Max Accuracy J -200 760 0.9 0.9 J 1.2 0.5
K -200 1260 2.4 1.5 K 1.1 0.8 T -200 400 2.1 1.2 T 0.8 0.3 E -270 1000 2.1 1.3 E 1.9 0.9 N28 -270 400 1.2 1.2 N28 0.9 0.9 N14 - 1300 - 1.5 N14 - 5.0 S - 1780 - 2.4 S - 1.6 R - 1780 - 2.4 R - 1.5 B - 1820 - 2.7 B - 1.8
: Connects to a PC via an inc l uded paral l el port cable;
: J, K, S, T, E, B, R & N
:
: .05, 0.1, 0.2, 0.5, 1, 2, 5 V
: ±0.25, .05, 0.1, 0.25, 0.5, 1, 2.5, 5 V
: 8 differential or 16 single-ended vol tage or 8
: 12-bit with no missing codes,
: 100 mV/°C
: 100K/100M Ohm, Switch-sel ectable on a per-
: 15.9 kHz switch-selectable on a
: 0.1%
: ±15 V
: 90 dB typ, DC to 60 Hz
: Software-compensated
: Software-compensated
: 512 locations
: 10 µs per channel, f i xed
: 10 µs to 10 hours, software-
: Sequencer programmable on a per-channel basis.
: Sequencer programmable on a per channel
: Software programmable for al l
(°C ) (°C ) (<°C ) (>°C ) Type <0°C>0°C
Digital I/O Inputs
Number
Outputs
Trigger Input
Counter/Timer Port Device Number Clock Usage Type Input High Voltage Input Low Voltage Output High Voltage Output Low Voltage
Thermocouple Resolution (°C)
: 8 fixed as inputs
Usage
: General-purpose register addressable or hi gh-speed
scanned via channel sequencer
Type
: TTL-compatible
High Voltage Low Voltage
Number Usage Type
: TTL-compatible
High Voltage Low
Voltage: 0.4V @ 2.5 mA sink
Type
: TTL-compatible
High Voltage Low Voltage
: 8254 (P0 only)
: Internal 100 kHz or external up to 10 MHz
: Register addressable
: TTL compatible
: 2.0 V min
: 0.8 V max
: 8 fixed as outputs
: General-purpose register addressable
: 3.0 V @ 2.5 mA sourc e
: 2.0 V min
: 0.8 V max
: 1 gate input, 1 clock input & 1 output
: 2.0 V min
: 0.8 V max
: 3.0 V @ 2.5 mA sourc e
: 0.4 V @ 2.5 mA sink
1-2 Introduction and Quick Start,
11-14-00
TempBook Users Manual
Quick Start
For those users who wish to get their TempBook up and running as quickly as possible, this section provides a brief explanation of the steps required. Note: unless already familiar with this type of system, most users will need to read chapter 2, Installation and Configuration.

Signal Connection

The thermocouple and volt age input signals are fed to the TempBook through a removable termination card. To remove this card, rotate the ejector handle with your thumb or finger. Once removed, the thermocouple or voltage connections should be made as shown in the figure.

PC Connection

Signal Connections, Differential and Single-Ended
Note: When connecting thermocouple or other low-level signals in addition to high-level signals, connect the low-level signals to the lowest numbered channels with connections in ascending order of signal magnitude.
The DIP switches located on the termination card connect optional biasing resistors as well as input filters.
For thermocouple or other differential inputs, these switches should be closed to provide the required bias current path.
For single-ended inputs these switches can be optionally opened or closed.
For further details, refer to section Termination Card and I/O Connectors in chapter 2.
The TempB ook communicates with a lap t op or desktop computer through the paral lel printer port. Connec t the supplied cable to the computers parallel port and the TempBook's parallel port.
TempBook Users Manual,
11-14-00
PC-to-TempBook Connection
Introduction and Quick Start 1-3

Power Connection

The TempBook is typically powered from the supplied wall-mount converter or from an optional DBK30A battery module. The wall-mount converter plugs into any standard 110 VAC wall outlet and its other end plugs into the circular DIN5 receptacle on the TempBook's rear panel. If using the battery module, please refer to the section Rechargeable Battery Module in chapter 2.

Software Installation

The TempBook/66 comes with a Microsoft Windows application (16-bit TempView) that provides the easiest means to collect data from the TempBook. To install the software insert the installation CD into your PCs CD drive. After agreeing with the legal statement a master setup screen will appear (see following figure).
TempBook Power Connection
Selecting TempBook Support from the Master Setup Screen
After selecting TempBook Support, click Start Install and follow the on-screen prompts. Once the setup program has installed the software, a TempBook program group will appear within
Windows. To start TempView, click on its program icon. The main window will soon display a spreadsheet of channels in rows and channel parameters in columns.
For information regarding the use of TempView, refer to chapter 3.
1-4 Introduction and Quick Start,
11-14-00
TempBook Users Manual
Installation, Configuration, and Calibration

Inspection

The TempBook components were carefully inspected prior to shipment. When you receive your data acquisition system, carefully unpack all items from the shipping carton and check for any obvious signs of physical damage that may have occurred during shipment. Immediately report any damage to the shipping agent. Retain all shipping materials in case you must return the unit to the factory.
Every TempBook is shipped with the following items:
TempBook Data Acquisition System
User's Manual
Installation CD
Calibration Constants Disk
Accessory Kit, including: CA-35-2 (2 ft parallel port cable) and an AC Adapter

Panel Connectors and Indicators

The TempBook front panel consists of 3 status-indicator LEDs. The rear panel consists of the power switch, power input, two DB25s for parallel port connection and pass-thru, and a slot to accept the input termination card. The function of each of these components is described below.
TempBook Panel Connectors and Indicators
POWER SWITCH This rocker arm switc h t u rns on the DC power to the TempBook when the "1" si de POWER INPUT This input connector ac cepts +7 VDC to +20 VDC.
TO PARALLEL PRINTER This parallel port can connect to any standard parallel pri nter. This allows the
FROM PC PARALLEL PORT This parallel port connects directly to the PC's parallel printer port. This all ows POWER This LED is ON when power is applied to the TempB ook (and the power switch is ON-LINE This LED is ON when the TempBook is in an Active state. OFF, when the A/D ACTIVE ON during an A/D scan sequence. I f the sequence has a smal l number of steps
of the switch is depressed.
user to attach both the TempBook and a parallel printer to the s ystem simultaneously.
the host system t o communicate with the TempBook. in the ON position). OFF, if power is not pres ent. TempBook is not enabled or in t he pri nter pass through mode. and occurs infrequently, this indicator will only flash briefly.
2
TempBook User’s Manual,
11-16-00
TempBook Front and Rear Panels
Installation, Confi gurat i on, and Calibration 2-1

Termination Card and I/O Connectors

The TempBook/66 accepts all analog and digital I/O signals via a removable termination card (see figure). This termination card has six screw terminal strips, a CJC temperature sensor, and input R/C filters which also provide a bias current return path for the TempBook's instrumentation amplifier. The filters/bias resistors are switch-selectable on a per channel basis.
TempBook Termination Card
Terminal strips J2 and J3 provide analog input signal connection. Note that the terminals are arranged in differential pairs for easy thermocouple connection. These terminal strips also provide analog signal common connections for convenient r eferencing of single -ended input signa ls.
Terminal strips J4 and J5 provide connections for the eight digital outputs and the TTL trigger input. These terminal strips also provide ground connections for referencing digital signals. Terminal strips J6 and J7 provide connections for the eight digital inputs, the pacer clock output (OUT2), and the three counter/timer (8254 P0) I/O signals.
The thermocouple or voltage connections should be made as shown in the following figure.
Analog Signal Connection
Note: When connecting thermocouple and other low-level signals in addition to high-level signals, the low­level signals should be connected to the lowest numbered channels with connections following in ascending order of signal magnitude.
2-2 Installation, Confi gurat i on, and Calibration
11-16-00
TempBook User’s Manual
Each of the 16 analog input channels is configured as shown in the figure (also, refer to the appendix for more information on wiring differential inputs).
The series resistance and shunt capacitance for m a singl e-pole low-pass filter with a corner freque ncy of 15.9 kHz. The shunt resistance provides the bias current path for the instrumentation amplifier.
When reading thermocouples, these filters should be switched in. If the filters are not used with thermocouples or any other differential input, then the user must provide a bias current return path to signal common. Note that for each differential
channel, two DIP switches need to be set.

Internal Configuration

To open the unit, place the TempBook on a flat surface. Remove the screw on the top rear of the case, and slide out the top cover. Reverse this procedure to assemble the unit.
The internal configuration of a TempBook/66 consists of setting the following jumpers to reflect the desired mode of operation:
Time Base (JP9)
Watchdog Timer Enable (JP8)
The location of each jumper is shown in the figure.

Watchdog Timer Enable/Disable (JP8)

This 3-pin header allows the elective use of the TempBook watchdog timer function. If using a printer with the TempBook, the watchdog timer should be enabled to allow the TempBook to be most reliably reset by the host computer. Note that enabling the watchdog timer might impede background measurements. If the user is not going to attach a printer, the timer is optional. The default setting is Watchdog Timer Disabled. To enable, place the shunt jumper in the enabled position as shown in the figure. To disable, place the jumper in the disabled position, as shown.

Time Base Selection (JP9)

This 2×2 header allows the user to select one of two oscillator derived frequencies to be applied to the pacer clock (8254 P1 & P2). The pacer clock sets the interval between scans in continuous trigger mode. The two frequencies are 1 MHz and 100 kHz. The most useful range of clock output frequencies for the average user would be provided by the 1 MHz setting (the default setting).

Hardware Installation

Connect the TempBook to any P C parallel p rinter por t (female DB25 ) by unplugging the pri nt er cable and plugging the male end of the supplied cable (CA-35) into the computer and the fe male end into the mating connector on the TempBook. Any printer port (LPT1, LPT2, or LPT3) may be used but should be noted for use in software installation.
TempBook allows for LP T pass-through for simultaneous data acquisition and printer operation. When using a printer in the system, attach the original printer cable male DB25 into the mating connector on the TempBook.
The TempBook may be powered by the supplied AC adapter that plugs into any standard wall outlet or from an isolated 7-20 VDC source of 1-2 A.
If using the power adapter, plug it into a 120 VAC outlet, and attach the low voltage end to the jack on the TempBook. Turn ON the power switch, and the POWER LED should be on.
TempBook User’s Manual
11-16-00
Installation, Confi gurat i on, and Calibration 2-3
At power-on, the printer should behave normally and can be checked by issuing a
command (or any other convenient method of checking the printer). (Installation of the software will be necessary before the TempBook can perform any functions.)

Rechargeable Battery Module (DBK30A)

For portable applications where external AC or DC power is not available, the DBK30A rechargeable nickel cadmium battery module can be used with the TempBook/66. This module is housed in a r ugged metal package that is the same size as the TempBook. It also comes with high-strength Velcro tabs that allow convenient mounti ng underneath the TempBook/66.
The DBK30A is a revised combination of the DBK30 and DBK31 battery modules. There is an internal slide switch which determines whether a DBK30A will act as a DBK30 or DBK31.
Note: Only the DBK30 mode should be used with the TempBook/66.
The DBK30 operating mode provides 14.4 VDC at 3.4 A-Hr. This setup can power the TempBook for 3 to 6 hours depending on the application. The battery module has built-in automatic battery-charging circuits, which quickly and safely recharge the internal batteries when connected to the supplied AC adapters. The only requirement for trouble-free operation is for the user to fully charge the battery module before attempting to use it.

Charging the Battery Modules

The DBK30A package includes a charger for the intended line voltage (either 120 VAC or 230 VAC). To charge the battery module, plug the output cable from the charger into the POWER IN connector on the DBK30A, and plug the charger into an appropriate source of AC power (see figure). The charge cycle will be initiated automatically, and the batteries will be fully charged after the charging cycle terminates.
Power
Source
PS-22 or PS-22E
START CHARGE
32:(5 ,1
72  9'&
32:(5 287 72 'DT%RR N
PRINT SCREEN
DBK30
Start Charge
Power In
Connecting the Charger
To initiate another charge cycle, depress the START CHARGE momentary rocker-arm switch. Subsequent charge cycles applied to a fully charged DBK30A will have no ill effect because the DBK30A will sense the fully-charged status of the batteries and revert to the trickle-charge state within a few minutes.
There 3 LED status indicators on the DBK30A provide information on the charge process or external load as noted in the table.
Power In
Battery Charging
Power Out
Illuminated when the charger is connected to a source of AC power and to the bat tery
module. Illuminated steadi l y while battery is in the high current (2-amp) charge mode. Flashing briefly, one or two flashes at a time, when the internal batt eri es are fully charged. Illuminated steadi l y when an external TempB ook product is connected and drawing current
from the battery modul es.
2-4 Installation, Confi gurat i on, and Calibration
11-16-00
TempBook User’s Manual

Battery Module Connection

The DBK30A package includes a short connecting cable (CA-115) to connect to the TempBook. This cable connects the Power Out connector on the DBK30A to the Power In connector on the TempBook (see figure).
The run time available from a DBK30A operating a TempBook will depend on what the TempBook is doing. This time can be as little as 3 hours or as much as 6 hours.
The DBK30A must periodically be fully discharged or the cells may develop "lazy chemistry" that may limit storage capacity. (This “memory” is characteristic for nickel-cadmium batteries.) To manually discharge a battery pack, connect a TempBook, and leave it turned on until the indicator lights go dark.
Connecting the TempBook to the Battery Module
&$87,21

Parallel Port Capabilities

The TempBook includes a test program which verifies your computer's parallel port, testing its standard and enhanced capabilities.
Standard LPT ports on an IBM compatible computer have two modes to read data from the printer
port: 4-bit and 8-bit. The 8-bit mode is somewhat faster than the 4-bit, but not all printer ports support this mode.
Enhanced parallel ports (EPP) are parallel p orts which include additional hardware that allows the
TempBook to communicate with the PC at 3 to 10 times the speed possible with standard parallel ports. This greatly improves data acquisition performance.
Enhanced parallel ports require special hardware, and only certain computers are EPP capable. Most laptop computers that use the Intel 386SL or 486SL chip set (which includes the 82360 I/O Controller) are EPP capable. For those computers which have plug-in card slots, EPP adapter cards are available. You may wish to contact your computer's manufacturer for details about your machine and possible adapter cards.
The TempBook test program, TEMPTEST.EXE (described in a later section) should be run to determine the PC's printer port capabilities.
Note: To take a dvantage of the improved performance of EPP when using a programming language, you must add the software command the command description in the Command Reference section of this manual.
tbkSetProtocol
(standard API) to your program. For details, refer to
TempBook User’s Manual
11-16-00
Installation, Confi gurat i on, and Calibration 2-5

TempBook Configuration Under Windows 95/98

Note: The TempBook/66 software installation is discussed in chapter 1. This section describes the configuration of TempBook devices under the Windows 95/98 operating systems.
A configuration utility is supplied via a control panel applet. The Daq Configuration applet allows you to add a devic e, remove a devi ce, or change existing configurati on settings. Daq Configuration also has a built-in test utility to test the device. The test utility provides feedback on the validity of the current configuration se ttings as well as provi ding relevant performance summaries.
Daq Configuration can be found in the Windows 95/98 control panels and can be executed any time that it is desirable to add, remove or change device configur ation settings. Daq Configuration may also be entered during driver installation. The following description applies to either method.
The Daq Configuration/Device Inventory scre en at right will display all currently configured devices. Displayed devices are indicated by their name and an identifying icon which indicates the device type. If no devices are currently configured, no devices will appear in this field.
The 4 buttons across the bottom of the Daq Configuration screen are used as follows:
Properties. Current configuration settings for a device can be changed by bringing up the corresponding properties screen. To do so, double-click the device icon or single-click the device and then double-click the Properties button.
Remove. The R removed if it is no longer installed or if the device’s configuration no longer applies. Note: if a device is removed, applications may no longer access the device. However, the device can be re-configured at any time using the Add Device function described below.
Close. The C
Add. The A configuration whenever a new device is added to the system. Failure to perform this step will prevent applications from properly accessing the device. Double­clicking the Add Device button will display a window as shown in the figure.
emove button is used to remove a device from the configuration. A device may be
lose button may be used at any time to exit the Daq Configuration applet.
dd Device button is used to add a device
Use the scroll bar to find the TempBook device type to be configured. Once found, click the device t ype (the type should then appear in the main edit box). Now double-click the OK button.
The next screen displays the properties for the TempBook device with the default configuration settings. Fields include:
The Device Name field is displayed with the default device name. However, this field can be changed to any descriptive name as desired. This device name is the name to be used with the (see enhanced API chapter) to open the device.
The Device Type field should indicate the device type which was initially selected. However, it can be changed here if necessary.
The Protocol field is used to set the parallel port protocol for communicating with the TempBook. Depending on your system, not all protocols may be available.
Note: IRQ Setting and DMA Setting for the TempBook are currently not configurable. These fields are
reserved for future use.
2-6 Installation, Confi gurat i on, and Calibration
11-16-00
daqOpen
TempBook User’s Manual
function
When all fields have been changed to the desired settings, you can click:
the Apply button to store the configuration.
the OK button to store the configuration and exit the current property screen.
the Cancel button to exit the current device configuration property screen without storing any changes.
the Test Hardware tab to test the current stored configuration for the device. This selection will bring up the Test property screen. Note: the next figure displays results from a previously run test. Initially, the screen will show no test results.
Before testing the TempBook, make sure the device has been properly installed and powered-on. Make sure the parallel port cable is firmly in place on both the TempBook and the proper LPT port in the computer.
Note: Testing the TempBook device may, in some cases, cause the system to hang. If test results are not
displayed in 30 seconds or the system does not seem to be responding, reboot the system. Upon power-up, re-enter the Daq Configuration and change the configuration settings to those that work properly. To test the current stored configuration for the device, click the Test button. Test results should be displayed within a few seconds. The test results have 2 components: Resource Tests and Performance Tests.

Resource Tests

The resource tests are intended to test system capability for the current device configuration. These tests are pass/fail. Resource test failure may indicate a lack of availability of the resource or a possible resource conflict.
Base Address Test
- This test will test the base address for the selected parallel port. Failure of this test may indicate that the parallel port is not properly configured within the system. See relevant operating system and computer manufacturer’s documentation to correct the problem.

Performance Tests

The performance tests are intended to test various TempBook functions with the current device configuration. These tests give quantitative results for each supported functional group. The results represent maximum rates at which the various operations can be performed. These rates depend on the selected parallel port protocol and will vary according to port hardware capabilities.
ADC FIFO Input Speed
maximum rate at which data can be transferred from the TempBook’s internal ADC FIFO to computer memory through the parallel port. Results are given in samples/second (sample is 2 bytes in length representing a single A/D count).
- This test will test the
TempBook User’s Manual
11-16-00
Installation, Confi gurat i on, and Calibration 2-7

Connection Troubleshooting

If communications cannot be established with the TempBook or if trying to connect causes the system to hang or crash, then you should:
Check that TempBook’s power LED is ON. If not ON, verify power connection between the TempBook and the power source.
Make sure the LPT cable is firmly attached to the computer’s proper LPT port and to the TempBook port labeled “TO COMPUTER”.
Check that the desired LPT port has the proper resource configurations. The base address and IRQ level must be properly configured and recognized by the operating system. The parallel port must be capable of generating interrupts for proper operation. (This information may be obtained in the Device Manager in the Control Panel of the operating system). More information on this subject can be found in the
Check the BIOS settings for the LPT port. Make sure the BIOS LPT protocol settings are compatible with the settings selected for the LPT port with the Control Panel applet.
Make sure the Daq Configuration Applet has been run and the proper LPT port and protocol have been selected for the device. The Daq Configuration applet can be found in the Control Panel of the operating system. The Test Hardware function in the control panel applet can be used to confirm proper communication with the device.
readmew.txt

Calibration of TempBook

The TempBook/66 is factory calibrated for gain and offset. After calibration, the unit is characterized for gain and offset errors, and software correction constants are calculated. For users who wish to use these constants within their own programs, see the Software Calibration and Zero Compensation chapter.
file in the current software release.

Calibration Constants File Installation

Each TempBook is shipped with a disk containing a calibration constants text file. The file is named serial_no.cal where serial_no is the serial number of the TempBook for which the constants were generated.
The default calibration constants filename assumed by TempView is tempbook.cal. The following command can be used to copy and rename the file if executed from the floppy disk drive.
COPY SERIAL_NO.CAL C:\TEMPBOOK\WIN\UTILS\TEMPBOOK.CAL

Hardware Calibration

Since the TempBook is factory characterized after calibration, user recalibration is not recommended. However, one exception to this recommendation is the calibration of the TempBook's internal 5V reference. This 5V reference is used to level-shift the amplified analog input signal for unipolar measurements. Reference-voltage drift is not compensated for with zero compensation; and therefore, periodic recalibration can improve unipolar measurement accuracy.
The following char acteristics ca n be calibrated through po t entiometer adjustments on the TempBook main board:
5V Reference Voltage
Instrumentation Amplifier Offset
Level Shift Amplifier Offset
ADC Offset
ADC Span
The TempBook includes a simple calibration program that can be used to perform these adjustments. If the user is only performing the reference voltage adjustment, then only a 4-1/2 digit DMM is required. If the user is performing the full TempBook calibration, then an adjustable voltage calibrator is also required.
A Microsoft Windows program, TEMPCAL.EXE, is provided to perform calibration of the TempBook. To use this program, install the TempBook Windows support and launch the TEMPCAL program; follow the on-screen instructions.
2-8 Installation, Confi gurat i on, and Calibration
11-16-00
TempBook User’s Manual
Using TempView
TempView is a 16-bit graphical Microsoft Windows application for operating TempBook hardware. No programming knowledge is required to operate this application. TempView allows you to set up an application to acquire data and save it directly to disk with the ability to transmit the data to other Windows applications, such as spreadsheets and databases. TempView provides the following capabilities:
Set up all of the analog input parameters, then acquire and save the data to a disk file.
Exercise TempBook’s digital I/O section.
Exercise the counter/timer.
Launch PostView, an independent application to graphically view waveforms previously recorded by TempView. PostView is discussed in chapter 4.

Application Startup

If you have not already installed TempView, refer to chapter 1 of this manual. To launch the application, double-click the TempView icon. TempView holds many user-configured parameters which can be saved to disk. The default configuration file name is “TEMPVIEW.CFG”. TempView will then proceed to search the working directory for the TEMPVIEW.CFG configuration file. The following conditions may apply:
If the default configuration file is found, all the required setup information will be extracted from it, and the application's main window will open.
If the default configuration file is not found, TempView will try to connect with the TempBook hardware with the following default parameters: Printer Port LPT1, Interrupt Level 7, and 4-bit Standard Protocol.
If connection with the TempBook is established, the applications main window will open with default setup.
If all of the above fails to establish communications with the TempBook, then a dialog box will appear asking whether or not you want to open a different setup file. Answering “Yes” will open another dialog box where you can select your file. If this is the first time you have used this application, no saved setups will be available; select “No”.
If a configuration file is selected, no further dialog boxes will appear, all the required setup information will be extracted from it, and the applications main window will open.
If no user configuration file is selected or found, or communications is not established, the next dialog prompts the user to choose a real instrument or a simulated instrument. If the hardware is not available and you just want to try out the software, select Simulated Instrument. The Simulated Instrument mode allows you to exercise all the software functions without any hardware installed. If the TempBook hardware is connected and switched on, select Real Instrument.
If Real Instrument was selected, an additional dialog box will appear, prompting you to select the LPT port that the hardware is connected to, the interrupt level of that port, and the parallel port protocol to use.
3
TempView will attempt to find the TempBook on the specified LPT port. If the hardware is found, the application's main window will open. If no hardware is found, a message appears and the application will open with the controls disabled.
To reconfigure the LPT port setting and try again, click Select LPT Port under the Select Port menu. If the TempBook hardware still cannot be identified by the software, exit TempView and try the TEMPTEST utility program.
TempBook User’s Manual,
11-16-00
Using TempView (16-bit) 3-1

TempView Components

The figure shows TempView’s main window that has areas for the following:
Analog input spreadsheet to summarize system configuration and show current readings
Trigger configuration, e v ent type and edge
Sequence repetition rate, number of scans, and averaging enable
Data destination (filename and data format)
High-speed digital input enable
Signal reference type

Analog Input Spreadsheet

The input spreadsheet allows the analog input channels to be configured and displayed. The spreadsheet consists of rows and columns much like a standard accounting spreadsheet.
Each
The
The 7 columns for each row are used as follows:
CH
rows by the corresponding analog input channel to configure.
ON
corresponding input during an acquisition. An acquisition consists of reading data to disk, either to charts or the input reading column of this spreadsheet. When a cell or block of cells in this column is selected, a selection box will appear above the spreadsheet that allows a "Yes" or "No" choice to enable or disable the channel. Double-clicking a cell in this column will toggle the channel status. The Make All Channels Active and Make All Channels Inactive menu items under the Edit menu can be used to globally change all channels to a "Yes" or "No".
Type
block of channels. Double-clicking a cell or block of cells in this column will select the next available gain or type.
row
selected; or 8 rows if differential inputs are selected.
columns
cells to be altered simultaneously while others allow only one cell to be changed at a time. Clicking a column header will select the entire column if possible.
- The channel-number column labeled "CH" is static and cannot be altered. This column identifies
- The column labeled "On" allows you to select whether or not data will be collected from the
- The "Type" column allows you to set the thermocouple or gain type for the selected channel or
TempView’s Main Window
configures a single analog input channel. There are 16 rows if single-ended inputs are
contain the configuration information for each channel. Some columns allow blocks of
3-2 Using TempView (16-bit)
11-16-00
TempBook User’s Manual
Pole - The "Pole" column shows the state of the channel polarity which can be either unipolar or bipolar. The channel polarity can be programmed on a per channel basis. If a cell or block of cells in this column is selected, a selection box will be displayed above the spreadsheet with the selections "Uni" and "Bi" when the cell is selected. Double-clicking in one of these cells will toggle the polarity.
Label - The "Label" column contains a descriptive name for the input channel. By default it contains a label similar to its channel number; however, you can enter a more relevant, descriptive label of 8 characters. This label will be used when selecting a specific channel in the analog trigger and chart selection lists. This column does not have a selection list above the spreadsheet and does not allow selecting blocks of cells.
Units - The "Units" column allows you to change the engineering units of each channel and apply a linear equation to the data read from the TempBook. When a cell or block of cells in this column is selected, a selection box is displayed containing mX+b as well as common engineering units (see figure). Selecting mX+b will pop up a window that allows the m and b of this equation and the engineering units label to be defined. The engineering units will then be displayed in the "Units" column, and the mX+b equation will be applied to the reading from the TempBook before the reading is displayed or written to disk. The X in this equation is the voltage or the degrees in Celsius read back from the TempBook. For example, if a TempBook channel is configured as bipolar and unity (×1) gain, the default voltage would be ±5 V. This corresponds to an m of 1, a b of 0 and an engineering unit of V. This could be changed to millivolts by setting m to 1000 and units to mV. This column could also be used to perform a software calibration of the TempBook. This is performed by reading known inputs at two different points of the input voltage range (usually at 0 and full scale) and solving the equation y = mX+b. The full-scale voltage, which changes according to the gain of the channel, is 5V/gain for bipolar channels and 10V/gain for unipola r channels.
Reading - The "Reading" column can display the analog input readings of the TempBook. This column cannot be altered by the user and is enabled by selecting Enable Input Reading Column under the Acquisition menu. This column will update the readings as fast as the computer will allow. If data is being written to disk while this column is enabled, it will be updated whenever possible. The spreadsheet cannot be altered while the input reading column is enabled.
In addition to the analog inputs, there is one 8-bit digital input channel accessible on the termination card. This high-speed digital input, which is read at the same rate as any analog inputs, can be enabled or disabled by clicking the "ChanOn" checkbox in the lower right of the analog input spreadsheet.
Acquisition Configuration
The acquisition configuration section of TempView’s main window is just to the right of the analog input spreadsheet. This section has 5 parts: the Trigger, Scan Frequency, Number of Scans, Signal Conditioning, and Data Destination sections. These sections allow you to set up all of the acquisition parameters for the analog inputs and the high-speed digital input channel. The analog acquisition configuration includes parameters fo r setting up a tri gger source, the scanning frequenc y after the trigger i s satisfied, the numbe r of scans to take after the trigger, and the file name for the collected data. These settings will be used when an acquisition-to-disk is started by selecting "Go" under the acquisition menu.
Trigger - The Trigger section selects the source of the trigger. When the trigger is satisfied, the scans are collected at the selected scan frequency and stored to disk. The sources are: Key Hit, which arms the acquisition and waits for the user to hit a key; and External TTL, which waits for a falling or rising edge on the 'trig' input terminal on the termination card.
Sequence Rep Rate - The scan frequency can be set in units of seconds, minute s and hours. Movi ng the slide switch changes the rate. The cursor can also be placed in the numeric field and a number can be entered directly. The maximum scan frequency is dependent on the number of channels that are enabled and whether or not averaging is enabled. Enabling more channels or enabling averaging will lower the maximum scan frequency.
Signal Cond Averaging - The Averaging checkbox enables or disables averaging of the analog input data. Averaging can be used to increase the effective accuracy of a noisy signal. Averaging will increase the
TempBook User’s Manual Using TempView (16-bit) 3-3
actual scan frequency and number of scans, but the perceived scan frequency and number of scans (which is set by TempView) does not change.
No. of Scans - The number of scans can range from 1 to 100,000. A scan includes all of the channels that are marked as "On" in the analog input configuration spreadsheet.
Data Destination - This section contains the file name and type of file(s) that exist after an acquisition-to­disk is complete. A file name can be typed in directly or the Browse Files button can be pressed to open a file-selection dialog box. The selected file will be placed directly into the filename field. During an acquisition, a raw binary file is created and updated as data is read. After the acquisition is complete, an ASCII text file and PostView binary file can be created if the appropriate checkbox is enabled. Both of these files can be read by PostView (described later in this chapter). If the raw binary checkbox is not enabled, the raw binary file will be deleted after creating the PostView or ASCII file.
After the acquisition is started, these parameters can not be altered.

Counter/Timer Window

The counter/timer window is displayed when ctr/tmr is selected under the Windows pull-down menu. This window allows configuration of the 8254's counter 0. Counter 0 is configured by selecting its function, clock source and initial count. When the Start Timer button is clicked, the counter configuration will take place.
Counter/Timer Window

Digital I/O Window

The digital I/O window is displayed when digital I/O is selected under the windows menu. This window provides interactive control of the 8 digital input lines and 8 digital output lines on the TempBook termination card. Select output values by clicking on the output witches which toggle between 0 and 1—or you can enter the hex value and <Enter>; the switch positions will update to reflect the new setting. When the Execute button is pressed, all output lines will be updated and all input lines will be read.

Charts and the Spreadsheet's "Reading" Column

Up to 4 charts can be displayed by selecting charts under the Window menu. Before the charts can be enabled, at l east one chart must be assigned a channel t hrough the channel’s drop-down list. When a channel is selected, you can change the minimum and maximum values displayed in the chart (see figure). This can be done whether or not the charts are currently enabled.
The charts and the spreadsheet Readings column are independently enabled. The charts can be enabled under the Charts menu of the Charts window. The Readings column can be enabled under the Acquisition menu of the main TempView window. These windows provide instant feedback of the analog input readings.
Data is read and displayed in the charts and Readings column as fast as the computer will allow. When an acquisition to disk has b egun using the Go command under the Acquisition menu, the charts and the spreadsheet Reading column take a lower priority, updating only when there is sufficient time in the acquisition-to-disk task. Therefore, the data seen in the charts may not be an accurate reflection of the data
3-4 Using TempView (16-bit)
11-16-00
TempBook User’s Manual
that is being placed on the disk. As the scan rate is increased, the acquisition-to-disk task will take up more processor time and the charts will be unable to keep up.

TempView Menu Items

File

The file menu provides four b asic functions:
New Set all parameters to their startup setting. Save Save the existing configuration for later recall. Load Load a saved configuration. Convert Binary to ASCII Convert a previously acquired binary file to an ASCII file that can be read by
Convert Binary to PostView Binary Convert a previously acquired binary file to a binary file t hat can be read by Exit Leave the TempView program.

Edit

The Edit menu includes the following functions:
Make All Channels Inactive This command places a "No" in the On field of all of the channels. I f your channel
Make All Channels Active This command places a "Yes" in the On f i el d of all of the channels. Fill Down When multiple cells within a column are selected, this command takes the top-
TempView Display Charts
spreadsheets or other analysis programs. the PostView application.
scan includes only a few channels, it may be easier to make all of the channels inactive, then turn on only those few channels that you want.
most selected cell and copies its c ont ents in the selected cel l s below.
TempBook User’s Manual Using TempView (16-bit) 3-5

Select Device

Window

Acquisition

The Select D evice menu includes the following functions:
Select LPT Port Brings up a dialog box prompting the user to select the LPT port on which the Tem pBook is
Simulated Device This command opens a TempView session but does not attempt t o communicate with
connected. After an LPT port i s selected, TempVi ew opens a new sess i on with t he TempBook hardware and attempts to communicat e with i t . If the hardware is found, the main window is opened. If no hardware is found, the us er i s alerted and the application is opened with the controls disabled. To rec onfigure the LPT port setting and t ry again, click Select LPT Port under the Select P ort menu. If the TempBook hardware still can not be identified by the software, exit TempView and try the TEMPTEST utility program.
TempBook hardware. Instead, the appl i cation simulates the interaction between the software and the hardware. If TempView is presently attached to real TempBook hardware, this command will close that session.
The Window menu includes the following functions:
PostView This command launches an i nstance of the PostV i ew applic at i on. Charts This command displays the charts window. Analog Output Thi s command displ ays the analog output window. Digital I/O This command displays the digital I/O window. Ctr/Tmr This command displays the counter/timer window.
The Acquisition menu includes the following functions:
Go This command arms the hardware for an acquisition to di sk. When the t ri gger i s satisfied,
Enable Input
Reading Column
the acquisition begins. All of the interactive I/O controls are disabled while the s ys tem is armed. No acquisition parameters can be altered at t hi s time.
This command reads the analog inputs and puts the numeric values in the spreadsheet i n
the "Reading" column. I f it is already enabled, this command disables i t .

Charts

The Charts menu of the charts window includes the following function:
Enable Charts This command s t arts the scroll chart runni ng. If the chart is already runni ng, this command
stops it.
3-6 Using TempView (16-bit)
11-16-00
TempBook User’s Manual
Using PostView

Introduction

TempView uses a 16-bit version of PostView, an independent program that allows you to view waveforms recorded by TempView. As the data file is being created, a descriptor file used by PostView is also created.
4
The program can be started from a toolbar PostView icon, or from a pull-down menu. PostView can also be started independent of TempView. Multiple sessions of PostView can be invoked concurrently to view several data files. To view a data file from within PostView, select Open under the File menu. When PostView is started from TempView, it automatically opens the selected destination file. To view other files, use Open under the File menu for the applicable program’s data files. To place channel waveforms into the window, select the number of charts from 1 to 16 under the Number of Charts menu item. Selecting N number of charts will automatically place the first N channels in the charts. Use the Channel Select List Box (Upper right corner of each chart) to view the desired channel. The Channel Select List Boxes contain labels that were assigned to the recorded channels by TempView.
The following table explains PostView toolbar items and is followed by a description of PostView Menu items.
TempBook User’s Manual,
11-16-00
PostView Main Window
Using PostView (16-bit) 4-1

PostView Toolbar Items

Open Print Zoom Out ><
Zoom In <>
Auto­Scale
Show Grid
Show Markers
PostView Toolbar Items
Open Accesses the Open Data Fi l e window. Print Sends the PostView chart(s ) to an assigned printer. Zoom Out
(
)
><
Zoom In (
)
<>
Autoscale Clicking the A ut o S cale button adjusts the Y-axis labels so that the visible waveform fills 90% of the Y-axis Adjust The Y-axis Adjust f i el ds show the chart’s minimum and maximum for visible charts i n the engineering
Show Grid Places a grid on the chart (s), or removes t he gri d i f already present. Show Markers Each chart contains a cross-hair marker that shows the numerical values of t i me and magnitude at its
Trigger Event Marker Stop Event Marker
The Scroll Bar at the bottom of the PostView window (see figure on previous page) al l ows t he waveforms to be scrolled right or left in two ways:
The Zoom Out button doubles the visible timebase, s howing more of the waveform. For example, if 10
seconds of information is visible, clicking the Zoom Out button will show 20 seconds.
The Zoom In button halves the visible timebase, showing less of the waveform. For example, i f 10
seconds of information is visible, clicking the Zoom In button will show 5 seconds.
chart’s range. units shown. Clicking the A uto Scale button automatically adjusts the Y-axis A dj ust fields. To adjust
any chart’s minimum or maximum, place the cursor in the desi red Y-axis Adjust field, and type in a new value.
present location in the waveform . The Markers start out at t he f a r l ef t of every chart, showing the time and magnitude of the first visible point .
Left mouse button allows the user to drag the marker of each chart
Right mouse button moves the markers from all
the charts
in unison
independently
.
.
The Options menu contains a function which allows you to turn markers on and off. W hen a check
appears in front of this it em, its associated indicator is on or visible. Selecting the menu item toggles the indicator (and the check mark) on and off.
The Trigger Event Marker on the time axis shows the l ocation of the trigger point. The Stop Event Marker on the time axis shows the location of the stop poi nt .
1. When clicked on, the small left and right arrow boxes scroll the waveforms approxim ately 20%.
2. The plain scroll button shows the rel ative location of the vis i bl e regi on of the waveforms and can be dragged along the scroll bar to any locat i on desired.
4-2 Using PostView (16-bit)
11-16-00
TempBook User’s Manual

PostView Menu Items

The following tables pertain to functions allowed by the pull-down menus.
File
Open Opens a data file that was created by TempView. PostView automat i cally detects whether the Print Window Prints the present PostV i ew window.
Exit Exits the File menu.
Number of Charts
1-16 After a data file has been opened, the number of desired charts can be selected. You can also
Go To
Percentage Automatically scrolls to the desired percent of the data file. For example, sel ecting 50% would Scan Number Automati cally scrolls the waveforms so the desired scan number is in view. This menu Time Automatically scrolls the waveforms so the desired time is in view.
Trigger Point Automatically scrolls the waveforms so the trigger point (t = 0) is in vi ew.
Options
Zoom Out Allows more of a chart(s) to be seen by decreasing the dimensi ons. Zoom In Zooms in on a chart(s), providing more detail to a smaller area of the chart(s). Autoscale Automatically generates a scale, in contrast to manually assigning the scale. Show Grid (Ctrl+G) Show Markers (Ctrl+K)
Help
Contents The initial PostVi ew help screen provides an overview and listing of the help f i l e contents. A Search Type a word or select one from the Show Topics l i st for quick acces s to help information.
Help on Help Provides instructions on how to use a Windows Help system. About Provi des the PostView version num ber, for example: Version 1.5.
file contains ASCI I or binary data.
use this menu selection to change the number of charts displayed.
display a waveform segment f rom the middle of the data file. selection invokes a dial og box which displays the number of scans in the file.
Allows grids to be turned off and on for al l vi sible graphs. W hen a check appears in front of an
item, its indi cator is on or visible.
Allows markers to be turned off and on for all visible graphs. When a check appears in front of
an item, its indi cator is on or visible.
single topic can be selected for quick acces s to help information.
TempBook User’s Manual
11-16-00
Using PostView (16-bit) 4-3

The PostView Timebase

PostView automatically detects the timebase of the data file and shows the time in seconds in the X-axis labels.
PostView can create files containing multiple timebases, pre-trigger and post-trigger data. In addition, with TempView you can create files that include post-stop data.
The following comments apply to TempView.
Note that the trigger point (t = 0) is not necessarily the first point in the data file.
If pre-trigger scans are available, they will be shown prior to the trigger point and labeled with negative time numbers.
If a dual timebase was used when collecting the data, PostView will show a discontinuity in the time axis when the timebase changes. When a dual timebase is used, the post-trigger scans are collected at one frequency while the pre-trigger and post-stop scans are collected at another.
If post-stop data is available (scans collected after the Stop Event), they are displayed after the Stop Event marker.

Data File Accessibility

In regard to TempView applications, PostView can access the program files at any time, even during the acquisition. If PostView reaches the end of a file while TempView is still collecting data, PostView will automatically display the new data as it becomes available.
For the fastest display of waveforms, select binary data storage.
Note:
4-4 Using PostView (16-bit)
11-16-00
TempBook User’s Manual
Programmer's Guide
This and the following chapters are written for users who wish to write their own programs to control and acquire data from the TempBook/66. This introductory chapter covers basic TempBook operation from a programmer’s perspective and the options available for API drivers and language s. Further detai l i s included through examples in the individual language support chapters, the command reference section, as well as the chapters on thermocouple linearization and software calibration & zero compensation.

A Programmer’s View of TempBook Operations

The TempBook provides flexible, high-spe e d, multi-channel data acquisition capabilities through the use of sophisticated analog and digital electronic circuitry. This circuitry allows up to 16 analog input channels to be read at an aggregate 100 kHz sampling frequency. Each of these channels can be read as a unipolar (0 to +V) or bipolar (±V) signal in one of 8 input voltage ranges. These ranges are determined by dividing the standard 0 to 10V unipolar or ±5V bipolar input range by the available gains of ×1, 2, 5, 10, 20, 50, 100, or
200. Additionally, each input can be read as a single-ended or differential signal (selecting differential limits the number of available channels to 8).
The conversion of these input signals to a digital code is accomplished by a high-performance 12-bit analog-to-digital converter (ADC). (The resultant digital code can then be converted into a voltage via a DAC). The output of the ADC is an unsigned value which is left­justified within a 16-bit data word. In unipolar and bipolar modes, the output code is related to the input voltage as shown in the table (12-bit data format and standard input range shown).
The analog section of the TempBook consists of the following: channel select multiplexers, a single-ended / differential selector, an instrumentation amplifier, programmable gain amplifiers, a unipolar / bipolar selector, and the 12-bit ADC.
5
Bipolar Unipolar
0x000 = -5V 0x000 = 0V 0x800 = 0V 0x800 = 5V 0xFFF = 4.9976V 0xFFF = 9.9976V
Block Diagram
The analog electronics are controlled by a scan-sequencer and control registers. The scan sequencer is implemented with a 16-bit × 512-location FIFO RAM. Each entry in the scan sequencer contains channel, gain, and polarity information. The single-ended/differential selection is controlled by a static control register entry. Once triggered, t he scan sequencer is stepped through at a constant ra te of 100 kHz until all sequencer entries have been read. At each step, an ADC conversion is performed and the resultant output is stored in a data buffer implemented with another 16-bit × 512-location FIFO RAM.
A scan is initiated by a trigger from a software command, a TTL input, or an internal pacer clock. In addition to the source, a mode (one-shot or continuous-trigger) can be selected.
In one-shot mode, the scan sequencer is stepped through once (scanned) each time a trigger is received.
In continuous mode, the scan sequencer waits for the selected trigger for the initial scan but subsequent scans are initiated by the pacer clock.
Note: the selection of one-shot or continuous mode has no effect if the pacer clock is selected as the trigger source.
TempBook User’s Manual Programmer's Guide 5-1
The pacer clock is generated by dividing an internal 1 MHz or 100 kHz clock by a programmable 32-bit counter. The pacer clock source selection is made by an internal jumper setting, and the counter is implemented by cascading P1 and P2 of an 8254 counter/timer chip.
The scan sequencer must be loaded prior to any data acquisition. When using the high-level data acquisition routines (as in the
adcex1
example programs), a single command can combine the scan sequencer setup, trigger selection, pacer clock programming, and data collection. When using the low-level data acquisition routines (as in
adcex2
and
adcex3
), these operations are broken out into separate
commands.
Note: When connecting thermocouple and other low-level signals in addition to high-level signals, the low-level signals should be programmed first into the scan sequence with the high-level signals following in ascending order of signal magnitude.
In addition to the 16 externally available analog input channels, two internal channels are provided for offset correction and thermocouple cold junction compensation. The external analog input channels are addressed as channels 0 ­15, the CJC channel is at address 16, and the internal shorted channel is at 18. The CJC channel must be included in the scan group when reading thermocouples. This channel reading is used by the thermocouple linearization functions. The shorted channel, when read at the same gain as an analog input channel, can be used to remove offset errors present at run time in the analog electronics. These topics are covered in greater detail in the Thermocouple Linearization and Zero Compensation chapters.
Besides zero compensation, software compensation can be used to improve measurement accuracy. The offset and gain errors present after factory calibration are characterized and recorded within a unit-specific calibration­constants file. The calibration-constants file is read by the data acquisition program at run time. The collected ADC data can then be corrected for offset and gain errors. This topic is covered in greater detail in the Software Calibration and Zero Compensation chapter.
In addition to analog input, the TempBook provides digital I/O and counter/timer function. Eight bits each of digital I/O are provided which can be accessed as register-addressable I/O ports. Additionally, the 8 bits of digital input can be read as part of the scan group by programming the scan sequencer with the appropriate channel definition. The digital inputs are then returned within the ADC data buffer and are right justified within the 16-bit data words. When the digital inputs are read in this way, the timing relationship between the trigger event and the analog & digital data is fixed.
A user accessible counter / timer is provided through the P0 p ort of the 8254. This port can be configured into one of several modes including one-shot and pulse-train generation as well as event counting. The clock input to this counter / timer port can be taken from an external or internal 100 kHz source. These topics are covered in greater detail in the Command Reference chapter under the
tbkConfCntr0
tbkSetTrig
and
commands.
The flowchart diagram shows the operation of a typical TempBook data acquisition program.
Data Acquisition
Program Flowchart
5-2 Programmer's Guide TempBook User’s Manual

Driver Options

The install disks include several “drivers” to accommodate various programming environments. This section is intended to help you decide which API and programming language to use in developing your application.
TempBook applications can be written to either the Standard TempBook API or to the Enhanced Daq* API. Standard API functions have the generically used with the TempBook, WaveBook, DaqBook, DaqBoard, and Daq PC-Card product lines. Enhanced API functions share the
tbk
… prefix. The Enhanced API is a new format which can be
daq
… prefix. Generally,
If starting with an existing TempBook Application written to Windows 3.1, the quickest port is to use or re-write code to the Standard API. If writing a new application, it is best to write code to the Enhanced API due to its improved performance and enhanced feature set (see following).
Standard API (
tbk
The standard API was originally written for the TempBook’s Windows 3.1 driver. However, it can be used under Windows 95 in 16-bit mode. The standard API is the only API option available for Windows 3.1 or DOS applications. Use the Standard API:
Enhanced API (
daq
The Enhanced API for 32-bit systems has several features that are not present in the standard API:
Because of these new features and other improvements, we recommend you use the Enhanced API whenever feasible. Use the Enhanced API:

Language Support

The following table shows language support for the standard and enhanced API drivers.
Standard API (16-bit) Supported Languages Enhanced API (or 32-bit Standard) Supported Languages
C/C++ Microsoft Visual C++ Borland C++ (v4.0 and greater) BASIC Microsoft Visual Basic (v4.0 and previous) QuickBASIC Pascal Turbo Pascal
…)
When developing a new or existing D OS application When developing a new or existing Windows 3.1 application
…)
Multi-device - can concurrently handle up to 4 devices (including WaveBooks, Daq* products, and/or TempBooks) Larger buffer - can handle up to 2 billion samples at a time Enhanced acquisition and trigger modes Direct-to-disk capabilities Wait-on-event features Uses multi-tasking advantages of Windows 95/NT
When developing new or existing Windows 95 applications When developing new or existing Windows NT applications When porting an existing Standard API application to 32-bit mode to take advantage of the Enhanced API features
C/C++ Microsoft Visual C++ (v2.2 and greater) Borland C++ (v4.0 and greater) BASIC Microsoft Visual Basic (v4.0 and greater)
Delphi Borland Delphi (v2.0)
TempBook User’s Manual Programmer's Guide 5-3
Notes
5-4 Programmer's Guide TempBook User’s Manual
Standard API Programming of the TempBook with C
Note: The enhanced API commands do not work exactly like the standard API commands; refer to chapters 10 and 11.

Accessing TempBook from a Windows Program

The structure of a Windows program generally dictates that actions take place in response to messages such as an operator key-press, mouse action, menu selection, etc. This discussion covers the basic actions needed to control the TempBook. How these actions are combined and coordinated in response to Windows messages is up to the application designer.

Accessing TempBook from a C-for-Windows Program

There is one library and one header file located in the TEMPBOOK\WIN\C directory. The header file, TEMPBOOK.H, must be included at the top of a C program using the allow the compiler to know what TempBook functions and constants are available.
The library, TEMPBOOK.LIB, must be included in the application's makefile or project file so that the linker will find the TempBook functions. This is a large memory model library; the appropriate compiler and linker options for a large memory model program must be invoked. See the documentation for your specific C compiler for a description on using header files, libraries, and memory models.
To use the example program located in the TEMPBOOK\DOS\C directory, create a makefile or project file which consists of the TBKEX.C source file, TBKEX.RC resource file, TBKEX.DEF definition file, TBKEX.ICO icon file and the TEMPBOOK.LIB library.
#include
command. This will
6

High-Level Analog Input

The following excerpt from TBKEX.C shows the usage of several high level analog input routines.
unsigned sample, buf [10], data[7], data2[80]; int i, scan, chan;
Set default operating mode to single-ended, bipolar. These parameters will affect all scanned channels.
tbkSetMode(0, 1);
Get one A/D sample from channel 0 at unity gain and print the unsigned integer that is returned. Since the TempBook contains a 12-bit A/D converter, the least significant 4 bits are undefined. Shifting the value to the right 4 times right justifies the 12 bit value in the 16 bit variable.
tbkRd(0, &sample, TgainX1); sprintf(tempstr, "Result of tbkRd : %4d\r\n\r\n", sample>4);
Get 10 samples from channel 0, trigged by the pacer clock with a 1kHz sampling frequency at unity gain. Once the data has been collected, print the 10 samples that were placed in the buffer.
tbkRdN(0, buf, 10, TtsPacerClock, 0, 1000, TgainX1); sprintf("tempstr, "Results of tbkRdN:"); strcat (response, tempstr); for(i=0;i<8;i++){
sprintf(tempstr, "%4d ", buf[i]>4); strcat (response, tempstr); }
Get 1 scan of channels 0 to 7 at unity gain. Once the data has been collected, print all 8 channel values.
tbkRdScan(0, 7, data, TgainX1); sprintf(tempstr"\r\n\r\nResults of tbkRdscan:\r\n"); strcat (response, tempstr); for(i=0;i<8;i++) { sprintf(tempstr"Channel: %2d Data: %4d\r\n", i, data[i]>4); strcat (response, tempstr); }
TempBook User’s Manual Standard API Programming of the TempBook with C 6-1
Get 10 scans of channels 0 to 7, triggered by the pacer clock with a 1kHz sampling frequency and unity gain, then print the scan data.
tbkRdScanN(0, 7, data2, 10, TtsPacerClock, 0, 1000, TgainX1); sprintf(tempstr"\r\nResults of tbkRdScanN Channels 0 - 7:"); strcat (response, tempstr);
for (scan=0 ; scan<8 ; scan++){ sprintf(tempstr"\r\nScan %d: ", scan); strcat (response, tempstr);
for (chan=0 ; chan<8 ; chan++){ sprintf(tempstr"%4d ", data2[(scan * 8) + chan]>4); strcat (response, tempstr); } }

Low-Level Analog Input

The following excerpt from TBKEX.C shows the usage of several low-level analog input routines.
unsigned int buf[80], scan, chan;
Set the default operating mode to single-ended, bipolar. These parameters will affect all scanned channels.
tbkSetMode(0, 1);
Setup the scan sequencer for channels 0 to 7 with each channel in the scan at unity gain.
tbkSetMux(0, 7, TgainX1);
Set the scan frequency for 1kHz.
tbkSetFreq(1000);
Make the Pacer Clock the trigger source. This will also arm and trigger the system.
tbkSetTrig(TtsPacerClock, 0, 0, 1);
Read 10 scans of data into the language buffer buf, then print the 8 scan values.
tbkRdNFore(buf, 10); sprintf(tempstr"\r\nResults of tbkRdNFore Channels 0 - 7:\r\n"); strcat (response, tempstr);
for (scan=0 ; scan<8 ; scan++) { sprintf(tempstr"\r\nScan %d: ", scan); strcat (response, tempstr);
for (chan=0 ; chan<8 ; chan++){ sprintf(tempstr"%4d ", buf[(scan * 8) + chan]>4); strcat (response, tempstr); } }

Analog Input in the Background

The following excerpt from TBKEX.C shows the usage of background acquisition functions. These functions setup the TempBook to collect data in the background while your program continues to process new lines of code in the foreground.
unsigned int data[80], chans[8], i, scan, chan; unsigned chargains[8], polarities[8], active; unsigned longcount;
6-2 Standard API Programming of the TempBook with C TempBook User’s Manual
Initialize the TempBook on LPT1 with interrupt 7.
tbkInit(LPT1, 7);
Set the default operating mode to single-ended, bipolar. These parameters will affect all scanned channels.
tbkSetMode(0, 1);
The TempBook has a sophisticated channel-gain sequencer that allows every channel in the defined scan to have a different gain and unipolar/bipolar setting. The following array assignment will be used to setup the sequencer to sample channels 0 through 7 in bipolar mode at unity gain. If desired, each channel could have been assigned a different gain and/or unipolar/bipolar setting.
for(i=0;i<8;i++){
chans[i] = i;
gains[i] = TgainX1;
polarities[i] = 1; }
Once the arrays are loaded with the desired channel numbers and their associated gain and unipolar/bipolar settings, the following function uses them to load the sequencer.
tbkSetScan(chans, gains, polarities, 8);
Set the Clock to 1 Hz. (This assumes that the time base selection jumper is in the default 1 MHz position)
tbkSetClk(1000, 1000);
Make the Pacer Clock the trigger source.
tbkSetTrig(TtsPacerClock, 1, 0, 0);
Setup the background acquisition of 10 scans. As the data is collected, place it into the array called data. Regardless of the status of the acquisition, the program will immediately return from this function call and proceed to the next line in our code. The data will be collected via interrupts and placed in the specified buffer in the background.
tbkRdNBack(data, 10, 0, 1);
At any point in the program, you can check the status of the background acquisition. The next lines of code poll the background status continuously until it is no longer active, then it exits the do loop and proceeds through the remainder of the program.
/* Check if acquisition is complete */ do { tbkGetBackStat(&active, &count); sprintf(tempstr"Transfer in progress : %2d scans acquired.\r",count); strcat(response, tempstr); } while (active != 0); sprintf(tempstr"\r\nAcquisition complete.\r\n\r\n");
Since the background acquisition is complete, print the data in the buffer.
sprintf(tempstr"Data Acquired:\r\n"); strcat(response, tempstr); for (scan=0 ; scan<8 ; scan++){ sprintf(tempstr, "\nScan %d:", scan); strcat(response, tempstr); for (scan=0 ; scan<8 ; scan++){ sprintf(tempstr" %4d", data[(scan * 8) + chan]>4); strcat(response, tempstr); } }
TempBook User’s Manual Standard API Programming of the TempBook with C 6-3

General Purpose Digital I/O Functions

The following except from TBKEX.C shows the usage of the general purpose digital I/O functions.
unsigned char bit, in_bit, out_bit, out_byte, in_byte;
Read the state of the digital input bit 3, and place its value in in_bit.
tbkRdBit(3, &in_bit);
Depending on its state, print a message.
if (in_bit) { sprintf(tempstr, "Digital input #3 is set\r\n\r\n"); strcat(response, tempstr); } else { sprintf(tempstr, "Digital input #3 is clear\r\n\r\n"); strcat(response, tempstr); }
Set the digital output bit 5 to a high state.
tbkWtBit(5, 1);
The following lines of code use the byte manipulation functions to perform a "walking-bit" test on the digital output port.
for (bit=0 ; bit<8 ; bit++) { out_byte = 0x01<bit;// Put a 1 in the bit(th) location of a byte tbkWtByte(out_byte);// Write that byte to the digital output port sprintf(tempstr, "Digital output byte written 0x%2x\n", out_byte); strcat(response, tempstr); }
Read the value from the digital input port (DI0 - DI7 inclusive), then print the result.
tbkRdByte(&in_byte); sprintf(tempstr, "Digital input byte is 0x%2x\r\n", in_byte); strcat(response, tempstr);

High-Speed Digital Input

The following excerpt from TBKEX.C shows the usage of the high-speed digital input function calls. The high-speed digital port can be specified as a channel in the analog scan sequence, just like an analog
input channel. In this way the high-speed digital port data is acquired synchronously with the analog input data and is placed in the same data buffer as the analog input data. This program sets up a scan which includes analog channels and the high speed digital port.
unsigned chans[9], data[9], i, chan; unsigned char gains[9], polarity[9];
Configure a scan consisting of analog i nput channels 0 thr ough 7.
for (i=0 ; i<8 ; i++){ chans[i] = i; // Analog input channels 0 - 7 gains[i] = TgainX1; // Unity gain }
Include the high speed port as the last channel in the scan. Note that the high speed channel can be placed anywhere in the scan.
chans[8] = TchHighSpeedDig; // High speed digital inputs gains[8] = TgainX1; // Put any gain, it doesn't matter
6-4 Standard API Programming of the TempBook with C TempBook User’s Manual
Initialize the TempBook on LPT1 with interrupt 7.
tbkInit(LPT1, 7);
Set the default operating mode to single-ended, bipolar. These parameters will affect all scanned channels.
tbkSetMode(0, 1);
Load the scan sequencer using a NULL pointer for the polarities array which indicates the use of the default, global polarity.
tbkSetScan(chans, gains, 0, 9);
Set the trigger source to software trigger.
tbkSetTrig(TtsSoftware, 0, 0, 0);
Trigger a scan.
tbkSoftTrig();
Read the A/D FIFO buffer and print the results.
tbkRdNFore(data, 1); sprintf("Analog input channels 0 - 7:\n"); strcat(response, tempstr);
for (chan=0 ; chan<8 ; chan++) sprintf(" %4d", data[chan]>4); strcat(response, tempstr); } sprintf(tempstr, "\nHigh speed digital inputs DI0 - DI7:\n"); sprintf(response, tempstr);

Counter/Timer Functions

The following excerpt from TBKEX.C shows the usage of the counter/timer functions. The counter/timer port a vailable through the termination card is the P0 port af an 8254 counter/timer chip.
This port can be configured through software t o perform sever al functions which are d escribed in detail in the command reference section under the tbkConfCntr0 command. This example demonstrates the usage of three of the counter/timer modes. Altho ugh the invocation of these modes is demonstrated there is no way to observe the function of the port without the connection of external test equipment or circuitry.
Configure CTR0 to use the internal 100 kHz clock.
tbkSetTrig(TtsSoftware, 0, 1, 0);
Configure CTR0 to mode 0, High on Terminal Count and write a count value of 100 to counter 0. After this the counter 0 output (OUT0) will go high after 100 pulses are received on the counter 0 gate input (GAT0).
tbkConfCntr0(Tc0cHighTermCnt); tbkWtCntr0(100);
Configure CTR0 to mode 1, Hardware Retriggerable One-Shot and write a count value of 1000 to counter
0. After this a rising edge on the counter 0 input (GAT0) will cause the output to go high for 10 msec.*/
tbkConfCntr0(Tc0cOneShot); tbkWtCntr0(1000);
Configure CTR0 t o mode 3, Square Wave Generator and write a count value of 20 to counter 0 . After this a square wave of 5kHz frequency should be present on the counter 0 output (OUT0).
tbkConfCntr0(Tc0cSquareWave); tbkWtCntr0(20);
TempBook User’s Manual Standard API Programming of the TempBook with C 6-5

High-Level Thermocouple Data Acquisition

The following excerpt from TBKEX.C demonstrates the use of the TempBook's high-level thermocouple temperature data acquisition routines. These functions have combined scan sequencer setup, ADC data collection, and thermocouple linearization.
int i, temp, temps[10]; unsigned buf[1200];
Set the default operating mode to differential, bipolar. These parameters will affect all scanned channels.
tbkSetMode(1, 1);
Get one temperature sample from a type J thermocouple on channel 0, then print the result.
tbkRdTemp(0, TbkTypeJ, &temp); sprintf(tempstr, "\r\nResults of tbkRdTemp\r\n"); strcat(response, tempstr); sprintf(tempstr, "Temperature: %4,1f \r\n", (float)temp/10.0); strcat(response, tempstr);
Get one temperature value from a type J thermocouple on channel 0 which is the average of 10 acquired values, then print the result. This has the effect of reducing the noise content of your signal. The 10 readings will be taken at 1kHz, with only one temperature value returned by the function.
tbkRdTempN(0, TbkTypeJ, 10, &temp, buf, 1000, 0); sprintf(tempstr, "\r\nResults of tbkRdTempN\r\n"); strcat(response, tempstr); sprintf(tempstr, "Temperature: %4.1f \r\n", (float)temp/10.0); strcat(response, tempstr);
Get one temperature value from a type J thermocouple on channe l s 0 through 7, then print the re sul t.
tbkRdTempScan(0, 7, TbkTypeJ, temps); sprintf(tempstr, "\r\nResults of tbkRdTempScan\r\n"); strcat(response, tempstr); for (i=0 ; i<8 ; i++){ sprintf(tempstr, "Channel %d Temperature: %4.1f \r\n", i, (float)temps[i]/10.0); strcat(response, tempstr);
Get 8 temperature values from type J thermocouple on channels 0 through 7 which are the average of 10 acquired values, then print the result. This has the effect of reducing the noise content of your signal. The 10 readings will be taken at 1kHz, with only one temperature value for each channel returned by the function.
tbkRdTempScanN(0, 7, TbkTypeJ, 10, temps, buf, 1000, 0); sprintf(tempstr, "\r\nResults of tbkRdTempScanN\r\n"); strcat(response, tempstr); for (i=0 ; i<8 ; i++){ sprintf(tempstr, "Channel %d Temperature: %4.1f \r\n", i, (float)temps[i]/10.0); strcat(response, tempstr); }
6-6 Standard API Programming of the TempBook with C TempBook User’s Manual

Thermocouple Linearizati on

The following excerpt from TBKEX.C, demonstrates the use of the TempBook's thermocouple linearization routines.
unsigned i, chans[11], data[1100]; unsigned char gains[11]; int temp[8];
The following lines of code assign channels and gains to the arrays that will be used to create a scan sequence. The position of the CJC in the scan and the assignment of the gains for all of the channels must conform to the conventions used by the linearization routines. See the command reference section for more information on scan configuration.
/* Configure chans array */ chans[0] = 18; /* Shorted channel*/ chans[1] = 18; /* Shorted channel */ chans[2] = 16; /* CJC channel */ chans[3] = 0; /* Thermocouple on channel 0 */ chans[4] = 1; /* Thermocouple on channel 1 */ chans[5] = 2; /* Thermocouple on channel 2 */ chans[6] = 3; /* Thermocouple on channel 3 */ chans[7] = 4; /* Thermocouple on channel 4 */ chans[8] = 5; /* Thermocouple on channel 5 */ chans[9] = 6; /* Thermocouple on channel 6 */ chans[10] = 7; /* Thermocouple on channel 7 */
/* Configure gains array */ gains[0] = TbkBiCJC; /* Bipolar CJC gain setting */ gains[1] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */ gains[2] = TbkBiCJC; /* Bipolar CJC gain setting */ gains[3] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */ gains[4] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */ gains[5] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */ gains[6] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */ gains[7] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */ gains[8] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */ gains[9] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */ gains[10] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */
Set the default operating mode to differential, bipolar. These parameters will affect all scanned channels.
tbkSetMode(1, 1);
Configure the scan sequencer,with the desired channels and gains. A zero for the polarity argument forces the use of the default polarity for all of the channels.
tbkSetScan(chans, gains, 0, 11);
Set the pacer clock for a 1 msec period.
tbkSetFreq(1000);
Use the Pacer Clock as the trigger source.
tbkSetTrig(TtsPacerClock, 0, 0, 0);
The following function tells all of the TbkTC functions to to use zero correction. Zero correction compensates for offset drift in the electronics due to ambient temperature changes and/or age.
tbkTCAutoZero(1);
Read 100 scans and place the raw data in the supplied buffer.
tbkRdNFore(data, 100);
Reset the trigger to prevent a buffer overrun.
TempBook User’s Manual Standard API Programming of the TempBook with C 6-7
tbkSetTrig(TtsSoftware, 1, 0, 0);
Configure and perform Thermocouple Linearization with block averaging on the raw ADC counts. The raw counts are in the data buffer, data. The converted temperature values will be returned in the buffer temp. With block averaging enabled one temperature, the average of all 100 scans, will be returned for each channel.
tbkTCSetup(11, 2, 8, TbkTypeJ, 1, 0); tbkTCConvert(data, 100, temp, 8);
The converted temperatures can now be printed to the screen.
for (i=0 ; i<8 ; i++){ sprintf(tempstr, "%8.1f ", (float)temp[i] / 10.0); strcat(response, tempstr); } sprintf(tempstr, "\r\n"); strcat(response, tempstr); SendDlgItemMessage(myDlg, 101, WM_SETTEXT, 0, (LONG)(LPSTR)response); EmptyMessageQueue(myDlg);

Sample Programs

High-Level Analog Input

/*********************************************** File:Adcex1.c Description:This example demonstrates the use of TempBook/66s highest level ADC functions. These functions have combined scan sequencer setup and ADC data collection. Functions Used:tbkRd(unsigned chan, unsigned *sample, unsigned char gain) tbkRdN(unsigned chan, unsigned *buf, unsigned count, unsigned char trigger, unsigned char oneShot, float freq, unsigned char gain) tbkRdScan(unsigned startChan, unsigned endChan, unsigned * buf, unsigned char gain) tbkRdScanN(unsigned startChan, unsigned endChan, unsigned * buf, unsigned count, unsigned char trigger, unsigned char oneShot, float freq, unsigned char gain) ***********************************************/
unsigned sample, buf[10], data[7], data2[80]; int i, scan, chan; sprintf(response,"\r\nAdcex1.c\r\n\r\n");
/* Set the default operating mode to single-ended, bipolar */ tbkSetMode(0, 1);
/* Get 1 ADC sample from channel 0 at unity gain. */ tbkRd(0, &sample, TgainX1);
/* Print results using a 12 bit data format */ sprintf(tempstr,"Result of tbkRd : %4d\r\n\r\n", sample>4); strcat(response,tempstr);
/* Get 10 samples from channel 0, trigged by the pacer clock with a */ /* 1000 Hz sampling frequency at unity gain. */ tbkRdN(0, buf, 10, TtsPacerClock, 0, 1000, TgainX1);
/* Print the results using a 12 bit data format */
sprintf(tempstr,"Results of tbkRdN:"); strcat(response,tempstr);
for(i=0;i<8;i++) { sprintf(tempstr,"%4d ", buf[i]>4); strcat(response,tempstr); } /* Get 1 sample from channels 0 through 7 at unity gain. */
6-8 Standard API Programming of the TempBook with C TempBook User’s Manual
tbkRdScan(0, 7, data, TgainX1);
/* Print the results using a 12 bit data format */
sprintf(tempstr,"\r\n\r\nResults of tbkRdscan:\r\n"); strcat(response,tempstr);
for(i=0;i<8;i++) { sprintf(tempstr,"Channel: %2d Data: %4d\r\n", i, data[i]>4); strcat(response,tempstr); }
/* Get 10 samples from channels 0 - 7, triggered by the pacer clock with a 1000 Hz sampling frequency and unity gain. */
tbkRdScanN(0, 7, data2, 10, TtsPacerClock, 0, 1000, TgainX1);
/* Print the results using a 12 bit data format */
sprintf(tempstr,"\r\nResults of tbkRdScanN Channels 0 - 7:"); strcat(response,tempstr);
for (scan=0 ; scan <8; scan++) { sprintf(tempstr,"\r\nScan %d: ", scan); strcat(response,tempstr);
for (chan=0 ; chan<8 ; chan++) {
sprintf(tempstr,"%4d ", data2[(scan * 8) + chan]>4) ; strcat(response,tempstr); } } SendDlgItemMessage(myDlg, 101, WM_SETTEXT, 0, (LONG)(LPSTR)response) ; EmptyMessageQueue(myDlg); }

Low-Level Analog Input

/*********************************************** File:Adcex2.c Description:This example demonstrates the use of the TempBook/66's lower level ADC functions. These functions allow separate scan sequencer setup, trigger source selection, and ADC data collection. Functions Used:bkSetMux(unsigned startChan, unsigned endChan, unsigned char gain) tbkSetFreq(float freq) tbkSetTrig(unsigned char trigger, unsigned char oneShot, unsigned char ctr0mode, unsigned char pacerMode) tbkRdNFore(unsigned _far *buf, unsigned count) *************************************************/
unsigned int buf[80], scan, chan; sprintf(response,"\r\nAdcex2.c\r\n");
/* Set the default mode of operation to single-ended bipolar */ tbkSetMode(0, 1);
/* Set the scan sequencer for channels 0 - 7 at unity gain */ tbkSetMux(0, 7, TgainX1);
/* Set the scan frequency for 1000 Hz */ tbkSetFreq(1000);
/* Set the trigger source for the Pacer Clock. Note that the trigger is armed immediately */ tbkSetTrig(TtsPacerClock, 0, 0, 1);
/* Read 10 scans of data */
TempBook User’s Manual Standard API Programming of the TempBook with C 6-9
tbkRdNFore(buf, 10);
/* Print the results using a 12 bit data format */ sprintf(tempstr,"\r\nResults of tbkRdNFore Channels 0 - 7:\r\n"); strcat(response,tempstr);
for (scan=0 ; scan<8 ; scan++) { sprintf(tempstr,"\r\nScan %d: ", scan); strcat(response,tempstr); for (chan=0 ; chan<8 ; chan++) { sprintf(tempstr,"%4d ", buf[(scan * 8) + chan]>4); strcat(response,tempstr); } }
sprintf(tempstr,"\r\n"); strcat(response,tempstr);
SendDlgItemMessage(myDlg, 101, WM_SETTEXT, 0, (LONG)(LPSTR)response); EmptyMessageQueue(myDlg); }

Analog Input in the Background

/*********************************************** File: Adcex3.c Description:This example demonstrates the use of the TempBook/66's background transfer routines. Functions Used:tbkRdNBack(unsigned _far *buf, unsigned count, unsigned char cycle, unsigned char updateSingle) tbkGetBackStat(unsigned char _far *active, unsigned long _far *count) ***********************************************/
unsigned int data[80], chans[8], i, scan, chan; unsigned char gains[8], polarities[8], active; unsigned long count;
sprintf(response,"\r\nAdcex3.c\r\n\r\n");
/* Set the default mode of operation to single-ended bipolar */ tbkSetMode(0, 1);
/* Set channels, gains, & polarities arrays to channels 0-7, bipolar, at unity gain. */
for(i=0;i<8;i++) { chans[i] = i; gains[i] = TgainX1; polarities[i] = 1; }
/* Load the scan sequencer FIFO */ tbkSetScan(chans, gains, polarities, 8);
/* Set Clock : 1Hz - xtal set to 1MHz */ tbkSetClk(1000, 1000);
/* Set pacer clock trigger source */ tbkSetTrig(TtsPacerClock, 1, 0, 0);
/* Read 10 scans of data in the background, cycle off, */ /* update on each scan */ tbkRdNBack(data, 10, 0, 1);
/* Check if acquisition is complete */ do {
6-10 Standard API Programming of the TempBook with C TempBook User’s Manual
tbkGetBackStat(&active, &count); sprintf(tempstr,"Transfer in progress : %2d scans acquired.\r",count); strcat(response,tempstr); } while (active != 0); sprintf(tempstr,"\r\nAcquisition complete.\r\n\r\n"); strcat(response,tempstr);
/* Print results using a 12 bit data format */
sprintf(tempstr,"Data Acquired:\r\n"); strcat(response,tempstr);
for (scan=0 ; scan<8 ; scan++) { sprintf(tempstr,"\r\nScan %d:", scan); strcat(response,tempstr);
for (chan=0 ; chan <8; chan++) { sprintf(tempstr," %4d", data[(scan * 8) + chan]>4); strcat(response,tempstr); } }
sprintf(tempstr,"\r\n"); strcat(response,tempstr);
SendDlgItemMessage(myDlg, 101, WM_SETTEXT, 0, (LONG)(LPSTR)response); EmptyMessageQueue(myDlg); }

General Purpose Digital I/O

/*********************************************** File: Adcex3.c Description:This example demonstrates the use of the TempBook/66's general purpose digital I/O ports. Functions Used:tbkRdBit(unsigned char bitNum, unsigned char *bitVal) tbkRdByte(unsigned char *byteVal) tbkWtBit(unsigned char bitNum, unsigned char bitVal) tbkWtByte(unsigned char byteVal) ***********************************************/
*/ unsigned char bit, in_bit, out_byte, in_byte; sprintf(response,"\r\nDigex1.c\r\n\r\n");
/* Read the state of digital input DI3 */ tbkRdBit(3, &in_bit);
if (in_bit) { sprintf(tempstr,"Digital input #3 is set\r\n\r\n"); strcat(response,tempstr); } else { sprintf(tempstr,"Digital input #3 is clear\r\n\r\n"); strcat(response,tempstr); }
/* Set digital output DO5 */ tbkWtBit(5, 1); /* Perform a 'walking bit' test by setting each digital output in order from DO0 to DO7 */ for (bit=0 ; bit<8 ; bit++) { out_byte = 0x01<bit; // Put a 1 in the bit(th) location of a byte tbkWtByte(out_byte);
// Write that byte to the digital output port
TempBook User’s Manual Standard API Programming of the TempBook with C 6-11
sprintf(tempstr,"Digital output byte written 0x%2x\r\n", out_byte); strcat(response,tempstr); }
/* Read the value from the digital input port (DI0 - DI7 inclusive) */ tbkRdByte(&in_byte);
sprintf(tempstr,"Digital input byte is 0x%2x\r\n", in_byte); strcat(response,tempstr); SendDlgItemMessage(myDlg, 101, WM_SETTEXT, 0, (LONG)(LPSTR)response); EmptyMessageQueue(myDlg); }

High-Speed Digital Input

/*********************************************** File: Digex2.c Description:This example demonstrates the use of the TempBook's high speed digital inputs. Functions Used:tbkSetScan(unsigned *chans, unsigned char *gains, unsigned char *polarity, unsigned count) tbkRdNFore(unsigned _far *buf, unsigned count) ***********************************************/
unsigned chans[9], data[9], i, chan; unsigned char gains[9], polarity[9];
sprintf(response,"\nDigex2.c\n\n");
/* Configure the channels and gains arrays for analog inputs 0-7 */ /* plus the high speed digital inputs */
for (i=0 ; i<8 ; i++) { chans[i] = i; /* Analog input channels 0 - 7 */ gains[i] = TgainX1; /* Unity gain */ polarity[i] = 1; /* Bipolar */ }
chans[8] = TchHighSpeedDig; /* High speed digital inputs */ gains[8] = TgainX1; /* Put any gain, it doesn't matter */ polarity[8] = 1; /* Put any polarity, it doesn't matter */
/* Set default operation to single-ended, bipolar */
tbkSetMode(0, 1);
/* Load the scan sequencer, NULL pointer for polarities array */ /* indicates use default polarity */
tbkSetScan(chans, gains, 0, 9);
/* Set software trigger source */
tbkSetTrig(TtsSoftware, 0, 0, 0);
/* Trigger a scan */
tbkSoftTrig();
/* Read the ADC FIFO buffer */
tbkRdNFore(data, 1);
/* Print the results */
sprintf(tempstr,"Analog input channels 0 - 7:\n");
6-12 Standard API Programming of the TempBook with C TempBook User’s Manual
strcat(response,tempstr);
for (chan=0 ; chan<8 ; chan++) { sprintf(tempstr," %4d", data[chan]>4); strcat(response,tempstr); }
sprintf(tempstr,"\nHigh speed digital inputs DI0 - DI7:\n"); strcat(response,tempstr);
sprintf(tempstr," 0x%x", (char)data[8]); strcat(response,tempstr);
SendDlgItemMessage(myDlg, 101, WM_SETTEXT, 0, (LONG)(LPSTR)response); EmptyMessageQueue(myDlg); }

Counter Timer Functions

/************************************ File: Ctrex1.c Description: This example demonstrates the use of the TempBook's counter timer functions. Functions Used: tbkConfCntr0(unsigned char config) tbkWtCntr0(unsigned cntr0) *************************************/
sprintf(response,"\r\nctrex1.c\r\n\r\n");
/* Configure CTR0 to use the internal 100kHz clock */
tbkSetTrig(TtsSoftware, 0, 1, 0);
/* Configure CTR0 to mode 1, Hardware Retriggerable One-Shot and write a count value of 1000 to counter 0. After this a rising edge on the counter 0 input (GAT0) will cause the output to go high for 10 msec. */
tbkConfCntr0(Tc0cOneShot);
tbkWtCntr0(1000);
/* Configure CTR0 to mode 3, Square Wave Generator and write a count value of 20 to counter 0. After this a square wave of 5kHz frequency should be present on the counter 0 output (OUT0) */
tbkConfCntr0(Tc0cSquareWave);
tbkWtCntr0(20); /* Configure CTR0 to use an external clock */ tbkSetTrig(TtsSoftware, 0, 0, 0); /* Configure CTR0 to mode 0, High on Terminal Count and write a count value of 100 to counter 0. After this the counter 0 output (OUT0) will go high after 100 pulses are received on the counter 0 clock input (CLK0) */ tbkConfCntr0(Tc0cHighTermCnt); tbkWtCntr0(100); SendDlgItemMessage(myDlg, 101, WM_SETTEXT, 0, (LONG)(LPSTR)response); EmptyMessageQueue(myDlg); }
TempBook User’s Manual Standard API Programming of the TempBook with C 6-13

High-Level Thermocouple Measurement

*********************************************** File: Description: This example demonstrates the use of the TempBook's high level thermocouple temperature data acquisition routines. These functions have combined scan sequencer setup, ADC data collection, and thermocouple linearization. Functions Used: tbkRdTemp(unsigned chan, unsigned tcType, int * temp) tbkRdTempN( unsigned chan, unsigned tcType, unsigned count, int * temp, unsigned * buf, float freq, unsigned avg ) tbkRdTempScan(unsigned startChan, unsigned endChan,unsigned tcType, int * temp) tbkRdTempScanN(unsigned startChan, unsigned endChan, unsigned tcType, unsigned count, int * temp, unsigned * buf, float freq, unsigned avg) ****************************************************/
int i, temp, temps[10]; unsigned buf[1200];
sprintf(response,"\r\nTempex1.c\r\n");
/* Set the default mode of operation to differential bipolar */
tbkSetMode(1, 1);
/* Get 1 ADC sample from a type J thermocouple on channel 0 and convert the reading to a temperature. Print the result. */
tbkRdTemp(0, TbkTypeJ, &temp); sprintf(tempstr,"\r\nResults of tbkRdTemp\r\n"); strcat(response,tempstr);
sprintf(tempstr,"Temperature: %4.1f \r\n", (float)temp/10.0); strcat(response,tempstr);
/* Get 10 ADC samples from a type J thermocouple on channel 0 and convert the readings to a single temperature using block averaging. Print the results. */
tbkRdTempN(0, TbkTypeJ, 10, &temp, buf, 1000, 0);
sprintf(tempstr,"\r\nResults of tbkRdTempN\r\n"); strcat(response,tempstr);
sprintf(tempstr,"Temperature: %4.1f \r\n", (float)temp/10.0); strcat(response,tempstr);
/* Get 1 ADC sample each from type J thermocouples on channels 0 through 7 and convert the readings to temperatures. Print the results */
tbkRdTempScan(0, 7, TbkTypeJ, temps);
sprintf(tempstr,"\r\nResults of tbkRdTempScan\r\n"); strcat(response,tempstr);
for (i=0 ; i<8 ; i++) { sprintf(tempstr,"Channel %d Temperature: %4.1f \r\n", i, (float)temps[i]/10.0); strcat(response,tempstr); }
6-14 Standard API Programming of the TempBook with C TempBook User’s Manual
/* Get 10 ADC samples each from type J thermocouples on channels 0 through 7 and convert the readings to temperatures using block averaging. Print the results */
tbkRdTempScanN(0, 7, TbkTypeJ, 10, temps, buf, 1000, 0);
sprintf(tempstr,"\r\nResults of tbkRdTempScanN\r\n"); strcat(response,tempstr);
for (i=0 ; i<8 ; i++) { sprintf(tempstr,"Channel %d Temperature: %4.1f \r\n", i, (float)temps[i]/10.0); strcat(response,tempstr); }
SendDlgItemMessage(myDlg, 101, WM_SETTEXT, 0, (LONG)(LPSTR)response); EmptyMessageQueue(myDlg); }

Low-Level Thermocouple Linearization

*********************************************** File: Description: This example demonstrates the use of the TempBook's thermocouple linearization routines. Functions Used: tbkTCSetup(unsigned nscan, unsigned cjcPosition, unsigned ntc, unsigned tcType, unsigned char bipolar, unsigned avg) tbkTCConvert(unsigned _far *counts, unsigned scans, int _far *temp, unsigned ntemp) *************************************************/
*/ unsigned i, chans[11], data[1100]; unsigned char gains[11]; int temp[8]; sprintf(response,"\r\nTempex2.c\r\n");
/* Configure chans array */ chans[0] = 18; /* Shorted channel*/ chans[1] = 18; /* Shorted channel*/ chans[2] = 16; /* CJC channel */ chans[3] = 0; /* Thermocouple on channel 0 */ chans[4] = 1; /* Thermocouple on channel 1 */ chans[5] = 2; /* Thermocouple on channel 2 */ chans[6] = 3; /* Thermocouple on channel 3 */ chans[7] = 4; /* Thermocouple on channel 4 */ chans[8] = 5; /* Thermocouple on channel 5 */ chans[9] = 6; /* Thermocouple on channel 6 */ chans[10] = 7; /* Thermocouple on channel 7 */
/* Configure gains array */ gains[0] = TbkBiCJC; /* Bipolar CJC gain setting */ gains[1] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */ gains[2] = TbkBiCJC; /* Bipolar CJC gain setting */ gains[3] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */ gains[4] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */ gains[5] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */ gains[6] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */ gains[7] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */ gains[8] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */ gains[9] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */ gains[10] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */
/* Set the default mode of operation to differential bipolar */ tbkSetMode(1, 1);
/* Configure the scan sequencer, will use default polarity. */ tbkSetScan(chans, gains, 0, 11);
TempBook User’s Manual Standard API Programming of the TempBook with C 6-15
/* Set the pacer clock for a 1 msec period */ tbkSetFreq(1000);
/* Configure for pacer clock trigger, continuous mode. */ tbkSetTrig(TtsPacerClock, 0, 0, 0);
/* Tell tbkTC.. functions to use zero correction */ tbkTCAutoZero(1);
/* Read 100 scans of ADC data */ tbkRdNFore(data, 100);
/* Reset the trigger to prevent a buffer overrun */ tbkSetTrig(TtsSoftware, 1, 0, 0);
/* Configure and Perform Thermocouple Linearization with block averaging */ tbkTCSetup(11, 2, 8, TbkTypeJ, 1, 0); tbkTCConvert(data, 100, temp, 8);
/* The converted temperatures can now be printed to the screen */ sprintf(tempstr,"\r\nThermocouple temperatures: Channels 0 through 7\r\n\r\n"); strcat(response,tempstr);
for (i=0 ; i<8 ; i++) { sprintf(tempstr,"%8.1f ", (float)temp[i] / 10.0); strcat(response,tempstr); } sprintf(tempstr,"\r\n"); strcat(response,tempstr);
SendDlgItemMessage(myDlg, 101, WM_SETTEXT, 0, (LONG)(LPSTR)response); EmptyMessageQueue(myDlg); }
6-16 Standard API Programming of the TempBook with C TempBook User’s Manual

Command Summary, C Language (Standard API)

Command Description
Initialization, Communication and Error Handling:
tbkInit (uint lptPort, uchar lptIntr)
tbkSelectPort (uint lptPort) tbkClose (void) tbkSetErrHandler (tbkErrorHandlerFPT
tbkErrHandler) tbkDefaultHandler (int tbkErrnum) tbkGetProtocol (int *protocol) tbkSetProtocol (int protocol)
Separate Scan Sequence, Pacer Clock and Trigger Commands:
tbkSoftTrig (void) tbkSetFreq (float freq) tbkGetFreq (float _far *freq) tbkSetClk (uint ctr1, uint ctr2) tbkSetMode (uchar di_se, uchar polarity) tbkSetMux (uint startChan, uint endChan, uchar
gain) tbkGetScan (uint *chans, uchar *gains, uchar
*polarity, uint *count)
Digital I/O and Counter/Timer Functions:
tbkSetScan (uint *chans, uchar *gains, uchar
*polarity, uint count) tbkSetTrig (uchar trigger, uchar oneShot, uchar
ctr0mode, uchar pacerMode)
Separate Data Read and Background Transfer Commands:
tbkRdFore (uint _far *sample)
tbkRdNFore (uint _far *buf, uint count) tbkRdNBack (uint _far *buf, uint count, uchar
cycle, uchar updateSingle) tbkGetBackStat (uchar _far *active, uint long
_far *count) tbkStopBack (void)
Data Read Commands with Combined Scan Sequencer, Pacer Clock and Trigger Setup and Thermocouple
Linearization:
tbkRd (uint chan, uint *sample, uchar gain) tbkRdN (uint chan, uint *buf, uint count, uchar
trigger, uchar oneShot, float uchar gain) tbkRdScan (uint startChan, uint endChan, uint
*buf, uchar gain) tbkRdScanN (uint startChan, uint endChan, uint
*buf, uint count, uchar trigger, uchar oneShot,
float freq, uchar gain) tbkRdTemp (uint chan, uint tcType, int temp)
tbkRdTempN (uint chan, uint tcType, uint count,
int *temp, uint *buf, float freq, uint avg) tbkRdTempScan (uint startChan, uint endChan, uint
tcType, int temp) tbkRdTempScanN (uint startChan, uint endChan,
uint tcType, uint count, int *temp, uint *buf,
float freq, uint avg)
Thermocouple Linearization Commands:
tbkTCSetup (uint nscan, uint cjcPosition, uint
ntc, uint tcType, uchar bipolar, uint avg) tbkTCConvert (uint _far *counts, uint scans, int
_far *temp, uint ntemp) tbkTCSetupConvert (uint nscan, uint cjcPosition,
uint ntc, uint tcType, uchar bipolar, uint avg,
uint _far *counts, uint scans, int *far *temp,
uint ntemp) tbkTCAutoZero (uint zero)
Establish communication with the TempB ook at the specified LPT
port and interrupt Select an initialized Tem pB ook as the current TempBook End communicat i on with t he TempBook Specify a user-defined routine to call when error occurs
Default error handling routine Get the current parallel port communication protocol Set the parallel port com munication protocol
Issue a software trigger to the TempBook Set the pacer clock f requency Read the pacer clock frequency Set the pacer clock f requency divider registers Specify input signal t ype (s i ngl e-ended or differential) Setup the scan sequencer for a range of channels at the sam e
gain Read the scan sequencer content s
Setup the scan sequencer with specific channels, gai ns, and
polarities Set the trigger source for analog data acquisition
Read a single ADC sample in t he foreground and increment the
scan sequencer Read multiple scans i n the foreground Read multiple scans i n t he background using interrupts
Determine is a background transfer is still in progress Stop the background transfer
Read a single sample from the specified channel Read multiple sampl es from the specif i ed channel
Read a single sample from the specified range of channel s Read multiple sampl es from the specif i ed range of channels
Read the thermocouple temperature once from the spec i fied
channel Read the thermocouple temperature from the specified channel
multiple tim es with optional averaging Read the thermocouple temperature once from each channel i n a
range Read the thermocouple temperature from each channel in a range
multiple tim es using optional averaging
Specify scan information used by tbkTCConvert Perform thermocoupl e l i nearization on scan data Combined tbkTCSetup and t bkTCConvert
Tell the thermocouple lineari zat i on functions that auto zeroing will
be used
TempBook User’s Manual Standard API Programming of the TempBook with C 6-17
Software Calibration and Zero Compensation Commands:
tbkReadCalFile (char *calfile) tbkCalSetup (uint nscan, uint readingsPos, uint
nReadings, uint chanType, uint chanGain, uint
bipolar, uint noOffset) tbkCalConvert (uint *counts, uint scans) tbkCalSetupConvert (uint nscan, uint readingsPos,
uint nReadings, uint chanType, uint chanGain,
uint bipolar, uint noOffset, uint *counts, uint
scans) tbkZeroSetup (uint nscan, uint zeroPos, uint
readingsPos, uint nReadings) tbkZeroConvert (uint *counts, uint scans) tbkZeroSetupConvert (uint nscan, uint zeroPos,
uint readingsPos, uint nReadings, uint *counts,
uint scans) tbkConfCntr0 (uchar config) tbkWtCntr0 (uint cntr0) tbkRdCntr0 (uint _far *cntr0, uchar mode) tbkRdBit (uchar bitNum, uchar *bitVal) tbkRdByte (uchar *byteVal) tbkWtBit (uchar bitNum, uchar bitVal) tbkWtByte (uchar byteVal)
Pretrigger Operation Commands:
tbkSetTrigPreT (uchar source, uint channels, uint
level, uint preCount, uint postCount) tbkRdNForePreT (uint _far *buf, uint count, uint
_far *retcount, uchar _far active) tbkRdNForePreTWait (uint _far *buf, uint count,
uint _far *retcount) tbkRdNBackPreT (uint _far *buf, uint count, uchar
cycle)
Read the calibration constants text file Specify scan information used by tbkCalConvert
Perform software calibrat i on on scan data Combined tbkCalSetup and t bkCalConvert
Specify scan information used by tbkZeroConvert function Perform zero compens ation on scan data
Combined tbkZeroSetup and tb kZeroConvert
Set the operating mode of t he counter/timer Write a value to t he counter/timer count down register Read the counter/timer hol d regi ster Read a specific digital i nput bit Read all digital inputs Write to a specific digital output bi t Write to all di gi tal outputs
Setup the trigger source and level for a pretrigger operation Read multiple scans f or a pretrigger operation in the foreground Read multiple scans f or a pretrigger operation in the foreground
continuing until the trigger event occurs
Read multiple scans f or a pretrigger operation in the background
6-18 Standard API Programming of the TempBook with C TempBook User’s Manual
Software Calibration and Zero Compensation
Note: The enhanced API commands do not work exactly like the standard API commands used in this chapter.
This section describes how to use the TempBook's software calibration and zero compensation functions to correct for gain and offset errors. To use the calibration constants shipped with the board, DaqView users should follow the instructions given on the calibration document containing these constants. The program will automatically use these constants.
Programmers wishing to use the TempBook’s thermocouple linearization functions with auto-zero compensation (rather than calling the zero compensation functions manually) should refer to the Thermocouple Linearization chapter of this manual.
Both software calibration and zero compensation increase the accuracy of the TempBook and its expansion cards by correcting for gain and offset errors. For example, when using a TempBook with software calibration, accuracy better than 1°C can be achieved. The calibration operation removes static gain and offset errors that are inherent in the hardware. This operation uses calibration constants, usually measured at the factory, to adjust for gain and optionally offset errors. The calibration constants do not change during the execution of a program but are different for each card and programmable gain setting.
Zero compensation removes offset errors while a program is running. This is useful in systems where the offset of a channel may change due to temperature changes, long-term drift or hardware calibration changes. By reading a shorted channel on the same card at the same gain as the desired channel, the offset can be removed at run-t ime. Note: The TempBook has channel 18 permanently shorted for performing zero compensation.
7

Software Calibration

Software calibration functions are designed to adjust TempBook readings to compensate for gain and offset errors. Calibration constants are calculated at the factory by measuring the gain and offset errors of a card at each programmable gain setting. These constants are stored in a calibration text file which can be read by a program at runtime. This allows new boards to be configured for calibration by updating this calibration file rather than re-compiling the program.
The calibration process is divided up into three steps:
Initialization consists of reading the calibration file.
Setup describes the characteristics of the data to be calibrated.
Conversion does the actual calibration of the data. All of the functions prototypes, return error codes and definitions are located in the TempBook.H header file (C language) or similar header file (other languages).

Initializing the Calibration Constants

Each TempBook is shipped with a disk containing a calibration constants file. The file is named serial_no.cal where serial _no is the serial number of the TempBook for which the constants were generated. This file should be copied into the directory from which the user’s program will be run. For convenience, this file can be renamed tempbook.cal which is the default calibration filename.
The initialization function for reading in the calibration constants from the calibration text file is
tbkReadCalFile
and operates as follows:
int tbkReadCalFile(char_*calfile)
char_*calfile
. The C language version of
calfile contains t he path (optional) and filename of t he calibration file. If calfile is NULL
or empty (""), the default calibration f ile TempBook.CAL will be read.
tbkReadCalFile
is similar to that o f other languages
This function, which is usually called once at the beginning of a program, will read all the calibration constants from the specified file. If calibration constants for a specific channel number and gain setting are not contained in the file, ideal calibration constants will be used—essentially performing no calibration for that channel. If an error occurs while trying to open the calibration file, ideal calibration constants will be used for all channels and a non-zero error code will be returned by the
TempBook User’s Manual Software Calibration and Zero Compensati on 7-1
tbkReadCalFile
function.

Calibration Setup and Conversion

Once the cal constants have been read from the cal file, they can be used by the
tbkCalConvert
calibrated. This function requires all data to be calibrated to be from consecutive channels configured for the same gain, polarity and channel type. The calibration can be configured to use only the gain calibration constant and not the offset constant. This allows the offset to be removed at runtime using the zero compensation functions described later in this chapter.
int tbkCalSetup ()
uint nscan uint readingsPos uint nReadings uint chanType
uint chanGain uint bipolar uint noOffset
tbkCalConvert
The previously called
int tbkCalConvert ()
uint *counts uint scans
For convenience, both the setup and convert steps can be performed with one call to
tbkCalSetupConvert
because data was read from channels at different gains.
int tbkCalSetupConvert ()
uint nscan uint readingsPos uint nReadings uint chanType
uint chanGain uint bipolar uint noOffset uint *counts uint scans
functions. The
tbkCalSetup
tbkCalSetup
tbkCalSetup
The number of readings in a single s can. The position of the readings to be c al i brated within the scan. The number of readings to calibrat e. The type of channel from which the readings to be calibrated are read. This
should be set to 1 when calibrating a CJC channel and 0 when reading any
other channel. The gain setting of the channels to be calibrated. Non-zero if the TempBook is configured for bipolar readings. If non-zero, the offset cal c onstant will not be used to calibrate the readings.
function will configure the order and type of data to be
and
function performs the actual calibration of one or more scans according to the
function. This function will modify the array of data passed to it.
The raw data from one or more scans. The number of scans of raw data in t he counts array.
. This is useful when the calibration needs to be performed multiple times
The number of readings in a single s can. The position of the readings to be c al i brated within the scan. The number of readings to calibrat e. The type of channel/board from which the readi ngs to be calibrated are read.
This should be set to 1 when calibrati ng a CJC channel and 0 when reading
any other channel. The gain setting of the channels to be calibrated. Non-zero if the TempBook is configured for bipolar readings. If non-zero, the offset cal c onstant will not be used to calibrate the readings. The raw data from one or more scans. The number of scans of raw data in t he counts array.

Calibration Example

In this example, several TempBook channels will be read and calibrated. This example assumes that the calibration file has been created according to the initializing calibration constants section of this chapter.
Although all of the channe l s i n t his example are read at the same gain, the same principles apply to calibration of channel readings at different gains. In that situation, channels to be read are grouped by gain within the scan sequence. Then,
tbkCalSetup
would be called once for each group of channels at a particular gain.
void main(void) {
unsigned sample, buf[10], data[8];
int i, scan, chan;
printf(“/nAdcex4.c/n”);
/* Set error handler and initialize TempBook*/ tbkSetErrHandler(myhandler); tbkInit(LPT1, 7);
7-2 Software Calibration and Zero Compensati on TempBook User’s Manual
tbkCalConvert
and
tbkCalSetupConvert
(or
)
/*Read the calibration constants from the calibration constant text file assuming the default name tempbook.cal*/
tbkReadCalFile(“”);
/* Set the default operating mode to differential, bipolar */
tbkSetMode(1,1);
/* Get 1 sample from channels 0 through 7 at unity gain */
tbkRdScan(0, 7, data, TgainX1);
/* Print the uncalibrated samples using a 12-bit format */ printf(/nUncalibrated Results of tbkRdScan:/n); for(i=0; i<8; i++)
printf(Channel: %2d Data: %4d/n, i, data[i]>4);
/* Setup and perform offset and gain software calibration of data */ tbkCalSetup(8, /* 8 readings within a scan */
0, /* First reading to be cal’d at position 0 */ 8, /* Calibrate 8 readings per scan */ 0, /* Channel type is 0 for non-CJC */ TgainX1 /* Reading taken at X1 gain */ 1, /* Readings are bipolar */
0); /* Perform zero as well as gain calibration */
tbkCalConvert (data, /*Pointer to array of readings */
1); /* 1 scan in that array */
/* Print the calibrated samples using a 12-bit format */ printf(/nCalibrated Results of tbkRdScan:/n); for(i=0; i<8; i++)
printf(Channel: %2d Data: %4d/n, i, data[i]>4);
/* Close and exit */ tbkClose }

Zero Compensation

The zero compensation functions require a shorted channel to be sampled at the same gain as the channels to be compensated.
The
tbkZeroSetup
within a scan, the size of the scan and the number of readings to zero. This function does not do the conversion. A non-zero return value indicates an invalid parameter error.
int tbkZeroSetup ()
uint nscan uint zeroPosition uint
readingsPosition
uint nReadings
The
tbkZeroConvert
tbkZeroSetup function
int tbkZeroConvert ()
uint *counts uint scans
function configures the location of the shorted channel and the channels to be zeroed
The number of readings in a single s can. The position of the zero reading within the scan. The position of the readings to be zeroed within the scan.
The number of readings per scan to be zero compensate.
function compensates one or more scans according the previously called
. This function will modify the array of data passed to it.
The raw data from one or more scans. The number of scans of raw data in t he counts array.
For convenience, both the setup and convert steps can be performed with one call to
tbkZeroSetupConvert
. This is useful when the zero compensation needs to be performed multiple
times because data was read from channels at different gains.
TempBook User’s Manual Software Calibration and Zero Compensati on 7-3
int tbkZeroSetupConvert ()
uint nscan uint zeroPosition uint
readingsPosition uint nReadings uint *counts uint scans

Zero Compensation Example

In this example, several TempB ook channels will be read and zero compensated. Although all of the channels in this example are read at the same gain, the same principles apply to calibration of channel readings at different gains. In that situation, channels to be read are grouped by gain within the scan sequence. Also within the scan sequence, the TempBook’s internal shorted channel would be read once at each gain used for channel measurement. Then,
tbkZeroSetupConvert
sure that the corresponding shorted channel reading for that gain is passed.
void main(void) {
unsigned int data[9], chans[9], i; unsigned char gains[9], polarities[9]; printf(/nAdcex5.c/n);
/* Initialize the channels, gains, and polarities arrays*/ chans[0] = 18; /* Shorted channel */ gains[0] = TgainX1 /* Same gain as analog input channels */ polarities[0] = 1; /* Bipolar */
for(i=0; i<8; i++) { chans[i] = i-1; /* Analog input channels 0 - 7 */ gains[i] = TgainX1 /* Unity gain */ polarities[i] = 1; /* Bipolar */ }
The number of readings in a single s can. The position of the zero reading within the scan. The position of the readings to be zeroed.
The number of readings per scan to be zero compensated. The raw data from one or more scans. The number of scans of raw data in t he counts array.
tbkZeroSetup
and
tbkZeroConvert
(or
) would be called once for each group of channels at a particular gain making
/*Set error handler and initialize TempBook */ tbkSetErrHandler(myhandler); tbkInit(LPT1, 7);
/* Set the default operating mode to differential, bipolar */
tbkSetMode(1,1);
/* Set the scan sequencer */
tbkSetScan(chans, gains, polarities, 9);
/* Configure trigger source and issue software trigger */ tbkSetTrig(TtsSoftware, 1, 0, 0); tbkSoftTrig();
/* Read the ADC data */ tbkRdNFore(data, 1);
/* Print the uncompensated samples using a 12-bit format.*/ printf(/nResults of tbkRdNFore before zero compensation:/n); for(i=0; i<8; i++)
printf(Channel: %2d Data: %4d/n, i, data[i]>4);
/* Setup and perform zero compensation of the data */ tbkZeroSetup(9, /* 9 readings within a scan */
0, /* Shorted channel at position 0 */ 1, /* First reading to be compensated at position 1 */ 8, /* Compensate 8 readings per scan */
tbkZeroConvert(data, /*Pointer to array of readings */
1); /* 1 scan in that array */
7-4 Software Calibration and Zero Compensati on TempBook User’s Manual
/* Print the compensated samples using a 12-bit format */ printf(/nResults of tbkRdNFore after zero compensation:/n); for(i=0; i<8; i++)
printf(Channel: %2d Data: %4d/n, i, data[i]>4);
/* Close and exit */ tbkClose }

Automatic Zero Compensation

The
tbkTCAutoZero
perform zero compensation. This is the easiest way to use zero compensation when making thermocouple measurements. When enabled, the thermocouple conversion functions will require a CJC zero reading and a TC zero reading to precede the actual CJC and TC reading.
int tbkTCAutoZero ()
uint zero
: See the thermocouple linearization section for a description and example of automatic zero
Note
compensation for thermocouple measurement.
function will configure the thermocouple linearization functions to automatically
If non-zero, will enable auto zero compensation in the tbkTC... functions
TempBook User’s Manual Software Calibration and Zero Compensati on 7-5
Notesc
7-6 Software Calibration and Zero Compensati on TempBook User’s Manual
Thermocouple Measurement
Note: The enhanced API commands do not work exactly like the standard API commands used in this chapter.
The TempBook software includes two groups of functions for o btaining thermocouple temperatures:
Low-level data conversion functions provide thermocouple linearization for previously acquired ADC data. Functions include:
tbkTCAutoZero
High-level thermocouple measurement functions provide combined scan sequencer setup, triggering, data collection, and linearization. Functions include:
tbkRdTempScan, tbkRdTempScanN
tbkTCSetup, tbkTCConvert, tbkTCSetupConvert,
.
tbkRdTemp, tbkRdTempN,
. Both of theses function groups support types J, K, T, E, N28, N14, S, R and B thermocouples. The TempBook accepts thermocouple attachment on differential input channels 0 thr ough 7. In addition, the TempBook provides a cold-junction compensation circuit on channel 16 and a permanently shorted input on channel 18 for performing zero compensation.
Two software techniques can be used to increase the measurement accuracy: software calibration and zero compensation. Software calibration uses gain and offset calibration constants, unique to each unit, to compensate for inherent errors. Zero compensation is a method by which offset voltages in the input amplifier stages can be removed at run-time. This is done by measuring a shorted channel at the same gain as the signal measurement to find the offset, and subtracting this from the actual reading. Both of these methods are described in the Zero Compensation and Calibration chapter.
The thermocouple linearization functions have a special auto-zero compensation feature that will perform zero compensation on the raw thermocouple data before linearizing. This auto-zero feature is enabled by default but can be disabled using the
tbkTCAutoZero
function.
8

Low-Level Thermocouple Data Conversion Functions

The low-level thermocouple linearization functions are designed to convert ADC data which was collected in a specific scan sequence format.
When not using the auto-zero feature, the scan sequence should consist of a CJC reading followed by thermocouple readings. If different thermocouple types are being read, the readings should be grouped by type with a CJC reading preceding each group. The thermocouple linearization functions must then be called once for each thermocouple type.
When using the auto-zero feature, the scan sequence should consist of 2 shorted channel reading followed by the CJC and thermocouple readings. The first shorted channel reading should be taken at the CJC gain and the second at the thermocouple gain. If different thermocouple types are being read, the reading should be grouped by thermocouple type with two shorted channel and one CJC readings preceding each group. The thermocouple linearization functions must then be called once for each thermocouple type.
The scan is not restricted to thermocouple measurements. The scan may include other signals such as voltage or digital input. The linearization functions will ignore this other data within the scan group.
The gain settings for the CJC and thermocouple types depend on the bipolar/unipolar setting of the TempBook as specified in the table below. Note: Unipolar operations are not recommended for thermocouple measurement unless the temperatures to be measured are guaranteed to be greater than the TempBook temperature.
TempBook Gain Codes
Type Unipolar Gain Code Unipolar Gain Bipolar Gain Code Bipolar Gain
CJC J K T E N28 N14 S R B
TbkUniCJC TbkUniTypeJ TbkUniTypeK TbkUniTypeT TbkUniTypeE TbkUniTypeN28 TbkUniTypeN14 TbkUniTypeS TbkUniTypeR TbkUniTypeB
50 100 100 200 50 100 100 200 200 200
TbkBiCJC TbkBiTypeJ TbkBiTypeK TbkBiTypeT TbkBiTypeE TbkBiTypeN28 TbkBiTypeN14 TbkBiTypeS TbkBiTypeR TbkBiTypeB
100 200 200 200 100 200 200 200 200 200
TempBook User’s Manual Thermocouple Measurement 8-1
The low-level te mperature conversion functions take data from one or more scans from the TempBook. They examine the CJC and thermocouple readings within that scan and, after optional averaging, convert them to
Scan Reading
0 1 2 3 4 5
CJC Zero J Zero CJC J1a J1b J1c
1
CJC Zero J Zero CJC J2a J2b J2c
2
CJC Zero J Zero CJC J3a J3b J3c
3
CJC Zero J Zero CJC J4a J4b J4c
4
temperatures which are stored as output. For example, assume the readings in the table at right.
This shows that the first two readings of each scan are a CJC zero reading and a TC zero reading. The third reading is from the CJC, and the remaining three readings are from three type J thermocouples. If the auto­zero feature is not used, the first two readings will be ignored. Otherwise, they will be used to remove any offset errors in the CJC and thermocouple reading before proceeding. When not using averaging, the CJC readings are combined with the thermocouple readings to produce one temperature result for each thermocouple reading. Reducing the 24 original readings to 12 temperatures (see table at right).
Scan Result
0 1 2
J1a J1b J1c
1
J2a J2b J2c
2
J3a J3b J3c
3
J4a J4b J4c
4
The conversion process is divided into two steps: setup and conversion. The setup step describes the characteristics of the temperature measurement, and the conversion step actually converts the data from raw readings to temperatures. All of the functions return error codes which are defined in TempBook.H which includes the function prototypes and definitions of the thermocouple type codes.
The setup function is
tbkTCSetup
. The C-language version of
the other programming languages and is de scribed below. Note:
uchar
is short for
unsigned char
. Further details in Command Reference chapter.
tbkTCSetup
uint
is short for
is very similar to that of
unsigned int
tbkTCSetup( uint nscan, uint cjcPosition, uint ntc, uint tcType, uchar bipolar, uint avg)
uint nscan
uint cjcPosition
uint ntc
uint tcType
uchar bipolar uint avg
The number of readings in a single s can of TempBook data. The
functions can convert several consecutive scans worth of data in a single
invocation. Valid range: 2 to 512. The position of the actual cold-junction compens ation circuit (CJC) reading within
each scan (not the CJC zero reading, i f any). The first reading of the scan is
position 0, and the last readi ng i s position nscan-1. Each scan of temperature
data must include a reading of the CJC. The CJC readings m ust be taken with
the appropriate unipolar or bipolar CJC gain setting. Valid range: 0 to nscan-2 with no zero compensation; 2 to nscan-2 with zero
compensation. The number of thermocouple readi ngs that are to be converted to temperature
values. The thermocouple s ignal readings must immediately follow the CJ C
reading in the scan data. The first thermocouple signal i s at scan position
cjcPosition+1, t he next is at cjcPosition+2, and so on. Valid range: 1 to nscan-1-cjcPosition. The type of thermocouples that generated the measurement s: J, K, T, E, N28,
N14, S, R, or B. Valid range: One of the predefined values:
TbkTCTypeT, TbkTCTypeE, TbkTCTypeN28, TbkTCTypeN14,
TbkTCTypeS, TbkTCTypeR or TbkTCTypeB.
Non-zero if the TempBook is configured for bipolar readings. The type of averaging to be performed. Valid range: any unsigned integer. Note: Since the therm ocouple voltage may be sm al l compared to the ambient
electrical noise, averagi ng may sometimes be necessary to yield a steady
temperature output. 0 specifies block averagi ng i n which al l of the scans are averaged together to
compute a single temperature measurement for each of the ntemp
thermocouples. 1 specifies no averaging. Each scan's readings are convert ed i nto ntemp
measured temperatures for a total of scans*ntemp results. 2 or more specifies moving average of the specifi ed number of scans. Each
scan's readings are averaged with the avg-1 precedi ng scans' readings before
conversion. The first avg-1 s cans are averaged with all of the preceding scans
because they do not have enough preceding scans. For example, if avg is 3,
then the results from the first scan are not averaged at all, the results f rom the
second scan are averaged with the first scan, the results from the third and
subsequent scans are averaged with the prec edi ng two scans as shown in the
next table.
TbkTCTypeJ, TbkTCTypeK,
, and
tbkTC
8-2 Thermocouple Measurement TempBook User’s Manual
Scan Readings from Channel Resul ts from Channel
11A 2A 1A 2A 2 1B 2B (1A+1B)/2 (2A+2B)/2 3 1C 2C (1A+1B+1C)/3 (2A+2B+2C)/3 4 1D 2D (1B+1C+1D)/3 (2B+2C+2D)/3 5 1E 2E (1C+1D+1E)/3 (2C+2D+2E)/3 6 1F 2F (1D+1E+1F)/3 (2D+2E+2F)/3
0 1 0 1
The conver s ion function is
tbkTCConvert
: (Note: Further details in Command Reference chapter.)
tbkTCConvert( uint *counts, uint scans, int *temp, uint ntemp)
uint *counts
uint scans
int *temp
uint ntemp
For convenience both setup and conversion can be performed at once by
A array of one or more scans of raw data as received from the TempBook. The ADC
data bits are in the 12 mos t significant bits of the 16-bit integers. Valid range: Each raw data item may be any 16-bit value. The number of scans of data i n counts. Valid range: 1 to 32768/nscan (c ounts is limit ed t o 64 Kbytes) The converted temperature result s. The integer values are 10 tim es the temperatures
in degrees C; e.g., 50°C would be represented as 500 and -10 °C would be -100. Valid range: Results range from -2000 (-200°C) to +13720 (+1372°C) depending on the
thermocouple type. The number of entries in the t emp array. This is checked by the functions to avoid
writing past the end of the tem p array. Valid range: If avg is 0, t hen ntc or greater. If avg is non-zero, then scans * ntc or greater.
tbkTCSetupConvert
: (Note:
Further details in Command Reference chapter.)
tbkTCSetupConvert(uint nscan, uint cjcPosition, uint ntc, uint tcType, uchar bipolar, uint avg, uint *counts, uint scans, int *temp, uint ntemp)
The auto-zero feature can be enabled disabled using the
tbkTCAutoZero
function: (Note: Further details
in Command Reference chapter.)
tbkTCAutoZero (uint zero)
uint zero
Non-zero to enable auto-zeroing; zero (0) to disable auto-zeroing.
Note: see the tempex2 example programs in the i ndividual language support chapters fore examples of using these functions.

High-Level Thermocouple Measurement Functions

The high-level thermocouple measurement functions are designed to provide combined scan sequencer setup, triggering, data collection, and linearization. There are 4 functions in this group:
tbkRdTemp tbkRdTempN tbkRdTempScan tbkRdTempScanN
Note: see tempex1 sample programs using these func tions in the individ ual language-support chapters.
Single-Channel Measurement (
tbkRdTemp
The analog input channel. This function also collects CJC and shorted channel readings for linearization and zero compensation. The CJC and thermocouple readings are then zero compensated and the thermocouple reading is linearized. The converted temperature is placed in a variable supplied by the calling program. (Note: Further details in Command Reference chapter.)
tbkRdTemp (uint chan, uint tcType, int *temp)
uint chan uint tcType int*temp
TempBook User’s Manual Thermocouple Measurement 8-3
Read a single thermocouple channel once. Read a single thermocouple channel multiple times. Read a range of thermocouple channels once. Read a range of thermocouple channels multiple times.
tbkRdTemp
)
function uses software triggering to immediately acquire one sample from the specified
The channel number to which the therm ocouple is attached. The type of thermocouple attached. A variable in which to store the measured temperature

Multiple Measurements from a Single Channel (tbkRdTempN)

The
tbkRdTempN
analog input channel and CJC and shorted channel readings for linearization and zero compensation. The CJC and thermocouple readings are zero compensated and the thermocouple readings are linearized. The converted temperatures are placed in an array supplied by the calling program. If block averaging is used, a single temperature is returned; otherwise, a number of temperatures equal to the number of scans specified are returned.
tbkRdTempN( uint chan, uchar tcType, uint count, int * temp, uint * buf, float freq, uint avg )
uint chan uint tcType uint count int *temp uint* buf float freq uint avg
function uses pacer clock triggering to acquire multiple samples from the specified
: Further details in Command Reference chapter.)
(Note
The channel number to which the therm ocouple is attached. The type of thermocouple attached. The number of scans to read. A variable in which to store the measured temperature. An array for the temporary storage of raw scan data (must be at least 4*count in length). The scan interval frequency. Type of averaging to be used. 0 - block averaging 1 - no averaging 2 - moving averaging

Multiple-Channel Measurement (tbkRdTempScan)

The
tbkRdTempScan
specified range of analog input channels. All of these channels must be of the same thermocouple type,. This function also collects CJC and shorted channel readings for linearization and zero compensation. The CJC and thermocouple readings are then zero compensated and the thermocouple readings are linearized. The converted temperatures are then placed in an array supplied by the calling program. details in Command Reference chapter.)
tbkRdTempScan(uint startChan, uint endChan, uchar tcType, int * temp)
uint startchan uint endChan uint tcType int *temp
function uses software t riggering to immediately acquire one sample from the
The starting channel number of t he range of thermocouple channels to read. The ending channel number of the range of thermocouple channels to read. The type of thermocouple attached. An array in which to store the measured temperatures (must be at least endChan ­startChan + 1 in length).
(Note
: Further

Multiple Measurements from Multiple Channels (tbkRdTempScanN)

The
tbkRdTempScanN
specified range of analog input channels. All of these channels must be of the same thermocouple type. This function also collects CJC and shorted channel readings for linearization and zero compensation. The CJC and thermocouple readings are then zero compensated and the thermocouple readings are linearized. The converted temperatures are placed in an array supplied by the calling program. If block averaging is specified, then a single temperature is returned for each channel; otherwise, a number of temperatures equal to the number of scans time the number of channels specified are returned. Command Reference chapter.)
tbkRdTempScanN(uint startChan, uint endChan, uchar tcType, uint count, int * temp, uint * buf, float freq, uint avg)
uint startchan uint endChan uint tcType uint count int *temp uint *buf
float freq uint avg
8-4 Thermocouple Measurement TempBook User’s Manual
function uses pacer clock triggering to acquire multiple samples from the
: Further details in
(Note
The starting channel number of t he range of thermocouple channels to read. The ending channel number of the range of thermocouple channels to read. The type of thermocouple attached. The number of scans to read. A variable in which to store the measured temperature. An array for the temporary storage of raw scan data (must be at l east [endChan ­startChan + 4] *count in length). The scan interval frequency. Type of averaging to be used. 0 - block averaging 1 - no averaging 2 - moving averaging
tbkCommand Reference (Standard API)

Overview

The first part of this chapter describes the TemBook/66 driver commands (this is the Standard API and is not to be confused with the Enhanced API). The first table lists the commands by their function types as defined in the driver header files. Then, the prototype commands are described in alphabetical order as indexed below. At the end of the chapter (beginning on page 9-32), several reference tables define parameters for: A/D Channel Descriptions, A/D Gain Definitions, A/D Trigger Source Definitions, Pre­Trigger Functions, Thermocouple Types, and the API Error Codes.
These TempBook software commands are described on the following pages:
Function Description Page
High- and Low-Level A/D Functions
tbkConfCntr0 tbkGetBackStat tbkGetFreq tbkGetScan tbkRd tbkRdCntr0 tbkRdFore tbkRdN tbkRdNBack tbkRdNBackPreT
tbkRdNFore tbkRdNForePreT
tbkRdNForePreTWait
tbkRdScan tbkRdScanN tbkRdTemp tbkRdTempN tbkSetMode tbkRdTempScan
tbkRdTempScanN
tbkSetClk tbkSetFreq tbkSetMux tbkSetScan tbkSetTrig tbkSetTrigPreT
tbkSoftTrig tbkStopBack tbkWtCntr0
Digital I/O Functions
tbkRdBit tbkRdByte tbkWtBit tbkWtByte
Thermocouple Functions
tbkTCConvert tbkTCSetup tbkTCSetupConvert
Configure the counter 0 mode 9-5 Read the status of a back ground A/D transfer 9-6 Read the current pacer clock frequency 9-6 Read the current scan configuration 9-7 Configure an A/D acquisiti on and read one sample from a channel 9-8 Read the current value of the counter 0 9-9 Read a single A/D sample and i ncrement the channel m ux 9-10 Configure an A/D acquisiti on and read multiple scans f rom a channel 9-10 Read count A/D scans in the background using interrupts 9-11 Reads multiple A/ D scans, initiated by the background Read count A/D samples in the foreground (polled mode) 9-12 Read multiple A/D s cans, initiated by in the foreground Read multiple A/D s cans, initiated by in the foreground without returning until the acquisition comple t es Configure an A/D acquisiti on and read one scan 9-14 Configure an A/D acquisiti on and read multiple scans 9-15 Take a single thermocouple readi ng from the given analog input channel 9-15 Take multiple thermocouple readings from the gi ven anal og i nput channel 9-16 Configure gain amp single-/di f ferential and polarity modes 9-21 Take thermocouple readings f rom analog input channels 'startChan' through 'endChan" Take multiple thermocouple readings from analog input channels 'startChan' through 'endChan" Set the pacer clock counters 9-20 Configure the pacer clock frequency in Hz 9-21 Configure a scan specifyi ng start and end channels 9-22 Configure up to 512 channels mak i ng up an A/D or HS digital input scan 9-24 Configure an A/D trigger 9-25 Set the trigger of analog level tri ggeri ng & initiates the coll ection of pre­trigger data acquisition Send a software trigger command to the TempBook 9-27 Stop a background A/D transfer 9-27 Write a value to c ounter 0 9-30
Read a bit on a digital input port 9-9 Read a byte from a digital input port 9-9 Program a bit on a digital output port 9-29 Output a byte to a digital output port 9-30
Convert raw A/D readings to temperature readi ngs 9-28 Set up parameters for subsequent temperature conversions 9-28 Set up and convert raw A/D readings into t emperature readings 9-29
tbkAdcSetrigPreT
tbkAdcSetTrigPretT
tbkAdcSetTrigPretT
command, in
command, command,
9
9-12
9-13 9-14
9-17 9-18
9-26
TempBook User’s Manual tbkCommand Referenc e (
Standard
API) 9-1
Software Calibration and Zero Compensation Functions
tbkTCAutoZero
tbkCalConvert tbkCalSetup tbkCalSetupConvert tbkReadCalFile tbkTCConvert tbkTCSetup tbkTCSetupConvert
Configure the thermocouple li neari zat i on functions to autom at i cally perform zero compensation Perform the actual c alibration of one or more scans 9-3 Configure the order and type of data to be cali brat ed 9-3 Perform both the setup and convert steps with one call 9-4 Read all the calibration constants from the specified file 9-19 Performs zero com pensation on one or more scans 9-28 Configure data for zero compensation 9-28 Perform both the setup and convert steps with one call 9-29
General Functions
tbkClose tbkGetProtocol tbkInit tbkSelectPort tbkSetErrHandler tbkSetProtocol
tbkDefaultHandler
End communicat i on with t he TempBook 9-4 Returns the current parallel port communications protocol 9-7 Initialize a single TempB ook 9-8 Select an initialized Tem pBook/66 as the current Tem pBook 9-19 Sets the handler that will be executed upon an error condition 9-20 Specifies the type of paral l el -port i mplementation and protocol available on the computer
9-27
9-23
9-6

Commands in Alphabetical Order

The following pages give the details for each TempBook/66 command listed in alphabetical order. Each section starts with a table that summarizes the main features of the command. An explanation follows (and in some cases a programming example or related information).
9-2 tbkCommand Referenc e (
Standard
API) TempBook User’s Manual
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uint *counts uint scans
Returns
See Also Program References
DLL Function
C
QuickBASIC
Visual Basic
Turbo Pascal
Parameters
uint nscan uint readingsPos uint nReadings uint chanType
uint chanGain uint bipolar uint noOffset
Returns
See Also Program References
tbkCalConvert
tbkCalConvert(uint *counts, uint scans); tbkCalConvert(unsigned *counts, unsigned scans); BtbkCalConvert%(counts%, ByVal scans%) VBtbkCalConvert% (counts%(), ByVal scans%) ftbkCalConvert( counts:WordP; scans:word):integer;
The raw data from one or more scans. The number of scans of raw data in t he counts array.
TerrZCInvParam TerrNoError tbkReadCalFile, tbkCalSetup, tbkCalSetupConvert
None
The
tbkCalConvert
the previously called
- Invalid parameter value
- No error
function performs the actual calibration of one or more scans according to
tbkCalSetup
function. This function will modify the array of data passed to it. See the Software Calibration and Zero Compensation chapter for a complete description of calibration.
tbkCalSetup
tbkCalSetup(uint nscan, uint readingsPos, uint nReadings, uint chanType, uint chanGain, uint bipolar, uint noOffset); tbkCalSetup(unsigned nscan, unsigned readingsPos, unsigned nReadings, unsigned chanType, unsigned chanGain, unsigned bipolar, unsigned noOffset); BtbkCalSetup%(ByVal nscan%, ByVal readingsPos%, ByVal nReadings%, ByVal chanType%, ByVal chanGain%, ByVal bipolar%, ByVal noOffset%) VBtbkCalSetup% (ByVal nscan%, ByVal readingsPos%, ByVal nReadings%, ByVal chanType%, ByVal chanGain%, ByVal bipolar%, ByVal noOffset%) tbkCalSetup(nscan:word;readingsPos:byte;nReadings:byte;chanType:word;chanGai n:word;:word;noOffset:word):integer;
The number of readings in a single s can. The position of the readings to be c al i brated within the scan. The number of readings to calibrat e. The type of channel from which the readings to be calibrated are read. This should be set to 1 when
calibrating a CJC channel and 0 when calibrat i ng any other channel. The gain setting of the channels to be calibrated. Non-zero if the readings are bipolar. If non-zero, the offset cal c onstant will not be used to calibrate the readings.
TerrZCInvParam TerrNoError tbkReadCalFile, tbkCalConvert, tbkCalSetupConvert
None
The
tbkCalSetup
function requires all data to be calibrated to be from channels configured for the same gain, polarity and channel type. The calibration can be configured to only use the gain calibration constant and not the offset constant. This allows the offset to be removed at runtime using the zero compensation functions. See the Software Calibration and Zero Compensation chapter for a complete description of calibration.
- Invalid parameter value
- No error
function will configure the order and type of data to be calibrated. This
TempBook User’s Manual tbkCommand Reference (
Standard
API) 9-3
tbkCalSetupConvert
DLL Function
C
QuickBASIC
Visual Basic
Turbo Pascal
Parameters
uint nscan uint readingsPos uint nReadings uint chanType
uint chanGain uint bipolar uint noOffset uint *counts uint scans
Returns
See Also Program References
For convenience, both the setup and convert steps can be performed with one call to
tbkCalSetupConvert
because data was read at different gains or polarities. See the Software Calibration and Zero Compensation chapter for a complete description of calibration.
tbkCalSetupConvert(uint nscan, uint readingsPos, uint nReadings, uint chanType, uint chanGain, uint bipolar, uint noOffset, uint *counts, uint scans); tbkCalSetupConvert(unsigned nscan, unsigned readingsPos, unsigned nReadings, unsigned chanType, unsigned chanGain, unsigned bipolar, unsigned noOffset, unsigned *counts, unsigned scans); BtbkCalSetupConvert% (ByVal nscan%, ByVal readingsPos%, ByVal nReadings%, ByVal chanType%, ByVal chanGain%, ByVal bipolar%, ByVal noOffset%, counts%, ByVal scans%) VBtbkCalSetupConvert% (ByVal nscan%, ByVal readingsPos%, ByVal nReadings%, ByVal chanType%, ByVal chanGain%, ByVal bipolar%, ByVal noOffset%, counts%(), ByVal scans%) tbkCalSetupConvert(nscan:word;readingsPos:byte;nReadings:byte; chanType:word;chanGain:word;bipolar:word; noOffset:word;counts:WordP;scans:word):integer;
The number of readings in a single s can. The position of the readings to be c al i brated within the scan. The number of readings to calibrat e. The type of channel from which the readings to be calibrated are read. This should be set to 1 when
calibrating a CJC channel and 0 when calibrat i ng any other channel. The gain setting of the channels to be calibrated. Non-zero if the readings are bipolar. If non-zero, the offset cal c onstant will not be used to calibrate the readings. The raw data from one or more scans. The number of scans of raw data in t he counts array.
TerrZCInvParam TerrNoError tbkReadCalFile, tbkCalSetup, tbkCalConvert
None
- Invalid parameter value
- No error
. This is useful when the calibration needs to be performed multiple times
tbkClose
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters Returns See Also Program References
tbkClose tbkInit
9-4 tbkCommand Referenc e (
int tbkClose(void) tbkClose(void); BtbkClose% () VBtbkClose% () tbkClose:integer;
None
TerrNoError tbkInit
- No error
is used to end communications with the TempBook/66. If
must be called b efore calling any other function.
Standard
API) TempBook User’s Manual
tbkClose
is called,
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uchar config
Returns See Also Program References
int tbkConfCntr0(uchar config); tbkConfCntr0(unsigned char config); BtbkConfCntr0% (ByVal config%) VBtbkConfCntr0% (ByVal config%) tbkConfCntr0( config:byte ):integer;
The configuration of Counter 0 (see tabl e bel ow for def i ni t i ons)
Description Value Note
Tc0cHighTermCnt 0x30 Tc0cOneShot 0x32 Tc0cDivByNCtr 0x34 Tc0cSquareWave 0x36 Tc0cSoftTrigStrobe 0x38 Tc0cHardTrigStrobe 0x3A
TerrNoError tbkWtCntr0, tbkRdCntr0, tbkSetTrig
None
- No error
High on terminal count Hardware retriggerable one-shot Rate Generator Square wave Software triggered strobe Hardware triggered strobe
tbkConfCntr0
tbkConfCntr0
programs the control register of Counter 0 in one of six modes. Counter 0 is a general purpose counter with input, gate and output lines. The input of counter 0 can be configured using the
ctr0mode
parameters of the
tbkSetTrig
command.
Mode 0, high on terminal count, is typically used to count events. After the initial count value (see
tbkWtCntr0
value at any time can be read using
) is set, the counter will decrement on each pulse of the Counter 0 input. The count
tbkRdCntr0
. Counter 0 output (pin 2 of P1), which is initially
low, will go high when the counter decrements to 0. Mode 1, hardware retriggerable one-shot, is used to generate a pulse following the occurrence of a
rising edge of the Counter 0 gate. The output, which is initially high, will go low after the hardware trigger is received until the count decrements to 0.
Mode 2, rate generator, acts as a divide-by-N counter. The output will be high until the counter
value decrements to 1, when the output goes low for 1 clock pulse before going high again.
Mode 3, square wave generator, is similar to mode 2 except for the duty-cycle. The output will be
high for half of the count value, and low for the other half. If the count value is odd, the output will remain high for the extra clock pulse.
Mode 4, software triggered strobe, will strobe each time the count value is loaded. The output is
initially high. After the count value is written and has decremented to 1, the output will go low for one clock pulse before going high agai n.
Mode 5, hardware triggered strobe, is similar to mode 4 except the strobe is initiated by a hardware
trigger (rising edge of Counter 0 gate).
TempBook User’s Manual tbkCommand Reference (
Standard
API) 9-5
tbkDefaultHandler
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
tbkErrnum
Returns See Also Program References
tbkDefaultHandler
the TempBook library is loaded, it invokes the default error handler whenever it encounters an error. The error handler may be changed with tbkSetErrHandler.
int tbkDefaultHandler( uchar tbkErrnum ); tbkDefaultHandler( int tbkErrnum ); BtbkDefaultHandler% (ByVal tbkErrnum%) VBtbkDefaultHandler% (tbkErrnum%) tbkDefaultHandler( tbkErrnum:integer );
The error code of the detected error. Nothing
tbkSetErrHandler
None
tbkGetBackStat
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uchar *active ulong *count
Returns
See Also Program References
tbkGetBackStat
number of bytes acquired by the last or current background operation initiated by the function.
int tbkGetBackStat(uchar *active, ulong *count); tbkGetBackStat(unsigned char _far *active, unsigned long _far *count); BtbkGetBackStat%(active%, count&) VBtbkGetBackStat% (active%, count&) tbkGetBackStat( active:ByteP; count:LongP ):integer;
A flag which will be returned non-zero if a background transfer is in progress, or 0 if not The number of scans acquired by the last or current background t ransfer
TerrOverrun TerrFIFOFull TerrNoError tbkRdNBack, tbkStopBack
None
displays an error message and then exits the application program. When
- Internal data buffer overrun
- ADC FIFO Overrun
- No error
determines if a background operation is still in progress. It also reads the
tbkRdNBack
tbkGetBackStat
FIFO in the TempBook/66 is filled before the user can read the data out. In which case, the data read may be invalid. If the can be returned. This means that the software is just fa st enough to read one buffer of data. If this error occurs, the amount of data available (specified by 'count') is valid, but the transfer was stopped.
tbkGetFreq
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
float *freq
Returns See Also Program References
tbkGetFreq
the 100 kHz/1 MHz jumper is set to the default position of 1MHz.
9-6 tbkCommand Referenc e (
can return two possible error codes.
tbkRdNBack
int tbkGetFreq(float *freq); tbkGetFreq(float _far *freq); BtbkGetFreq% (freq!) VBtbkGetFreq% (freq!) tbkGetFreq( freq:FloatP ):integer;
A variable to hold the currently defi ned sampling frequency in Hz Valid values: 100000.0 - 0.0002
TerrNoError tbkSetFreq, tbkSetClk
None
- No error
is called with the cycle flag enabled, a
TerrFIFOFull
reads the sampling frequency of the pacer clock. Note:
Standard
API) TempBook User’s Manual
is returned if the data
TerrOverrun
tbkGetFreq
assumes that
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
protocol
Returns See Also Program References
DLL Function C
QuickBASIC Visual Basic Turbo Pascal Parameters
uint *chans
uchar *gains
uchar polarity
uint count
Returns See Also Program References
int tbkGetProtocol(int *protocol) tbkGetProtocol(int *protocol); BtbkGetProtocol% (protocol%) VBtbkGetProtocol% (protocol%) tbkGetProtocol( protocol:DataP ):integer;
A pointer to a value that will be set to the current protoc ol chosen from the protocol c odes listed below (additional EPP implementation codes may be described in the README file).
Name Description Value
TbkProtocolNone TbkProtocol8 TbkProtocol4 TbkProtocol4FPort TbkProtocolSL
An error number, or 0 is no error.
tbkInit, tbkSetProtocol
None
tbkGetProtocol
sets the protocol set to either
returns the current parallel port communications protocol.
TbkProtocol8
standard parallel port protocol.
int tbkGetScan(uint *chans, uchar *gains, uchar *polarities, uint *count); tbkGetScan(unsigned *chans, unsigned char *gains, unsigned char *polarity,
unsigned *count); BtbkGetScan% (chans%, gains%, polarity%, ByVal count%) VBtbkGetScan% (chans%(), gains%(), polarity%(), count%) tbkGetScan( chans:WordP; gains:ByteP; polarity:ByteP; count:word ):integer;
An array to hold up to 512 channel numbers or 0 i f the channel informati on i s not desired. See table at end of chapter for valid values. An array to hold up to 512 gain values or 0 if the channel gain information is not desired. See table at end of chapter for valid values. Zero value causes TempBook to default to Unipolar mode. Non-zero val ue causes default Bipolar mode. All ADC convers i ons except those started with
A variable to hold the number of val ues returned in the chans and gains arrays .
TerrNoError tbkSetScan, tbkSetMux
None
tbkGetScan
- No error
reads the current scan sequence consisting of up to 512 channels, gains and
polarities.
TempBook/66Communication Disabled 0 8-bit I/O 1 4-bit I/O 2 Far Point F/Port EPP Interface 10 82360 SL EPP Interface 20
or
TbkProtocol4
tbkSetProtocol
tbkGetProtocol
tbkInit
, indicating either 8-bit or 4-bit
may be used to specify other protocols.
tbkGetScan
tbkSetScan
will use the default polarity.
initially
TempBook User’s Manual tbkCommand Reference (
Standard
API) 9-7
tbkInit
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
unchar lptIntr The LPT interrupt level (7 for LPT1) uchar lptPort The LPT port number (See table below for defini tions.)
Returns
See Also Program References
tbkInit
communications with a TempBook unit, reset the TempBook hardware to power-on conditions, and select the TempBook as the current TempBook. TempBook only after the TempBook.
int tbkInit(uchar lptPort, uchar lptIntr); tbkInit(unsigned int lptPort, unsigned char lptIntr); BtbkInit% (ByVal lptPort%, ByVal lptIntr%) VBtbkInit% (lptPort%, lptIntr%) tbkInit( lptPort:byte; lptIntr:byte ):integer;
Description Value
LPT1 0x00 LPT2 0x01 LPT3 0x02 LPT4 0x03
TerrNotOnLine TerrBadChannel TerrNoTempBook TerrNoError tbkSelectPort, tbkClose
None
- No communicati on with TempBook
- Invalid LPT channel
- No TempBook/66detected
- No error
is used to perform multiple functions: initialize subroutine library variables, establish
tbkInit
tbkClose
command is called to terminate communications with the
can be called to reinitialize the
tbkRd
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uint chan unit *sample unchar gain
Returns
See Also Program References
tbkInit
Note:
tbkAdcRd
will perform the following tasks: Stop any current acquisition Set the scan group to channel 1 with a gain of 1 Set the pacer clock to 100 kHz Reset the counter/timers
tbkInit
int tbkRd(uint chan, uint *sample, uchar gain); tbkRd(unsigned chan, unsigned *sample, unsigned char gain); BtbkRd% (ByVal chan%, sample%, ByVal gain%) VBtbkRd% (chan%, sample%, gain%) tbkRd( chan:word; sample:WordP; gain:byte ):integer;
A single channel number (s ee t abl e at end of chapter for valid values). A pointer to a value where an A/D sample is stored The channel gain (see table at end of chapter for valid values)
TerrFIFOFull TerrInvGain TerrInvChan TerrNoError tbkRdN, tbkSetMux, tbkSetTrig, tbkSoftTrig, tbkRdFore
None
must be called before any other TempBook function
- Buffer Overrun
- Invalid gain
- Invalid channel
- No Error
is used to take a single reading from the given A/D channel. This function will use a
software trigger to immediately trigger and acquire one sample from the specified A/D channel.
9-8 tbkCommand Referenc e (
Standard
API) TempBook User’s Manual
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uchar bitNum
uchar *bitVal
Returns
See Also Program References
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uchar *byteVal
Returns See Also Program References
int tbkRdBit(uchar bitNum, uchar *bitVal); tbkRdBit(unsigned char bitNum, unsigned char *bitVal); BtbkRdBit% (ByVal bitNum%, bitVal%) VBtbkRdBit% (bitNum%, bitVal%) tbkRdBit( bitNum:byte; bitVal:ByteP ):integer;
The bit number of the specified digital I/O port to read Valid values: 0 - 7 A variable to hold the value of the s pecified bit (non-zero if asserted, 0 if unasserted)
TerrInvBitNum TerrNoError tbkWtByte, tbkRdByte, tbkWtBit
None
tbkRdBit
int tbkRdByte(uchar *byteVal); tbkRdByte(unsigned char *byteVal); BtbkRdByte%(digIn%) VBtbkRdByte% (digIn%) tbkRdByte( byteVal:DataP ):integer;
A variable to hold the value of the digi t al input byte
TerrNoError tbkWtByte, tbkWtBit, tbkRdBit
None
tbkRdByte
tbkRdBit
- Invalid bit number
- No error
reads the state of a single digital input bit.
tbkRdByte
- No error
reads the 8-bit digital input byte.
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uint *cntr0
uchar latch
Returns See Also Program References
int tbkRdCntr0(uint *cntr0, uchar latch); tbkRdCntr0(unsigned _far *cntr0, unsigned char mode); BtbkRdCntr0% (cntr0%, ByVal latch%) VBtbkRdCntr0% (cntr0%, latch%) tbkRdCntr0( cntr0:WordP; mode:Byte ):integer;
The value read back from the Counter 0 hol d regi ster Valid values: 0 - 65535 If latch is non-zero, the count regis ter will be latched into the hold register before reading. If latch is zero, the count regist er will be read directly. Direct reading should only be performed when no clock pulses are present.
TerrNoError tbkConfCntr0, tbkWtCntr0
None
tbkRdCntr0
counter 0 (see
tbkRdCntr0
- No error
reads the hold register of counter 0. This function is normally used with mode 0 of
tbkConfCntr0
) to read the current count value.
TempBook User’s Manual tbkCommand Reference (
Standard
API) 9-9
tbkRdFore
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uint *sample
Returns
See Also Program References
tbkRdN
DLL Function
C
QuickBASIC
Visual Basic Turbo Pascal
Parameters
unit chan uint *buf uint count
uchar trigger uchar one shot float freq uchar gain
Returns
See Also
Program References
int tbkRdFore(uint *sample); tbkRdFore(unsigned _far *sample); BtbkRdFore% (sample%) VBtbkRdFore% (sample%) tbkRdFore( sample:WordP ):integer;
A pointer to a value where an A/D sample is stored Valid values: (See
TerrFIFOFull TerrNoError tbkReadFIFO, tbkSetTag, tbkSetClk, tbkSetTrig, tbkSetScan
None
tbkRdFore
tbkSetTag
- Buffer overrun
- No error
will read one sample from the A/D data FIFO. This function, unlike the
)
tbkRd
function, will not configure the trigger source. It assumes that the A/D converter has already been configured to acquire data.
Note: If the A/D converter has not been configured to acquire data, this function may wait indefinitely, hanging the computer.
int tbkRdN(uint chan, uint *buf, uint count, uchar trigger, uchar oneShot, float freq, uchar gain); tbkRdN(unsigned chan, unsigned *buf, unsigned count, unsigned char trigger, unsigned char oneShot, float freq, unsigned char gain); BtbkRdN% (ByVal chan%, buf%, ByVal count%, ByVal trigger%, ByVal oneShot%, ByVal freq!, ByVal gain%) VBtbkRdN% (chan%, buf%(), count%, trigger%, oneShot%, freq!, gain%)
tbkRdN( chan:word; buf:WordP; count:word; trigger:byte; oneShot:byte; freq:real; gain:byte ):integer;
A single channel number (see table at end of chapter for valid values) An array where the A/D scans will be returned The number of scans to be taken Valid values: 1 - 32767 The trigger source (see table at end of chapter for valid values) A flag that if non-zero enables one-s hot trigger mode, otherwise enables continuous mode. The sampling frequency in Hz (100000.0 to 0.0002)
tbkRdN
The channel gain (see table at end of chapter for valid values)
TerrFIFOFull TerrInvGain TerrIncChan TerrInvTrigSource TerrInvLevel tbkRd, tbkRdScan, tbkRdScanN, tbkRdNFore, tbkSetFreq, tbkSetMux, tbkSetClk, tbkSetTrig
None
is used to take multiple scans from a single A/D channel. This function will configure the
- Buffer overrun
- Invalid gain
- Invalid channel
- Invalid trigger
- Invalid level
pacer clock, arm the trigger and acquire ‘count’ scans from the specified A/D channel.
9-10 tbkCommand Referenc e (
Standard
API) TempBook User’s Manual
DLL Function C
QuickBASIC Visual Basic Turbo Pascal Parameters
uint *buf uint count
uchar cycle uchar updateSingle
Returns
See Also Program References
tbkRdNBack
return control back to the user’s program after initiating the background transfer. The user can then monitor the status of the background transfer with the transfer with the can perform other tasks in the foreground. This function assumes that the A/D acquisition has already been setup.
If the cycle flag is true, the background transfer will run continuously looping back to the beginning of ‘buf’ after ‘count’ scans have been read. This allows the user to read large amounts of data without calling buffer and processes the data before it gets overwritten, the background transfer can run indefinitely. In this mode, the user should get the total number of scans written into ‘buf’ using
tbkGetBackStat
difference between these two totals is the number of unprocessed valid scans in ‘buf’ that the user can process.
tbkRdNBack
int tbkRdNBack(uint *buf, uint count, uchar cycle, uchar update Single); tbkRdNBack(unsigned _far *buf, unsigned count, unsigned char cycle, unsigned
char updateSingle); BtbkRdNBack% (buf%, ByVal count%, ByVal cycle%, ByVal updateSingle%) VBtbkRdNBack% (buf%(), count%, cycle%, updateSingle%) tbkRdNBack( buf:WordP; count:word; cycle:byte; updateSingle:byte ):integer;
An array where the A/D scans will be placed The number of scans to be taken Valid values: 1 - 32767 A flag that if non-zero will enable continuous operation, or if 0 will disable it A flag that if non-zero will enable single scans to be read into buf or if 0 will enable buf to be updat ed in a block of 256 scans
TerrMultBackXfer TerrNoError tbkGetBackStat, tbkBackStop, tbkSetTag, tbkSetClk, tbkSetTrig
None
reads multiple A/D scans in the background using interrupts. This function will
tbkBackStop
tbkRdNBack
- Background read already in progress
- No error
tbkGetBackStat
function or stop the
function. Because the transfer occurs in the background, the user
multiple times. As long as the user monitors how much data is in the
and keep track of the total number of scans processed in a variable. The
Note: the Visual Basic chapter includes an example program which demonstrates how to use the cycle mode of
The
updateSingle
tbkRdNBack
sample at a time or in blocks of 256 scans. Enabling data during slow acquisitions as the data is acquired. Because the
.
flag allows the user to control whether the TempBook/66 updates ‘buf’ one
updateSingle
allows the user to read A/D
updateSingle
flag is directly tied to the number of interrupts that will be generated on the computer, the flag should not be enabled if the acquisition rate is greater than roughly 500 scans per second (sampling rate * # of channels). For example, an a cquisition running at 1 Hz might enable the
updateSingle
flag so that the data can be read each second rather than waiting for 256 seconds. An acquisition running at 10,000 Hz would disable the flag so the computer does not hang.
TempBook User’s Manual tbkCommand Referenc e (
Standard
API) 9-11
tbkRdNBackPreT
DLL Function C
QuickBASIC Visual Basic Turbo Pascal Parameters
uint *buf uint count uchar cycle
Returns
See Also Program References
tbkRdNBackPreT
the background. This function will return control to the user's program after initiating the background transfer. The user can then monitor the status of the background transfer with the
tbkGetBackStat
transfer occurs in the background, the user can perform other tasks in the foreground. This function assumes that the pre-trigger acquisition has already been setup using the command.
If the 'cycle' flag is true, the background transfer will run continuously looping back to the beginning of 'buf' after 'count' scans have been read. Under this mode, the background transfer will continue until the acquisition completes. This allows the user to collect large amounts of data without calling
tbkRdNBackPreT
processes the data before it gets overwritten, the background transfer can run until the acquisition completes. In this mode, the user should get the total number of scans written into 'buf' using the
tbkGetBackStat
The difference between these two totals is the number of unprocessed valid scans in 'buf' that the user can process.
int tbkRdNBackPreT(uint *buf, uint count, uchar cycle); tbkRdNBackPreT(unsigned int _far *buf, unsigned int count, unsigned char
cycle); BtbkRdNBackPreT% (buf%, ByVal count%, ByVal cycle%) VBtbkRdNBackPreT% (buf%(), count%, cycle%) tbkRdNBackPreT(buf:WordP; count:word; cycle:byte):integer;
An array where the A/D scans will be placed. The number of scans to be taken (1-32767) A flag that if non-zero will enable continuous operation, or if 0 will disable it
TerrMultBackXfer TerrNoError tbkGetBackStat, tbkBackStop, tbkSetTag, tbkSetTrigPreT
PRETEX3 (all languages)
- Background read already in progress
- No error
reads multiple A/D scans, initiated by the
function or stop the transfer with the
tbkBackStop
tbkSetTrigPreT
function. Because the
command, in
tbkSetTrigPreT
several times. As long as the user monitors how much data is in the buffer and
function and keep track of the total number of scans processed in a variable.
If, however, the 'cycle' flag is false, the background transfer will only collect the number of scans specified in 'count'. If this is the case, a number of the data collected during the pre-trigger mode acquisition.
tbkRdNFore
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uint *buf uint count
Returns
See Also Program References
tbkRdNFore
does not use interrupts and does not return control immediately to the program. It will return only when ‘count’ scans have been read. This function will not configure the A/D acquisition and assumes that the A/D converter has already been configured to acquire data.
Note: If the A/D converter has not been configured to acquire data, this function may wait indefinitely, hanging the computer.
tbkRdNBack
int tbkRdNFore(uint *buf, uint count); tbkRdNFore(unsigned _far *buf, unsigned count); BtbkRdNFore% (buf%, ByVal count%) VBtbkRdNFore% (buf%(), count%) tbkRdNFore( buf:WordP; count:word ):integer;
An array where the A/D samples will be placed The number of scans to be taken Valid values: 1 - 32767
TerrFIFOFull TerrNoError tbkSetClk, tbkSetTrig
- Buffer overrun
- No error
reads multiple A/D scans in the foreground. Unlike
calls may be necessary to read all
tbkRdNBack
, this function
9-12 tbkCommand Referenc e (
Standard
API) TempBook User’s Manual
DLL Function C
QuickBASIC Visual Basic Turbo Pascal
Parameters
uint *buf uint count
uint *retcount uchar *active
Returns
See Also Program References
tbkRdNForePreT
int tbkRdNForePreT(uint *buf, uint count, uint *retcount, uchar *active); tbkRdNForePreT(unsigned int _far *buf, unsigned int count, unsigned int _far
*retcount, unsigned char _far *active); BtbkRdNForePreT% (buf%, ByVal count%, retcount%, active%) VBtbkRdNForePreT% (buf%(), count%, retcount%, active%) tbkRdNForePreT( buf:WordP; count:word; retcount: WordP; active:ByteP ):integer;
An array where the A/D samples will be placed The number of scans to be taken Valid values: 1 - 32767 Pointer to an integer representing t he number of scans actual l y t aken Pointer to a flag indicating whether or not the pre-trigger acquisition is still active
TerrFIFOFull TerrNoError tbkSetTrigPreT, tbkSetTag, tbkRdNForePreTWait, tbkRdNBackPreT
PRETEX1 (all languages)
tbkRdNForePreT
the foreground. Unlike the does not return control immediately to the application program. It will only return when either the specified count has been satisfied or the acquisition completes.
This function may be called subsequent to configuring a pre-trigger acquisition using the
tbkSetTrigPreT
two possible conditions are met: 1) The specified number of scans has been collected, or, 2) the trigger has been detected and the acquisition has completed. In the latter case, the returned 'active' flag will be 0 and the number of scans actually collected will be returned in 'retcount'.
- Buffer overrun
- No error
reads multiple A/D scans, initiated by the
tbkRdNBackPreT
command, this function does not use interrupts and
tbkSetTrigPreT
command, in
command. Once this command has been called, it will return only when one of
Note: If the A/D converter has not been configured to acquire data, this function may wait indefinitely, hanging the computer.
TempBook User’s Manual tbkCommand Referenc e (
Standard
API) 9-13
tbkRdNForePreTWait
DLL Function C
QuickBASIC Visual Basic Turbo Pascal Parameters
uint *buf uint count
uint *retcount
Returns
See Also Program References
tbkRdNForePreTWait
command, in the foreground. Unlike the return until the acquisition completes. It will only return when the specified trigger event has occurred and the specified post trigger count has been satisfied.
This function may be called subsequent to configuring a pre-trigger acquisition using the
tbkSetTrigPreT
trigger has been detected and the acquisition has completed. The amount specified in the ‘count’ parameter specifies the length of the supplied buffer in scans. Unlike command will not return when ‘count’ is satisfied; instead, it will continue acquiring by wrapping the scans to the beginning of the buffer until the final post-trigger scan is collected and the acquisition completes.
int tbkRdNForePreTWait(uint *buf, uint count, uint *retcount); tbkRdNForePreTWait(unsigned int _far *buf, unsigned int count, unsigned int
_far *retcount); BtbkRdNForePreTWait% (buf%, ByVal count%, retcount%) VBtbkRdNForePreTWait% (buf%(), count%, retcount%) tbkRdNForePreTWait( buf:WordP; count:word; retcount:WordP):integer;
An array where the A/D samples will be placed The number of scans to be taken Valid values: 1 - 32767 Pointer to an integer representing t he number of scans actual l y t aken
TerrFIFOFull TerrNoError tbkSetTrigPreT, tbkRdNForePreT, tbkRdNBackPreT
PRETEX2 (all languages)
- Buffer overrun
- No error
reads multiple A/D scans, initiated by the
tbkRdNForePreT
tbkSetTrigPreT
command, this function will not
command. Once this command has been called, it will return only when the
tbkAdcRdNForePreT
this
tbkRdScan
DLL Function C
QuickBASIC Visual Basic Turbo Pascal Parameters
uint startChan uint endChan uint *buf unchar gain
Returns
See Also Program References
When the acquisition completes, control will be returned to the application program along with the actual number of scans collected in the ‘retcount’ parameter.
Note: If the A/D converter has not been configured to acquire data or the trigger event never occurs, this function may wait indefinitely, hanging the computer.
int tbkRdScan(uint startChan, uint endChan, uint *buf, uchar gain); tbkRdScan(unsigned startChan, unsigned endChan, unsigned * buf, unsigned
char gain); BtbkRdScan% (ByVal startChan%, ByVal endChan%, buf%, ByVal gain%) VBtbkRdScan% (startChan%, endChan%, buf%(), gain%) tbkRdScan( startChan:word; endChan:word; buf:WordP; gain:byte ):integer;
The starting channel of the s can group (see table at end of chapter for val i d val ues) The ending channel of the scan group (see t abl e at end of chapter for valid values) An array where the A/D scans will be placed The channel gain (see table at end of chapter for valid values)
TerrInvGain TerrInvChan TerrNoError tbkRd, tbkRdN, tbkRdNScan, tbkSetMux, tbkRdFore, tbkSetClk, tbkSetTrig
tbkRdScan
reads a single sample from multiple channels. This function will use a software trigger
- Invalid gain
- Invalid channel
- No error
to immediately trigger and acquire one scan consisting of each channel starting with ‘startChan’ and ending with ‘endChan’.
9-14 tbkCommand Referenc e (
Standard
API) TempBook User’s Manual
DLL Function
C
QuickBASIC
Visual Basic
Turbo Pascal
Parameters
uint startChan uint endChan uint *buf uint count
uchar trigger uchar one Shot float freq
uchar gain
Returns
See Also Program References
tbkRdScanN
int tbkRdScanN(uint startChan, uint endChan, uint *buf, uint count, uchar trigger, uchar one Shot, float freq, uchar gain ); tbkRdScanN(unsigned startChan, unsigned endChan, unsigned * buf, unsigned count, unsigned char trigger, unsigned char oneShot, float freq, unsigned char gain); BtbkRdScanN% (ByVal startChan%, ByVal endChan%, buf%, ByVal count%, ByVal trigger%, ByVal oneShot%, ByVal freq!, ByVal gain%) VBtbkRdScanN% (startChan%, endChan%, buf%(), count%, trigger%, oneShot%, freq!, gain%) tbkRdScanN( startChan:word; endChan:word; buf:WordP; count:word; trigger:byte; oneShot:byte; freq:real; gain:byte ):integer;
The starting channel of the s can group (see table at end of chapter for val i d val ues) The ending channel of the scan group (see t abl e at end of chapter for valid values) An array where the A/D scans will be placed The number of scans to be read Valid values: 1 - 65536 The trigger source (see table at end of chapter for valid values) A flag that if non-zero enables one-s hot trigger mode The sampling frequency in Hz Valid values: 100000.0 - 0.0002 The channel gain (see table at end of chapter for valid values)
TerrInvGain TerrInvChan TerrInvTrigSource TerrInvLevel TerrFIFOFull TerrNoError tbkRd, tbkRdN, tbkRdScan, tbkRdNFore, tbkSetClk, tbkSetTrig
tbkRdScanN
pacer clock, arm the trigger and acquire ‘count’ scans consisting of each channel starting with ‘startChan’ and ending with ‘endChan’.
- Invalid gain
- Invalid channel
- Invalid trigger
- Invalid Level
- Buffer Overrun
- No error
reads multiple scans from multiple A/D channels. This function will configure the
tbkRdTemp
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uint chan uint tcType int *temp
Returns
See Also Program References
tbkRdTemp
The reading will be zero corrected, span corrected, and linearized to yield a temperature reading in tenths of a degree Celsius. This function will use software triggering to immediately trigger and acquire one sample.
If a calibration constant file with the default name, “ program then no span correction is performed.
tbkSetMode
operation in either unipolar or bipolar mode.
TempBook User’s Manual tbkCommand Referenc e (
tbkRdTemp(uint chan, uchar tcType, int * temp) tbkRdTemp(unsigned chan, unsigned tcType, int * temp); BtbkRdTemp% (ByVal chan%, ByVal tcType%, temp%) VBtbkRdTemp% (chan%, tcType%, temp%) tbkRdTemp( chan:word; tcType:word; temp:DataP):integer;
Single channel number (see tabl e at end of chapter for valid values) Thermocouple type (see table at end of chapter for valid values) Pointer to a value where the converted tem perature is to be stored
TerrInvChan TerrTCE_Type tbkTCSetup, tbkTCConvert, tbkTCSetupConvert
TEMPEX1 (all languages)
- Invalid Channel
- Invalid Thermocouple Type
is used to take a single thermocouple reading from the given analog input channel.
tempbook.cal
”, is not visible to the calling
must be called before this function to configure the TempBook for differential
Standard
API) 9-15
tbkRdTempN
DLL Function
C
QuickBASIC
Visual Basic Turbo Pascal
Parameters
uint chan uint tcType uint count int *temp uint* buf float freq
uint avg
Returns
See Also
Program References
tbkRdTempN
The readings will be zero corrected, span corrected, and linearized to yield temperature reading(s) in tenths of a degree Celsius. This function will use pacer clock triggering to acquire samples at the rate defined in the parameter averaging.
tbkRdTempN( uint chan, uchar tcType, uint count, int * temp, uint * buf, float freq, uint avg ) tbkRdTempN( unsigned chan, unsigned tcType, unsigned count, int * temp, unsigned * buf, float freq, unsigned avg ); BtbkRdTempN% (ByVal chan%, ByVal tcType%, ByVal count%, temp%, buf%, ByVal freq!, ByVal avg%) VBtbkRdTempN% (chan%, tcType%, count%, temp%(), buf%(), freq!, avg%)
tbkRdTempN( chan:word; tcType:word; count:word; temp:DataP; buf:WordP; freq:real; avg:word ):integer;
Single channel number (see tabl e at end of chapter for valid values) Thermocouple type (see table at end of chapter for valid values) Number of scans to read. Pointer to a value where the converted tem perature is to be stored Pointer to an array where the raw ADC counts are to be stored. Sampling frequency in Hz Valid values: 100000.0 - 0.0002 Type of averaging to be used. 0 - block averaging 1 - no averaging 2 - moving averaging
TerrInvChan TerrTCE_Type TerrInvCount tbkRdTemp, tbkRdTempScan, tbkRdTempScanN, tbkTCSetup, tbkTCConvert, tbkTCSetupConvert
TEMPEX1 (all languages)
- Invalid Channel
- Invalid Thermocouple Type
- More than 1 scan specified with freq = 0
is used to take multiple thermocouple readings from the given analog input channel.
. The parameter
freq
is used to spec ify no, block, or moving
avg
A pointer to a buffer array must be provided for storage of the raw ADC counts. The array dimension must be at least 4 * count.
If a calibration constant file with the default name “
tempbook.cal
” is not visible to the calling
program, then no span correction is performed.
tbkSetMode
must be called before this function to configure the TempBook for differential
operation in either unipolar or bipolar mode.
9-16 tbkCommand Referenc e (
Standard
API) TempBook User’s Manual
DLL Function C
QuickBASIC Visual Basic Turbo Pascal
Parameters
uint startchan uint endChan uint tcType int *temp
Returns
See Also
Program References
tbkRdTempScan
tbkRdTempScan(uint startChan, uint endChan, uchar tcType, int * temp) tbkRdTempScan(unsigned startChan, unsigned endChan, unsigned tcType, int *
temp); BtbkRdTempScan% (ByVal startChan%, ByVal endChan%, ByVal tcType%, temp%) VBtbkRdTempScan% (startChan%, endChan%, tcType%, temp%()) tbkRdTempScan( startChan:word; endChan:word; tcType:word; temp:DataP):integer;
Single channel number (see tabl e at end of chapter for valid values) Ending channel of the scan group (s ee table at end of chapter for valid values) Thermocouple type (see table at end of chapter for valid values) An array where the A/D scan will be placed.
TerrInvChan TerrTCE_Type tbkRdTemp, tbkRdTempN, tbkRdTempScanN, tbkTCSetup, tbkTCConvert, tbkTCSetupConvert
TEMPEX1 (all languages)
tbkRdTempScan
through 'endChan'. The readings will be zero corrected, span corr ected, and lineariz ed to yield temperature readings in tenths of a degree Celsius. This function will use software triggering to immediately trigger and acquire one scan.
- Invalid Channel
- Invalid Thermocouple Type
is used to take thermocouple readings from analog input channels 'startChan'
If a calibration constant file with the default name " program, then no span correction is performed.
tbkSetMode
must be called before this function to configure the TempBook for differential
operation in either unipolar or bipolar mode.
tempbook.cal
" is not visible to the calling
TempBook User’s Manual tbkCommand Referenc e (
Standard
API) 9-17
tbkRdTempScanN
DLL Function
C
QuickBASIC
Visual Basic
Turbo Pascal
Parameters
uint startchan uint endChan uint tcType uint count int *temp uint *buf float freq
uint avg
Returns
See Also
Program References
tbkRdTempScanN
‘startChan’ through ‘endChan’. The readings will be zero-corrected, span-corrected, and linearized to yield temperature readings in tenths of a degree Celsius. This function will use pacer-clock triggering to acquire samples at the rate defined in the parameter to specify no, b lock, or moving averaging.
tbkRdTempScanN(uint startChan, uint endChan, uchar tcType, uint count, int * temp, uint * buf, float freq, uint avg) tbkRdTempScanN(unsigned startChan, unsigned endChan, unsigned tcType, unsigned count, int * temp, unsigned * buf, float freq, unsigned avg); BtbkRdTempScanN% (ByVal startChan%, ByVal endChan%, ByVal tcType%, ByVal count%, temp%, buf%, ByVal freq!, ByVal avg%) VBtbkRdTempScanN% (startChan%, endChan%, tcType%, count%, temp%(), buf%(), freq!, avg%) tbkRdTempScanN( startChan:word; endChan:word; tcType:word; count:word; temp:DataP; buf:WordP; freq:real; avg:word ):integer;
Single channel number (see tabl e at end of chapter for valid values) Ending channel of the scan group (s ee table at end of chapter for valid values) Thermocouple type (see table at end of chapter for valid values) Number of scans to read. Pointer to a value where the converted tem peratures are to be stored Pointer to an array where the raw ADC counts are to be stored. Sampling frequency in Hz Valid values: 100000.0 - 0.0002 Type of averaging to be used.
TerrInvChan TerrTCE_Type TerrInvCount tbkRdTemp, tbkRdTempN, tbkRdTempScan, tbkTCSetup, tbkTCConvert, tbkTCSetupConvert
TEMPEX1 (all languages)
- Invalid Channel
- Invalid Thermocouple Type
- More than 1 scan specified with freq = 0
is used to take multiple thermocouple readings from analog input channels
. The parameter
freq
avg
is used
A pointer to a buffer array must be provided for storage of the raw ADC counts. The array dimension must be at leas t count * (endChan - star tChan + 4).
If a calibration constant file with the default name “
tempbook.cal
” is not visible to the calling
program, then no span correction is performed.
tbkSetMode
must be called before this function to configure the TempBook for differential
operation in either unipolar or bipolar mode.
9-18 tbkCommand Referenc e (
Standard
API) TempBook User’s Manual
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
char *calfile
Returns
See Also Program References
tbkReadCalFile
tbkReadCalFile(char *calfile); tbkReadCalFile(char *calfile); BtbkReadCalFile% (ByVal calfile$) VBtbkReadCalFile% (ByVal calfile$) tbkReadCalFile(calfile : string) : integer;
The file name with optional path information of the cali brat ion file. If calfi l e i s NULL or empty (""), the default calibration file TEMPBOOK .CAL will be read.
TerrNoError TerrInvCalfile tbkCalSetup, tbkCalConvert, tbkCalSetupConvert
None
tbkReadCalFile
calibration text file. This function, which is usually called once at the beginning of a program, will read all the calibration constants from the specified file. If calibration constants for a specific gain setting are not contained in the file, ideal calibration constants will be used, essentially performing no calibration for that channel. If an error occurs while trying to open the calibration file, ideal calibration constants will be used for all channels and a non-zero error code will be returned by the
tbkReadCalFile
See the Software Calibration and Zero Compensation chapter for a complete description of calibration.
- No error
- Error occurred while opening or reading calibration f i le
is the initialization function for reading in the calibration constants from the
function.
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uchar lptPort
Returns
See Also Program References
int tbkSelectPort(uchar lptPort); tbkSelectPort(unsigned int lptPort); BtbkSelectPort% (ByVal lptPort%) VBtbkSelectPort% (lptPort%) tbkSelectPort( lptPort:byte ):integer;
The LPT port number (see table below for definitions.)
Description Value
LPT1 0x00 LPT2 0x01 LPT3 0x02 LPT4 0x03
TerrNotOnLine TerrBadChannel TerrNoTempBook TerrNoError
tbkSelectPort
- No communicati ons with TempBook
- Invalid LPT channel
- No TempBook/66 detected
- No error
selects an initialized TempBook. This function causes any subsequent function
calls to be performed on this TempBook. Because
tbkSelectPort
Note:
tbkInit
is only needed when using multiple TempBooks.
must be called with the corresponding LPT port before
select it.
tbkInit
tbkSelectPort
initializes then selects a TempBook,
tbkSelectPort
can
TempBook User’s Manual tbkCommand Referenc e (
Standard
API) 9-19
tbkSetClk
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uint ctr1
uint ctr2
Returns
See Also Program References
tbkSetClk
pacer clock can be used to control the sampling rate of the A/D converter. The frequency is defined to be xtal/ctr1*ctr2) where xtal is the frequency of the board crystal (either 1 MHz or 100 kHz).
int tbkSetClk(uint ctr1, uint ctr2); tbkSetClk(unsigned ctr1, unsigned ctr2); BtbkSetClk% (ByVal ctr1%, ByVal ctr2%) VBtbkSetClk% (ctr1%, ctr2%) tbkSetClk( ctr1:word; ctr2:word ):integer;
The value of the counter 1 divisor Valid values: 0 - 65535 The value of the counter 2 divisor Valid values: 0 - 65535
TerrInvClock TerrNoError tbkSetFreq, tbkGetFreq
tbkSetErrHandler
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
tbkErrHandler
Returns See Also Program References
*** For C and Pascal Only - If the driver detects an error condition during its operation, it
tbkSetErrHandler(tbkSetErrHandlerFTP tbkErrorHandler); tbkSetErrHandler(tbkErrorHandlerFPT tbkErrorHandler); BtbkSetErrHandler% (ByVal tbkErrorHandler&) VBtbkSetErrHandler% (tbkErrorHandler%) tbkSetErrHandler( tbkErrorHandler:ErrorFuncT ):integer;
This is a function that takes an integer (error code) and returns nothing, or NULL to disable.
TerrNoError tbkDefaultHandler
automatically calls a default system error handler. This command allows the user to supply an error handler that is automatically called when a system error is detected.
- Invalid clock
- No error
sets the frequency of the pacer clock using the two specified counter values. The
- No error, or an error number
*** For Visual Basic and QuickBASIC - If the driver det ects an error condition during its operation,
it will pass the error code as the return value of each function. This command allows the user to set a BASIC error number which will be generated when an error occurs. The error can then be handled using the standard ONERROR feature of BASIC.
9-20 tbkCommand Referenc e (
Standard
API) TempBook User’s Manual
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
float freq
Returns See Also Program References
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uchar di_se
uchar polarity
Returns See Also Program References
tbkSetFreq
int tbkSetFreq(float freq); tbkSetFreq(float freq); BtbkSetFreq% (ByVal freq!) VBtbkSetFreq% (freq!) tbkSetFreq( freq:real ):integer;
The sampling frequency in Hz Valid values: 100000.0 - 0.0002
TerrNoError tbkGetFreq, tbkSetClk
None
tbkSetFreq
- No error
calculates then sets the frequency of the pacer clock using the specified frequency in Hz. The frequency is converted to two counter values that control the frequency of the pacer clock. In this conversion, some resolution of the frequency may be lost. the exact frequency setting of the pacer clock.
tbkSetClk
can be used to explicitly set the two
tbkRdFreq
can be used to read
counter values of the pacer clock. The pacer clock can be used to control the sampling rate of the A/D converter.
tbkSetMode
tbkSetMode(uchar di_se, uchar polarity); tbkSetMode(unsigned char di_se, unsigned char polarity); BtbkSetMode% (ByVal di_se%, ByVal polarity%) VBtbkSetMode% (ByVal di_se%, ByVal polarity%) tbkSetMode( di_se:byte; polarity:byte ):integer;
Zero value causes TempBook to go to single-ended mode (power-on default). Non-zero value causes differenti al mode. Zero value causes TempBook to default to Unipolar mode. Non-zero val ue causes default Bipolar mode. All ADC convers i ons except those started with
TerrNoError
None
tbkSetMode
is used to program the gain amp for single-ended or differential operation and to set the default polarity.
tbkSetScan
- No error
will use the default polarity.
Single-ended operation measures the voltage of the selected channel referred to analog ground. Differential operation measures differences in voltage between a pair of selected channels.
Polarity is unipolar or bipolar:
Unipolar maximum voltage range is 0 to +10 V
Bipolar maximum voltage range is -10 to +10 V.
TempBook User’s Manual tbkCommand Referenc e (
Standard
API) 9-21
tbkSetMux
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uint startChan uint endChan uchar gain
Returns
See Also Program References
int tbkSetMux(uint startChan, uint endChan, uchar gain); tbkSetMux(unsigned startChan, unsigned endChan, unsigned char gain); BtbkSetMux% (ByVal startChan%, ByVal endChan%, ByVal gain%) VBtbkSetMux% (startChan%, endChan%, gain%) tbkSetMux( startChan:word; endChan:word; gain:byte ):integer;
The starting channel of the s can group (see table at end of chapter for val i d val ues) The ending channel of the scan group (see t abl e at end of chapter for valid values) The gain value for all channels (see t abl e at end of chapter for valid values)
TerrInvGain TerrIncChan TerrNoError tbkSetScan, tbkGetScan
tbkSetMux
sets a simple scan sequence of local A/D channels from ‘startChan’ to ‘endChan’ all
- Invalid gain
- Invalid channel
-No error
with the specified gain value. This provides a simple alternative to channels need to be acquired.
tbkSetScan
if consecutive
9-22 tbkCommand Referenc e (
Standard
API) TempBook User’s Manual
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
protocol
Returns See Also Program References
tbkSetProtocol
int tbkSetProtocol( int protocol) tbkSetProtocol(int protocol); BtbkSetProtocol% (ByVal protocol%) VBtbkSetProtocol% (protocol%) tbkSetProtocol( protocol:integer ):integer;
One of the predefined protocol codes l i sted below (additional protocol codes may be described in the README file).
Name Description Value
TbkProtocol8 TbkProtocol4 TbkProtocolFPort TbkProtocolSL TbkProtocolSMC666 TbkProtocolEPPBIOS TbkProtocolPastEPP
An error number, or 0 if no error.
tbkInit, tbkGetProtocol
tbkSetProtocol
specifies to the TempBook/66 driver the type of parallel-port implementation and protocol that is available on the computer. The driver then attempts to configure the computer and the TempBook/66 to communicate using the specified protocol. Since establishing the protocol may affect the settings of the TempBook, after
tbkInit
has established communications with and reset the TempBook. Switching protocols
during normal TempBook/66 operation is not recommended. Two types of parallel port implementations are supported by the TempBook: standard and enhanced.
Standard parallel ports, using the TempBook/66 manufacturer’s proprietary protocols, are capable of receiving data either 4 or 8 bits at a time. When possible, 8-bit operation is preferred (it is much faster), but not all standard parallel ports support 8-bit data reception.
8-bit I/O 1 4-bit I/O 2 Far Point F/Port EPP Interface 10 82360 SL EPP Interface 20 SMC 37C666 EPP mode 30 EPP bios mode 40 WBK20/21 Fast EPP mode 50
tbkSetProtocol
should only be invoked immediately
Enhanced parallel ports (EPP) include extra hardware that increases the rate of data transfer to 3 to 10 times the rate of a standard parallel port. Unfortunately, not every computer includes EPP capability and attempting to use EPP on an incompatible computer may cause the TempBook/66 driver to access I/O locations which are not part of the printer port interface. Such accesses may interfere with other operations and cause the computer to operate incorrectly. For this reason, EPP operation must be explicitly requested by the program.
When the TempBook/66 is initialized by
tbkInit
port protocol: either 8-bit, if possible, or the slower 4-bit protocol. After
tbkSetProtocol
If
tbkSetProtocol
may be used to switch to another supported protocol.
is unable to establish communications using the specified protocol, then it
, it is initially configured for a standard parallel
tbkInit
has completed,
will try to establish communications using the standard port protocols, first 8-bit, then the slower 4­bit. In such an event,
tbkSetProtocol
will not return an error indication unless it is unable to
establish any protocol. In any case,
tbkGetProtocol
may be used to check the current operating protocol.
TempBook User’s Manual tbkCommand Referenc e (
Standard
API) 9-23
tbkSetScan
DLL Function C
QuickBASIC Visual Basic Turbo Pascal Parameters
uint *chans uchar *gains uchar polarities
uint count
Returns
See Also Program References
tbkSetScan
corresponding gains. As many as 512 entries can be made in the scan configuration. Any analog input channel at any gain can be included in the scan. Channels can be entered multiple times at the same or different gain. The high-speed digital I/O port can also be includ ed although its gai n value will be ignored.
int tbkSetScan(uint *chans, uchar *gains, uchar polarities, uint count); tbkSetScan(unsigned *chans, unsigned char *gains, unsigned char *polarity,
unsigned count); BtbkSetScan% (chans%, gains%, polarity%, ByVal count%) VBtbkSetScan% (chans%(), gains%(), polarity%(), count%) tbkSetScan( chans:WordP; gains:ByteP; polarity:ByteP; count:word ):integer;
An array of up to 512 channel numbers (see table at end of chapter for vali d val ues) An array of up to 512 gain values (see table at end of chapter for valid values) An array of up to 512 polarity values. Zero val ue causes TempBook/66 to select Unipolar mode. Non­zero values causes Bipolar mode. The number of values in the chans and gai ns arrays Valid values: 1 - 512
TerrNotCapable TerrInvGain TerrInvChan TerrNoError tbkGetScan, tbkSetMux
- No high speed digital
- Invalid gain
- Invalid channel
- No error
configures a scan sequence consisting of multiple channels, polarities and
9-24 tbkCommand Referenc e (
Standard
API) TempBook User’s Manual
DLL Function
C
QuickBASIC
Visual Basic
Turbo Pascal
Parameters
uchar trigger uchar one Shot ctr0mode
pacer Mode
Returns
See Also Program References
tbkSetTrig
int tbkSetTrig(uchar trigger, uchar one shot, uchar ctr0 mode, uchar pacer Mode); tbkSetTrig(unsigned char trigger, unsigned char oneShot, unsigned char ctr0mode, unsigned char pacerMode); BtbkSetTrig% (ByVal trigger%, ByVal oneShot%, ByVal ctr0mode%, ByVal pacerMode%) VBtbkSetTrig% (ByVal trigger%, ByVal oneShot%, ByVal ctr0mode%, ByVal pacerMode%) tbkSetTrig( trigger:byte; oneShot:byte; ctr0Mode:byte; pacerMode:byte ):integer;
The trigger source (see table at end of chapter for valid values) A flag that if non-zero enables one-s hot trigger mode, otherwise enables continuous mode A non-zero flag selects an internal 100 kHz clock to be t he i nput to counter 0. If the flag is zero, only t he external clock is the input t o counter 0. See figure in A flag that if zero, disabl es the external TTL Trigger from affecting the pacer clock. If the flag is non-zero, any low-level on the TTL trigger will cause the pacer clock to pause.
TerrInvTrigSource TerrInvLevel TerrNoError tbkConfCntr0
tbkSetTrig
tbkConfCntr0
- Invalid level
- No error
sets and arms the trigger of the A/D converter. Eight trigger sources and several mode flags can be used to generate a wide variety of acquisitions. The will stop any current acquisitions, empty the TempBook/66 of any data previously acquired and arm the TempBook/66 using the specified trigger source.
for detailed diagram.
- Invalid trigger
tbkSetTrig
command
The pacer clock trigger source can be used to acquire data at a constant frequency. The sampling rate can be set using the
tbkSetClk
or
tbkSetFreq
functions. The one-shot flag has no
meaning when using this trigger source. The software trigger source allows the user to trigger the A/D from software using the
tbkSoftTrig
function. When the one-shot mode is enabled, a single scan will be initiated by the software trigger. In the continuous mode (one-shot disabled), sending a software trigger will cause the A/D converter to sample at the rate of the pacer clock.
An external TTL pulse can be used to initiate a scan or start an acquisition when using the external TTL rising or falling edge trigger source. The external TTL pulse should be applied to the trig input. The pulse will initiate a single scan in one-shot mode and a continuous acquisition at the pacer clock frequency in continuous mode.
Setting the counter 0 mode flag true will enable an onboard 100 kHz clock to be ANDed with the counter 0 input to produce the input to counter 0. If nothing is connected to counter 0 input, the line will float high essentially clocking counter 0 off the 100KHz clock. If this flag is false, counter 0 can only be clocked from the counter 0 input pin. Counter 0 can be used as an alternative trigger source by connecting the counter 0 output to the trig input and choosing an external TTL trigger. Counter 0 can also be used for general counter applications.
The pacer mode flag enables/disables operation of the pacer clock. If this flag is non-zero, the pacer clock will be gated with the trig input. If it is zero, the pacer clock will be enabled.
TempBook User’s Manual tbkCommand Referenc e (
Standard
API) 9-25
tbkSetTrigPreT
DLL Function
C
QuickBASIC
Visual Basic Turbo Pascal
Parameters
uchar trigger
uint channel uint level uint precount uint postcount
Returns
See Also Program References
tbkSetTrigPreT
trigger data acquisition. The empty the TempBook/66 of any data previously acquired, arm the TempBook/66 using the specified analog level trigger source and will immediately begin the collection of the specified amount of pre­trigger data.
This command allows the configuration of a data acquisition that includes both pre-trigger and post­trigger data. The specified pre-trigger amount indicates the number of pre-trigger scans to be collected before the trigger is armed. The trigger event will only be recognized after the specified pre-trigger amount has been satisfied and the trigger is armed. This means that the specified pre­trigger amount represents the minimum amount of pre-trigger data which will actually be collected. The specified post-trigger amount represents the number of scans taken after the detection of the trigger event. This amount represents the exact number of scans taken subsequent to the detection of the trigger event.
int tbkSetTrigPreT(uchar trigger, uint channel, uint level, uint precount, uint postcount); tbkSetTrigPreT(unsigned char source, unsigned int channel, unsigned int level, unsigned int preCount, unsigned int postCount); BtbkSetTrigPreT% (ByVal source%, ByVal channel%, ByVal level%, ByVal preCount%, ByVal postCount%) VBtbkSetTrigPreT% (source%, channels%, level%, preCount%, postCount%)
tbkSetTrigPreT( source:byte; channel:word; level:word; preCount:word; postCount:word):integer;
The analog trigger source -
DtsAnalogFallNeg
The channel in the current scan group t o trigger on The level for the specified c hannel at which to detect the trigger (0-4095) The number of pre-trigger scans t o collect before arming t he trigger (1-32767) The number of post-trigger sc ans to collect after the occurrence of the trigger (1-32767)
TerrInvTrigSource TerrInvLevel TerrNoError tbkSetFreq, tbkSetClk, tbkRdNForePreT, tbkRdNForePreTWait, tbkRdNBackPreT
PRETEX1, PRETEX2, PRETEX3 (ALL LANGUAGES)
DtsAnalogRisePos, DtsAnalogFallPos, DtsAnalogRisNeg,
- Invalid trigger
- Invalid level
- No error
sets the trigger for analog level triggering and initiates the collection of a pre-
tbkSetTrigPreT
command will stop any current acquisition,
The pacer clock may be used to set up the sampling rate for the acquisition. The sampling rate can best be set by using the
The four analog trigger sources, rising or falling slope with either a positive or negative level, can be used with any one of the channels in the currently defined scan group. This channel parameter represents the relative channel within the scan group. It does not necessarily represent the actual physical channel number.
When setting up a pre-trigger acquisition, a specific command set must be used to retrieve the data. This command set includes
tbkRdNBackPreT
for each specific command in this chapter.
9-26 tbkCommand Referenc e (
Standard
tbkSetClk
or
tbkSetFreq
tbkRdNForePreT, tbkRdNForePreTWait
commands.
and
. For more information on these commands, refer to the command description
API) TempBook User’s Manual
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters Returns See Also Program References
tbkSoftTrig
int tbkSoftTrig(void); tbkSoftTrig(void); BtbkSoftTrig% () VBtbkSoftTrig% () tbkSoftTrig:integer;
None
TerrNoError tbkSetTrig
- No error
is used to send a software trigger command to the TempBook. This software trigger can be used to initiate a scan or an acquisition from a program after configuring the software trigger as the trigger source.
DLL Function int tbkStopBack(void); C QuickBASIC Visual Basic Turbo Pascal Parameters Returns See Also Program References
tbkStopBack
tbkStopBack(void); BtbkStopBack% () VBtbkStopBack% () tbkStopBack:integer;
None
TerrNoError tbkRdNBack, tbkGetBackStat
- No error
stops a background operation initiated by the
tbkRdNBack
tbkSoftTrig
tbkStopBack
function.
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uint zero
Returns
See Also
Program References
tbkTCAutoZero
tbkTCAutoZero(uint zero); tbkTCAutoZero(unsigned zero); BtbkTCAutoZero% (ByVal zero%) VBtbkTCAutoZero% (ByVal zero%) tbkTCAutoZero( zero:word):integer;
If non-zero will enable auto zero compensation in the
TerrZCInvParam TerrNoError tbkZeroSetup, tbkZeroConvert, tbkZeroSetupConvert, tbkTCSetup, tbkTCConvert, tbkTcSetupConvert
None
The
tbkTCAutoZero
- Invalid parameter value
- No error
function will configure the thermocouple linearization functions to automatically perform zero compensation. This is the easiest way to use zero compensation with the TempBook. When enabled, the thermocouple conversion functions will require a CJC zero reading and a TC zero reading to precede the actual CJC and TC reading.
tbkTC
… functions
TempBook User’s Manual tbkCommand Referenc e (
Standard
API) 9-27
tbkTCConvert
DLL Function C
QuickBASIC Visual Basic Turbo Pascal Parameters
uint *counts uint scans int * temp uint ntemp
Returns
See Also Program References
tbkTCConvert
degrees Celsius. Note: Total number of conversions (scan * chans/scan) must be less than 32 K.
tbkTCSetup
DLL Function
C
QuickBASIC
Visual Basic
Turbo Pascal
Parameters
uint nscan
uint cjcPosition
uint ntc
uint tcType uint bipolar uint avg
Returns
See Also Program References
tbkTCSetup
tbkTcConvert (uint *counts, uint scans ,int *temp, uint ntemp); tbkTCConvert(unsigned _far *counts, unsigned scans, int _far *temp, unsigned
ntemp); BtbkTCConvert% (counts%, ByVal scans%, temp%, ByVal ntemp%) VBtbkTCConvert% (counts%(), ByVal scans%, temp%(), ByVal ntemp%) tbkTCConvert(counts:WordP; scans:word; temp:DataP; ntemp:word):integer;
Raw A/D data from one or more sc ans Number of scans of raw data in c ounts Variable array to hold converted temperatures Size of temperature array
TerrTCE_NOSETUP TerrTCE_PARAM TerrNoError tbkTCSetup, tbkTCSetupConvert
None
- Setup was not called
- Param out of range
- No Error
takes raw A/D readings and converts them to temperature readings in tenths of
tbkTCSetup(uint nscan, uint cjcPosition, uint ntc , uint tcType, uchar bipolar, uint avg); tbkTCSetup(unsigned nscan, unsigned cjcPosition, unsigned ntc, unsigned tcType, unsigned char bipolar, unsigned avg); BtbkTCSetup% (ByVal nscan%, ByVal cjcPosition%, ByVal ntc%, ByVal tcType%, ByVal bipolar%, ByVal avg%) VBtbkTCSetup% (ByVal nscan%, ByVal cjcPosition%, ByVal ntc%, ByVal tcType%, ByVal bipolar%, ByVal avg%) tbkTCSetup(nscan, cjcPosition, ntc, tcType:word; bipolar:byte; avg:word):integer;
Number of readings in a scan. Valid range: 1- 512 Position of CJC reading within a scan. Valid range: 0 - (nscan-1) 2 -(nscan-1), if auto-zeroing is used. Number of thermocoupl es immediately f ollowing CJC. Valid range: 1 - (nscan-cjcposition-1) Type of thermocouple (see tabl e at end of chapter for valid types) Zero for unipolar, non-zero for bipolar. Type of averaging to be used.
TerrTCE_PARAM TerrTCE_TYPE TerrNoError tbkTCConvert, tbkTCSetupConvert
None
- Parameter out of range
- Invalid thermocouple type
- No Error
sets up paramete rs for subsequent temperature conversions.
9-28 tbkCommand Referenc e (
Standard
API) TempBook User’s Manual
DLL Function
C
QuickBASIC
Visual Basic
Turbo Pascal
Parameters
uint nscan
uint cjcPosition
uint ntc
uint tcType uint bipolar uint avg uint *counts uint scans int *temp uint ntemp
Returns
See Also Program References
int tbkTCSetupConvert(uint nscan,uint cjcPosition, uint ntc, uint tcType,uchar bipolar,uint avg, uint *counts, uint scans, int *temp, ); tbkTCSetupConvert(unsigned nscan, unsigned cjcPosition, unsigned ntc, unsigned tcType, unsigned char bipolar, unsigned avg, unsigned _far *counts, unsigned scans, int _far *temp, unsigned ntemp); BtbkTCSetupConvert% (ByVal nscan%, ByVal cjcPosition%, ByVal ntc%, ByVal tcType%, ByVal bipolar%, ByVal avg%, counts%, ByVal scans%, temp%, ByVal ntemp%) VBtbkTCSetupConvert% (ByVal nscan%, ByVal cjcPosition%, ByVal ntc%, ByVal tcType%, ByVal bipolar%, ByVal avg%, counts%(), ByVal scans%, temp%(), ByVal ntemp%) tbkTCSetupConvert(nscan, cjcPosition, ntc, tcType:word; bipolar:byte; avg:word; counts:WordP; scans:word; temp:DataP; ntemp:word):integer;
The number of readings in a single s can. Valid range: 1- 512 The position of the CJC reading within the scan. Valid range: 0 - (nscan-1) 2 -(nscan-1), if auto-zeroing is used. The number of thermocouple readi ngs that immediately follow the CJC reading within the scan. Valid range: 1 - (nscan-cjcposition-1) The type of thermocouples being measured (see table at end of c hapter for valid types) Non-zero if the TempBook/66 is configured for bipolar readings. The type of averaging to be performed: block, none or moving. The raw data from one or more scans. The number of scans of raw data in counts. The converted temperatures in t enths of a degree C. The number of elements provi ded i n the temp array (for error check i ng).
TerrTCE_PARAM TerrTCE_TYPE TerrNoError tbkTCSetup, tbkTCConvert
None
- Invalid thermocouple type
- No Error
tbkTCSetupConvert
tbkTCSetupConvert
- Parameter out of range
sets up and converts raw A/D readings into temperature readings.
tbkWtBit
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uchar bitNum
uchar bitVal
Returns
See Also Program References
tbkWtBit
TempBook User’s Manual tbkCommand Referenc e (
int tbkWtBit(uchar bitNum, uchar bitVal); tbkWtBit(unsigned char bitNum, unsigned char bitVal); BtbkWtBit% (ByVal bitNum%, ByVal bitVal%) VBtbkWtBit% (bitNum%, bitVal%) tbkWtBit( bitNum:byte; bitVal:byte ):integer;
The bit number to assert/ unassert Valid values: 0 - 7 A flag that if non-zero will assert the specified bit , if 0 the bit is unasserted
TerrInvBitNum TerrNoError tbkWtByte, tbkRdByte, tbkRdBit
- Invalid bit number
- No error
sets or clears a single digital output bit.
Standard
API) 9-29
tbkWtByte
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uchar byteVal
Returns See Also Program References
tbkWtByte
tbkWtCntr0
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uint cntr0
Returns See Also Program References
tbkWtCntr0
applications of counter 0.
int tbkWtByte(uchar byteVal); tbkWtByte(unsigned char byteVal); BtbkWtByte% (ByVal digOut%) VBtbkWtByte% (ByVal digOut%) tbkWtByte( byteVal:byte ):integer;
The value to write to the specified port Valid values: 0 - 255 for 8-bit port s 0-15 for 4-bit ports
TerrNoError tbkRdByte, tbkWtBit, tbkRdBit
- No error
writes a byte to the 8-bit digital output port.
int tbkWtCntr0(uint cntr0); tbkWtCntr0(unsigned cntr0); BtbkWtCntr0% (ByVal cntr0%) VBtbkWtCntr0% (ByVal cntr0%) tbkWtCntr0( cntr0:word ):integer;
The value to write to the count down register of Counter 0 Valid values: 0 - 65535
TerrNoError tbkConfCntr0, tbkRdCntr0
- No error
loads the count down register of Counter 0. See
tbkAdcConfCntr0
for various
tbkZeroConvert
DLL Function C QuickBASIC Visual Basic Turbo Pascal Parameters
uint *counts uint scans
Returns
See Also Program References
The
tbkZeroConvert
tbkZeroSetup
Software Calibration and Zero Compensation chapter for a complete description of zero compensation.
9-30 tbkCommand Referenc e (
tbkZeroConvert(uint *counts, uint scans); tbkZeroConvert(unsigned *counts, unsigned scans); BtbkZeroConvert% (counts%, ByVal scans%) VBtbkZeroConvert% (counts%(), ByVal scans%) tbkZeroConvert(counts:WordP; scans:word):integer;
The raw data from one or more scans. The number of scans of raw data in t he counts array.
TerrZCInvParam TerrNoError tbkZeroSetup, tbkZeroSetupConvert, tbkAutoZero
None
- Invalid parameter value
- No error
function compensates one or more scans according the previously called
function. This function will modify the array of data passed to it. See the
Standard
API) TempBook User’s Manual
DLL Function
C
QuickBASIC
Visual Basic
Turbo Pascal
Parameters
uint nscan uint zeroPosition uint
readingsPosition
uint nReadings
Returns
See Also Program References
The zeroed within a scan, the size of the scan and the number of readings to zero. This function does not do the conversion. A non-zero return value indicates an invalid parameter error. See the Software Calibration and Zero Compensation chapter for a complete description of zero compensation.
tbkZeroSetup
tbkZeroSetup(uint nscan, uint ZeroPosition, uint readingsPosition, uint nReadings); tbkZeroSetup(unsigned nscan, unsigned zeroPos, unsigned readingsPos, unsigned nReadings); BtbkZeroSetup% (ByVal nscan%, ByVal zeroPosition%, ByVal readingsPos%, ByVal nReadings%) VBtbkZeroSetup% (ByVal nscan%, ByVal zeroPosition%, ByVal readingsPos%, ByVal nReadings%) tbkZeroSetup( nscan:word; zeroPos:word; readingsPos:word; nReadings:word):integer;
The number of readings in a single s can. The position of the zero reading within the scan The position of the readings to be zeroed within the scan.
The number of readings immediately following the zero reading that are sampled at the sam e gai n as the zero reading.
TerrZCInvParam TerrNoError tbkZeroConvert, tbkZeroSetupConvert, tbkAutoZero
None
tbkZeroSetup
- Invalid parameter value
- No error
function configures the location of the shorted channel and the channels to be
DLL Function
C
QuickBASIC
Visual Basic
Turbo Pascal
Parameters
uint nscan uint zeroPosition uint
readingsPosition
uint nReadings
uint *counts uint scans
Returns
See Also Program References
For convenience, both the setup and convert steps can be performed with one call to
tbkZeroSetupConvert
multiple times because data was read from channels at different gains or polarities. See the Software Calibration and Zero Compensation chapter for a complete description of zero compensation.
tbkZeroSetupConvert
tbkZeroSetupConvert(uint nscan, uint ZeroPosition, uint readingsPosition, uint nReadings, uint *counts, uint scans); tbkZeroSetupConvert(unsigned nscan, unsigned zeroPos, unsigned readingsPos, unsigned nReadings, unsigned *counts, unsigned scans); BtbkZeroSetupConvert% (ByVal nscan%, ByVal zeroPosition%, ByVal readingsPos%, ByVal nReadings%, counts%, ByVal scans%) VBtbkZeroSetupConvert% (ByVal nscan%, ByVal zeroPosition%, ByVal readingsPos%, ByVal nReadings%, counts%(), ByVal scans%) tbkZeroSetupConvert(nscan:word;zeroPos:word;readingsPos:word;nReadings:word; counts:WordP;scans:word):integer;
The number of readings in a single s can. The position of the zero reading within the scan The position of the readings to be zeroed within the scan.
The number of readings immediately following the zero reading that are sampled at the sam e gai n as the zero reading. The raw data from one or more scans. The number of scans of raw data in t he counts array.
TerrZCInvParam TerrNoError tbkZeroSetup, tbkZeroConvert, tbkAutoZero
None
- Invalid parameter value
- No error
. This is useful when the zero compensation needs to be performed
TempBook User’s Manual tbkCommand Referenc e (
Standard
API) 9-31

API Reference Tables

These tables provide information for programming with the TempBook/66 Application Programming Interface. The tables are organized as follows:
API Parameter Reference Tables
Table Tit le Page
A/D Channel Descriptions 9-32 A/D Gain Definitions 9-32 A/D Trigger Source Definitions 9-32 Pretrigger Functions Trigger Sourc e Def i ni tions 9-33 Thermocouple Types 9-33 API Error Codes - C Languages 9-33 API Error Codes - QuickBASIC 9-34 API Error Codes - Turbo Pascal 9-35 API Error Codes - Visual Basic 9-36
A/D Channel Descriptions
A/D Channel Source
0 to 15* Analog input channels 0 t o 15 16 CJC Channel 18 Shorted Channel 272 High-speed digital Inputs *Note: In differential mode only channels 0 to 7 are valid.
A/D Gain Definitions
BASE UNIT Description Value
TgainX1 0x00 TgainX2 0x10 TgainX5 0x20 TgainX10 0x30 TgainX20 0x11 TgainX50 0x21 TgainX100 0x31 TgainX200 0x32
TbkBiCJC 0x21 TbkBiTypeJ 0x31 TbkBiTypeK 0x31 TbkBiTypeT 0x32 TbkBiTypeE 0x21 TbkBiTypeN28 0x31 TbkBiTypeN14 0x31 TbkBiTypeS 0x32 TbkBiTypeR 0x32 TbkBiTypeB 0x32 TbkUniCJC 0x31 TbkUniTypeJ 0x32 TbkUniTypeK 0x32 TbkUniTypeT 0x32 TbkUniTypeE 0x31 TbkUniTypeN28 0x32 TbkUniTypeN14 0x32 TbkUniTypeS 0x32 TbkUniTypeR 0x32 TbkUniTypeB 0x32
9-32 tbkCommand Referenc e (
A/D Trigger Source Definitions
Definition Value Trigger
TtsPacerClock TtsSoftware TtsTTLFall TtsTTLRise
Standard
API) TempBook User’s Manual
0x00 8254 Pacer Cloc k 0x10 Software 0x20 External TTL falling edge 0x30 External TTL rising edge
Error Name
TerrNoError TerrBadChannel TerrNotOnLine TerrNoTempBook TerrBadAddress TerrFIFOFull TerrInvChan TerrInvCount TerrInvTrigSource TerrInvGain TerrInvPort TerrInvChip TerrInvBitNum TerrInvClock TerrInvTod TerrInvGateCtrl TerrInvOutputCtrl TerrInvInterval TerrTypeConflict TerrMultBackXfer TerrInvDiv TerrTCE_TYPE TerrTCE_TRANGE TerrTCE_VRANGE TerrTCE_PARAM TerrTCE_NOSETUP
TerrOverrun TerrZCInvParam TerrZCNoSetup
TerrInvCalFile TerrMemLock TerrMemHandle TerrNoPreTActive
Pretrigger Functions Trigger Source Definitions
Definition Value Trigger
TtsAnalogFallNeg TtsAnalogRiseNeg TtsAnalogRisePos TDtsAnalogFallPos
0x40 Falling below a negative setpoint 0x50 Rising above a negative setpoint 0x60 Rising above a positive setpoint 0x70 Falling below positive set poi nt
Thermocouple
Types
Description Value
TbkTypeJ TbkTypeK TbkTypeT TbkTypeE TbkTypeN28 TbkTypeN14 TbkTypeS TbkTypeR TbkTypeB
18 19 20 21 22 23 24 25 26
API Error Codes - C Languages
Error Code Description
0x00 No error 0x01 Specified LPT c hannel was out -of-range 0x02 Requested TempBook is not on-line 0x03 TempBook is not on the requested channel 0x04 Bad function addres s 0x05 FIFO Full detected, possible data corruption 0x10 Invalid analog input c hannel 0x11 Invalid count parameter 0x12 Invalid trigger source parameter 0x14 Invalid channel gain parameter 0x17 Invalid port param et er 0x18 Invalid chip parameter 0x1A Invalid bit number parameter 0x1B Invalid clock parameter 0x1C Invalid time-of-day parameter 0x20 Invalid gate control parameter 0x21 Invalid output control parameter 0x22 Invalid interval parameter 0x23 An integer was passed to a function requiring a character 0x24 A second back ground t ransfer was requested 0x25 Invalid Fout divis o r 0x26 TC type out-of-range 0x27 Temperature out-of-CJC-range 0x28 Voltage out-of-TC-range 0x29 Unspecified parameter value error 0x2A 0x2C A buffer overrun occ urred 0x2D Invalid zero com pensation parameter 0x2E 0x2F Cannot open the specified calibration f i l e 0x30 Cannot lock allocated memory from Windows 0x31 Cannot get a memory handle from Windows 0x32 No pre-trigger configured
tbkTCConvert
tbkZeroConvert
called before
tbkTCSetup
called before
tbkZeroSetup
TempBook User’s Manual tbkCommand Referenc e (
Standard
API) 9-33
Error Name
CONST TerrNoError% CONST TerrBadChannel% CONST TerrNotOnLine% CONST TerrNoTempBook% CONST TerrBadAddress% CONST TerrFIFOFull% CONST TerrInvChan% CONST TerrInvCount% CONST TerrInvTrigSource% CONST TerrInvGain% CONST TerrInvPort% CONST TerrInvChip% CONST TerrInvBitNum% CONST TerrInvClock% CONST TerrInvTod% CONST TerrInvGateCtrl% CONST TerrInvOutputCtrl% CONST TerrInvInterval% CONST TerrTypeConflict% CONST TerrMultBackXfer% CONSTTerrInvDiv% CONST TerrTCE.TYPE CONST TerrTCE.TRANGE CONST TerrTCE.VRANGE CONST TerrTCE.PARAM CONST TerrTCE.NOSETUP
CONST TerrOverrun% CONST TerrZCInvParam CONST TerrZCNoSetup
CONST TerrInvCalFile CONST TerrMemLock CONST TerrMemHandle CONST TerrNoPreTActive
API Error Codes - QuickBASIC
Error Code Description
&H00 No error &H01 Specified LP T channel was out-of-range &H02 Requested TempBook is not on-line &H03 TempBook i s not on the requested channel &H04 Bad functi on address &H05 FIFO Full detect ed, possible data corruption &H10 Invalid &H11 Invalid count parameter &H12 Invalid trigger source parameter &H14 Invalid channel gai n parameter &H17 Invalid port parameter &H18 Invalid chip parameter &H1A Invalid bit number parameter &H1B Invalid clock parameter &H1C Invalid time-of-day parameter &H20 Invalid gate c ont rol parameter &H21 Invalid output control parameter &H22 Invalid interval parameter &H23 An integer was passed to a function requiring a charact er &H24 A second background transfer &H25 Invalid Fout divi sor &H26 TC type out of range &H27 Temperature out-of-CJC-range &H28 Voltage out-of-TC-range &H29 Unspecifi ed parameter value error &H2A &H2C A buffer overrun occurred &H2D Invalid zero compensation parameter &H2E &H2F Cannot open the specified calibrati on file &H30 Cannot lock al l ocated memory from Windows &H31 Cannot get a memory handle from Windows &H32 No pre-trigger confi gured
tbkTCConvert
tbkZeroConvert
called before
tbkTCSetup
called before
tbkZeroSetup
9-34 tbkCommand Referenc e (
Standard
API) TempBook User’s Manual
Error Name
TerrNoError TerrBadChannel TerrNotOnLine TerrNoTempBook TerrBadAddress TerrFIFOFull TerrInvChan TerrInvCount TerrInvTrigSource TerrInvGain TerrInvPort TerrInvChip TerrInvBitNum TerrInvClock TerrInvTod TerrInvGateCtrl TerrInvOutputCtrl TerrInvInterval TerrTypeConflict TerrMultBackXfer TerrInvDiv TerrTCE_TYPE TerrTCE_TRANGE TerrTCE_VRANGE TerrTCE_PARAM TerrTCE_NOSETUP
TerrNot Capable TerrOverrun TerrZCInvParam TerrZCNoSetup
TerrInvCalFile TerrMemLock TerrMemHandle TerrNoPreTActive
API Error Codes - Turbo Pascal
Error Code Description
0 No error 1 Specified LPT channel was out-of-range 2 Requested TempBook is not on-l i ne 3 TempBook is not on the requested channel 4 Bad function address 5 FIFO Full detected, possible data corruption 16 Invalid 17 I nval i d count parameter 18 I nval i d trigger source parameter 20 I nval i d channel gain parameter 23 I nval i d port parameter 24 I nval i d chip parameter 26 I nval i d bi t number parameter 27 I nval i d clock parameter 28 I nval i d time-of-day parameter 32 I nval i d gate control parameter 33 I nval i d output control parameter 34 I nval i d i nterval parameter 35 A n i nt eger was pas sed to a function requiring a character 36 A second background transfer was request ed 37 I nval i d Fout divisor 38 TC t ype out -of -range 39 Temperature out-of-CJC-range 40 V ol t age out-of-TC-range 41 Uns pecified parameter value error 42 43 TempBook not capable of func tion 44 A buf fer overrun occurred 45 I nval i d zero compensation paramet er 46 47 Cannot open t he specified calibration file 48 Cannot l ock allocated memory from W i ndows 49 Cannot get a memory handle from Windows 50 No pre-t ri gger configured
tbkTCConvert
tbkZeroConvert
called before
tbkTCSetup
called before
tbkZeroSetup
TempBook User’s Manual tbkCommand Referenc e (
Standard
API) 9-35
API Error Codes - Visual Basic
Error Name
Global Const TerrNoError% Global Const TerrBadChannel% Global Const TerrNotOnLine% Global Const TerrNoTempBook% Global Const TerrBadAddress% Global Const TerrFIFOFull% Global Const TerrInvChan% Global Const TerrInvCount% Global Const TerrInvTrigSource% Global Const TerrInvGain% Global Const TerrInvPort% Global Const TerrInvChip% Global Const TerrInvBitNum% Global Const TerrInvClock% Global Const TerrInvTod% Global Const TerrInvGateCtrl% Global Const TerrInvOutputCtrl% Global Const TerrInvInterval% Global Const TerrTypeConflict% Global Const TerrMultBackXfer% Global Const TerrInvDiv% Global Const TerrTCE_TYPE% Global Const TerrTCE_TRANGE% Global Const TerrTCE_VRANGE% Global Const TerrTCE_PARAM% Global Const TerrTCE_NOSETUP%
Global Const TerrOverrun% Global Const TerrZCInvParam Global Const TerrZCNoSetup
Global Const TerrInvCalFile Global Const TerrMemLock Global Const TerrMemHandle Global Const TerrNoPreTActive
Error Code Description
&H00 No error &H01 Spec i f i ed LPT channel was out-of-range &H02 Request ed TempBook is not on-line &H03 Tem pBook is not on the requested c hannel &H04 Bad f unction address &H05 FIFO Full det ected, possible data corrupt ion &H10 Invalid &H11 Invalid count parameter &H12 Invalid trigger source parameter &H14 Invali d channel gain parameter &H17 Invalid port parameter &H18 Invalid chip parameter &H1A Invalid bit number parameter &H1B Invalid cl ock parameter &H1C Invalid time-of-day param eter &H20 Invali d gate control parameter &H21 Invali d output control parameter &H22 Inval i d i nterval parameter &H23 An integer was passed to a function requiring a character &H24 A s econd background transfer &H25 Inval i d Fout divisor &H26 TC type out-of-range &H27 Tem perature out-of-CJC-range &H28 Voltage out-of-TC-range &H29 Unspecified parameter value error &H2A &H2C A buffer overrun occurred &H2D Invalid zero compensation parameter &H2E &H2F Cannot open the specified c al i bration file &H30 Cannot lock allocated memory from Windows &H31 Cannot get a memory handle from Windows &H32 No pre-trigger configured
tbkTCConvert
tbkZeroConvert
called before
tbkTCSetup
called before
tbkZeroSetup
9-36 tbkCommand Referenc e (
Standard
API) TempBook User’s Manual
Enhanced API Programming Models (TempBook)

Overview

The enhanced Application Programming Interface (API) allows you to create custom software to satisfy your TempBook data acquisition requirements. Two chapters explain the enhanced API: this chapter gives you the basic concepts needed to write effective programs, and chapter 11 describes the API functions in detail. This chapter explains how to combine the API functions into useful routines and is divided into 3 parts:
Data Acquisition Environment outlines related concepts and defines system capabilities the programmer must work with (the API , hardware features, and signal management).
Programming Models explains the sequence and type of operations necessary for data acquisition. These models provide the software building blocks to develop more complex and specialized programs. The description for each model has a flowchart and example program excerpt.
Summary Guide of Selected API Functions is an easy-to-read table that describes when to use the basic API functions.
10
Note: The TempBook enhanced API is a subset of the
32-bit data acquisition applications (TempBook, WaveBook, DaqBook, DaqBoar d, Daq PC-Card, etc). This manual describes the commands that pertain to the TempBook.

Data Acquisition Environment

In order to write effective data acquisition software, programmers must understand:
Software tools (the API documented in this manual and the programming language—you may need to consult documentation for your chosen language)

Hardware capabilities and constraints

General concepts of data acquisition and signal management

Application Programming Interface (API)

The API includes all the software functions needed for building a data acquisition system with the hardware described in this manual. Chapter 11 (daqCommand Reference—Enhanced API) supplies the details about how each function is used (parameters, hardware applicability, etc). In addition, you may need to consult your language and computer documentation.

Enhanced vs Standard API

Major differences between the enhanced and standard APIs were described in the introductory chapter (Programmer’s Guide). Language support varies as follows:
The enhanced API (32-bit only) accommodates C, Visual Basic, and Delphi.
The standard API (16-bit only) accommodates C, QuickBASIC, Visual Basic, and Turbo Pascal 7.
Note: Coding for the enhanced and standard API cannot be used together; enhanced and standard models
are slightly different (this chapter is for the enhanced API models; chapters 6 to 8 demonstrate examples using the standard AP I).
DaqX
API which provides a common interface for
Hardware Capabilities and Constraints
To program the system effectively, you must understand your hardware capabilities. Obviously you cannot program the hardware to perform beyond its design and specifications, but you also want to take full advantage of the system’s power and features. You may need to refer to sections that describe your hardware’s capability. In addition, you may need to consult your computer documentation. In some cases, you may need to verify the hardware setup, use of channels, and signal conditioning options (some hardware devices have jumpers and DIP switches that must match the programming, especially as the system evolves).
TempBook User’s Manual
Enhanced
API Programming Models (TempBook) 10-1

Signal Environment

Several data acquisition concepts are listed here; you must apply these concepts as needed in your situation. Some of these concepts include:
Parameters in the various A/D routines include: number of channels, number of scans, start of conversion triggering, timing between scans, and mode of data transfer. Channels sampled in a scan can be consecutive or non-consecutive with the same or different gains. The scan sequence makes no distinction between local and expansion channels.
Device and parameter identification Scan rates and sequencing
. With multiple scans, the time between scans becomes a parameter.
. Refer to the related reference tables in chapter 11.
This time can be a constant or can be dependent upon a trigger.
Triggering options
. Triggering starts the A/D conversion. The trigger can be an external analog or
TTL trigger or a program-controlled software trigger. Refer to the trigger functions in chapter 11.
Foreground/background
. Foreground transfer routines require the entire transfer to occur before returning control to the application program. Background routines start the A/D acquisition and return control to the application program before the transfer occurs. Data is transferred while the application pro gram is running. Data will be transferred to the user memory buffer during program execution in 1 sample or 2048 sample blocks, depending on the configuration. The programmer must determine what tasks can proceed in the background while other tasks perform in the foreground and how often the status of the background operations should be checked.

Basic Models

This section outlines basic programming steps commonly used for data acquisition. Consider the models as building blocks that can be put together in different ways or modified as needed. As a general tutorial, these examples use Visual Basic since most programmers know BASIC and can transla t e to other languages as needed. The enhanced API programming models discussed in this chapter include:
Model Type Model Name Page Configuration Acquisition
Data Handling
Initialization and Error Handling 10-3 Foreground Acquisition with One-Step Commands
Temperature Acquisiti on Using One-Step Commands Counted Acquisition Usi ng Li near Buffers Indefinite Acquisi tion, Direct-To-Disk Using Circular Buffers Multiple Hardware Scans, Software Triggering Background Acquisit i on Temperature Acquisiti on Using TC Conversion Functions Double Buffering Direct-to-Disk Trans fers Transfers With Driver-Allocated Buffers
10-5 10-7
10-9 10-11 10-14 10-16 10-18 10-21 10-23 10-26
10-2
Enhanced
API Programming Models (TempBook) TempBook User’s Manual

Initialization and Error Handling

This section demonstrates how to initialize the Daq* and use various methods of error handling. Most of the example programs use similar coding as detailed here. Functi ons used include:
VBdaqOpen&(daqName$)
VBdaqSetErrorHandler&(errHandler&)
VBdaqClose&(handle&)
All Visual Basic programs should include the DaqX.bas file into their project. The DaqX.bas file provides the necessary definitions and function prototyping for the DAQX driver DLL.
handle& = VBdaqOpen&(“TempBook0”) ret& = VBdaqClose&(handle&)
The Daq* device is opened and initialized with the
daqOpen
function.
daqOpen
takes one parameter— the name of the device to be opened. The device name information can be accessed or changed via the Daq* Configuration utility located in the operating system’s Control Panel. The
daqOpen
call, if successful, will return a handle to the opened device. This handle may then be used by other functions to configure or perform other operations on the device. When operations with the device are complete, the device may then be closed using the
daqOpen
will return -1.
daqClose
function. If the device could not be found or opened,
The DAQX library has a default error handler defined upon loading. However; if it is desirable to change the error handler or to disable error handling, then the
daqSetErrorHandler
function may be used to setup an error handler for the driver. In the following example the error handler is set to 0 (no handler defined) which disables error handling.
ret& = VBdaqSetErrorHandler&(0&)
If there is a Daq* error, the program will continue. The function’s return value (an error number or 0 if no error) c an help you debug a program.
If (VBdaqOpen&(“TempBook0”) < 0) Then
“Cannot open “TempBook0”
Daq* functions return
Print “daqErrno& : ”; HEX$(daqErrno&)
End If
daqErrno&
.
The next statement defines an error handling routine that frees us from checking the return value of every Daq* function call. Although not necessary, this sample program transfers program control to a user­defined routine when an error is detected. Without a Daq* error handler, Visual Basic will receive and handle the error, post it on the screen and terminate the program. Visual Basic provides an integer variable (ERR) that contains the most recent error code. This variable can be used to detect the error source and take the appropriate action. The function
daqSetErrorHandler
tells Visual Basic to assign ERR to a specific value when a Daq*error is encountered. The following line tells Visual Basic to set ERR to 100 when a Daq*error is encountered. (Other languages work similarly; refer to specific langua ge documentation as needed.)
handle& = VBdaqOpen&(“TempBook0”) ret& = VBdaqSetErrorHandler&(handle&, 100)
On Error GoTo ErrorHandler
The than the standard error handler that Visual Basic uses automatically. The program uses to transfer program control to the label ErrorHandler if an error is encountered.
Daq* errors will send the program into the error handling routine. This is the error handler. Program control is sent here on error.
TempBook User’s Manual
On Error GoTo
ErrorHandler:
command in Visual Basic allows a user-defined error handler to be provided, rather
On Error GoTo
Enhanced
API Programming Models (TempBook) 10-3
errorString$ = "ERROR in ADC1" errorString$ = errorString$ & Chr(10) & "BASIC Error :" + Str$(Err) If Err = 100 Then errorString$ = errorString$ & Chr(10) & "DaqBook Error
: " + Hex$(daqErrno&)
MsgBox errorString$, , "Error!"
End Sub
10-4
Enhanced
API Programming Models (TempBook) TempBook User’s Manual
Loading...