8 HP E1340A Arbitrary Function Generator User’s Man ual Contents
Certification
Hewlett-Pac kard Compa ny certif ies that this product m et its published sp ecifi cation s at the time of shipment from the factory. H ewlettPackard further certifies that its calibration measurements are traceable to the United Stat es Nation al Instit ute of Stand ard s and Technology (for m erl y Nat ional Bur ea u of Standar ds ), to the ex tent allo wed by that orga ni zati on’ s cal ib rat ion f ac ili t y, and t o th e calibration
facilities of ot her International Standards Organization members.
Warranty
This Hewlet t-Pa ck ar d product is warr ante d agai nst de fect s in mate rials and w orkmansh ip for a period of three years from date of shipment. Duration and conditions of warranty for this product may be superseded when the product i s i nt egrated into (be com es a part of)
other HP product s. Du ring the warrant y period, Hewlett-Packard Company will, at its opt ion, either repair or repl ace pr oducts which
prove to be defective.
For warranty se r vice or repair, this product mu st be r et ur ned to a service facility designated by Hewl et t -P ackard (HP). Buyer sha l l pr epay shipping cha rges to HP and HP shall pay shipping charges to re tu rn the product to Buyer. However, Buyer shall pay all shipping
charges, duties, and taxe s for products returned to HP from anot her count r y.
HP warrants that its softwar e and firmwar e designa ted b y HP for use with a product will execute its programmin g instru cti ons wh en
properly installe d on that product. HP does not warrant that the operat ion of the product, or software , or firmware will be uninterrupted
or er ro r f r ee.
Limitation Of Warrant y
The foreg oin g warra nt y sh al l not apply t o defects resulting from impr oper or inadequate m ai nt enance by Buyer, Buyer-supplied products or interfacing, unauthori ze d m odificati on or misus e, operation outside of the environmenta l specificat i ons for the product, or improper site prep arat i on or maint ena nce.
The design and imp le mentation of an y circuit on thi s pr oduct is the sole responsibility of the Buyer. HP does not warrant th e Buyer’s
circuitr y or malfunctions of HP products that result from the Bu yer’s circuitry. In addition, HP d oes not warrant a n y damage that occurs as a result of the B uyer’s circuit or any defects that re sult from Buyer-supplied product s.
NO OTHER WARRANTY IS EXPRESSED OR IMPLIED. HP SPECIFICALLY DISCLAIMS THE IMPLIED WARR ANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Exclusive Remedie s
THE REMED IES PROVIDED HEREIN ARE BUYER’S SOLE AND EXCLUSIVE REMEDIES. HP SHALL NOT BE LIABLE
FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER BASED ON CONTRACT, TORT, OR ANY OTHER LEGAL THEORY.
Notice
The information contained in this document is subject to change without notice. HEWLETT-PACKARD (HP) MAKES NO WARRANTY OF ANY KIND W ITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. HP shall not be liable for errors contained
herein or for incidental or consequential damages in connection with the furnishing, performance or use of this material. This document c ontains proprietary information whi ch is protected by copyright. All rights are reserved. No part of this document may be photocopied, reproduced, or translate d to another lan guage wit h out the prior written consent of Hewlett -Packar d C ompany. HP assumes no
responsibility for the use or reliability of its software on equipment that is not furnished by HP.
Restricted Rights Legen d
Use, dupli ca tion or discl osu re by the U. S. Go vernme nt is subje ct to rest rict i ons as set fort h in subparagraph (c)(1)(i i) of the Right s in
Technical Data and Comp uter Softwa re clause in D F ARS 252.227-701 3.
Hewlett-Packar d Company
3000 Hanover Street
Palo Alto, Cal if ornia 943 04 U.S. A.
Rights for non-DOD U.S. Government Departments and Agen ci es are as set f orth in F AR 52.227 -19 (c) (1,2).
HP E1340A Arbitrar y Function Gene rat or Modu le Use r’s Manu al
HP E1340A Arbitrary Function Generator Module User’s Manual 9
Documentatio n History
All Editions and Updates of this manual and their creation date are listed below. The first Edition of the manual is Edition 1. The Edition number increment s by 1 whenever the manua l is revised . Updates , which are issued betw een Edi ti ons, c ontain repla ce ment pa ges
to correct or add additional information to the current Edition of the manual. Whenever a new Edition is created, it wil l contain all of
the Update inf ormat ion for the pre viou s Editi on. Each new Ed iti on or Update also incl ude s a revis ed c op y of this documentation history page.
Instruction manual symbol affixed to product. Indicat es that the user must refer to t he
manual for specific WARNING or CAUTION information to avoid personal injury
or damage to the product.
Indicates the field wiring terminal that must
be connected to earth ground before operating the equipment—protects against electrical shock in case of fault.
Frame or chassis ground termi nal — t ypi-
or
cally connects to the equipment’s metal
frame.
WARNING
CAUTION
Alternating current (AC).
Direct curren t (DC).
Indicate s ha za rdous voltages.
Calls at te nt i on t o a pr ocedure, practi ce, or
condition that could cause bodily injury or
death.
Calls at te nt i on t o a pr ocedure, practi ce, or condition that could possibly cause damage to
equipme nt or perma nen t los s of data.
WARNINGS
The following ge ner al safet y prec aut ions mus t be observed du ring al l phas es of oper ation , ser vice , and repai r of this pr oduct.
Failure to comply with these precautions or with specific warnings elsewhere in this manual violates safety standards of design,
manufacture, and inten ded use of the product. Hewlett-Packard Company assumes no liability for the cust o mer’s failu re to
comply with these requirements.
Ground the equipment: For Safety Cl as s 1 equipmen t (equ ipment ha vin g a protective ea rth ter mi nal) , an unint erru ptib le sa fety earth
ground must be provide d from the ma in s power sour ce to the produ ct input wi rin g termi nals or suppli ed power cable .
DO NOT operate the produc t in an explosive at mospher e or in the presen ce of flammable gases or fume s.
For continued protect ion a gainst fire, repl ace the line fuse (s) only with fuse(s) of the same voltage and current rating a nd type .
DO NOT use repaired fuses or short-circui ted fuse holders.
Keep away from live circuits: Operatin g personnel must not remove equipment covers or shields. Procedures involving the removal
of covers or shields are for use by service-trained personnel onl y. Under certain conditions , dangerous voltages may exist even with the
equipment switched off. To avoid dangerous ele ctrical shock , DO NOT perf orm procedures involving cover or shield removal unless
you are qualified to do so.
DO NOT operate damaged equipment: Whene ver it i s p ossibl e tha t the sa fe ty protection features buil t int o t his pr oduct have been impaired, eithe r t hr ough physical dam a ge, exces si ve moisture, or any ot her re as on, REMOVE POWER and do not use the product until
safe operation can be verified by service-trained personnel. If necessary, return the product to a Hewlet t-P ackar d Sales and Se rvice O ffice for service and repair to ensure that safety features are maintaine d.
DO NOT service or adjust alon e: Do not attempt internal service or adjustment unless another person, capable of rendering first aid
and resuscitation, is present.
DO NOT substitute parts or modify equipment: Because of the danger of introducing additional hazar ds, do not install substitut e
parts or perform any unauthorized modifica tion to the product. Retur n the product to a Hewlet t-P ackar d Sales and Ser vice O ffice for
service and repair to ensure that safety features a re ma i nt ai ned.
10 HP E1340A Arbitrary Function Generator Module User’s Manual
Declaration of Conformity
according to ISO/IEC Guide 22 and EN 45014
Manufacturer’s Name:Hewlett-Pa ckar d C ompany
Loveland Manufacturing Center
Manufact urer’s Addre s s:815 14th Street S.W.
Loveland, Colorado 80537
declares, that the product:
Product Name:Arbitrary Function Generator
Model Number :E1340A
Produc t Opt ion s:All
conforms to the following Pr od uct Spe cifi cati ons :
IEC 801-2:1991/ E N5008 2-1 (1 992) : 4kVCD, 8k VA D
IEC 801-3:1984/ E N5008 2-1 (1 992) : 3 V/m
IEC 801-4:1988/ E N5008 2-1 (1 992) : 1kV P ower Lin e
.5kV Signal Lines
Supplementary Information: The product her ewi th c ompl ies wit h th e requirements of the Low Voltage Directive
73/23/EEC and the EMC Directive 89/336/ EEC and carri es the CE-mark ing acc ordingly.
Tested in a typical configuration in an HP B-Size VXI mainframe.
April, 1995Jim White, QAManagerApril, 1995Jim White, QA Manager
European conta ct: Your loca l He wlett-Pa cka rd Sales a nd Servi ce O ffic e or Hewlett- Packa rd GmbH, Departm ent
HQ-TRE, Herr en ber ger Straße 130, D- 71034 Böblingen, Germ a ny (FAX + 49-7031-14-3143 ).
HP E1340A Arbitrary Function Generator Module User’s Manual 11
Notes
12 HP E1340A Arbitrary Function Generator Module User’s Manual
Please fold and tape for mailing
Reader Comment Sheet
HP E1340A Arbitrary Function Generator Modul e User’s Manual
Editio n 3
You can help us improve our manual s b y sharing your commen ts and sug gesti ons. In apprec iat ion of your time, we will
enter yo u in a quarterly drawing for a Hewlett -Pac kar d Palmt op Personal Computer (U.S. government employees
cannot participate in the drawing).
Your Name
C ompany N ame
Job Title
Address
City, State/Province
Country
Zip/Postal C ode
Telephone Number with Area Code
Please list the syste m contr ol ler , oper ati ng syste m, pr ogr a m ming la ng uage, and pl ug-in mo dules you are using.
fold here
BUSINESS REPLY MAIL
FIRST CLASSPERMIT NO. 37LOVELAND,CO
HEWLETT-PACKARD COMPANY
cut along this line
Measurement Systems Division
Learning Products Department
P.O. Box 301
Loveland, CO 80539-9984
NO POSTAGE
NECESSARY
IF MAILED
IN THE
UNITED STATES
Please penci l-in one circl e for each statement below:Disagree Agree
• The documentation is well organized.OOOOO
•Instructions are easy to understand.OOOOO
•The documentation is clearly written.OOOOO
•Examples are clea r a nd useful.OOOOO
•Illustrati ons are clear and help ful.OOOOO
•The documentation meets my overall expectations.OOOOO
Please write any c omments or suggestions be l ow--be specific.
fold here
14 HP E1340A Arbitrary Function Generat or Module User’s Manual
Getting Started with the HP E1340A
Chapter Contents
Chapter 1
This chapter shows you ho w to configure, install, and b egi n using the
HP E1340A Arbitrary Function Generator (AFG). The main sections of this
chapter include:
This section shows how to prepare the AFG for use. Included are
instructions to install the AFG, to download the AFG Device Driver, and to
addre ss t he AFG.
Installing the AFGThe AFG can be installed in any mainfra me slot, except slot 0. For
installation instructions in a B-Size VXIbus System, refer to the B-size
Installation an d Getting Start ed Guide. For install ation instructio ns inC-Size VXIbus Systems, refer to the C-size Installat ion an d Getting Start ed
Guide.
Downloading the
AFG Devic e D ri v e r
The HP E1340A AFG driver allows the AFG to operate in an
HP E1300/E1301 Ma inframe or HP E1405/E1 406 Co mma nd Mo dule using
the Standard Commands for Programmable Instruments (i.e., SCPI)
instrument command language. The driver is supplied on the AFG’s
example program disks (see “Instrument and Programming Languages” on
page 19 f or more i nf ormat ion on the disks).
15 Gettin g Started with the HP E1340AChapter 1
The procedure for downloading the driver is contained in the HP
Installation N ote Do wnloadin g Device Drivers. The E1300/E1301
Mainframe Manual, H P E1405 Command Module Manu al, and E1406
Command Module Manual also contain the installation procedure.
Mainframe/Command
Module Requirements
Recommended
Systems to Download
the Drivers
To download a driver, the ROM version number of the HP E1300/E1301
Mainframe or HP E1405 Command M odu le must be A.06.00 or above. To
determine the version number, send t he IEEE 488.2 common command
*IDN?. A typical returned value (for the HP E1300A Mainframe) is:
HEWLETT-PACKARD,E1300A,0,A.06.01
where "A.06.01" is the version nu mber.
The AFG instrument driver can be downloaded with the following systems.
HP BASIC with an External HP- IB Controller
This system downloads the driver o ver th e Hewlett-P ac kard Interface Bus
(HP-IB*) with an HP BASIC controller, like the HP Series 200/300
computer. Be sure to connect the computer to the Mainframe’s / Command
Module’s HP-IB port. The program to download the driver is named
“VXIDLD_GET”, and is in GET/ S AVE f ormat. The pr o gra m is located on
the HP IBASIC example program disk (HP part number E1340-10035).
This disk is f orm at ted in the LIF format.
HP IBASIC in an HP E1300/E1301 Mainframe or
HP E1405/E1406 Command Module
This system downloads the drivers using the HP IBASIC (i.e., HP
Instrument BASIC) pr ogra m la nguage. The language comes with options to
the HP E1300/E1301 M ainframe and the HP E1405/ E1406 Command
Modules. IBASIC reads dis ks formatted in either the LIF or M S-DOS®
format and can use either example program disk (depend ent on your disk
drive). To download the driver from the LIF disk or t he DOS disk, use
“AUTOST”.
Externally Connected MS-DOS® Computer
This system downloads the driver us ing an MS-DOS computer over the
RS-232 serial int erface. Connect the computer to th e Mai nframe’s /
Command Module’s RS-232 port. The program to download the driver is
named “VXIDLD.EXE” and is located on the DOS example program disk
(HP part number E1340-10036). Th is disk is formatted for MS-DOS.
* HP-IB is Hewlett-Packard’s implement at ion of IEEE Std 488. 1-1 978
Chapter 1Getting Started with the HP E1340A 16
AFG Logical
Address
The AFG is shipped from the factory with a logical addre ss setting of 80,
as shown in Figure 1-1.
The E1340A AFG logical address is us ed:
• to place the AFG in the servant area of a commander
(e.g. HP E1405/E1406 C omm and M o dule).
• to address the AFG (see “Addressing the AFG” later in this chapter).
Figure 1-1. Setting the Logical Address
17 Gettin g Started with the HP E1340AChapter 1
Assigning the AFG to a
Commander
In VXIbus systems, each device must be in the servant area of a
commander. Note th e following wh en assigning the E1340 A AFG:
• In a B-size system, the system instrument is the commander. Any
AFG logical address (1 - 255) places the AFG in the commander
servant ar ea. The AFG logical addre ss should remain at 80, or if
necessary, set to some other multiple of 8 (s ee “Addressing the
AFG”).
• The E1340A AFG is a register-based device. If the AFG’s driver is
downloaded in t he HP E1405/E1406 Command Module, then the
AFG must be in th e serva n t a r ea o f the Command Module to
prog ram with SCP I commands.
Addr essing t he AF GThe following information explains how the AFG is addressed using
dif feren t com p u ter ( contr o ller) configur ations.
IB ASICTo program the AFG in a B-size or C-size system using IBASIC, the AFG
must have a unique address. The addr ess is a combinat i on of the IBASIC
interface select code, the Mainframe’s/Command Module’s primary HP-IB
address, and the AFG’s s ec ondary HP-IB address. An addr ess in this form
in an HP IBASIC sta tement appears as:
External Controller
and PC
OUTPUT 80910;"SOUR: RO SC:SOUR INT"
Interface Select Code (8): The IBASIC interface select code is 8. This
select code is used to access all devices installed in B-size and C-size
systems under IBASIC control.
Primary HP-IB Address (09): This is the address of the HP-IB port on the
Mainframe or C ommand Modu le . Valid add r esses are 0 to 30. The
mainframe/command module has a factory set address of 9.
Secondary HP-IB Address (10): This address is derived from the logical
address of the de vice (AFG) by dividing t he logical address by 8. F or t he
E1340A AFG factory set logical address of 80, the secondary address is 10.
When programming the AFG from an external computer such as a HP
Series 300 or PC, the addressing convention used is the same as IBASIC
exc ept for th e interface select code. An exam p le is sho wn b elow:
OUTPUT 70910;"SOUR: RO SC:SOUR INT"
Interface Select Code (7): Determined by the address of the HP-IB
interface card in the computer. In most Hewlett-Packard computers, this
card has a factory set address of 7, including the HP 82335 HP-IB Interface
Card (this card was used with an HP Vectra personal computer to create the
C and QuickBASIC example programs).
Chapter 1Getting Started with the HP E1340A 18
The Pri mary HP-IB Address and Secondary HP-IB Address are the
same as described previously for IBASIC programming.
Instrument and Programming Languages
The purpose of this manual is to teach you how to use the E1340A AFG. To
do this, the manual uses block diagrams, flowcharts, and example programs.
The programs s hown in the manual are SCPI pr ogr a ms wr itten in HP
IBASIC. These programs, and Quic kBASIC and C language v ersions of the
programs are on the following disks whic h ship with the manual:
• HP E1340A Instrument Driver and HP IBASIC Example Progra ms -
3.5" 720 kbyte disk (E1340-10035)
• HP E1340A Instrument Driver and QuickBASIC and C Language
Example programs - 3.5" 1.44 M byte disk (E1340-10036)
SCPI ProgrammingSCPI (Standar d Comm a nds for Programm ab le Instru ments) is an
ASCII-based instrument command language des igned for test and
measurement instruments. The HP E1300/E1301 Main frame or
HP E1405/E1406 Comm a nd Mo dule with the AFG drive r installed
interprets the ASCII command strings and sets the AFG accordingly. The
Mainframe/Command Module does this by writing to the AFG registers.
SCPI Command
Structure
The AFG SCPI command set is found in Chapter 7. SCPI commands are
based on a hierarchical structure, also known as a tree system. In this
system, ass ociated commands are grouped together under a common node
or root, t hus, for ming subtree s o r subsystem s. An example i s the AF G’s
’ARM’ subsystem shown below.
ARM
[:STARt|SEQuence[1]]
[:LAYer[1]]
:COUNt <
:LAYer2
:COUNt <
:SLOPe <
:SOURce <
is the root keyword of the command, :STARt|SEQuence1 is the
ARM
second level keyword,
so on. A colon (:) always s eparates a command keyword from a lower level
keyword as shown below:
ARM:LAY2:SOUR EXT
number>
number>
edge >
source>
:LAYer1 and :LAYer2 are th ird leve l ke ywords, a n d
19 Gettin g Started with the HP E1340AChapter 1
A semicolon (;) is us ed to s epara te two commands within the same
subsystem, and can also save typing. For e xa mple, sending th is c omma nd
messa ge:
ARM:LAY2:SOUR EXT ;SLO P POS; COUN 10
Is the same as sending these three commands:
ARM:LAY2:SOUR EXT
ARM:LAY2:SLO P POS
ARM:LAY2:COUN 10
Manual FormatThe typical format of commands listed in the command reference and
throughout t his manual is:
[SOURce:]FREQuency:MODE <mode>
Command headers enclosed in brackets are optional. UPPER CASE letters
in the header are required, lower case letters can be omitted. To aid in
learni ng the AFG command set, all headers are incl uded in the example
programs; however, the headers are abbreviated. In an example
program, the previous statement with a mode parameter of
appear as:
FIX would
SOUR:FREQ:MODE FIX
Command CouplingMany of the AFG SCPI commands are value coupled. This means that the
value set by one command may affect the valid limits for the values of other
commands. This can resu lt in "Settings Conf lict" errors when t h e program
executes. To prevent these errors, the AFG commands must be executed in
a "Coupling Group".
The AFG uses one coupling group. Commands not in the coupling group
must precede or follow commands in the coupling group. Executing
uncoupled commands in the coupling group breaks the coupling and can
cause a "Settings Conflict" error.
The coupling group and associated commands can be found in Appendix B,
Table B-2.
Chapter 1Getting Started with the HP E1340A 20
How to Execute
Coupled Commands
Command coupling determines the AFG programming sequence. Coupled
comma nd s must be contiguou s and execut ed in the same program statement .
This is done by placing the co mmands in the same program line, or by
suppressing the end-of-line terminator until the last (coupled) command has
been sent (HP IBASIC progra ms on ly).
To send multiple commands in a single line or in a single statement, the
commands ar e linked with a semi colon (;) and a colo n (:). This is illustrated
in the foll owing l ines :
SOUR:ROSC:SO UR INT;:SOUR:F UNC: SHAP SIN
or
SOUR:ROSC:SOUR INT;
:SOUR:FUNC:SHAP SIN
Both techniques are used in the programs found throughout this manual.
Note that the semicolon (;) and colon (:) link commands with in different
subsystems. Only a semicolon (;) is required t o link commands within the
same s ubs ystem (s ee “SCPI C o m mand Structure” earlier in this chapt er).
NoteSee “HP IBASIC Language Programs” later in this chapter for information
on suppressing the end-of-l ine te rmin ato r.
21 Gettin g Started with the HP E1340AChapter 1
HP IBASIC
Language Programs
The following information identifies the system on which the
HP IBASIC programs were written and shows how the programs are
structured.
System ConfigurationExcept where noted, the example programs in HP IBASIC were developed
(and tested) on the following system:
Mainframe:HP E1301A Mainframe
(IBASIC Opt io n)
HP E1340A Logical Address: 80
Instrument Language:SCPI
Program StructureThe structure of an example program in HP IBASIC is s hown below:
1!RE-SAVE“ARB_GEN”
2!This program generates a 4096 point, 0 to 5V ramp waveform.
3!The data is transferred to the AFG as voltages.
4!
10!Assign I/O path between IBASIC and the E1340A.
20ASSIGN @Afg TO 80910
30COM @Afg, Waveform(1:4096)
40!
50!Set up error checking
60ON INTR 8 CALL Errmsg
70ENABLE INTR 8;2
80OUTPUT @Afg;“*CLS”
90OUTPUT @Afg; “*SRE 32”
100OUTPUT @Afg; “*ESE 60”
110!
120!Call the subprogram which resets the AFG.
130CALL Rst
140!Set AFG parameters
150OUTPUT @A fg;“SOUR:ROSC:SO UR INT;”; !re fe re nc e osci llato r
160OUTPUT @A fg; “:SOUR:F REQ:FIX 1E3;”;!frequency
170OUTPUT @Afg; “:SOUR:FUNC:S HAP USER; ”; !func ti on
180OUTPUT @Afg; “:SOUR:VO LT :LEV:IMM:AMPL 5.1V ”!scale
amplitude
190!
200!Call subprogram which defi ne s waveform segment .
210CALL Ramp_wave
220!
230!Select output sequence and initiate waveform
240OUTPUT @Afg;“SOUR:FUNC:USER A”
250OUTPUT @A fg;“INIT:IMM” !wait-for-arm stat e
Chapter 1Getting Started with the H P E1340A 22
Contin ued on next page
260!
270WAI T .1!allow interrupt to be serviced
280OFF INTR 8
290END
300!
310SUB Ramp_wave
320 Ramp_wave: !Subprogram which defines a ramp waveform
330COM @Afg,Waveform(*)
340FOR I=1 TO 4096
350Waveform(I)=I*.00122
360NEXT I
370!
380OUT PUT @A fg; “SOUR:LIST:SEGM:SEL A”!Selec t segme nt name
390OUT PUT @Afg;“ SOUR:LIST : SEG M:VOLT”;Wavef orm(*)!loa d
waveform point s
400SUBEND
410!
420SUB Rst
430 Rst: !Subprogram which resets the E1340.
440COM @Afg,Waveform(*)
450OUTPUT @A fg;“*RST;*OPC?” !reset the AFG
460ENTER @Afg;Complete
470SUBEND
480!
490SUB Errmsg
500 Errmsg: !Subprogram which displays E1340 program ming error s
510COM @Afg,Waveform(*)
520DIM Message$[256]
530!Read AFG status byte register and clear service request bit
540B=SPOLL(@Afg)
550!End of statem ent if error occur s among coupl ed com mands
560OUTPUT @A fg;“”
570OUT PUT @Afg;“ABORT”!abort output waveform
580REPEAT
590OUTPUT @Afg;“SYST:ERR?” !read AFG error queue
600ENTER @Afg;Code,Message$
610PRINT Code,Message$
23 Gettin g Started with the HP E1340AChapter 1
620UNTIL Code=0
630STOP
640SUBEND
Turning Off (Suppressing) the End-Of-Line Terminator
As mentioned, coupled commands must be contiguous and executed in the
same program statement. By su ppre ssing the end-of-line (EOL) terminator
(Line Feed) on a command line, c oupled commands can be sent on separate
lines, yet as a single program statement.
In HP IBASIC programs, the EOL terminator is suppressed by placing a
semico lon ( ; ) following the q u otation mark ( “ ) which closes the
command string. In the program above, the commands in lines 150 - 180 are
in the coupling group. The semicolons following the command strings in
lines 150 throu gh 170 suppre ss t h e EOL terminator; t heref ore lines 15 0 180 are sent as a single statement.
Getting Programs
The HP IBASIC programs are stored on the disk as ASCII files. The
program name is shown in the program titl e and in line 1 of the pr ogram
1 !RE-SAVE"ARB_GEN"). To get a program, type:
(e.g.,
GET “file name” (e.g., GET “ARB_GEN”)
Declaring IBASIC Variables in COM (common) Memory
When writing or modifying IBASIC programs , array variables can b e
declared in COM (common) memory. Variables not in COM memory resid e
in the IBASIC stack. The ’stack’ is a 32 kB yte (d efault) s egmen t of memo ry
which contai ns components su ch as pointers and lo cal variab les f or
subprograms and de clarations. When too many variables (or too large a n
array) are in the stack, Error 2 - Memory Overflow will occur. If a memory
overflow occurs, the stack size can be changed with the command
PROGram:MALLocate < nbytes> (see the Instr ument BASIC User’s Man ual
for more information).
Chapter 1Getting Started with the HP E1340A 24
C La nguage
Programs
All of the C Language example programs in this manual are written for the
HP 82335 HP-IB Inter fa ce Car d using the HP-IB Command Library for C.
Unless otherwise noted, the library functions used in the programs are
com patible with the ANSI C standard.
The following identifies the system on which the programs are written,
shows how to compile the programs, and gives a typical example program.
System ConfigurationThe C programs were developed on the following syst em:
Controller:HP Vectra 386/25 personal computer
(386 processor operated at 25 MHz)
HP-IB Interface Card:HP 82335 HP-IB Interface with
/AL” and “-ml” parameters to t he appropriate types when
compiling in the smal ler mem or y models (see t he appropriate C Lang u age
manual for the parameter type).
C Program ExampleFollowing is an example program written in C using the HP 82335 HP- IB
Interface Card. The program:
• sends commands to the AFG to generate an arb itrary wa veform
• receives data from t he AFG
• shows how to send coupled commands
• performs error checking of the AFG
Chapter 1Getting Started with the HP E1340A 26
/* ARB_GEN.C - This program generates a 4096 points ramp. The data to */
/* generate the ramp is transferred to the AFG as voltages */
/* Include the following header files */
#include <stdio.h>
#include <string.h>
#include <malloc.h>/* Use “alloc.h” for Turbo C(c) or C++(c) */
#include <cfunc.h>/* This file is f r om the HP-IB Command Library Disk */
/*********************************************************************************/
void main(void)/* Run the program */
{
rst_clr( );/* Reset the AFG */
gen_seg();/* Generate segment list and output sequence */
run_query();/* Query wav eform segment memory */
}
/*********************************************************************************/
void gen_seg(void)
{
char static *set_com m ands[] =/* Use “set_commands” to setup the AFG */
{
“SOUR:ROSC:SOUR INT; ”/* Select the Ref. Oscillator */
“:SOUR:FREQ:FIX 1e3;”/* Set waveform frequency */
“:SOUR:FUNC:SHAP USER;”/*
Command to select the user function */
“:SOUR:VOLT:LEV: IMM: AMP L 5.1V”,/* Set the amplit ude */
“SOUR:LIST:SEGM :SE L a”/* Select the segm ent nam e */
},
27 Gettin g Started with the HP E1340AChapter 1
Contin ued on next page
*seg_commands =/* Use “seg_commands” to store segm ents */
“SOUR:LIST:SEGM:VOLT ”,/* Command to send volts data */
*out_commands[] = / *
Use th e “out_com mands” array to generate outpu t */
{
“SOUR:FUNC:USER a”,/* Select the user name */
“INIT:IMM”/* Start waveform generation */
};
float*Wave_seg;
intloop,
seg_size = 4096;/* Set the segment size to 4096 point s */
/*
Allocate sufficient memory for storing the segments into computer memory */