36 Getting Started
Chapter 1
',0$>@
!Dimension array to hold data entered
287387&/26(#
!Close all channels
287387567
!Open all channels by resetting module
28738767$723(5(1$%
!Enable bit 8 of status operation event register
2873876&$1#
!Scan all channels
287387,1,7
!Initiate the scan using the default
TRIG[:IMM]
:+,/(127%,7632//
!Serial poll bit 7 of the status byte until it is high
35,17:$,7,1*)256&$1&203/(7(
(1':+,/(
28738767$723(5"
!Query the status operation event register
(17(5$
!Bit 8 reported high (status byte bit 7 was high)
35,1767$723(5(9(17%,7 $
!Print response to the
STAT:OPER
query
(1'
RUN the program. You should hear channel relays opening and closing,
especially when a large channel list is scanned.
Exercise 4: Check for
System Errors
You can add the following lines to the program in Exercise 3 to verify that
no system errors were generated. It is always a good idea to check if your
program causes the instrument to report any errors during program
development (such as command strings that are invalid and cause an error
to be sent to the instrument’s error queue). You can read the instrument’s
error queue by inserting the following four program lines (all errors are read
until the error queue is "+0, No errors").
5(3($7
2873876<67(55"
(17(5$$
!A gets the error number,
A$ gets the
!error message
35,17$$
817,/$
See "Using Interrupts With Error Checking" in Chapter 2 for detecting errors
with interrupts. For example, inserting the following (incorrect) program line:
28738775,*6285&%86
will cause an error to be sent to the error queue because
75,*6285&%86
is an incorrect command header (must be
75,*6285%86
). The instrument
still functions using the default value
75,*,00HGLDWH
. To know that an error
was reported and your instrument is doing what you intended it to do, you
must read the error register with a
6<67HP(55RU"
command.
You can insert this program segment at different places in your program to
see where the error is generated when debugging your program if it cannot
be determined from the error message or by examining the program lines.
In this case, the error is returned as
8QGHILQHGKHDGHU
which means
the command header was incorrectly specified. This error is generated by
the instrument driver while trying to parse the command (the error -113 is
documented in the command module manual).
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com