Text preview for : 24461A(KPC_TM_252CKPC488_252C2TM).pdf part of Keithley 24461A(KPC TM 252CKPC488 252C2TM) Keithley KPCI 24461A(KPC_TM_252CKPC488_252C2TM).pdf
Back to : 24461A(KPC_TM_252CKPC488_ | Home
KPC-TM
and
KPC488.2TM
Trigger MasterTM
Interfaces
User Guide
for the
KPGTM and KPC488.2TM
Trigger Master""
--
Interfaces
RwisionA-FebntaylSS8
Copvrishfl Kdtbley Data Acquisilicm 1993
ParI Number: 24461
KEITHLEY DATA ACQUlSlTiON - Keithley MetraSyWAsyst
440 Myles Slandiih Blvd., Taunton, MA 02780
TEL 508/880-3000, FAX 508/880.0179
-3-
Warranty Information
All products manufactured KeithIeyDataAcquisitionarewarrantedagsinst
by defectivematerials
and
workmanship foraperiodofone yearfrom thedateof deliveryto theoriginalpurchaser.Any product
that is found to be defectivewithin the warrantyperiod will, at the option of the manufacmrer, be
repairedor replaced.This warnutty doesnot apply M productsdamagedby improperuse,
Warning
Keithley Data Acquisition assumes liability for damagesconsequent
no
lo the use of tkii product. This product is not designedwith
componentsof a level of reliability suitable for use io life support or
critical applications.
Informationfurnishedby Keithley DataAcquisitionis believed beaccurateandreliable.However,
to
Keithley Data Acquisition assumes responsibilityfor the use of such information nor for any
no
infringementsof patentsor other rights of third partiesthat may result from its use.No licenseis
grantedby implicationor otherwiseunderany patentrights of Keithley Data Acquisition.
Copyright
All tights reserved. part of this publicationmay be reproduced,
No storedin a retrieval system,or
transmittedin any form by any means,electronic,mechanical,photoreproductive,recording, or
otherwisewithout the expressprior written permission Keithley Data Acquisition.
of
Note:
Keitkley MetraBy@`, Trigger Mast@`, and Trigger-LiokTMare trademarksof Keithley Data
Acquisition.
BASKI?' is a trademark DsrtmouthCollege.
of
IBM@' and Micro Channel Architecture'" are registeredtrademarksof International Business
MachinesCorporation.
PC, XT, AT, and PSh sre trademarks InternationalBusiness
of MachinesCorporation.
MicrosofttR'is a registeredtrademark Microsoft Corporation.
of
Turbo C'"' and TurboPascal'*' sre registeredtrademarks Borland IntemationaI.
of
-4-
Contents
CHAPTER 1 - INTRODUCTION
1.1 General Description l-l
1.2 Distribution Software 1-4
1.3 Specifications I-4
1.4 Trigger-Link 1-5
CHAPTER 2 - INSTALLING Trigger Master
2.1 Introduction 2-1
2.2 Inspecting the Boards 2-1
2.3 Setting Up the KPC-TM Board 2-2
2.4 Setting Up the KPC488.2TM Board 2-3
2.5 Installing Trigger Master 2-4
2.6 Running PLAYDOS.EXE or PLAYWIN.EXE 2-4
CHAPTER 3 - USING THE Trigger Master DRIVER
3.1 Introduction 3-1
3.2 Using the Driver 3-I
Using the Driver with BASICA 3-1
Accessing the Driver from C 3-2
Accessing the Driver from QuickBASIC and VisualBASIC 3-2
QuickBASIC 3-2
VisualBASIC 3-3
Accessing the Driver from TurboPascal 3-3
3.3 STCINIT 3-4
Calling STCINIT from BASICA 3-4
Calling STCINIT from C 3-5
Calling STCINIT from QuickBASIC and VisualBASIC 3-5
Calling STCINIT from TurboPascal and TurboPascal for Windows 3-5
3.4 STCSET 3-6
Calling STCSET from BASICA 3-6
Calling STCSETfmm C 3-6
Calling STCSET from QuickBASiC and VisualBASIC 3-7
Calling STCSET from TurboPascal and TurboPascal for Windows 3-7
3.5 STCCMD 3-7
Command Syntax 3-8
General Information 3-8
Line Numbers 3-Q
Extensions 3-9
Integer Arguments 3-Q
Time Scales 3-10
Contents
Sending Commands in the Programming Languages 3-l 1
Calling STCCMD from BASICA 3-11
Calling STCCMD from C 3-l 1
Calling STCCMD from QuickBASIC and VisualBASIC 3-12
Calling STCCMD from TurboPascal and
TurboPascal for Windows 3-12
The Command Set 3-13
ARM 3-13
BEGIN 3-14
CONT 3-14
DO 3-15
END 3-15
FLAG 3-15
HALT 3-l 6
LOOP 3-16
TRIG 3-16
WAIT 3-17
X 3-17
3.6 STCSTAT 3-18
Request Syntax 3-19
General 3-19
Extensions 3-19
Making Requests in Programming Languages 3-19
Calling STCSTAT from BASICA 3-20
Calling STCSTAT from C 3-20
Calling STCSTAT from QuickBASIC and VisualBASIC 3-20
Calling STCSTAT from TurboPascal and
TurboPascal for Windows 3-21
Values Returned by STCSTAT 3-21
Interpreting Values in BASICA 3-22
Interpreting Values in C 3-24
Interpreting Values in QuickBASIC and VisualBASIC 3-25
Interpreting Values in TurboPascal and
TurboPascal for Windows 3-26
The Request Set 3-27
ARM 3-27
CONT 3-27
FLAG 3-28
LOOP 3-28
STATUS 3-29
TRIG 3-30
WAIT 3-31
-6-
3.7 STCLOAD 3-31
Calling STCLOAD from BASICA 3-31 -
Calling STCLOAD from C 3-31
Calling STCLOAD from QuickBASIC and VisualBASIC 3-32
Calling STCLOAD from TurboPascal and
TurboPascal for Window 3-32
3.8 STCDUMP 3-32
Calling STCDUMP from BASICA 3-32
Calling STCDUMP from C 3-33
Calling STCDUMP from QuickBASIC and VisualBASIC 3-33
Calling STCDUMP from TurboPascal and
TurboPascal for Window 3-33
CHAPTER 4 - PROGRAMMING EXAMPLES
4.1 Introduction 4-1
4.2 BASICA Language Example 4-2
4.3 C Language Example 4-7
4.4 QuickBASIC Example 4-11
4.5 TurboPascal Example 4-15
CHAPTER 5 - CREATING PROGRAMS FOR Trigger Master MEMORY
5.1 Introduction 5-1
CHAPTER 6 - CREATING A BACKGROUND DATA ACQUlSllION SYSTEM
FORDOS
6.1 Introduction 6-1
6.2 The TSR Structure 6-2
NOKPC488 and MISSINGGPIBDEV 6-3
STCRUN 6-4
WAITONSTC and JMPWAITSTC 6-5
WAITONGPIB and WAITONAUX 6-5
STCFLAG 6-5
STCLOG 6-6
STCEXIT 6-6
6.3 A TSR Log 6-7
6.4 A TSR Example 6-8
6.5 Creating a TSR for C 6-11
- 7.
Contents
APPENDIXES
Appendix A - Trigger Master ERROR MESSAGES
Appendix 6 - COMMAND QUICK START
B.l Generate Trigger Outputs B-1
8.2 Waft For Trigger Inputs B-l
8.3 Enter Program Mode B-2
0.4 Set Up and Terminate Program Loop (Program Mode Only) B-2
8.5 Generate a Wait (Program Mode Only) 0-2
B.6 Track Program Execution and Generate interrupts B-2
B.7 Exit Program Mode B-3
8.6 lnftiate Program Execution B-3
B.9 Halt Trigger Master Execution B-3
B.10 Continue Execution of Halted Program B-3
Appendix C - REQUEST QUICK START
C.1 Check Remaining Trigger Inputs Established by
ARM Command C-l
c.2 Check Remaining Trigger Outputs Established by TRIG Command C-l
c.3 Check the Actual State of the Trigger Lines C-l
c.4 Check Time Remaining Before Next Trigger C-l
C.5 Check Program Progress c-2
C.6 Check Remaining Loop Count c-2
c.7 Check Remaining Delay Time c-2
-.s-
Chapter 1
INTRODUCTION
1.1 GENERAL DESCRIPTION
Trigger Masterm is a system trigger controller for instruments and data acquisition
boards with external triggering. Trigger Master supports a variety of trigger functions
occurring in data acquisition systems.Trigger Master monitors trigger inputs, creates
delays, and generatestrigger outputs.
An outstanding feature of Trigger Master is its ability to run programs from its own
memory and to generateinterrupts at appropriate stepsof program execution. This
allows Trigger Master, with some adjunct data acquisition hardware, to operate as an
autonomous data acquisition system in your personal computer (PC) while you use
your PC for other purposes,
Trigger Master is implemented on two boards:
. The KPC-TM board provides Trigger Master as a stand-alone plug-in board for the
PCru/XTn'/ATn"' computer.
. The KPC488.2TMboard combines Trigger Master with the high performance
KPC488.2ATGPIB interface to provide a standard interface with GPIB instruments.
Note: This manual describesTrigger Master. For information on the IEEE-488
functions, refer to the manual IEEE 488 InterfaceBoardswhich accompaniesthe
KPC488.2TMboard.
Figure l-1 is a block diagram of Trigger Master.
Physically, Trigger Master is equipped with an 8-pin MicroDIN connector which has 6
trigger lines and 2 ground lines. In addition to Trigger-Linkn' introduced later in this
chapter, the MicroDIN can connect directly to standard BNC connectors using the 8502
Trigger-Link Adapter.
Chapter 2 describesconfiguring and installtng the boards.
Trigger Master employs proprietary chips containing statemachines that run from an 8-
MHz clock. This allows Trigger Master to respond to a change of trigger inputs by
generating a trigger output within 1.25us. The state machine coordinates all functions
including the interfaces to Trigger-Link and the PC bus.
A PC program controls Trigger Master using 11 SCPI-like commands which a driver
transforms to microcode instructions, sending them to Trigger Master. Trigger Master
supports three modes of operation:
INTRODUCTION l-1
Figure l-1 Trigger Master Block Diagram
. One mode of operation, ImmediateMode,allows some commands to be executed
immediately by Trigger Master.
. The secondmode of operation, ProgrumMode, allows Trigger Master to store
commands in a 1-Kbyte program RAM as they are received for later execution.
Storing the program into RAM provides extremely powerful performance, since the
state machine can perform two level looping (one nested loop); for repeated
operations, the state machine uses available counters. This mode allows you to start
program storage and execution at any memory location, therefore allowing several
small programs to be resident in memory and allowing you to start them as
required.
. The third mode of operation, Run Mode,occurs while the Trigger Master executesa
program.
A user can generatetrigger programs using any of the following methods:
. Passcommand strings from the user program to the Trigger Master driver.
. Write trigger programs using an ASCII-output word processorand then compile the
programs with STCCOMP.EXE.
. Program interactively using PLAYWIN.EXE and PLAYDOSEXE, running,
respectively, from the Windows and DOS environments.
Any word processorthat provides ASCII output allows you to write Trigger Master
programs, store them in ASCII, and then "compile" the output using the STCCOMP.EXE
program. Chapter 6 describesthis procedure. The resulting "object" file is then easily
loaded into Trigger Master program memory and executed.
1 - 2 Trigger Master INTERFACES USER GUIDE
The Trigger Master driver supports up to four boards simultaneously. The driver
acceptsthe following commands:
ARM Set trigger input condition and wait for trigger
BEGIN Enter program mode
CONT Restarta halted program at the next step
DO Mark the start of a program sequencethat is to be performed as a loop
END Mark the end of a program mode sequencewith a HALT and return to
immediate mode
FLAG Write a value to a diagnostic flag register (to trace program execution)
HALT Halt Trigger Master operation
LOOP Mark the end of a program loop
TRIG Generatetriggers
WALT Cause a program to executea time delay
X Begin program execution
The program STCRUNCOBJ,described in Chapter 6, builds terminate-and-stay-resident
programs (TsRs)for programs written in C. These programs are driven by interrupts
generated by the Trigger Master; the programs can run in the background in a DOS
environment while you run other programs from DOS.
Chapter 3 describesthe PLAYDOSEXE and PLAYWIN.EXE programs which allow you
to become familiar with the commands and requests,test your hardware without doing
any programming, and generateTrigger Master programs for future execution.
PLAYDOSEXE runs in the DOS environment, while PLAYWINEXE executesfrom
Windows. Referto Appendix B for a quick start on the commands and Chapter 3 for a
detailed description of the commands.
In addition to sending commands to Trigger Master you can also request information
from Trigger Master. Trigger Master supports the following requests:
ARM Return information about the trigger detect circuitry
CONT Return the current Trigger Master program position
FLAG Read the value from the diagnostic flag register
LOOP Return the execution status of a Trigger Master program loop
STATUS Return the value from the Trigger Master status register
TRIG Return information about the trigger output circuitry
WAIT Return the remaining delay time
Refer to Appendix C for a quick start on the requests and seeChapter 3 for a detailed
description of the requests.Chapter 4 provides programming examples of the
commands and requestsin the supported languages.
INTRODUCTION l-3
1.2 DISTRIBUTION SOFIWARE
This manual refers to Trigger Master software as the Di.dribution Software. The
Distribution Software contains utility files and driver files. Chapter 3 discussesthese
1.3 SPEClFlCATlONS
Channels: 6 Input/Output
Basic Functions: Trigger Detection
Trigger Generation
Delay Generation
PC Interrupts
Micro Sequencer:
Modes: Program, Immediate, or Run
Looping: 2 Levels
Loop Repeat: 1 - 4096
Trigger Repeat: l-4096
Sequencer RAM: 1024bytes
Time Base Drift: 100ppm max
Trigger Input Pulse Width: 4OOnsmin
Trigger Output Pulse Width: 5us
Detection Latency: 900 ns max
Async Trigger Latency: 2.2 us max (trigger in to trigger out)
Programmable Delay: Range Resolution
1 us to 65.536ms 1 us
10 us to 655.36ms 1ous
100us to 6.5546set 100us
1 ms to 65.536set 1 ms
Trigger Connector: &pin microDIN
Modes: Sync, semi-sync (Trigger-Link), async
Power Consumption:
KPC-TM: 450mA @5Vmax
KPC488.2T2TM: 1650mA @5Vmax
Environmental:
Operating Temperature: oto+70c
Storage Temperature: -25 to +85 C
Humidity: 0 to 95%, non-condensing
Dimensions:
KPC-TM: 4.25in H x 5.0 in. W (half-slot)
KPC488.2TM: 4.25in. H x 13.25in. W (ii.ilI slot)
Software:
Call Driver Languages: BASICTM, QuickBASIC, C, Turbol'ascalsr',
VisualBASIC for DOS.
Trigger Master DLL: Operation with Windows 3.x languages.Includes
VisualBASIC, Borland C++, C for Windows, and
TurboPascal.
1 - 4 Trlgger Master INTERFACES USER GUIDE
1.4 Trigger-Link
Trigger Master supports Trigger-Liim, which brings a new dimension of flexibility,
accuracy,and throughput to test and instrumentation systems.This section introduces
the features of Trigger-Link
You can easily changethe trigger paths between instruments using Trigger-Link with
GPIB commands. The precise trigger signals on Trigger-Link enhancethe accuracy and
throughput of the system. Even systems which contain lnsbuments without Trlgger-
Link can benefit by using the 8502Trigger-Link Adapter. The 8502Trigger-Link Adapter
is the interface to Trigger-Link for conventional BNC trigger connections.Figure l-2
illustrates various Trigger-Link configurations.
Mechanically, Trigger-Link consistsof a cable with six signal paths and two grounds
which can be permanently daisy-chained between a group of instruments. The signal
paths convey trigger signals between instruments. With GPIB commands, instruments
can be configured to use one or more of the signal paths in a variety of modes.Thus the
trigger configuration of a group of instruments can be easily altered by software to suit
the requirements of a particular test.
ElectricalIy, Trigger-Link provides paths for trigger pulses between instruments, thus
eliminating the late&es involved with coordinating trigger functions with the GPIB
interface. This greatly increasessystem throughput and measurement preciseness all for
instrument systems.Instruments, which completely embrace the Trigger-Link standard,
employ a fast-track link between the trigger input and function execution and between
function conclusion and acknowledge output. Today, many instruments service the
trigger/acknowledge connectorsperiodically using a microprocessor that performs
other functions. However, this procedure results in unknown and variable timing
latencles as well as slower response.
Trigger-Link supports three trigger modes:
SYNC MODE A source sendsa trigger pulse or sequenceof pulses to synchronize
the activities of one or more receivers.There is no acknowledgement
from the receiver(s)that they have received a pulse and are
responding properly to the trigger(s).
ASYNC MODE The conventional two-wire handshake protocol where triggers are
sent on one line and the receiver acknowledges on a secondline.
Conceivably, multiple instruments could share a common trigger
source,but each instrument would require a separate
acknowledgement line.
SEMI-SYNC An innovative extension of the async mode which allows a single
trigger sourceand multiple receivers to carry out a handshake on a
single line. The trigger source will pulse the trigger line to an active
state for about 5 us. Upon receipt of the bigger all receiverswlIl hold
the trigger line in the active state before the trigger source goes
inactive. Eachindividual receiver will continue to hold the line active
until that receiver is ready to acknowledge it has completed its task.
When the line goesinactive the trigger source will know that all
receivers have completed their tasks.
INTRODUCTION `I - 5
Figure l-2 Trigger-Link Configuration Examples
I- 6 Trigger Master INTERFACES USER GUIDE
Chapter 2
INSTALLING Trigger Master
2.1 INTFlODUCTlON
The installation of Trigger Master includes the following:
. inspecting the KPC-TM and KPC488.2TMboards.
. setting jumpers and switches on the KPC-TM and KPC488.2TMboards.
. inserting the two boards into your PC.
. attaching all cablesto the boards.
. running the PLAYDOS.EXEand PLAYWINEXE programs to exerciseand verify
proper operation of the boards.
2.2 INSPECTING THE BOARDS
Remove eachboard from their protective packaging by grasping the metal rear panel
and removing the board from the anti-static bubble package.
Note: You should handle the boards only by their edges.A static electric
discharge can damage the integrated circuits on the boards.
INSTALLING Trigger Master 2-1
2.3 SETTING UP THE KPC-TM BOARD
The KPC-TM board is a stand-alone system trigger controller which requires four byte-
wide I/O addresses.The board contains a switch to set up the baseaddress in
increments of four bytes. This switch decodesaddresslines A9 to A2. The KPC-TM
board ships with a default setting of 3lO(hexadecimal)as shown in Figure 2-l. The
position OFF corresponds to a logical 1 and the position ON to a logical 0. Table 2-1 lists
the baseaddresseswith the appropriate switch settings for each address.
Figure 2-l KPC-TM Card Jumper and Switch Locations.
You can configure the KPC-TM board to generate interrupts on levels 2 through 7 by
changing the jumper on jumper block J2.Trigger Master ships with the interrupts
disabled as shown in Figure 2-1.
Note: The KPC-TM BaseAddress switch settings are position values only. Refer to
Table 2-1 for the corresponding Address Line values.
Address Switch
Decimal Hexadecimal &&e m
512 200 9 1
256 100 a 2
128 80 7 3
64 40 6 4
32 20 5 5
16 10 4 6
a a 3 7
4 4 2 a
Table 2-l Base Address Switch Setdngs
2 - 2 Trigger Master INTERFACES USER GUIDE
2.4 SElllNG UP THE KPC488.2Thl BOARD
The KPC488.2TMboard implements the trigger master control function and GPIB
control function on the sameboard. Both the trigger master and GPIEifunctions can
generateinterrupts. This manual describesthe settings for the interrupt Jumpersand the
switch and jumper settings for the GPIB function. Refer to the accompanying user
manual, IEEE 488 InterfaceBoards, further information. Figure 2-2 shows the locations
for
of the jumpers and switches on the KPC488.2Th4 card.
2-2 KPC-488.2TIMCard Jumper and Switch Locations
To prevent the same level from being used by both functions, use the interrupt three-
row jumper blocks to selectthe interrupt.
Use Jumper blocks J5and J3,shown in Figures
3-2 and 3-3, to set the interrupts levels for the
GPIB and Trigger Master. The top and middle
rows of the jumper blocks set the GPIB
interrupt level, and the bottom and middle
rows set the Trigger Master level.
. Placing a lumper vertically on the upper
and middle rows enablesan interrupt level
for the GPIB. Placing a jumper vertically on
the middle and bottom rows enablesan
F3gurfs Jumper Blocks J5 and J
29
interrupt level for Trigger Master.
r%ampfe
. Placing the GPIB jumper horizontally on
the upper row disables the GPIB interrupt and placing the trigger master jumper
horizontally on the bottom row disables the bigger master interrupt.
Figure 2-3 illustrates enabling interrupt level 12 for the GPIB and enabling interrupt
level 15 for Trigger Master (note that level 13 is unavailable on the PC/AT bus).
INSTALLING Trigger Master 2 - 3
Trigger Master requires four byte-wide addresses; switch SW3 to set the base
use
address in increments of 4. The switch decodesaddresslines A9 through A2. The
position OFF corresponds to a logical 1 and the position ON to a logical 0. The boards
ship with a default setting of 3lO(hexadecimal)as shown in Figure 2-2.
2.5 INSTALLING Trigger Master
Follow this procedure to install Trigger Master into your PC.
1. Turn the PC power switch to OFF. Unplug the power cord and disconnect all cables
from the rear of the system unit.
2. Remove the cover mounting screws from the rear of the system unit.
3. Slide the system unit cover forward. When the cover can go no further, tilt it up and
remove it from the base.
Note: Install the KPC488.2TM board into a 16-bit slot; the KPC-TM board can
use an S-bit slot.
4. Remove the rear panel cover screw from one of the computers add-on slots.
5. Pressthe board firmly into the main board expansion slot.
6. SeatTrigger Master cable in the Micro-DIN connectorand align the board before
tightening the rear panel mounting screw.
7. Securethe board with the rear panel mounting screw.
8. Align the rear cover, sliding it back into place. Reinstall the mounting screws.
9. Turn on the PC.
10. Make a backup of all application diskettes before copying the applications to your
PC's hard disk.
11. Run the PLAYDOSEXE and PLAYWIN.EXE programs to exercisethe boards.
Sincethe Trigger Master cable should seatcompletely in the MICRO DIN connector, you
may want to insert the cable and test the alignment of the card before tightening the
screw holding the bracket.
2.6 RUNNING PLAYDOSEXE or PLAYYVINEXE
Check the hardware and exerciseTrigger Master after installation by running either the
PLAYDOSEXE or PLAYWIN.EXE program. PLAYDOSEXE runs from the DOS
environment and PLAYWIN.EXE executesin the Windows environment.
PLAYDOSEXE and PLAYWIN.EXE provide a menu interface to the standard Trigger
Master driver calls without requiring the use of a programming language. You can also
use theseprograms to create and document Trigger Master programs.
2 - 4 Trigger Master INTERFACES USER GUIDE
The driver supports the following calls, which are described in detail in Chapter 3:
STCCMD SendsTrigger Master commands to the active Trigger Master
either for immediate execution or storage in Trigger Master
program memory.
STCDUMP Savesthe contents of the active Trigger Master program memory
to a binary file.
STCINIT Checks for the presenceof a Trigger Master. If Trigger Master is
found, it is initialized and made active. The driver can
simultaneously control up to four boards in the same computer.
STCLOAD Loads the contents of a binary file into Trigger Master program
memory.
STCSET Selectsa different Trigger Master to becomeactive (this Trigger
Master must have been initialized).
STCSTAT Requestsstatus information from the active Trigger Master.
The PLAYDOSEXE and PLAYWIN.EXE programs operate by listing these calls in a
main menu. When you select a call from the main menu, a form appropriate to that call
appears.Windows or buttons are provided, where necessary,for entering data or
making selectionsspecific to that call. After l3ling in any blanks on the form, press the
button for the call to start execution. Any error messages retumed from the driver are
displayed.
Eachform contains a "Help" button that provides assistanceon that form. Context-
sensitive help is also available. To enable context-sensitivehelp, you must first include
the files PLAYWIN.HLP or PLAYDOSHLP in the samedirectory as the executible files
PLAYWIN.EXE or PLAYDOSEXE. Accesshelp by pressing cFl> in PLAYWIN.EXE or
Shift+If you selectthe STCCMD command from the main menu, a new menu appears listing
all the possible commands you may include with STCCMD. When you selecta
command, another form appears that is specific to the that command. When you push
the STCCMD button, a window displays the command string sent to the driver. The
"Man" selection is an option that allows you to manually.enter your own command
string (the string can contain multiple commands). If an error occursduring execution of
the STCCMD command, the driver displays an error messageand places the value "**"
into your command string at the point the driver detected the error.
The "Man" form has a button that enablesthe "Paste"option. With this option on,
commands sent without errors from other command forms will also appear in the "Man"
form command window. This procedure allows you to document a Trigger Master
program as you createit. You can save the contents Trigger Master memory with the
STCDUMP command. Since the STCDUMP command createsa non-readable binary file,
you can use the "paste" provision to savethe contents of the command window to obtain
a file of the command sequenceused to generatethe program.
When you executethe STCSTATcommand, the command normally returns the status
only once.When you make a status request from PLAYWIN.EXE or PLAYDOSEXE, a
form is created which continually reads and displays the status.This procedure allows
you to follow the status changesas Trigger Master executesa program or command.
INSTALLING Trigger Master 2 - 5
You can also watch the CONT STATUS request during program creation to determine
where the next program instruction will be loaded in memory.
The PLAYDOSEXE and PLAYWIN.EXE programs provide two methods of choosing a
different call or command and exiting a form:
. Choosea new form without closing the current form. When you bring the current
form back up, the data you previously entered is still in the form. This procedure
simplifies the manual entry of commands, since you can recall the previous ten
commands by using the arrow keys at the side of the entry window. You can also
size and position forms to suit your needs.
. Click on the upper-lefthand button and choosethe close option from the menu
displayed. When you next bring up the form, the data is reinitialized. To exit the
program, closethe main menu (this automatically closesall forms).
2 - 6 Trlgger Master INTERFACES~USERGUIDE
Chapter 3
USING THE Trigger Master DRIVER
3.1 INTRODUCTION
The Trigger Master driver supports the following languages:BASICA, Microsofto'
QuickBASIC, VisualBASIC (for DOS and Windows), Microsof@ C, C++, and C for
Windows, and Borlando' TurboPascaland TurboPascalfor Windows.
. For Windows applications, a Trigger Master DLL is placed in your Windows
directory.
. For DOS environment applications in QuickBASIC, VisualBASIC, C, and
TurboPascal,a Trigger Master file is linked with the application program.
. For BASICA, a Trigger Master binary file is loaded with the program.
For maximum efficiency with all languages, the application program makes a direct call
to the appropriate driver codeusing the following calls-z
STCINIT Checksfor and initializes a Trigger Master at a specified board
addressand then setsthe driver to control that board. The driver
can simultaneously control up to four boards.
STCSET Switches Trigger Master control to a different board. The board
must have been initialized.
STCCMD Sendscommands to Trigger Master.
STCSTAT Requestsstatus from Trigger Master.
STCLOAD Loads a binary flle into Trigger Master program memory.
STCDUMP SavesTrigger Master program memory to a binary file.
3.2 USING THE DRIVER
The following sections describe"instalhng" the driver in each of the supported
languages.
Using the Driver with SASICA
Run the following code segmentto load the driver In BASICA:
260 CLBhR 52-1024
, ' leave a045 for interface.
270 DBP sxo = 0
USING THE Trigger Master DRIVER 3 - 1
Accessing the Driver from C
For Microsoft@'C, compile your program and link the resulting object file with stcc.Zib
using a command such as the following:
You will need to include at least the function prototypes from stc.hin your program.
Note: For C or C++ programs running under Windows, do not link the
program to stcc.Zib. Instead, copy the file sfcIib.dll to your Windows
directory; the function prototypes in stcZib.dZl identical to those in stc.h.
are
Accessing the Driver from QuickBASIC and VisualBASIC
QuickBASIC
Use one of the following methods when building an executableprogram from the DOS
prompt:
. If you use Version 4 or greater or Version 7 with near strings, link your program to
stcqb.lib.
. If you use Version 7 with far strings (compiled with /Fs), link your program to
stcqbzlib.
To run your program in the appropriate QuickBASIC environment, load the program
with one of the following files:
. For Version 7, use the file stcqb7.qlb.
. For Version 4.0 to version 7, use the file stcqb4.qlb.
In either case,you must include at least the function protocols from the file stcqb.biin
your program.
3 - 2 Trigger Master INTERFACES USER GUIDE
VisualBASIC
PlaceVisualBASIC function declarations in the Global section.
. For DOS applications:
To run a program from the environment, use the command VBDOS
/LSTCVED.QLB to load VisualBASIC with the Quick Library STCVBD.QLB.
Include function prototypes for the Trigger Master calls by incorporating the
Trigger Master include files with the statement `INCLUDE stcvbd.bi. The file
STCVBD.BIalso includes error code definitions and an array to hold error
messagestrings. If you do not need to display error messages, delete the array;
otherwise, use the code in STCVBDLBASto initialize the srray. You can build an
executablefile from the environment or from the command line. To build the file
from the command line, first compile each form or BASIC module of your project
using the command line compiler. Then, from the command line, link the
resulting object modules with the Trigger Master VisualBASIC for DOS library
STCVBDJJB to produce the executablefile. The following command line
example illustrates the production of the file EXVBDMAK:
BeaxvBD.Pm
BCsxvsD.aAs
LIta sxvm BxvBDI,,,STcvBP.LIB;
. For Windowsapplications:
Copy the file STCUB.DLLto your Widows directory.You will needto includefunction
prototypes theTrigger Mastercalls in your global data The file STCVBWJXT
for
includesfunctiondeclarations appropriate the Globalsectionof a VisualBASICfor
for
Windowsapplication. This file alsodefineserror codes an error array.If you wish to
and
usethe errorarray,you mustincludecodefrom STCVBHXT in the load procedure of
your first form. Thediffarencebetween STCVBWXXT andthe DOSprogramfile
the file
STCVBDJXTis in the functiondeclarations which areappropriate STCLJB.DU.
to
Accessing the Driver from TurboPascal
Accessthe driver from a TurboPascalprogram (version 6) by including the following
statements in your program.
Far TurboPascal for Windows, copy the file STCLIB.DLL to your Windows directory
and include the folIowing statement in your program.
The include files contain function prototypes for the calls and define error codes.If you
want to display error messages, include an array for error strings. The file STCTPIPAS
contains code that you can add to your program to initialize the error array.
USING THE Trigger Master DRIVER 3 - 3
3.3 STClNll
STCINIT checks for the presenceof a board by writing to Trigger Master program
memory. STCINIT initially writes the value 0 and then increments this value through
255fdecimal). As the memory register is written, Trigger Master automatically
increments the on-board memory location so successive memory locations are loaded
with increasing values until reaching 255. At this point, STCINIT resetsto 0 and repeats
the processuntil it writes to ail 1024memory locations.
STCINIT then reads back the values. The processof reading the values automatically
increments the memory location. If the read value matches the write value, memory is
cleared and STCINIT returns with no error.
If the board is present, it becomes"active" so that all subsequent cornmands or requests
to the driver will be sent to that board. Up to four boards can be initialized; as each
board is initialized, it becomesthe "active" board. To reactivate an initialized board, use
the STCSETcaIl.
Note: Every time you run a program, you must initialize Trigger Master by
calling STCINIT before making any other calls. During initialization, only
Trigger Master program memory is deared; other registers may retain
values from previous program execution.
STCINIT requires three arguments as follows:
STC~I'E~il9b,al%,i2%)
The variables definitions and ranges are as follows:
Variable Definition Ranae
il% (integer) Trigger Master reference number o-3
al% Trigger Master board address 0-7FC
i2% (integer) Indicates success of call 0 = suooessful
non0 = unsuccessful
(refer to Appendix A for Trigger Master error messages.)
Calling STCINIT from BASICA
Use the following BASICA code segment to initialize a Trigger Master at address
30fhex):
630 PRnm "mitialize board "2 m!mmm; *I It. address "i
610 PRINT Rsxs mmADDR%) t I' her"
650 ORLL STCIWITmsmmd%, RzamDDR%, -1
660 LF RMNON% THPN GOT0 2130
Note: You must define ail arguments for the STCINIT call (BRDNUM%,
BRDADDR%, ERRNUM%) before making the call
3 - 4 Trigger Master INTERFACES USER GUIDE
Calling STClNlT from C
Use the following code segment to initialize Trigger Master in C:
In C you can send values to the driver by placing them directly in the call. For example,
you could use the following code:
stchit(0, 0x300,ierr);
Since the driver returns err, you must have a predeflned variable to receive its value.
Calling STUN/T from QuickBASE and VisualBASIC
Use the following code to call STCINIT from QuickBASIC and VisuaIBASE
DIN .rerr As INTBOBR
DIMB.rcLNum As INmaR
DIMbdAddr AsIwmeER
s-=0
brdMdr ii &a310
PaIm "Ildtialie.3 board "IBrdaumi" at address "i
PRX"`,' BgX$tbrdiuWrl; " hex"
In QuickBASIC and VisualBASIC, you can send values to the driver by placing them
directly in the call. For example, you could use the following code:
CALL s+cinie(o. LH310,*err1
Since the driver rehms rerr, you must have a predeflned variable to receive its value.
Calling STCINIT from TurboPascal and TurboPascal for Windows
The following code illustrates calling STCINIT from a TurboPascalor TurboPascal for
Windows program:
stcinir(1.$314,err~;
USING THE Trigger Master DRIVER 3 - 5
3.4 STCSET
Use STCSETin multiboard systemsto switch the driver from one board to another. The
boards must have been previously initialized with the STCINIT command (described in
the previous section).STCSETacceptstwo arguments as follows:
The argument il% is an integer in the range of 0 through 3 that identifies the
board.
The argument i2.%is an integer that receivesan error code. A value of 0 indicates
no error (refer to Appendix A for a list of error messages).
3.6 Trigger Master INTERFACES USER GUIDE
Calling STCSET from QuickBASIC and VisualBASIC
The following code segment illustrates calling STCSETin QuickBasic and VisualBASIC.
BdM.UUEO
Calling STCSET from TurboPascal and TurboPascal for Windows
The following code illustrates calling STCSETfrom a TurboPascal or TurboPascalfor
Windows program.
stcsetIl,*rr) i
3.5 STCCMD
STCCMD sends commands to a board. STCCh4Dacceptsthree arguments as follows:
01refersto a stringthat contains command be translated the driver into
a to by
microcode. translated
The microcode thensentto Trigger Mastereitherfor execution
is
by theon-boardstatemachineor for storage theTrigger Mastermemory.The,driver
in
parses command,
the checkingfor unknowncommands, invalid syntax,or valuesout of
range.
ix%is an integerthat receives error code.The driver returnsa valueindicatingthe
an
sIatusof errors:a valueof 0 indicates errors;refer to AppendixA for a list of error
no
messages.
ia is anintegerthat receives positionof the last character driver parsed.
the the Sincethe
driver stopsparsingthe command whenit encounters error,this valueprovides
line an
assistance ermr debugging.
for
Note: Trigger Masterexecutes commands they areparsed.
as IfTrigger Master
discovers errorin a multiple-command
an string,it executes commands
the prior
to the errorandthen returnswith an emlr code.
Referto AppendixB for a quick introductionto the commands
usingexamples.
Run
PLAYDOS.EXBor PLAYWIN.EXB to experiment the commands a non-program
with in
environment. AppendixA for a description the errormessages.
See of
USINGTHETrigger Master DRIVER 3 - 7
Command Syntax
This section describesthe syntax for the string argument (cl) in the STCCMD call. The
STCCMD call supports the following commands: ARM, BEGIN, CONT, DO, END,
FLAG, HALT, LOOP, TRIG, WAIT, and X.
General Information
The following rules apply to ail STCCMD commands:
. Spell out the commands in their entirety (abbreviations are not supported).
. Complete each command with a semicolon (;l.
. Use any combination of uppercaseand lowercaseletters wlthin strings (the driver is
insensitive to the caseof characters).
. Do not use embedded spaceswlthin a command. For example, the command "be
gin;' is illegal.
Some examples of legal and illegal strings are as follows:
IIlerral Legal
beg; Begin;
begin b&N;
In the example "beg", the driver returns the position 3 and the error 3 which correspond
to the "Incomplete Command" error. As soon as the driver encounters an error it returns
You can group multiple commands together using blank spaces(spaces,tabs, carriage
returns, and line feeds) to improve readability. The following examples are equivalent:
bWfi.Wd;
begin ; end;
begin:
6JUd;
The driver executesmultiple commands contained in a single string when it encounters
a semicolon. In the previous example, the driver executesthe "begin" command when
the driver parses the ";11
following "begin". As a result, the driver executescommands
one at a time. When the driver encountersan error, the previous commands have
already been executed.
3 - 8 Trigger Master INTERFACES USER GUIDE
Line Numbers
The commands ARM and TRIG must be followed by one or more line numbers. The
line numbers indicate which of the six trigger lines are armed to look for trigger inputs
or will generatetrigger outputs. When either command specifiesmultiple lines, the line
values must be separatedby commas. The following examples illustrate legal and illegal
line values:
j&g@ gg&
trig 1, 5; trig 1 5;
TRIG 6:
trig3,2,1;
Note: You may use the same number more than once in a command line. This
does not alter the operation and is not flagged as an error.
Extenslons
Certain commands accept extensions, which further define the command. You must
spell out the entire extension (abbreviations are not accepted)and each extension must
be precededby a colon. The following example initiates Trigger Master program
execution with interrupts enabled:
For additional information on L, refer to the section"The CommandSet".
Commands can be followed by one or more integers. An integer cannot contain
embedded spaces,but the number may be separatedfrom the command using one or
more spaces. integers in the following example indicate the memory location where
The
program storage should start. The examples of legal and illegal command lines are:
&g& j&&
beginl23; begin 1 231
begin 133~
begin 123 ;
The driver checksthe range of the number and returns an error if the value is out of
range.
USING THE Trigger Master DRIVER 3 - 9
Time Scales
Two commands require time arguments: WAIT and TRIG. The WAIT command
generatestime delays in a program running from Trigger Master memory (for further
information on both commands, refer to the section "The Command Set"). The WAIT
command syntax is:
%.ais a floating-pointnumberthat specifies magnitudeof time.
a
t indicatesa time scaleusingoneof the following threevalues:
sorS seconds
m or M milliseconds
n or U microseconds
The magnitude limes (a.=) that canbe usedwith the WAIT command
of rangefrom 1
microsecond through65.535seconds. canwrite time valuesusinganychoiceof milts. For
You
example, minimum andmaximumtimesmaybe entered any of the following values:
the as
Minimum Maximum
lu 65535000~
.OOl m 65535 m
0.000001 s 65.535 s
The magnitude of the time between any leading and trallmg zeros must fit in a 16-bit
counter; therefore, the range is between 1 and 65535.This limits the so-called resolution
of the time scale (how fine a time increment you may specify). This allows the use of up
to five digits for 1 to 65535,but only four digits for 6554to 9999.For example, the values
0.06553400 and 0.06553500 are legal, but the value 0.06553600 is illegal. The driver
s s s
allows an increase of 0.00000100 from the value 0.06553400 to 0.06553500 If we
s s s.
attempt to increment the sameamount to get to 0.06553600 the driver returns the error
s,
"TIME OVER RESOLUTION". This requires a rounding up to the next higher value in
the digit to the left; in this example, the next larger value of time that can bespecified is
0.06554000 This value representsan increment of 0.00000500; next incremental
s. the
value would be 0.00001000 0.06555000
(to s).
3 - 10 Trigger Master INTERFACES USER GUIDE
The time resolution depends on the time value as shown in the following table:
Delav Ranqe Resolution
0.000001 s to 0.065535 s 1 usec
0.065540 s to 0.65535 s 10 usec
0.65540 s to 6.5535 s 100 usec
6.5540 s to 65.635 s 1000 usec
Note: If you attempt to enter the digits 65536,the driver returns the error "TIME
OVER RBSOLUTION". Unless your time scaleis microseconds,you wlll
be over-range well.
as
Sanding Commands in fbe Programmhg Languages
Commands are sent by calling STCCMD with the appropriate arguments. One of the
arguments is the string specifying the command. The general features of those strings
have been diicussed ln the previous section and the detailed use of eachstring will be
discussedin the following section. This section shows the use of the call in each of the
programming languages supported.
Calling STCCMD from BASICA
In BASICA, you must define all arguments before making the calI
Calling STCCMD from C
In C, you must declare unsigned variables to receiveinformation from the driver.
However, the command string sent to the driver can be inserted directly in the call.
USING THE Trigger Master DRIVER 3 - 11
Calling STCCMD from QuIckBASiC and VisualBASIC
In QuickBASIC and VisualBASIC you must declare integer variables to receive
information from the driver. However, the command string sent to the driver can be
inserted directly in the call.
begircme$ "begin;"
5 ' begin pro*ram
DM rerr As Ib!mOBR
DIMPOEa As *NmoaR
PRINT "Sand"i begincma$; EOmfwad"
`8
CALL s+ccmd(beginamd$, rerr, post)
IP r*rr <> WOWRRORCALL 9!awN Brrorzxit(rerr~
Calilng STCCMD from TurboPascal and TurboPascal for Wlndows
In TurboPascaland TurboPascal for Windows you must also declare unsigned variables
to receive information from the driver. However, the COmmand string sent to the driver
can be inserted directly in the call.
STCTPUB is a special interface to TurboPascal that acceptsa standard TurboPascal
string. STCLIBDLL is a general DLL that expectsso-called "c" strings. To send strings to
the DLL in TurboPascalfor Windows, createa string with a NULL character on the end
outside the call, and pass the "second element" of the string in the call.
3 - 12 Trigger Master INTSRFACES USER GUIDE
The Command Set
The command set consistsof ARM, BEGIN, CONT, DO, END, FLAG, HALT, LOOP,
TRIG, WAIT and X. The Trigger Master mode of operation determines how the
commands are operated on:
. In immediate mode, Trigger Master executescommands as they are received.The
commands BEGIN and CONT operate only in this mode.
. In program mode, the commands are stored in Trigger Master memory for future
execution. The commands DO, END, LOOP, and WAIT operate only in this mode.
. In run mode, Trigger Master is executing a program and will only recognize the
HALT command.
The remaining commands (ARM, FLAG, HALT, TRIG, and XI can be used in any mode
of operation.
The following sectionsdiscussthe commands in detail.
ARM
The Trigger Master trigger-detect logic latches trigger edges on the six trigger input lines
(the default is high-to-low transitions). The ARM command specifiesa trigger input
transition pattern to be detected.When the ARM command executesin a Trigger Master
stored program, the program waits until the pattern is detected before proceeding to the
next program step. In immediate mode, you can loop using the TRIG request
(previously described) to detect the pattern.
The ARM command must be followed by one or more line numbers. If you enter
multiple line numbers, separateeachnumber using commas. Specifying the sameline
number more than oncehas no effect and is not flagged as an error. The following
example waits for high-to-low trigger transitions on lines 1 and 5.
-.si
You can specify the edge to latch by using a + (low-to-high) or - (high-to-low, the
default) behind the line number. The following example waits for a low-to-high
transition on line 1 and high-to-low transitions on lines 3 and 5.
ann I.+, a-, 5;
Note: Becauseof the latching nature of the detect circuit, the edges need not
occur simultaneously and the state of the trigger lines wlll generally
differ from the pattern specified in ARM when the trigger condition is
met.
In program mode, ARM supports the REP extension which allows you to wait for the
trigger pattern to be repeated from 1 to 4096times before proceeding. The following
command line will wait for 23 repetitions of a trigger pattern of high-to-low transitions
on lines 1 and 4. Each time the pattern is detected, latches are automatically cleared and
rearmed.
USING THE Trigger Master DRIVER 3 - 13
The general syntax for the ABM command is:
ARM flI+l-l 1....)[:Fsz nn1:
The variable r mustbe within the range1 through6 andthe variableIYL
mustbe in the range1
through4096.
BEGIN
Use BEGIN only in immediate mode to switch Trigger Master to program mode. The
BEGIN command optionally acceptsa single argumenb the Trigger Master program
memory address where the program will start loading. This integer argument must be
in the range 0 through 1023(the default starting address, with no argument, is 0). The
following example switches the driver to program mode and initializes the program
counter to 40.
begin 40;
The general syntax for the BEGIN command is:
The variable = mustbe in the range0 through1023.
Normally, you will startprogramloadingandexecutionat address but you may alsohave
0,
multiple programsin memory(terminate eachprogramwith an END or HALT command).
To load or execute
multiple programs, mustknow the locationsof the instructions.
you
Determinetheselocationseitherby building a programfrom PLAYWNEXE or
PLAYDOSJXE or by using the techniques described in Chapter 5, Creating Programs
for
Trigger MasterMemory.
CONT
Use CONT in immediate mode to restart a program that was stopped by a HALT
command or FLAG[m]:INT command within the program. You cannot reliably restart a
program that has been halted externally (from outside the program). If the program
contains additional FLAG[nn]:INT commands, use the CONT command with the INT
extension to clear the previous interrupt and arm Trigger Master to generateanother
interrupt. The following example restarts a program without interrupts:
This example restarts a program executing out of Trigger Master memory. The general
syntax for the CONT command is:
ccmz Ir1NTl;
Note: If you enableTrigger Masterto generate
interrupts,you must supplyyour own interrupt
servicemutlnes.
3 - 14 Trigger Master INTERFACES USER GUIDE
DO
Use DO in program mode to mark the start of a sequenceof code which is to be
repeated. The DO command requires a single argument, which is an integer in the range
of 1 through 4096.The argument specifiesthe number of times the code sequenceis to
repeat. The code sequencemust be terminated by the LOOP command (described later
in this section).The driver allows two levels of loops; the driver will flag an error if you
attempt to start a third level. In the following example, first command1 executes,then
command2; this code sequencerepeats25 times:
de 25; cemmand1; c-i loop;
The general DO syntax is:
Donni
nn is in the range 1 through 4096
END
Use END in program mode to insert a HALT (described later in this section) and return
Trigger Master to immediate mode. The driver wIII return an error if you attempt to end
a program that has DO commands which ha