Agilent E1340A User Manual

Contents
HP E1340A Arbitrary Function Generator User’s Manual
Warranty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
WARNINGS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Safety Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Declaration of Conformity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Reader Comment Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1. Getting Started with the HP E1340A . . . . . . . . . . . . . . . . . . . . . . . . 15
Chapter Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Preparation for Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Downloading the AFG Device Driver . . . . . . . . . . . . . . . . . . . . . . . . 15
AFG Logical Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Addressing the AFG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Instrument and Programming Languages . . . . . . . . . . . . . . . . . . . . . . . . . 19
SCPI Program mi ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
SCPI Command Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Command Coupling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
How to Execute Coupled Commands . . . . . . . . . . . . . . . . . . . . . . . . 21
HP IBASIC Language Progra m s . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
C Language Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
QuickBASIC Language Progra ms . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Introductory Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
AFG Self-Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Resetting and Clearing the AFG . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Querying the P o wer-On/ Re set Configuration . . . . . . . . . . . . . . . . . . . . 37
Checking for Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Generating a Sine Wave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
HP E1340A Example Progra ms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
2. Generating Standard Waveforms with the HP E1340A . . . . . . . . . . . . . . 41
Chapter Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Standard Waveforms Flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Generating DC Voltages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
C and QuickBASIC Program Versions . . . . . . . . . . . . . . . . . . . . . . . . 44
Generating Sine, Triangle, and Square Waves . . . . . . . . . . . . . . . . . . . . . . 45
C and QuickBASIC Program Versions . . . . . . . . . . . . . . . . . . . . . . . . 46
Generating Ramp Waves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
C and QuickBASIC Program Versions . . . . . . . . . . . . . . . . . . . . . . . . 49
Selecting the Amplitude Levels and Output Units . . . . . . . . . . . . . . . . . . . . 50
C and QuickBASIC Program Versions . . . . . . . . . . . . . . . . . . . . . . . . 51
Program Commen t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Reference Oscillator Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Output Load Commen t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Contents HP E1340A Arbitrary Function Generator User’s Manual 1
Output Units Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Using MINimum a nd MAXimum Paramet er s . . . . . . . . . . . . . . . . . . . . 53
3. Generating Arbitrary Waveforms with the HP E1340A . . . . . . . . . . . . . . 55
Chapter Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Arbitrary Waveforms Flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
How the AFG Generates Arbitrary Waveforms . . . . . . . . . . . . . . . . . . . . . . 56
Generati ng a Si m ple Ar bi trary Waveform . . . . . . . . . . . . . . . . . . . . . . . . 59
C and QuickBASIC Program Versions . . . . . . . . . . . . . . . . . . . . . . . . 62
Executing Several Waveform Segments . . . . . . . . . . . . . . . . . . . . . . . . . 65
C and QuickBASIC Program Versions . . . . . . . . . . . . . . . . . . . . . . . . 68
Arbitrary Waveform Hopping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
C and QuickBASIC Program Versions . . . . . . . . . . . . . . . . . . . . . . . . 72
Generating Built-In Arbitrary Waveforms . . . . . . . . . . . . . . . . . . . . . . . . 73
C and QuickBASIC Program Versions . . . . . . . . . . . . . . . . . . . . . . . . 75
Sample Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Generating a Damped Sine Wave . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Generating a n Ex p onent ial Cha rge/Discharge Waveform . . . . . . . . . . . . . . 78
Generating a Sine Wave with Spikes . . . . . . . . . . . . . . . . . . . . . . . . . 79
Generating a Half- Rectifi ed Sine Wave . . . . . . . . . . . . . . . . . . . . . . . 80
Program Commen t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Amplitude Effects on Voltage List . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Reference Oscillator Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Waveforms in the EPRom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
4. HP E1340A Sweeping and Frequency-Shift Keying . . . . . . . . . . . . . . . 83
Chapter Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
The Command Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Programming Flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Sweeping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Sweeping Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Sweeping Using Start and Stop Frequen cies . . . . . . . . . . . . . . . . . . . . . 85
C and QuickBASIC Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Sweeping Using Start and Span Frequenc i es . . . . . . . . . . . . . . . . . . . . . 88
C and QuickBASIC Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Sweep Point s Vs. Sweep Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
C and QuickBASIC Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Frequency-Shift Keying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Program Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Program Commen t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Reference Oscillator Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
AFG Frequency Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Frequency Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
2 HP E1340A Arbitrary Function Generator User’s Man ual Contents
5. HP E1340A Arming and Marker Outputs . . . . . . . . . . . . . . . . . . . . . 95
Chapter Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
The ARM Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
The ARM States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Initiating Waveforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Arming the AFG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Arming Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Setting the
Arm Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Setting the Arm and Wa veform Cycle Count . . . . . . . . . . . . . . . . . . . . 99
Gating the Waveforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Aborting Waveforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Marker Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Marker Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Available Marker Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Generating Zero Crossing Marker Pulses . . . . . . . . . . . . . . . . . . . . . . 104
Program Commen t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Reference Oscillator Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
AFG Frequency Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
AFG Arming Sourc es . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
AFG Arm Count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Waveform Repetition Count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Enabling the Gate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
6. HP E1340A High Speed Operation . . . . . . . . . . . . . . . . . . . . . . . . . 109
Chapter Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Using DAC Dat a to Generate Waveforms . . . . . . . . . . . . . . . . . . . . . . . . 109
Program Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Using Definite Length Blocks to Transfer Data . . . . . . . . . . . . . . . . . . . . . . 113
Definite Length Block Data Format . . . . . . . . . . . . . . . . . . . . . . . . . 113
Data Byte Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Program Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Using the VXIbus Backplane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Using the VXIbus Backplane to Download Segment Data . . . . . . . . . . . . . 120
Downloading Segment Data into Memor y . . . . . . . . . . . . . . . . . . . . . . 120
Downloading Directly into the DAC . . . . . . . . . . . . . . . . . . . . . . . . . 120
Program that Downloa ds and Ex ecutes Wa ve form Segment s in Memory . . . . . . 120
Program to Download Directl y to the DAC . . . . . . . . . . . . . . . . . . . . . 126
Program Commen t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Amplitude Effects on DAC Codes . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Incorrect AFG Oper ation from Incorrect DAC Codes . . . . . . . . . . . . . . . . 129
Contents HP E1340A Arbitrary Function Generator User’s Manual 3
7. HP E1340A Command Reference . . . . . . . . . . . . . . . . . . . . . . . . . 131
Chapter Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Command Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Common Command Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
SCPI Command F orma t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Command Separa t or . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Abbreviated Comm ands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Implied (Opt ional) Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
SCPI Command Pa ra m et er s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Parameter Types, Explanations, and Examples . . . . . . . . . . . . . . . . . . . 134
Optional Par am eters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Querying
Parameter
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
SCPI Command Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Command Coupling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Linking Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
SCPI Command Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
ABORt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
ARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
[:STARt][:LAYer[1]] :COUNt . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
[:STARt]:LAYer2 :COUNt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
[:STARt]:LAYer2 :SLOPe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
[:STARt]:LAYer2 :SOURce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
CALibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
:AC:BEGin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
:AC:POINt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
:DATA:AC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
:DATA[:DC] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
[:DC]:BEGin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
[:DC]:POINt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
:STATe:AC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
INITiate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
[:IMMediate] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
OUTPut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
:IMPedance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
:LOAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
[SOURce:]ARBitrary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
:DAC:SOURce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
:DOWNload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
:DOWNload :COMPlet e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
[SOURce:]FREQuency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
:CENTer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
[:CW|:FIXed] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
:FSKey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
:MODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
:SPAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
:STARt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
4 HP E1340A Arbitrary Function Generator User’s Man ual Contents
:STOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
[SOURce:]FUNCtion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
[:SHAPe] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
:USER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
[SOURce:]LIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
[:SEGMent] :CATalog? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
[:SEGMent]:DEFine? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
[:SEGMent]:SELect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
[:SEGMent]:VOLTage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
[:SEGMent]:V O LTage:DAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
[:SEGMent]:VO LTage:POI Nts? . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
:SSEQuence :CAT alog? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
:SSEQuence :DEFine? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
:SSEQuence:SELect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
:SSEQuence :SEQuence ? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
:SSEQuence :SEQuence :SEGMents? . . . . . . . . . . . . . . . . . . . . . . . . 166
[SOURce:]MARKer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
:FEED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
:POLarit y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
[SOURce:]RAMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
:POLarit y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
[SOURce:]ROSCillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
:FREQuency :EXTer nal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
:GATE:ST ATe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
:SOURce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
[SOURce:]SWEep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
:COUNt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
:POINts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
:TIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
[SOURce:]VOLTage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
[:LEVel][:IMMediate] [: AMPLitude] . . . . . . . . . . . . . . . . . . . . . . . . 177
[:LEVel][:IMM ediate] [: AMPLitude]:UNIT [:VOLTag e] . . . . . . . . . . . . . . 179
[:LEVel][:IMMediate]: OFFSet . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
STATus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
:OPERati on |Q UEStionable :CONDition? . . . . . . . . . . . . . . . . . . . . . . 182
:OPERati on | QUEStionable :E NABle . . . . . . . . . . . . . . . . . . . . . . . . 182
:OPERati on |Q UEStionable [:EVENt]? . . . . . . . . . . . . . . . . . . . . . . . 183
:OPERation |QUEStionable :NTRansition . . . . . . . . . . . . . . . . . . . . . . 183
:OPERation |QUEStionable :PTRansition . . . . . . . . . . . . . . . . . . . . . . 184
:PRESet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
SYSTem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
:ERRor? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
:VERSion? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
TRIGger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
[:STARt]:CO UNt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
[:STARt]:SOURce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
IEEE-488. 2 Common Command s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Contents HP E1340A Arbitrary Function Generator User’s Manual 5
*CLS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
*DMC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
*EMC and *EMC? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
*ESE and *ESE? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
*ESR? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
*GMC? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
*IDN? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
*LMC? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
*LRN? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
*OPC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
*OPC? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
*PMC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
*RCL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
*RMC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
*RST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
*SAV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
*SRE and *SRE? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
*STB? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
*TST? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
*WAI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
SCPI Conforma nce Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
8. HP E1340A AFG Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Status System Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
The Operation Status Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
The Standard Event Status Group . . . . . . . . . . . . . . . . . . . . . . . . . . 207
The Status Byte Status Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Using the Standard Event Status Group . . . . . . . . . . . . . . . . . . . . . . . 210
9. HP E1340A Block Diagram Description . . . . . . . . . . . . . . . . . . . . . . 211
Chapter Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
AFG Descripti on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
What is an Arbitrary Waveform? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Generating Waveforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
Output DAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Reference Oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Frequency Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Output Circuitry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
Microprocessor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
Input/Output Connectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
A. HP E1340A Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Appendix Conten t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Instrument Sp ecifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
General and VXI Cha racteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
6 HP E1340A Arbitrary Function Generator User’s Man ual Contents
B. HP E1340A Useful Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Appendix Conten t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
C. HP E1340A Register-Based Programming . . . . . . . . . . . . . . . . . . . . 229
Appendix Conten t s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
Register Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
The Base Addres s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
Computer Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Throughput Speed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Embedded Computer Programm in g (C-Size Systems) . . . . . . . . . . . . . . . . 232
IBASIC Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
External Computer Programming . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Programmi ng Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Register Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
The READ Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
The ID Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
The Device Type Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
The Status Re gister . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
The Query Response Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
The WRITE Reg isters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
The Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
The Command and Parameter Registers . . . . . . . . . . . . . . . . . . . . . . . 238
The Input Data Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
Command Descriptions and Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Setting the Output Fun ction an d Loading RAM . . . . . . . . . . . . . . . . . . . 243
Setting the Signal Fr equenc y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
Setting the Output At ten ua t i on . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Setting the Amplitud e O ffset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
Setting the S weep Rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
Setting the Burst C ount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
The AFG Output M ode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
Starting the Waveform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
Querying the A F G . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
AFG Soft Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Aborting the Waveform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Program Timing and Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
AFG Reset Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Configuring the AFG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Querying AFG Pa ra meters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Example Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
Opcode/Parameter Quick Re feren ce . . . . . . . . . . . . . . . . . . . . . . . . . 256
Generating a
Sine Wave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
Multiple Waveforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Internally Triggering a Burst of Cycles . . . . . . . . . . . . . . . . . . . . . . . . 260
Extern al ly Triggering a Burst of Cycles . . . . . . . . . . . . . . . . . . . . . . . 261
Frequency-Shift Keying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
Contents HP E1340A Arbitrary Function Generator User’s Manual 7
Notes
Waveform Hopping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
Sweeping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
Gating the Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
Downloading an Arbitrary Waveform . . . . . . . . . . . . . . . . . . . . . . . . 266
Fast Frequency Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Sending Data Directly to the DAC . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Example Program Subprograms . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Querying AFG Pa ra meters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
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 ewlett­Packard further certifies that its calibration measurements are traceable to the United Stat es Nation al Instit ute of Stand ard s and Tech­nology (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 ship­ment. 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 e­pay 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 prod­ucts or interfacing, unauthori ze d m odificati on or misus e, operation outside of the environmenta l specificat i ons for the product, or im­proper 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 oc­curs 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 CON­TRACT, TORT, OR ANY OTHER LEGAL THEORY.
Notice
The information contained in this document is subject to change without notice. HEWLETT-PACKARD (HP) MAKES NO WAR­RANTY OF ANY KIND W ITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAR­RANTIES 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 docu­ment c ontains proprietary information whi ch is protected by copyright. All rights are reserved. No part of this document may be photo­copied, 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
Copyright © 1995 He wle tt-Pa cka rd Company. All Right s Reser ve d.
Edition 3
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 Edi­tion 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 his­tory page.
Edition 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Jan uar y, 1992
Update 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . August, 1992
Edition 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . March, 1993
Edition 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . April, 1995
Safety Symbols
Instruction manual symbol affixed to prod­uct. Indicat es that the user must refer to t he manual for specific WARNING or CAU­TION information to avoid personal injury or damage to the product.
Indicates the field wiring terminal that must be connected to earth ground before operat­ing the equipment—protects against electri­cal 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 con­dition 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 im­paired, 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 f­fice 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 :
Safety: IEC 1010-1 (1990) Incl . Amend 1 (1992) /E N610 10-1 (1993)
CSA C22.2 #1010.1 (1 992) UL 1244
EMC: CISPR 11:1990/EN55011 (1991): Group1 Class A
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, 1995 Jim White , QA ManagerApril, 1995 Jim 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 CLASS PERMIT NO. 37 LOVELAND,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
fold here
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.
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:
Preparation for Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 15
Installing the AFG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 15
Downloadi ng the A F G Device Driver. . . . . . . . . . . . . . . . Page 15
AF G Lo gical Add ress. . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pag e 17
Addressing the AFG. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 18
Instrument and Programming Languages . . . . . . . . . . . . . . . Page 19
HP IBASIC La nguage Pro grams . . . . . . . . . . . . . . . . . . . . Page 22
C Language Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 25
QuickBASIC Language Programs. . . . . . . . . . . . . . . . . . . Page 31
Introductory Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 36
AF G Self-Te s t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 36
Resetting and Clearing the AFG . . . . . . . . . . . . . . . . . . . . Pag e 37
Queryi ng the Power-On/ Res et Con figu rat i on . . . . . . . . . . Pag e 37
Checking for Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 38
Generating a Sine Wave. . . . . . . . . . . . . . . . . . . . . . . . . . . Page 40
HP E1340A Example Programs . . . . . . . . . . . . . . . . . . . . . . Page 40
Preparation for Use
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 AFG The 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 in C-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 E1340A Chapter 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 1 Getting 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 E1340A Chapter 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 G The following information explains how the AFG is addressed using
dif feren t com p u ter ( contr o ller) configur ations.
IB ASIC To 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).
The Pri mary HP-IB Address and Secondary HP-IB Address are the same as described previously for IBASIC programming.
Chapter 1 Getting Started with the HP E1340A 18
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 Programming SCPI (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 E1340A Chapter 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 Format The 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 Coupling Many 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 1 Getting 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).
Note See “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 E1340A Chapter 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 Configuration Except 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 Structure The 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. 20 ASSIGN @Afg TO 80910 30 COM @Afg, Waveform(1:4096) 40 ! 50 !Set up error checking 60 ON INTR 8 CALL Errmsg 70 ENABLE INTR 8;2 80 OUTPUT @Afg;“*CLS” 90 OUTPUT @Afg; “*SRE 32” 100 OUTPUT @Afg; “*ESE 60” 110 ! 120 !Call the subprogram which resets the AFG. 130 CALL Rst 140 !Set AFG parameters 150 OUTPUT @A fg;“SOUR:ROSC:SO UR INT;”; !re fe re nc e osci llato r 160 OUTPUT @A fg; “:SOUR:F REQ:FIX 1E3;”; !frequency 170 OUTPUT @Afg; “:SOUR:FUNC:S HAP USER; ”; !func ti on 180 OUTPUT @Afg; “:SOUR:VO LT :LEV:IMM:AMPL 5.1V ”!scale
amplitude
190 ! 200 !Call subprogram which defi ne s waveform segment . 210 CALL Ramp_wave 220 ! 230 !Select output sequence and initiate waveform 240 OUTPUT @Afg;“SOUR:FUNC:USER A” 250 OUTPUT @A fg;“INIT:IMM” !wait-for-arm stat e
Contin ued on next page
Chapter 1 Getting Started with the H P E1340A 22
260 ! 270 WAI T .1 !allow interrupt to be serviced 280 OFF INTR 8 290 END 300 ! 310 SUB Ramp_wave 320 Ramp_wave: !Subprogram which defines a ramp waveform 330 COM @Afg,Waveform(*) 340 FOR I=1 TO 4096 350 Waveform(I)=I*.00122 360 NEXT I 370 ! 380 OUT PUT @A fg; “SOUR:LIST:SEGM:SEL A”!Selec t segme nt name 390 OUT PUT @Afg;“ SOUR:LIST : SEG M:VOLT”;Wavef orm(*)!loa d
400 SUBEND 410 ! 420 SUB Rst 430 Rst: !Subprogram which resets the E1340. 440 COM @Afg,Waveform(*) 450 OUTPUT @A fg;“*RST;*OPC?” !reset the AFG 460 ENTER @Afg;Complete 470 SUBEND 480 ! 490 SUB Errmsg 500 Errmsg: !Subprogram which displays E1340 program ming error s 510 COM @Afg,Waveform(*) 520 DIM Message$[256] 530 !Read AFG status byte register and clear service request bit 540 B=SPOLL(@Afg) 550 !End of statem ent if error occur s among coupl ed com mands 560 OUTPUT @A fg;“” 570 OUT PUT @Afg;“ABORT” !abort output waveform 580 REPEAT 590 OUTPUT @Afg;“SYST:ERR?” !read AFG error queue 600 ENTER @Afg;Code,Message$ 610 PRINT Code,Message$
waveform point s
620 UNTIL Code=0 630 STOP 640 SUBEND
23 Gettin g Started with the HP E1340A Chapter 1
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 1 Getting 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 Configuration The 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
Command Library
Mainframe: HP 75000 Series B/C
Slot0/Resource Manager: HP E1301A Mainframe/E14 05/E1 406
Command Module
HP E1340A Logical Address:80
Instrument Language: SCPI
C Compiler Used Unless otherwise noted, all C Language programs were co mpiled (and
tested) using the following compilers:
Microsoft
Microsoft
Bo rland Turbo C
Borland Turbo C++
®
C Version 5.10
®
QuickC© Version 2.0
©
Version 2.0
©
Version 1.0
Running a Program To run a program, first comp ile and link the program to make an executable
file. To compile a program:
Link the approp riate HP-IB C libra r y (located on t he HP-IB
Command Library disk that came with the HP-IB Interface Card). Use the following libraries :
Microsoft
®
C and QuickC©: clhpib.lib
Turbo C
©
and C++©: tchhpib.lib
If NOT compiling i n the Large/Huge memory mode l, inc lu d e the
“cfunc.h” header file in the program (located on the HP-IB Command Library disk that came with the HP-IB Interface Card).
25 Gettin g Started with the HP E1340A Chapter 1
Be sure the necessary paths have been added to the
AUTOEXEC.BAT file for the co mpilers to find the library and header files (s ee the app ropr ia t e C Language manual to set the proper pat hs).
To compile t he progra ms fr om the DOS command line using the Large memory model, execute the following:
Microsoft
cl /AL <path \pro gram na m e> path \clhpib.lib
Microsoft
qcl /AL <pat h \pro gram na m e> path \clhpib.lib
Turbo C
tcc -ml <path \program name> path \tchhpib.lib
Change the “ compiling in the smal ler mem or y models (see t he appropriate C Lang u age manual for the parameter type).
®
C:
®
QuickC©:
©
and Turbo C++©:
/AL” and “-ml” parameters to t he appropriate types when
C Program Example Following 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 1 Getting 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 */
#define ISC 7L /* Assigns the HP-IB select code */ #define ADDR 70910L /*
/* Functions */ void gen_seg(void); void cmd_exe(char *commands[], int length); void run_query(void); void rst_clr(void); void send_data(char *commands, float *Wave_seg, int num_size); void check_error(char *func_tion);
Assign an I/O path between the computer and the AFG */
/*********************************************************************************/ 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;” /* “:SOUR:VOLT:LEV: IMM: AMP L 5.1V”, /* Set the amplit ude */
“SOUR:LIST:SEGM :SE L a” /* Select the segm ent nam e */ },
Command to select the user function */
Contin ued on next page
27 Gettin g Started with the HP E1340A Chapter 1
*seg_commands = /* Use “seg_commands” to store segm ents */
“SOUR:LIST:SEGM:VOLT ”, /* Command to send volts data */
*out_commands[] = / * { “SOUR:FUNC:USER a”, /* Select the user name */ “INIT:IMM” /* Start waveform generation */ };
float *Wave_seg; int loop,
seg_size = 4096; /* Set the segment size to 4096 point s */
/*
Allocate sufficient memory for storing the segments into computer memory */
Wave_seg = (float*) malloc (seg_size * sizeof (float));
/* Setup the AFG */
cmd_exe (set_commands, sizeof(set_commands) / sizeof(char*));
/* Call routine to check for AFG errors */
check_error(“gen_seg (set_com mands)”);
Use th e “out_com mands” array to generate outpu t */
/* Calculate the segments */
for (loop = 0; loop < seg_size; loop ++)
Wave_seg[loop] = (loop * .00122);
/* Call function to execut e the fi nal comm and with segment data */
send_data(seg_commands, Wav e_ seg, seg_size);
/* Call routine to check for AFG errors */
check_error(“gen_seg (seg_commands)”);
/* Setup the AFG for output */
cmd_exe(out _comm ands, sizeof(out_commands) / sizeof( char*));
/* Call routine to check for AFG errors */
check_error(“gen_seg (out_commands)”);
Contin ued on next page
Chapter 1 Getting Started with the HP E1340A 28
/* Free the allocated memory */ free (Wave_seg); } /*********************************************************************************/ void cmd_exe(char *commands[] , int length) { int loop;
/* Execute each command group using a loop */ for (loop = 0; loop < length; loop++)
IOOUTPUTS(ADDR, commands[loop], strlen(commands[loop])); }
/*********************************************************************************/ void send_data(char *commands, float *Wave _ seg, int num_ size) { char static state[2] = {13, 10};
/*
First disable EOI and EOL to send continuous data to the AFG; send last
command
*/ IOEOI (ISC, 0);IOEOL (ISC, “ ”, 0); IOOUTPUTS (ADDR, commands, strlen(commands));
/*
Re-enable EOL and EO I for normal HP-IB operat i on; th en send the data */
IOEOI (ISC, 1);IOEOL (ISC, state, 2); IOOUTPUTA (ADDR, Wave_seg, num_size); } /*********************************************************************************/ void run_query(void) { char name[6]; int length = 5;
/* Query segment memory */ IOOUTPUTS(ADDR, “SOUR:LIST:SEGM:SEL?”, 19); IOENTERS(ADDR, name, &length);
printf(“\nWavef orm Segm ent curr entl y sel ect ed: % s”, name); }
Contin ued on next page
29 Gettin g Started with the HP E1340A Chapter 1
/*********************************************************************************/ void rst_clr(void) { flo at in to ;
/*
Executes the commands that resets th e AFG and clears its error register */
IOOUTPUTS(ADDR, “*RST;*OPC?”, 10); IOENTER(ADDR, &int o); IOOUTPUTS(ADDR, “*CLS;*OPC?”, 10); IOENTER(ADDR, &int o); } /*********************************************************************************/ void check_error(char *func_tion) { char into[161]; int length = 160;
IOOUTPUT S(ADDR, “SYST:ERR?”, 9); /* Query error register */ IOENTERS(ADDR, into, &length) ; /* Enter error message */
if (atoi(into) != 0) /* Determine if error is present */
/* If errors present, print and exit */
{
while (atoi(into) != 0)
{
printf(“Error %s in function %s\n\n”, into, func_ti on); IOOUTPUTS(ADDR, “SYST:ERR?”, 9); IOENTERS(ADDR, into, &length);
}
exit(1); } }
Chapter 1 Getting Started with the HP E1340A 30
QuickBASIC
Language Programs
All of the Quic kBASIC Language exam ple programs in this manual are written for the HP 82335 HP-IB Interface Card using the HP-IB Command Library for BASIC.
The following identifies the system on which the programs are written, shows how to compile the programs, and gives a typical example program.
System Configuration The QuickBASIC pr o grams were developed on the following system:
Controller: HP Vectra 386/25 personal computer
(386 processor operated at 25 MHz)
HP-IB Interface Card: HP 82335 HP-IB Interface with
Command Library
Mainframe: HP 75000 Series B/C
Slot0/Resource Manager: HP E1301A Mainframe/E14 05/E1 406
Command Module
HP E1340A Logical Address:80
Instrument Language: SCPI
Running a Program To run a program, first comp ile and link the program to make an executable
file. You can e ither compile and link the pr o gram in the QuickBASIC environment, or compile and link separately on the command li ne as follows.
Using the QuickBASIC Environment
To compile and link a pro gr a m, select the Q uickBASIC env ironment as follows:
qb <path \progra m nam e> /l
This loads both the program and HP-IB library into the QuickBASIC environment. Note that t his only selects the QuickBASIC version 4.0 and above environment. For ot he r ver s ions of QuickB ASIC, r efer to the “HP 82335 Using the HP-IB Interface and Command Library” manual.
Using the Command Line
To compile and link using the c omma nd line is a two step method as follows:
\path \qbhpib
First, compile the program by executing:
bc <path \program name >
31 Gettin g Star ted with the HP E1340A Chapter 1
This gen erates an object lis t ing that has t he same name as the pr ogra m name with an OBJ extension. This object file must be linked to the HP-IB library.
Second, link the HP-IB library:
link <path \program name>
Af ter prom pted for a run file, press the Enter k ey. The execu t able file wi th an EXE extension is then generated.
QuickBASIC Program
Example
The following is an example program written in Qu ic kBASIC using the HP 82335 HP-IB Interface Card. The program:
sends commands to the AFG to generat e an arbitrary waveform
receives data from t he AFG
shows how to send coupled commands
performs error checking of the AFG
’ ARB_GEN.BAS - This program generates a 4096 points ramp. The data to ’ generate the ramp is transferred to the AFG as voltages
DECLARE SUB GenSeg () DECLARE SUB CmdExe (Commands$(), Length%) DECLARE SUB SendData (Commands$, WaveSeg!(), NumSize%) DECLARE SUB RstClr () DECLARE SUB CheckError (FuncType$) DECLARE SUB RunQuery ()
COMMON SHARED ADDR&, ISC&
REM $INCLUDE: ’QBSETUP’
ISC& = 7 ’Assigns the HP-IB select code ADDR& = 70910 ’Assign an I/O path between the computer and the AFG
CALL RstClr ’ Reset the AFG CALL GenSeg ’ Generate segment list and output sequence CALL RunQuery ’ Query segment name
END
SUB CheckError (FuncType$)
Max.Length% = 160: Actual.Length% = 0
Contin ued on next page
Chapter 1 Getting Started with the HP E1340A 32
Info$ = SPACE$(Max.Length%)
CALL IOOUTPUTS(ADDR&, “SYST:ERR?”, 9) ’ Query error regi ster CALL IOENTERS(ADDR&, Info$, Max.Lengt h%, Actual .Lengt h% ) Info$ = LEFT$(Info$, Actual.Length%)
IF VAL(Info$) <> 0 THEN CLS WHILE VAL(Info$) <> 0
PRINT : PRINT Info$; “ in function: ”; FuncType$
Actual.Length% = 0
CALL IOOUTPUT S(ADDR&, “SYST:ERR?”, 9)
CALL IOENTERS(ADDR&, Inf o$, Max .Lengt h%, Actual .Lengt h%)
Info$ = LEFT$(Info$, Actual.Length%) WEND END END IF
END SUB
SUB CmdExe (Com m ands$(), Length%)
FOR I = 1 TO Length% CALL IOOUTPUTS(ADDR&, Commands$(I) , LEN(Com mands$(I))) NEXT I
END SUB
SUB GenSeg
DIM SetCommands$(1 TO 2) DIM OutCommands$(1 TO 2) DIM WaveS eg!(1 TO 4096)
SetCommands$(1) = “SOUR:ROSC:SOUR INT;” ’ SetCommands$(1) = SetCommands$(1) + “:SOUR:FREQ:FIX 1e3;” ’ Set
Select the Ref. Oscillator
waveform frequency
SetCommands$(1) = SetCommands$(1) + “:SOUR:FUNC:SHAP USER;”
’ Select user function
Contin ued on next page
33 Gettin g Started with the HP E1340A Chapter 1
SetCommands$(1) = SetCommands$(1) + “:SOUR:VOLT:LEV:IMM:AMPL 5.1V”
’ Set the amplitude
SetCommands$(2) = “SOUR:LIST:SEGM:SEL a” ’ S e l e c t t h e s e g m e n t n a m e
SegCommands$ = “SOUR:LIST:SEGM:VOLT ” ’ Com man d t o se nd vo l ts dat a
OutCom mands$(1) = “SOUR:FUNC:USER a” ’ Select the user name
OutCom mands$(2) = “INIT:IMM” ’ Start waveform generation
’ Setup the AFG CALL CmdExe(SetComm ands$(), 2)
’ Call function to check for AFG errors CALL CheckError(“GenSeg (SetCommands)”)
’ Calculate the segments; store in memory FOR I = 1 TO 4096 WaveSeg!(I) = I * .00122 NEXT I
’ Call function to execute the final command with segment data CALL SendData(SegCommands$, Wa veSeg!(), 4096)
’ Call function to check for AFG errors CALL CheckError(“GenSeg (SegCommands)”)
’Setup the AFG for output CALL CmdExe(OutCommands$(), 2)
’ Call function to check for AFG errors CALL CheckError(“GenSeg (OutCommands)”)
END SUB
SUB RstClr
CALL IOOUTPUTS(ADDR&, “*RST;*OPC?”, 10) CALL IOENTER(ADDR&, Into!)
Contin ued on next page
Chapter 1 Getting Started with the HP E1340A 34
CALL IOOUTPUTS(ADDR&, “*CLS;*OPC?”, 10) CALL IOENTER(ADDR&, Into!)
END SUB
SUB RunQuery
Max.Length% = 20: Actual.Length = 0 Info$ = SPACE$(Max.Length%)
’ Query segment name CALL IOOUTPUTS(ADDR&, “SOUR:LIST:SEGM: SEL?”, 19) CALL IOENTERS(ADDR&, Info$, Max.Lengt h%, Actual .Lengt h%) Info$ = LEFT$(Info$, Actual.Length%)
PRINT : PRINT “Segment Name: ”; Info$
END SUB
SUB SendData (Commands$, WaveSeg!(), NumSize%)
Endline$ = CHR$(13) + CHR$(10)
’ First disable EOI and EOL to send continuous data t o t he AFG ; send l ast command
CALL IOEOI(ISC&, 0) CALL IOEOL(ISC&, “ ”, 0) CALL IOOUTPUTS(ADDR&, Commands$, LEN(Commands$))
’ Re-enable EOL and EOI for normal HP-IB operation; then send the data CALL IOEOI(ISC&, 1) CALL IOEOL(ISC&, Endline$, LEN(Endl ine$)) CALL IOOUTPUTA(ADDR&, SEG WaveSeg!(1), NumSize%)
END SUB
35 Gettin g Started with the HP E1340A Chapter 1
Introductory Programs
The introductory programs in this section include:
AFG Self-Test
Resetting the AFG and clearing its status registers
Querying the AFG power-on/reset settings
Checking for Errors
Generating a sine wave
AFG Self-Test The AFG self-test is executed with the command:
*TST?
Table 1-1. HP E1340A Self-Test Codes.
Self-Test Code Descr ip tion
HP IBASIC (SLFTST)
0 Test passed 1 Test fai led. An error m ess a g e describ es the failure.
The self-test checks communication bet ween the E1340A and the E1300/01 mainframe or C omman d M odule. Upon completion of the test, one of the self-test codes listed in Table 1-1 is returned.
1 !RE-SAVE “SLFTST” 10 !Send the self-test command, enter and display the r esult. 20 DIM Message$[256] 30 OUTPUT 80910;"*T ST?" 40 ENTER 80910;Rslt 50 IF Rslt <>0 THEN 60 REPEAT 70 OUTPUT 80910;"SYST:ERR?" 80 ENTER 80910;Code,Message$ 90 PRINT Code,Me ssage$ 100 UNTIL Code=0 110 END IF 120 PRINT Rslt 130 END
Chapter 1 Getting Started with the HP E1340A 36
C and QuickBASIC
Programs
The C and QuickBASIC v ersions of SLFTST are on the C language exampl e programs disk (HP P/N E1340-10036).
Resetting and
Clearing the AFG
HP IBASIC (RSTCLS)
The commands used to reset and clear the AFG are:
*RST *CLS
Resett i n g t he AFG s ets it to its powe r-o n configur ation and cl ea r i n g t h e AFG clears its statu s registers. Status register programming is covered in Chapter 8.
1 !RE-SAVE"RSTCLS" 10 !Assign an I/O path between IBASIC and the AFG . 20 ASSIGN @Afg TO 80910 30 COM @Afg 40 !Call the subprogram 50 CALL Rst_cls 60 END 70 ! 80 SUB Rst_cls 90 Rst_cls: !subprogram which r esets and clears the AFG. 100 COM @Afg 110 OUTPUT @Afg;"*RST;*CLS;*OPC?" !reset and clear t he AFG 120 ENTER @Afg;Complete 130 SUBEND
C and QuickBASIC
Programs
Querying the
Power-On /Rese t
Configurat ion
The C and QuickB ASIC versions of RSTCLS are on the C language exampl e programs disk (HP P/N E1340-10036).
After resetting the AFG or cycling power, the AFG parameters are set to the ir p ower -on v alues. These va lues are l i st ed in A ppen dix B, Table B-5.
The command which queries each AFG parameter setting is:
*LRN?
37 Gettin g Started with the HP E1340A Chapter 1
HP IBASIC (LRN)
1 !RE-SAVE “LRN” 10 !Assign an I/O path between IBASIC and the AFG . 20 ASSIGN @Afg TO 80910 30 !Call the subprogram 40 CALL Lrn_conf(@Afg) 50 END 60 ! 70 SUB Lrn_conf(@Afg) 80 Lrn_conf: !subprogram which queries the AFG reset configur ation 90 DIM Lrn$[1000],Temp$[40] 100 OUTPUT @Afg;"*LRN?" 110 ENTER @AFG;Lrn$ 120 Temp$="" 130 FOR I=1 TO LEN(Lrn$) 140 IF Lrn$[I,I]=";" THEN 150 PRINT Temp$ !print Temp$ when ; is received 160 Temp$="" 170 ELSE 180 Temp$=Tem p$&Lrn$[ I,I] !build Temp$ from *LRN data 190 END IF 200 NEXT I 210 SUBEND
C and QuickBASIC
Programs
The C and Quic kBASIC versions of LRN ar e on th e C langua g e e xa mple programs disk (HP P/N E1340-1 0036 ).
Checking for Errors The followi ng HP I BAS IC pr ogr a m shows the lines and subprogram added
to th e HP IBASIC programs to check for error s. Line 140 c lea r s the AFG standard event st atus r eg ist er. Li nes 150 and 160 u nmask the appropr iate bits in the A FGs status byte register and standard event status register.
When an error occurs, the subprogram “Errmsg” reads the AFG error queue and displays the code and message. Note that line 310 is used to force an "end of stateme nt " c ondition should a syntax error occur in a group of commands. Otherwise, the considered as part of the group and be ignored by the AFG SCPI interpreter.
Note An alternative HP IBASIC err or checking program is in the C-Size VXIbus
Systems Installation an d Getting Start ed Guide. Error checking routines for
C language and QuickBASIC programs are found in programs ARB_GEN.C and ARB_GEN.BAS, l isted previously in this chapter.
ABORT command in line 320 could be
Chapter 1 Getting Started with the HP E1340A 38
HP IBASIC (ERRORCHK)
1 !RE-SAVE"ERRORCHK" 2 !This program represents the method used to check for programmin g 3 !errors in HP IBASIC programs. 10 !Assign I/O path between IBASIC and the E1340A. 20 ASSIGN @Afg TO 80910 30 COM @Afg 40 !Define branch to be taken when an E1340A error occurs. 50 !Enable IBASIC interface to generate interrupt when error occu rs. 60 ON INTR 8 CALL Errmsg 70 ENABLE INTR 8;2 80 !Clear all bits in the standard event status register, unmask the 90 !standard event status group summary bit in the E1340A status byte 100 !register (decimal weight 32), unma sk the query error, device 110 !dependent error, execution error, and command error bit s 120 !(decimal sum 60) in the E1340A standard event status register. 130 OUTPUT @Afg;"*CLS" 140 OUTPUT @A fg; "*SRE 32 " 150 OUTPUT @Afg;"*ESE 60" 160 ! 170 !Subprogram calls would be here 180 ! 190 WAIT .1 !allow error branch to occur before turning intr off 200 OFF INTR 8 210 END 220 ! 230 SUB Errmsg 240 Errmsg: !Subprogram which displays E1340 program ming error s 250 COM @Afg 260 DIM Message$[256] 270 !Read AFG status byte regist er and cle ar service request bit 280 B=SPOLL(@Afg) 290 !End of statement if error occurs among coupled commands 300 OUTPUT @Afg;"" 310 OUTPUT @Afg;"ABORT " !abort output waveform 320 REPEAT 330 OUTPUT @Afg;"SYST:ERR?" !read AFG error queue 340 ENTER @Afg;Code,Message$ 350 PRINT Code,Message$ 360 UNTIL Code=0 370 STOP 380 SUBEND
39 Gettin g Started with the HP E1340A Chapter 1
Generating a Sine
Wave
HP IBASIC (RSTSINE)
To output a s ine wa ve , only an amplitude needs to be specified and the AFG placed in the wait-for-trigger state (INIT). Using the minimum amount of AFG commands , th is programs g enerat es a 10 kHz, 10 Vp-p sine wav e.
1 !RE-SAVE"RSTSINE" 2 !This program outputs a sine wave based on a specified amplitude 3 !and the reset settings of the AFG. 4 ! 10 !Assign an I/O path between IBASIC and the AFG . 20 ASSIGN @Afg TO 80910 30 COM @Afg 40 ! 50 !Reset the AFG 60 CALL Rst 70 OUTPUT @AFG; "SOUR:V OLT :LEV: IM M:AMP L 5" !set amplitude 80 OUTPUT @Afg;"INIT:IMM" !output sine wave using reset condition s 90 END 100 ! 110 SUB Rst 120 Rst: !subprogram which r esets the AFG. 130 COM @Afg 140 OUTPUT @Afg;"*RST ;*O PC?" !reset the AFG 150 ENTER @Afg;Complete 160 SUBEND
C and QuickBASIC
Programs
The C and QuickB ASIC versions of RSTSINE are on th e C language exampl e programs disk (HP P/N E1340-10036).
HP E1340A Example Programs
For easy reference, names and de scriptions of the example programs in this man ual are summa rized in Appendix B, Table B-1.
Chapter 1 Getting Started with the HP E1340A 40
Generating Standard Waveforms with the
Chapter Contents
Chapter 2
HP E1340A
This chapter shows how to generate standard wav eforms (SINusoid,
SQUare, TRIangle, and RAMPS) using the HP E1340A 12-Bit Arbitrary
Function Generator (hereafter called the “AFG”).
The following sections show ho w to generat e standard wave forms, how to setup the AFG for different output loads, how to select the output amplitude units (i.e., V, Vpeak, etc.), and h ow to set the waveform amplitude and offset. The sections are as follows:
Standard Waveforms Flowchart . . . . . . . . . . . . . . . . . . . . . . Page 41
Generating DC Voltages . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 43
Generating Sine, Triangle. and Square Waves . . . . . . . . . . . Page 45
Generating Ramp Waves . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 47
Selecting the Amplitude Levels and Output Units . . . . . . . . Page 50
Pro g ram Commen t s. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pag e 52
Standard Waveforms Flowchart
The flowchart on page 42 shows the sequence used to generate standard waveforms. The reset (power-on) values of each command are also noted on the f lowchart. The programs in this chapter begin with a reset (the IEEE
*RST command) which places the AFG into its power-on state. Thus,
488.2 the programs do not execute all of the commands on the flowchart.
41 Generating Standard Waveforms with the HP E1340A Chapter 2
Chapter 2 Generati ng St anda rd Waveforms with the HP E1340A 42
Generating DC Voltages
This progra m outputs a +5 V DC volta ge. The c ommands ar e:
1. Reset the AFG -
The *RST command aborts an y waveform output and selects the sinusoid function.
2. Select the Function -
[SOURce:]FUNCtion[:SHAPe] DC
This command selects the DC function.
3. Set the Amplitude -
[SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] <amplitude>
This command specifies the amplitude. Refer to the section called “Selecting the Amplitude L evels and Ou tput Units” on page 50 for more inform ation.
HP IBASIC Program Example (DCVOLTS)
1 !RE-SAVE“DCVOLTS” 2 !This program outputs 5V dc. 3! 10 !Assign I/O path between IBASIC and the E1340A. 20 ASSIGN @Afg TO 80910 30 COM @Afg 40 ! 50 !Set up error checking 60 ON INTR 8 CALL Errmsg 70 ENABLE INTR 8;2 80 OUTPUT @Afg;“*CLS” 90 OUTPUT @Afg; “*SRE 32” 100 OUTPUT @Afg; “*ESE 60” 110 ! 120 !Call the subprogram which resets the AFG. 130 CALL Rst 140 ! 150 !Set AFG parameters 160 OUTPUT @Afg;“SOUR:FUNC:SHAP DC” !func tion 170 OUTPUT @A fg; “SOUR:VOLT:LEV:IMM:AM PL 5V ” !amplitude 180 ! 190 WAI T .1 !allow interrupt to be serviced
*RST
Contin ued on next page
43 Generating Standard Waveforms with the HP E1340A Chapter 2
200 OFF INTR 8 210 END 220 ! 230 SUB Rst
300 SUB Errmsg
C and QuickBASIC
Program Versions
The C example program, DCVOLTS.C, is in directory “CPROG” and the QuickBASIC example program, DCVOLTS.BAS, is in directory “QBPROG” on the C and QuickBASIC example disk (part number E1340-10036).
Chapter 2 Generati ng St anda rd Waveforms with the HP E1340A 44
Generating Sine, Triangle, and Square Waves
This pro gram outputs a Sine Wave at 1 kHz and 5 V output le vel. The commands are:
1. Reset the AFG -
The *RST command aborts an y waveform output and selects the sinusoid function.
2. Set the Waveform Frequency -
[SOURce:]FREQuency[:FIXed] <frequency>
Thi s command specifies the waveform frequency. R efer to Appendix B for the frequency limits.
3. Select the Function -
[SOURce:]FUNCt ion[: SHAP e] SINusoid
This command selects the SINusoid function. (Although *RST automatically selects this function, it is selected here for good programming practice.) For the Triangle and Square Wave functions, use the
SINusoid.
4. Set the Amplitude -
[SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] <amplitude>
TRIangle and SQUare parameters, respectively, instead of
*RST
This command specifies the amplitude. Refer to the section called “Selecting the Amplitude L evels and Ou tput Units” on page 50 for more inform ation.
5. Initiate t he Waveform -
INITiate[ :I MMediate]
This command gen erates an immediate output with the arm source
IMMediate. Refer to Chapter 5 for triggering information.
set to
45 Generating Standard Waveforms with the HP E1340A Chapter 2
HP IBASIC Program Example (SINEWAVE)
1 !RE-SAVE“SINEW AVE ” 2 !This program generates a 5V, 1 kHz sine wave. 3! 10 !Assign I/O path between IBASIC and the E1340A. 20 ASSIGN @Afg TO 80910 30 COM @Afg 40 ! 50 !Set up error checking 60 ON INTR 8 CALL Errmsg 70 ENABLE INTR 8;2 80 OUTPUT @Afg;“*CLS” 90 OUTPUT @Afg; “*SRE 32” 100 OUTPUT @Afg; “*ESE 60” 110 ! 120 !Call the subprogram which resets the AFG. 130 CALL Rst 140 ! 150 !Set AFG parameters 160 OUTPUT @Afg;“SOUR:FREQ: FI X 1E3;”;!frequ ency 170 OUTPUT @A fg; “:SOUR:FUNC:SHAP SIN;”;!functi on 180 OUTPUT @A fg; “:SOUR:VOLT:LEV:IMM:A MPL 5V”!amplit ude 190 OUTPUT @A fg;“INIT:IMM” !wait-for-arm state 200 ! 210 WAI T .1 !allow interrupt to be serviced 220 OFF INTR 8 230 END 240 ! 250 SUB Rst
320 SUB Errmsg
C and QuickBASIC
Program Versions
The C example program, SINEWAVE.C, is in directory “CPROG” and the QuickBASIC example program, SINEWAVE.BAS, is in directory “QBPROG” on the C and QuickBASIC example disk (part number E1340-10036).
Chapter 2 Generati ng St anda rd Waveforms with the HP E1340A 46
Generating Ramp Waves
This progra m outputs a ne gat ive goi ng Ramp at 10 kHz, 4 V output leve l, and +1 V offset. The commands are:
1. Reset the AFG -
The *RST command aborts any waveform output, selects the sinusoid function, sel ects the 42.9 MHz referenc e oscillator source, 10 kHz frequency, arm sta rt immediate, 0 V offs et, and 0 V output.
2. Set the Frequency -
[SOURce:]FREQuency[:FIXed] <frequency>
This command specifies the frequency. Refer to Appendix B for the frequency limits.
3. Select the Function -
[SOURce:]FUNCt ion[: SHAP e] RAMP
This command selects the RAMP function.
4. Select the Ramp P olarit y -
[SOURce:]RAMP :POLari ty INVerte d
This command selects the polarity of the RAMP wave. Use NORMal for the initial voltage to go positive; use INVerted f or t he initial voltage to go negative.
*RST
5. Set the Amplitude -
[SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] <amplitude>
This command specifies the amplitude. Refer to the section called “Selecting the Amplitude L evels and Ou tput Units” on page 50 for more inform ation.
47 Generating Standard Waveforms with the HP E1340A Chapter 2
6. Set the Offset -
[SOURce:]VO LTage[ :LE Vel ][ :IMM edi ate] :OF F Set <offs et >
This command specifies the offset. Refer to the section called “Selecting the Amplitude L evels and Ou tput Units” on page 50 for more inform ation.
7. Initiate t he Waveform -
INITiate[ :I MMediate]
This command gen erates an immediate output with the arm source
IMMediate. Refer to Chapter 5 for triggering information.
set to
HP IBASIC Program Example (RAMPWAVE)
1 !RE-SAVE"RAMPWAVE" 2 !This program generates a 4V, 10 kHz negative-going ramp wav e. 3! 10 !Assign I/O path between IBASIC and the E1340A. 20 ASSIGN @Afg TO 80910 30 COM @Afg 40 ! 50 !Set up error checking 60 ON INTR 8 CALL Errmsg 70 ENABLE INTR 8;2 80 OUTPUT @Afg; "*CLS" 90 OUTPUT @Afg;"*SRE 32" 100 OUTPUT @Afg;"*ESE 60" 110 ! 120 !Call the subprogram which resets the AFG. 130 CALL Rst 140 ! 150 !Set AFG parameters 160 OUTPUT @Afg; "SOUR:ROSC:SOUR INT;";!reference oscillator 170 OUTPUT @Afg;":SOUR:FREQ:FIX 10E3;";!frequency 180 OUTPUT @Afg;":SOUR:FUNC:SHAP RAMP;";!function 190 OUTPUT @Afg;":SOUR: RAM P:POL INV;";!ramp polarity 200 OUTPUT @A fg; ":SOUR:VOLT :LEV :I MM:AMPL 4V;";!a mplitude 210 OUTPUT @A fg; ":SOUR:VOLT :LEV :I MM:OFFS 1V"!of fset 220 OUTPUT @A fg;"INIT:IMM" !wait-for-arm state 230 ! 240 WAI T .1 !allow interrupt to be serviced 250 OFF INTR 8 260 END 270 ! 280 SUB Rst
Contin ued on next page
Chapter 2 Generati ng St anda rd Wavefo rms with the HP E1340A 48
350 SUB Errmsg
C and QuickBASIC
Program Versions
The C example program, RAMPWAVE.C, is in directory “CPROG” and the QuickBASIC example program, RAMPWAVE.BAS, is in directory “QBPROG” on the C and QuickBASIC example disk (part number E1340-10036).
49 Generating Standard Waveforms with the HP E1340A Chapter 2
Selecting the Amplitude Levels and Output Units
This pro gra m s hows h ow t o s et the out put a mp litude using the VPP (volts peak-to-peak) output unit. The commands are:
1. Reset the AFG -
The *RST command aborts any waveform output, selects the sinusoid function, sel ects the 42.9 MHz r eference oscillator sourc e, arm start immediat e, 0 V offset, and 0 V output.
2. Select the Output Units -
[SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude]:UNIT:VOLTage <units>
This command selects the following output units:
V - Volts VPK - Volts peak VPP - Volts peak-to-peak VRMS - Volts rms W - Watts DBM|DBMW - dB referenced to 1 milliwatt
These units are assu med only if no other units are specified in the
[SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] <amplitude>
command. The output units are only valid for amplitude and not offsets (volts is required for offsets).
3. Set the Amplitude and the Offset -
[SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] <amplitude>
*RST
[SOURce:]VO LTage[ :LE Vel ][ :IMM edi ate] :OF F Set <
These commands specify the amplitude and offset. Refer to Appendix B for the amplitude limits. The maximum value of the combined amplitude and offset voltages must remai n within the 7 V limit.
4. Initiate t he Waveform -
INITiate[ :I MMediate]
This command gen erates an immediate output with the arm source
IMMediate. Refer to Chapter 5 for triggering information.
set to
offset>
Chapter 2 Generati ng St anda rd Waveforms with the HP E1340A 50
HP IBASIC Program Example (OUTPUNIT)
1 !RE-SAVE“OUTPUNIT” 2 !This program sets the AFG’s output uni t s to volts peak-to-peak. 3! 10 !Assign I/O path between IBASIC and the E1340A. 20 ASSIGN @Afg TO 80910 30 COM @Afg 40 ! 50 !Set up error checking 60 ON INTR 8 CALL Errmsg 70 ENABLE INTR 8;2 80 OUTPUT @Afg;“*CLS” 90 OUTPUT @Afg; “*SRE 32” 100 OUTPUT @Afg; “*ESE 60” 110 ! 120 !Call the subprogram which resets the AFG. 130 CALL Rst 140 ! 150 !Set AFG parameters 160 OUTPUT @A fg; “SOUR:VOLT:LEV:IMM:AM PL:UNIT:VOLT VPP”
!output units
C and QuickBASIC
Program Versions
200 OUTPUT @A fg; “SOUR:VO LT:LEV:IMM:AMPL 8;”;!amplitude 210 OUTPUT @A fg; “:SOUR:VO LT:LEV:IMM:O F F S 1”!offse t 220 OUTPUT @Afg;“INIT:IMM ” !wait-for-arm state 230 ! 240 WAI T .1 !allow interrupt to be serviced 250 OFF INTR 8 260 END 270 ! 280 SUB Rst
350 SUB Errmsg
The C example program, OUTPUNIT.C, is in directory “CPROG” and the QuickBASIC example program, OUTPUNIT.BAS, is in directory “QBPROG” on the C and QuickBASIC example disk (part number E1340-10036).
51 Generating Standard Waveforms with the HP E1340A Chapter 2
Program Comments
The following comments gi ve additio nal details on the pro gram exa mples in this chapter.
Reference
Oscillator Sources
Outp ut Load
Comments
Output Units
Comments
The SINusoid, SQUare, TRIangle, and RAMP functions can use any
of the Ref erenc e Osci llator Sour ces. The sources, selected by
[SOURce:]ROSCi llator: SO URce, are:
INTernal - 42.949 6729 6 MHz (power -on value) EXTernal - User provided value (the front panel “Aux In” BNC)
If using the EXTernal refer ence oscillator sou rce, ent e r the sou rce
frequency to the AFG using
[SOURce:]ROS Ci ll ator: F REQuency:EXTernal <f requency>.
For correct output a mp litu de values, the load applied to the AFG
“Signal Output” terminals must b e the same va lue as the selected AFG output impedance value.
To o utpu t to an open circ uit, ex ecute OUTPut:LOAD INFini t y or
9.9E+37. The HP E1340A then outputs the corre ct am plitude and
offset for an open circuit. The amplitude and offset range are doubled while resolution worsens by a factor of 2.
The selected unit type can be overridden by sending a unit suffix
with the amplitude command. For example, if the selected unit is VPP, sendi n g:
[SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] 5V
changes the unit type to volts (i.e., V) for that command. However, the default unit type remains in eff ect for subseq u ent ampl itude commands that are sent without the unit suffix.
The V (volts) suffix and VPK (volts peak) suffix generate the same
amplitude values for all time varying waveforms like
SQUare, TRIangle, and RAMPS.
SINusoid,
The default unit type only applies for amplitudes an d not for offsets.
The unit for offsets must always be specified in “ example, executing:
[SOURce:]VOLTage:OFFSet .1VPP
causes an error . To prev ent t h e error, ex ecute either:
[SOURce:]VOLTage:OFFSet 0.1
V” for volts. For
or
[SOURce]:VOLTage:OFFSet 0.1V
Chapter 2 Generati ng St anda rd Waveforms with the HP E1340A 52
The W, DBM, and DBMW unit types references the amplitude levels
to the 50 values are meaningless and not available when selecting an open circuit load.
output load valu e. Thus, t he W, DBM, a nd DBMW
Using MINimum
and MAXimum
Parameters
You can exec ute many commands (like [SO URce :]FR EQue ncy[ :CW|:F IXed ]) using the However, values when received using the values of other commands in effect at that time. The values of oth er commands af fecting the computation are subseq uently changed, but the already computed MIN and
MAX valu es do not change.
Thus, if a group of coupled commands are sent where the
MAXimum parameters conflict with the current AFG setting, the AFG
generates an error. This happens even though the commands that f ollow may set th e AFG to a state that d oes not conflict with the
MAXimum parameters.
For best results, use values in th e commands and do not use the and MAXimum parameters.
MINimum or MAXimum parameters instead of a number value.
MIN and MAX are internally converted immediately to numeric
MIN and MAX
MINimum and
MINimum and
MINimum
53 Generating Standard Waveforms with the HP E1340A Chapter 2
Chapter 2 Generati ng St anda rd Waveforms with the HP E1340A 54
Generating Arbitrary Waveforms with the
Chapter Contents
Chapter 3
HP E1340A
This chapter shows how to generate arbitrary waveforms using the HP E1340A 12-Bit Arbitrary Function Generator (called the “AFG”).
The following sections show how to generate arbitrary waveforms. Also included are example programs that generat e various arbitrary wave for ms. The sections are as follows:
Arbitrary Waveforms Flowchart . . . . . . . . . . . . . . . . . . . . . . Page 55
Gen erating a Simple Arbi trar y Wav ef orm . . . . . . . . . . . . . . Page 59
Executing Several Waveform Segments . . . . . . . . . . . . . . . . Page 65
Arbitrary Waveform Hopping . . . . . . . . . . . . . . . . . . . . . . . . Page 69
Generating Built-In Arbitrary Waveforms . . . . . . . . . . . . . . Page 73
Sam ple Programs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pag e 76
Generating a Damped Sine Wave . . . . . . . . . . . . . . . . . . . Page 76
Generating an Exponential Charge/Discharge
Wa veform. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 78
Generating a Sine Wave with Spikes. . . . . . . . . . . . . . . . . Page 79
Generating a Half-Rectified Sine Wave . . . . . . . . . . . . . . Page 80
Prog ram Commen t s. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pag e 82
Arbitrary Waveforms Flowchart
The flowchart on page 58 shows the commands and the command execution order to generate standard wa ve forms. The reset (power-on) values of each command are also noted on the flowchart. Note that the IEEE 488.2 command places the AFG into its po wer- on st at e. Th us, it may be unnecessary to execute all of the commands on the flowchart.
*RST
55 Generating Arbitrary Waveforms with the HP E1340A Chapter 3
How the AFG Generates Arbitrary Waveforms
Refer to Figure 3-1. A n arbitrary waveform consists of two parts, a waveform segment (or all points on a waveform) and a segment sequenc e. The segments contain the actual voltage points of the waveform. The segment sequ ence determines which waveform segments are to be output.
The AFG has four waveform segments available: A, B, C, and D. The size of each waveform segment is 4096 points. Thus, to store data into a wavefo rm segment, the numb er of data items (or waveform p oints) must be
4096.
To output a w aveform, set the user function to out put one or more of the waveform segments. To output a waveform with a single waveform segment, use one of the A through D waveform seg ments. To ou tput wav efo rms with mu ltip le wav e f orm segment s, us e a comb i n a tio n o f AB o r ABCD waveform segments. The AB combination outputs the 8192 point waveform defined by the A and B waveform segments. Thus, the A segment is output first and then the B segment . The ABC D combination outputs the 16384 point waveform defined by the A , B, C, an d D waveform segments. Thus, the A segment is output first and the D segment is output last.
Similarly, t h e AB combinat ion output s a waveform with 8192 points and the ABCD combination outputs a waveform with 16384 points.
The segment values can be either sent as voltage values
[SOURce:]LIST[:SEGMent]:VOLT <voltage_list>) or DAC
(use (digital-to-ana log converter) codes
[SOURce:]LIST[:SEGMent]:VOLT:DAC <voltage_list>).
(use If sent as voltage values, the AFG converts them to DAC codes before storing them in memory.
To output a w aveform, th e AFG set s t he DAC to the voltage value of the selected waveform segment. The wav eform frequency determines the waveform repetition rate.
Chapter 3 Generating Ar bitr ary Waveforms with the HP E1340A 56
Figure 3-1. Generating Arbitrary Waveform s
57 Generating Arbitrary Waveforms with the HP E1340A Chapter 3
Chapter 3 Generating Ar bitr ary Waveforms with the HP E1340A 58
Generating a Simple Arbitrary Waveform
This program shows h ow to generate an a rb itrar y waveform with a single waveform segment. The examp l e generates a 4096 point ramp. The AFG stores the waveform segment into segment memory as voltage data points. The commands are:
1. Reset the AFG -
The *RST command aborts an y waveform output and sets the AFG to a defined state.
2. Select the Reference Oscillator -
[SOURce:]ROS Cill ator:SO URce <sourc e>
This command selects the Reference Oscillator Source (see “Program Comments” later in this chapter).
3. Set the Waveform Frequency -
[SOURce:]FREQuency[:CW|FIXed] <frequency>
This command sets the repetition rate of the waveform. See Appendix B for the frequency limits.
4. Select the Arbitrary Waveform Function -
[SOURce:]FUNCt ion[: SHAP e] USER
This command selects the arbitrary waveform function.
5. Set the Maximum Output A mplitude -
[SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] <amplitude>
*RST
This command specifies the maximum output amplitude. The amplitude must be equal or grea ter than the maximum volt age value of the waveform segment. Refer to App endix B for th e amplitude limits.
59 Generating Arbitrary Waveforms with the HP E1340A Chapter 3
6. Select the Waveform Segment -
[SOURce:]LIST[:SEGMent]:SELect <name>
Use either A, B, C, or D in <name> for the waveform segment.
7. Store the Waveform Segment as Voltages -
[SOURce:]LIST [:SE GMent] :VOLT age <voltage_l ist>
This command stores the points of the waveform segment into the AFG’s segmen t mem ory. These points are sent to the AFG as volts which are the output voltage points that constitutes the waveform segment.
8. Select the User Name -
[SOURce:]FUNCtion:USER <name>
This command s elects the wavef orm segment to be output. Make the name in this command the same name as the waveform segment to be output.
9. Initiate t he Waveform -
INITiate[ :I MMediate]
This command gen erates an immediate output with the arm source
IMMediate. Refer to Chapter 5 for triggering information.
set to
10. Query the Waveform Segment (Optional) -
[SOURce:]LIST [ :SE Gm ent] :SELect ?
This command retur ns the currently selected waveform segment.
Chapter 3 Generating Ar bitr ary Waveforms with the HP E1340A 60
HP IBASIC Program Example (ARB_GEN)
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. 20 ASSIGN @Afg TO 80910 30 COM @Afg, Waveform(1:4096) 40 ! 50 !Set up error checking 60 ON INTR 8 CALL Errmsg 70 ENABLE INTR 8;2 80 OUTPUT @Afg;“*CLS” 90 OUTPUT @Afg; “*SRE 32” 100 OUTPUT @Afg; “*ESE 60” 110 ! 120 !Call the subprogram which resets the AFG. 130 CALL Rst 140 !Set AFG parameters 150 OUTPUT @A fg;“SOUR:ROSC:SO UR INT;”;!reference oscillator 160 OUTPUT @A fg; “:SOUR:F REQ:FIX 1E3;”;!fre quency 170 OUTPUT @Afg; “:SOUR:FUNC:S HAP USER; ”;!function 180 OUTPUT @Afg; “:SOUR:VO LT :LEV:IMM:AMPL 5.1V ”!scale
190 ! 200 !Call subprogram which defi ne s waveform segment . 210 CALL Ramp_wave 220 ! 230 !Select output sequence and initiate waveform 240 OUTPUT @Afg;“SOUR:FUNC:USER A” 250 OUTPUT @A fg;“INIT:IMM” !wait-for-arm state 260 ! 270 WAI T .1 !allow interrupt to be serviced 280 OFF INTR 8 290 END 300 ! 310 SUB Ramp_wave 320 Ramp_wave: !Subprogram which defines a ramp wavefo rm 330 COM @Afg,Waveform(*) 340 FOR I=1 TO 4096 350 Waveform(I)=I*.00122 360 NEXT I 370 ! 380 OUTPUT @Afg;“SOUR:LIST : SEGM:SEL A”!Select segme nt name
amplitude
Contin ued on next page
61 Generating Arbitrary Waveforms with the HP E1340A Chapter 3
390 OUTPUT @Afg; “ SOUR:LIST :SEGM:VO LT”;Waveform(*)!load
waveform point s
400 SUBEND 410 ! 420 SUB Rst
490 SUB Errmsg
C and QuickBASIC
Program Versions
The C example program, ARB_GEN.C , is i n directory “CPROG” and the QuickBASIC example program, ARB_GEN.BAS, is in directory “QBPROG” on the C and QuickBASIC example disk (part number E1340-10036).
Transferring Data in C To transfer data to the AFG requires that the data sent with the
[SOURce:]LIST[:SEGMent]:VOLTage c om man d mu s t be contigu ous. T o do
this, send no carria ge return (CR) and line feed (LF) before transf err i ng all the data. The function below):
1. Disable EOI and EOL using
2. Next, sent to the AFG the SCPI
send_data function does this as follows (refer to the C
IOEOI (IS C, 0 ) and IOEOL (ISC, “ ”, 0),
respectively.
ISC conta ins the HP-IB sel ect c ode, and the 0 and “ ”
(NULL) valu es d isab les the carriage retur n (C R) a nd line feed (LF) to allow the AFG to receive a command string without a terminator.
[SOURce:]LIST[:SEGment]:VOLTage command str ing using IOOUTPUTS (ADDR, commands, strlen(commands)). ADDR
contains the AFG HP-IB address, commands contains the SCPI command string, and
commands. This enab les the AFG to receive voltage data. S ince CR
strlen(com mands) contains the string length of
or LF is disabled, the AFG holds execution until all the data is sent.
3. Enable EOI and EOL using respectively. The va riable
IOEOI (ISC, 1) and IOEOL (ISC, state, 2),
state contains the decimal codes for CR
and LF. Although EOL and EOI are enabled, no CR and LF is sent until all voltage dat a tra nsfer is compl eted (next step).
Chapter 3 Generating Ar bitr ary Waveforms with the HP E1340A 62
4. The volta ge data values are sent next usin g the array Wave_seg in
IOOUTPUTA (ADDR, Wave_seg, num_size). The valu es in Wave_seg are in a floating point format. IOOUTPUTS automatically
separates each value in the arrays by a comma ( , ).
5. After all the data is sent, the data transfer terminates with a CR and LF. This lets the AFG know that it can rec eive a new co mmand.
void send_data(char *commands, float *Wave _ seg, int num_ size) {
char static state[2] = {13, 10};
/* First disable EOI and EOL; then send the last command */ IOEOI (ISC, 0); IOEO L (ISC, “ ”, 0); IOOUTPUTS (ADDR, commands, strlen(commands));
/* Re-enable EOL and EOI for normal HP-I B operation; then
send the last data */ IOEOI (ISC, 1);IO EOL (ISC, state, 2); IOOUTPUTA (ADDR, Wav e _ seg, num_s i ze);
}
Transferring Data in
QuickBASIC
To transfer data to the AFG requires that the data sent with the
[SOURce:]LIST[:SEGMent]:VOLTage c om man d mu s t be contigu ous. T o do
this, send no carria ge return (CR) and line feed (LF) before transf err i ng all the data. The
SendData routine in the QuickBASIC program do this as
follows (refer to the QuickBASIC routine below):
1. Disable EOI and EOL using respectively.
ISC& contains the HP-IB select code, the 0 and “ ”
IOEOI (IS C &, 0 ) a nd I OEOL (ISC&, “ ”, 0),
(NULL) valu es d isab les the carriage retur n (C R) a nd line feed (LF) to allow the AFG to receive a command string without a terminator.
2. Next, sent to the AFG the SCPI
[SOURce:]LIST[:SEGment]:VOLTage command str ing using IOOUTPUTS(ADDR& , Commands$, LEN(Commands$). ADDR&
contains the AFG HP-IB address, Commands$ contains the SCPI command string, and
Commands$. This enables the AFG to receive voltage data. Since
LEN(Comm ands$) contains the string length of
CR or LF is disabled, the AFG holds execution until all the data is sent.
3. Enable EOI and EOL using
Endline$, LEN(Endline$))
IOEOI(ISC&, 1) and IOEOL(ISC&,
, resp ectively. The va riable Endline $
contains the decimal codes for CR and LF. Although EOL and EOI are enabled, no CR and LF is sent until all voltage data transfer is completed (next step).
63 Generating Arbitrary Waveforms with the HP E1340A Chapter 3
4. The volta ge data values are sent next usin g the array WaveSeg! () in
IOOUTPUTA(ADDR& , SEG WaveSeg!(1), NumSize%). The values
WaveSeg! are in a floating point format. IOOUTPUTS
in automatically separates each value in the arrays by a comma ( , ).
5. After all the data is sent, the data transfer terminates with a CR and LF. This lets the AFG know that it can rec eive a new co mmand.
SUB SendData (Commands$, WaveSeg!(), NumSize%)
Endline$ = CHR$(13) + CHR$(10)
’ First disable EOI and EOL; then send the last command CALL IOEOI(ISC&, 0) CALL IOEOL(ISC&, “ ”, 0) CALL IOOUTPUTS(ADDR&, Commands$, LEN(Commands$))
’ Re-enable EOL and EOI for normal HP-IB operation; then send the data CALL IOEOI(ISC&, 1) CALL IOEOL(ISC&, Endline$, LEN(Endl ine$)) CALL IOOUTPUTA(ADDR&, SEG WaveSeg!(1), NumSize%)
END SUB
Chapter 3 Generating Ar bitr ary Waveforms with the HP E1340A 64
Executing Several Waveform Segments
This program shows h ow to generate an a rb itrar y waveform that combines two different waveform segments. One waveform se g ment generates a 1 kHz, 5 V sine wave. The other one generates a 1 kHz, 5 Vpeak triangle. The commands are:
1. Reset the AFG -
The *RST command aborts wav eform output and sets the AFG to a defined state.
2. Set the Waveform Frequency -
[SOURce:]FREQuency[:CW|FIXed] <frequency>
This command sets the repetition rate of the waveform. See Appendix B for the frequency limits.
3. Select the Arbitrary Waveform Function -
[SOURce:]FUNCt ion[: SHAP e] USER
This command sel ects the arbitrary wavefo rm function. Couple the command to th e previous frequen cy command.
4. Set the Maximum Output A mplitude -
[SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] <amplitude>
This command specifies the maximum output amplitude. The amplitude must be equal or grea ter than the maximum volt age value of the waveform segment. Refer to App endix B for th e amplitude limits
*RST
5. Select the First Wavefor m Seg m en t -
[SOURce:]LIST[:SEGMent]:SELect A
Use A to select the first waveform segment.
65 Generating Arbitrary Waveforms with the HP E1340A Chapter 3
6. Store the First Waveform Segment as Voltages -
[SOURce:]LIST [:SE GMent] :VOLT age <voltage_l ist>
This command stores the points of t he “A” waveform segment into the AFG’s s egm e nt me mory. These points are sent to the AFG as volts which are t he output voltage points that constitutes the waveform segment.
7. Select the Second Waveform Segment -
[SOURce:]LIST[:SEGMent]:SELect B
Use B to select the second waveform segment.
8. Store the Second Waveform Segment as Voltages -
[SOURce:]LIST [:SE GMent] :VOLT age <voltage_l ist>
This command stores the points of the B waveform segment into the AFG’s segmen t mem ory. These points are sent to the AFG as volts which are the output voltage points that constitutes the waveform segment.
9. Select the User Name -
[SOURce:]FUNCtion:USER AB
This command selects the waveform segments to b e ou tput
AB).
(i.e.,
10. Initiate t he Waveform -
INITiat e[:IMMediat e]
This command gen erates an immediate output with the arm source
IMMediate. Refer to Chapter 5 for triggering information.
set to
Chapter 3 Generating Ar bitr ary Waveforms with the HP E1340A 66
HP IBASIC Program Example (MULSEG)
1 !RE-SAVE“MULSEG” 2 !This program generates an arbitrary waveform compri sed of t wo 3 !wavef orm segments. One segm ent is a sine wave and the other 4 !segment is a triangle wave. 5! 10 !Assign I/O path between IBASIC and the E1340A. 20 ASSIGN @Afg TO 80910 30 COM @Afg,Waveform1(1:4096),Waveform2(1:4096) 40 ! 50 !Set up error checking 60 ON INTR 8 CALL Errmsg 70 ENABLE INTR 8;2 80 OUTPUT @Afg;“*CLS” 90 OUTPUT @Afg; “*SRE 32” 100 OUTPUT @Afg; “*ESE 60” 110 ! 120 !Call the subprogram which resets the AFG. 130 CALL Rst 140 ! 150 !Set AFG parameters 160 OUTPUT @Afg;“SOUR:FREQ: FI X 10E3;”;!frequency 170 OUTPUT @Afg; “:SOUR:FUNC:S HAP USER; ”; !func tion 180 OUTPUT @Afg; “:SOUR:VO LT :LEV:IMM:AMPL 5.1V ” !scale
190 ! 200 !Call subprogram which defi ne s waveform segment s A and B. 210 CALL Sine_tri_wave 220 ! 230 !Select output sequence and initiate waveform 240 OUTPUT @Afg;“SOUR:FUNC:USER AB” 250 OUTPUT @A fg;“INIT:IMM” !wait-for-arm state 260 ! 270 WAI T .1 !allow interrupt to be serviced 280 OFF INTR 8 290 END 300 ! 310 SUB Sine_tri_ wave 320 Sine_tri_wave: !Subprogram which defines waveforms 330 COM @Afg,Waveform1(*),Waveform2(*) 340 FOR I=1 TO 4096 350 Waveform1(I )= 5*(SI N(2*PI *(I/ 4096))) 360 NEXT I 370 !
amplitude
Contin ued on next page
67 Generating Arbitrary Waveforms with the HP E1340A Chapter 3
380 OUTPUT @Afg;“SOUR:LIST : SEGM:SEL A”
!select segme nt name
390 OUTPUT @Afg;“ SOUR:LIST : SEG M: VOLT”;Waveform1(*)
!load wavef orm poi nts
400 !
420 Waveform2(I)=I*.0024414 430 NEXT I 440 FOR I=2048 TO 4096 450 Waveform2(I)=(4096-I )*.0024414 460 NEXT I 470 ! 480 OUTPUT @Afg;“SOUR:LIST : SEG M: SEL B” !selec t segme nt nam e 490 OUTPUT @Afg;“ SOUR:LIST : SEG M: VOLT”;Waveform2(*)
!load wavef orm poi nts
500 SUBEND 510 ! 520 SUB Rst
590 SUB Errmsg
C and QuickBASIC
Program Versions
The C exampl e program, M ULSEG.C, is in directory “CPROG” and the QuickBASIC example program, MULSEG.BAS, is in directory “QBPROG” on the C and QuickBASIC example disk (part number E1340-10036).
Chapter 3 Generating Ar bitr ary Waveforms with the HP E1340A 68
Arbitrary Waveform Hopping
This program performs waveform hopping of waveform segments A and B. Use a very stable 1 kHz, 0 to 5 V square wave applied to the AFG’s “Aux In” connector to switch between the waveform segments. The positive level of the square wave out puts waveform segment A t o gener at e a 5 cy cle sine wave. The zero level of the square wa ve outputs waveform segment B to generate a 5 cycle triangle wave. (You may need to adjust the 1 kHz square wave to output a s ta b le arbitrary wavef orm.) There will be ab out a 20 msec delay between a transition on the “Aux In” connector and the output switching.
1. Reset the AFG -
The *RST command aborts wav eform output and sets the AFG to a defined state.
2. Setup the AFG f or an Arbitrary Wa ve fo rm Output -
[SOURce:]FREQuency[:CW|FIXed] <frequency> [SOURce:]FUNCt ion[: SHAP e] USER [SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] <
These co mman ds setup the AFG t o output ar b itrary wa v eforms.
3. Select the First Wavefor m Seg m en t -
[SOURce:]LIST[:SEGMent]:SELect A
Use A to select the first waveform segment.
4. Store the First Waveform Segment as Voltages -
[SOURce:]LIST [:SE GMent] :VOLT age <voltage_l ist>
This command stores the points of t he “A” waveform segment into the AFG’s s egm e nt me mory. These points are sent to the AFG as volts which are t he output voltage points that constitutes the waveform segment.
*RST
amplitude>
69 Generating Arbitrary Waveforms with the HP E1340A Chapter 3
5. Select the Second Waveform Segment -
[SOURce:]LIST[:SEGMent]:SELect B
Use B to select the second waveform segment.
6. Store the Second Waveform Segment as Voltages -
[SOURce:]LIST [:SE GMent] :VOLT age <voltage_l ist>
This command stores the points of the “B” waveform segment into the AFG’s s egm e nt me mory. These points are sent to the AFG as volts which are t he output voltage points that constitutes the waveform segment.
7. Select the User Name -
[SOURce:]FUNCtion:USER HOP_AB
This command setup the AFG to hop between waveform segments A and B.
8. Initiate t he Waveform -
This command gen erates an immediate output with the arm source
IMMediate. Refer to Chapter 5 for triggering information.
set to
HP IBASIC Program Example (ARB_HOP)
1 !RE-SAVE“ARB_HOP” 2 !This program hops (selects) between tw o w aveform s egments based 3 !on the level of a 1 kHz, 0 to 5V square wave applied t o the AFG’ s 4 !“Aux In” connector. A low level selects segment A (sine wave), a 5 !high level selects segment B (triangle wave). 6! 10 !Assign I/O path between IBASIC and the E1340A. 20 ASSIGN @Afg TO 80910 30 COM @Afg,Waveform1(1:4096),Waveform2(1:4096) 40 ! 50 !Set up error checking 60 ON INTR 8 CALL Errmsg 70 ENABLE INTR 8;2 80 OUTPUT @Afg;“*CLS” 90 OUTPUT @Afg; “*SRE 32” 100 OUTPUT @Afg; “*ESE 60” 110 ! 120 !Call the subprogram which resets the AFG. 130 CALL Rst 140 !Set AFG parameters 150 OUTPUT @Afg;“SOUR:FREQ: FI X 10E3;”;!frequency 160 OUTPUT @Afg; “:SOUR:FUNC:S HAP USER; ”; !func tion
INITiat e[:IMMediat e]
Contin ued on next page
Chapter 3 Generating Ar bitr ary Waveforms with the HP E1340A 70
170 OUTPUT @Afg; “:SOUR:VO LT :LEV:IMM:AMPL 5.1V ” !scale
amplitude
180 ! 190 !Call subprogram which defi ne s waveform segment s A and B. 200 CALL Sine_tri_wave 210 ! 220 !Select output sequence and initiate waveform 230 OUTPUT @Afg;“SOUR:FUNC:USER HO P_AB” 240 OUTPUT @A fg;“INIT:IMM” !wait-for-arm state 250 ! 260 WAI T .1 !allow interrupt to be serviced 270 OFF INTR 8 280 END 290 ! 300 SUB Sine_tri_ wave 310 Sine_tri_wave: !Subprogram which defines
waveforms
320 COM @Afg,Waveform1(*),Waveform2(*) 350 FOR I=1 TO 4096 360 Waveform1(I )= 5*(SI N(2*PI *(I/ 4096))) 370 NEXT I 380 ! 390 OUTPUT @Afg;“SOUR:LIST : SEGM:SEL A”!Select segme nt name 400 OUTPUT @Afg;“ SOUR:LIST : SEG M: VOLT”;Waveform1(*)
!load wavef orm poi nts
410 ! 420 FOR I=1 TO 2047 430 Waveform2(I)=I*.0024414 440 NEXT I 450 FOR I=2048 TO 4096 460 Waveform2(I)=(4096-I )*.0024414 470 NEXT I 480 ! 490 OUTPUT @Afg;“SOUR:LIST : SEGM:SEL B”!Select segme nt name 500 OUTPUT @Afg;“ SOUR:LIST : SEG M: VOLT”;Waveform2(*)
!load wavef orm poi nts
510 SUBEND 520 ! 530 SUB Rst
600 SUB Errmsg
71 Generating Arbitrary Waveforms with the HP E1340A Chapter 3
C and QuickBASIC
Program Versions
The C exampl e program , AR B_HOP . C, is in di rectory “CPROG” and the QuickBASIC exam p le progr a m, ARB_HOP.BAS, is in direct ory “QBPROG” on the C and QuickBASIC example disk (part number E1340-10036).
Chapter 3 Generating Ar bitr ary Waveforms with the HP E1340A 72
Generating Built-In Arbitrary Waveforms
The AFG has 16 built-in arbitrary wavefor ms availab le for us e. All of these waveforms have 4096 points and are stored in an EPR OM (see “Program Comments” for the waveform listing). To execute the waveforms, download the data points into wa veform segment A, B, C, or D. The following program downloads and generates the 16th waveform.
1. Reset the AFG -
The *RST command aborts wav eform output and sets the AFG to a defined state.
2. Setup the AFG f or an Arbitrary Wa ve fo rm Output -
[SOURce:]FREQuency[:CW|FIXed] <frequency> [SOURce:]FUNCt ion[: SHAP e] USER [SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] <
These co mman ds setup the AFG t o output an arb itra ry wavef orm.
3. Download the Waveform Data from the EEProm into M emory -
[SOURce:]ARBi trary: DO WNl oad <source>, <dest>, <length>
This command downloads the segment data from the EPROM where
<source> selects the waveform block in the EPROM, <dest> is the
waveform segment name (i.e., A, B, C, or D), and waveform segment length (i.e., 4096).
4. Select the User Name -
[SOURce:]FUNCtion:USER <name>
*RST
amplitude>
<length> is the
This command s elects the wavef orm segment to be output. Make the name in this command the same name as the waveform segment to be output.
73 Generating Arbitrary Waveforms with the HP E1340A Chapter 3
5. Initiate t he Waveform -
INITiate[ :I MMediate]
This command gen erates an immediate output with the arm source
IMMediate. Refer to Chapter 5 for triggering information.
set to
HP IBASIC Program Example (ROM_DOWN)
1 !RE-SAVE“ROM_DOWN” 2 !This program downloads a 4096 point waveform to waveform segment 3 !memory from block 16 (EEPR16) of the AFG’s waveform EEPROM. 4! 10 !Assign I/O path between IBASIC and the E1340A. 20 ASSIGN @Afg TO 80910 30 COM @Afg 40 ! 50 !Set up error checking 60 ON INTR 8 CALL Errmsg 70 ENABLE INTR 8;2 80 OUTPUT @Afg;“*CLS” 90 OUTPUT @Afg; “*SRE 32” 100 OUTPUT @Afg; “*ESE 60” 110 ! 120 !Call the subprogram which resets the AFG. 130 CALL Rst 140 ! 150 !Set AFG parameters 160 OUTPUT @Afg;“SOUR:FREQ: FI X 1E3;”;!frequ ency 170 OUTPUT @Afg; “:SOUR:FUNC:S HAP USER; ”;!function 180 OUTPUT @A fg; “:SOUR:VOLT:LEV:IMM:A MPL 5V”!amplit ude 190 OUTPUT @Afg;“SOUR:ARB:DOWN EEPR16, A, 4096”!download
200 OUTPUT @Afg;“SOUR:FUNC:USER A” !select sequence 210 OUTPUT @A fg;“INIT:IMM” !wait-for-arm state 220 ! 230 WAI T .1 !allow interrupt to be serviced 240 OFF INTR 8 250 END 260 ! 270 SUB Rst
waveform
340 SUB Errmsg
Chapter 3 Generating Ar bitr ary Waveforms with the HP E1340A 74
C and QuickBASIC
Program Versions
The C example program, ROM_DOWN.C , is i n directory “CPROG” and the QuickBASIC example program, ROM_DOWN.BAS, is in directory “QBPROG” on the C and QuickBASIC example disk (part number E1340-10036).
75 Generating Arbitrary Waveforms with the HP E1340A Chapter 3
Sample Programs
The following programs generate various arbitrary waveforms. All programs output waveforms at a 1 kHz waveform frequency and 5 V amplitude.
Due to the similarity of all the programs, only the first program is completely presented here. Only the differences are shown by the other programs.
Generating a
Damped Sine Wave
This program generates a Damped Sine Wave using 4096 segments or points.
HP IBASIC Program Example (SIN_D)
1 !RE-SAVE“SIN_D” 2 !This program generates a damped sine wave. 3! 10 !Assign I/O path between IBASIC and the E1340A. 20 ASSIGN @Afg TO 80910 30 COM @Afg, Waveform(1:4096) 40 ! 50 !Set up error checking 60 ON INTR 8 CALL Errmsg 70 ENABLE INTR 8;2 80 OUTPUT @Afg;“*CLS” 90 OUTPUT @Afg; “*SRE 32” 100 OUTPUT @Afg; “*ESE 60” 110 !
Contin ued on next page
Chapter 3 Generating Ar bitr ary Waveforms with the HP E1340A 76
120 !Call the subprogram which resets the AFG. 130 CALL Rst 140 ! 150 !Set AFG parameters 160 OUTPUT @Afg;“SOUR:FREQ: FI X 1E3;”;!frequ ency 170 OUTPUT @Afg; “:SOUR:FUNC:S HAP USER; ”;!function 180 OUTPUT @Afg; “:SOUR:VO LT :LEV:IMM:AMPL 1.1V ” !scale
amplitude
190 ! 200 !Call subprogram which defi ne s waveform segment . 210 CALL Damped_sine 220 ! 230 !Select output sequence and initiate waveform 240 OUTPUT @Afg;“SOUR:FUNC:USER A” 250 OUTPUT @A fg;“INIT:IMM” !wait-for-arm state 260 ! 270 WAI T .1 !allow interrupt to be serviced 280 OFF INTR 8 290 END 300 ! 310 SUB Damped_sine 320 Damped_sine: ! Subprogram which define s a damped sine wave 330 COM @Afg,Waveform(*) 340 A =4/4096 350 W=(2*PI)/50 360 FOR T=1 TO 4096 370 Waveform(T)=EXP(-A*T)*SIN(W*T) 380 NEXT T 390 ! 400 OUTPUT @Afg;“SOUR:LIST : SEGM:SEL A”!select segme nt name 410 OUTPUT @Afg; “SOUR:LIST:SEG M: VOLT”;Waveform ( *)!load
420 SUBEND 430 ! 440 SUB Rst
waveform point s
510 SUB Errmsg
C and QuickBASIC
Program Versions
The C example program, SIN_D.C, is in directory “ CPROG” and the QuickBASIC exam p le progr a m, SIN_D.BAS, is in direct ory “QBPROG” on the C and QuickBASIC example disk (part number E134 0-10036).
77 Generating Arbitrary Waveforms with the HP E1340A Chapter 3
Generating an
Exponential
This program generates an Exponential Charge/Discharge Waveform with 4096 segments or points.
Charge/Discharge
Waveform
HP IBASIC Program Example (CHARGE)
This pro gram is similar to the “SIN_D” BASIC program on page 76, with the foll owing diff eren ces:
1 !RE-SAVE“CHARGE” 2 !This program generates an exponential charge/discharge waveform.
210 CALL Charge
310 SUB Charge 320 Charge:!Subprogram which defines an exponential charge/discharge 330 !waveform. 340 COM @Afg,Waveform(*) 350 Rc=400 360 FOR T=1 TO 4096 370 IF T>=0 AND T<2047 THEN 380 Waveform(T)=1*(1-EXP(-T/Rc)) 390 END IF 400 IF T>=2047 THEN 410 Waveform(T)=1*(1-EXP(-2048/Rc))-1*(1-EXP(-(T-2047)/Rc)) 420 END IF 430 NEXT T 440 ! 450 OUTPUT @Afg;“SOUR:LIST : SEGM:SEL A”!select segme nt name 460 OUTPUT @Afg; “ SOUR:LIST :SEGM:VO LT”;Waveform(*)!load
waveform point s
470 SUBEND
Chapter 3 Generating Ar bitr ary Waveforms with the HP E1340A 78
C and QuickBASIC
Program Versions
The C exampl e program , C HARGE.C, is in directory “CPROG” and the QuickBASIC example program, CHARGE.BAS, is in directory “QBPROG” on the C and QuickBASIC example disk (part number E1340-10036).
Generating a Sine
Wave with Spikes
This program generat es a Sine Wave with Spikes using 4096 s egments or points.
HP IBASIC Program Example (SPIKES)
This pro gram is similar to the “SIN_D” BASIC program on page 76, with the foll owing diff eren ces:
1 !RE-SAVE“SPIKES” 2 !This program generates a sine wave with a spike.
150 !Set AFG parameters 160 OUTPUT @Afg;“SOUR:FREQ: FI X 1E3;”;!frequ ency 170 OUTPUT @Afg; “:SOUR:FUNC:S HAP USER; ”; !func tion 180 OUTPUT @Afg; “:SOUR:VO LT :LEV:IMM:AMPL 1.5V ” !scale
amplitude
190 ! 200 !Call subprogram which defi ne s waveform segment . 210 CALL Sine_spike
310 SUB Sine_spike 320 Sine_spike: !Subprogram which defin es a sine wave with a spike 330 COM @Afg,Waveform(*) 340 FOR I=1 TO 4096 350 Waveform(I )=.5*SI N(2*PI *(I /4096)) 360 NEXT I 370 Width=50
Contin ued on next page
79 Generating Arbitrary Waveforms with the HP E1340A Chapter 3
380 FOR J=1 TO W idth/ 2 390 Waveform(J+1024)=W aveform( J+1024)+ J*.04 400 NEXT J 410 FOR J=1 TO W idth/ 2 420 Waveform(J+1024+ Width/ 2)= Waveform (J+1024+ Width/ 2)
+1-(J*.04 ) 430 NEXT J 440 ! 450 OUTPUT @Afg;“SOUR:LIST : SEGM:SEL A”!select segme nt name 460 OUTPUT @Afg; “ SOUR:LIST :SEGM:VO LT”;Waveform(*)!load
waveform point s
470 SUBEND
C and QuickBASIC
Program Versions
Generating a
Half-Rectified Sine
Wave
The C exampl e program, SPIKES.C, is in directory “CPROG” and the QuickBASIC example program, SPIKES.BAS, is in directory “QBPROG” on the C and QuickBASIC example disk (part number E134 0-10034).
This program generates a Half-Rectified Sine Wave using 4096 segme nts or poi nts.
Chapter 3 Generating Ar bitr ary Waveforms with the HP E1340A 80
HP IBASIC Program Example (SIN_R)
This pro gram is similar to the “SIN_D” BASIC program on page 76, with the foll owing diff eren ces:
1 !RE-SAVE“SIN_R” 2 !This program generates a 1/2 wave rect ified si ne wav e.
210 CALL Rec_sine
310 SUB Rec_sine 320 Rec_sine: !Subprogram whi ch defines a recti f ie d sine wave 330 COM @Afg,Waveform(*) 340 FOR I=1 TO 4096 350 Waveform(I)=SIN( 2*PI*( I/4096)) 360 NEXT I 370 FOR I=2049 TO 4096 380 Waveform(I)= 0 390 NEXT I 400 ! 410 OUTPUT @Afg;“SOUR:LIST : SEGM:SEL A”!select segme nt name 420 OUTPUT @Afg; “SOUR:LIST:SEG M: VOLT”;Waveform ( *)!load
430 SUBEND
waveform point s
C and QuickBASIC
Program Versions
The C example program, SIN_R.C, is in directory “CPROG” and the QuickBASIC example program, SIN_R.BAS, is in directory “QBPROG” on the C and QuickBASIC example disk (part number E134 0-10036).
81 Generating Arbitrary Waveforms with the HP E1340A Chapter 3
Program Comments
The following comments gi ve additio nal details on the pro gram exa mples in this chapter.
Amplitude Effects
on Voltage List
Reference
Oscillator Sources
Waveforms in the
EPRom
If the segment data is sent as voltage values, the AFG changes the data into digital-to-ana log con verter (D AC) co des. Th is requires t hat the voltage value of the segment data MUST NOT exceed the AFG’s current amplitude level (set by does, the AFG generat es an error.
[SOURce:]VOLTage[ :LE Vel][:I MMedi ate] [:AM PLitude] ). If it
The SINusoid, SQUare, TRIangle, and RAMP functions can use any
of the Ref erenc e Osci llator Sour ces. The sources, selected by
[SOURce:]ROSCi llator: SO URce, are:
INTernal - 42.949 6729 6 MHz (power -on value) EXTernal - User provided value (the front panel “Aux In” BNC)
If using the EXTernal refer ence oscillator sou rce, ent e r the sou rce
frequency to the AFG using
[SOURce:]ROS Ci ll ator: F REQuency:EXTernal <f requency>.
The following are the waveforms located in the EPRom:
EEPRom1 Sine Wave EEPRom2 Triangle Wave EEPRom3 Sin(x)/x for 8.25 radians EEPRom4 Haversine EEPRom5 Square Wave EEPRom6 First ten terms of a Squa re Wave EEPRom7 First four terms of a Square Wave EEPRom8 Falling Ram p EEPRom9 First 20 ter ms of a Falling Ramp EEPRom10 Rising Ramp EEPRom11 First 20 terms of a Rising Ramp EEPRom12 White Noise EEPRom13 Modulated White Noise EEPRom14 A 3rd, 4th, 5th Harmonic Chord EEPRom15 8 cycles of a linear ris ing S ine Wave EEPRom16 Positive half-cycle Sin e Wave
Chapter 3 Generating Ar bitr ary Waveforms with the HP E1340A 82
HP E1340A Sweep ing and Frequency- Shift
Chapter Contents
This chapter c overs the sweeping and frequ ency-shift keying (FSK) f eatures of the HP E1340A Arbitrary Function Generator (AFG). The chapter is organized as follows:
Swe eping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 85
Sweeping Using Start a n d Stop FrequenciesPage 85 Sweeping Us in g S t art a nd Spa n F requ enciesPage 8 8
Sweep Poin t s Vs. Sweep Ti me . . . . . . . . . . . . . . . . . . . . . Page 90
Frequency-S hift Keyi ng. . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 92
Program CommentsPage 94
The Command Reference
Chapter 4
Keying
Detailed information on the commands introduced in this chapter can be found in Chapter 7 under “ Command Reference”. The commands in this chapter are shown in their entirety (optional headers included) to help you locate them in t h e reference.
Programming Flowchart
The flowchart on page 84 shows the commands and the command execution order to generate standard wa ve forms. The reset (power-on) values of each command are also noted on the flowchart. Note that the IEEE 488.2 command places the AFG into its po wer- on st at e. Th us, it may be unnecessary to execute all of the commands on the flowchart.
*RST
83 HP E1340A Sweeping and Frequency-Shift Keying Chapter 4
Chapter 4 HP E1340A Sweeping and Frequency-Shift Keying 84
Sweeping
The AFG offers linear frequency sweeping of standard wavefor ms (i.e. sine, square, triangle, ramp) and arbitrary waveforms from 0.0 Hz to 15 M Hz for s in e wav es, and 0.0 Hz to 1 MHz for s qu are , trian gle , a n d r a m p waves.
The comman d subsystems covered in this s ection include:
[SOURce:]ROSCillator
[SOURce:]FREQuency
[SOURce:]SWEep
Sweeping
Considerations
Sweeping Using
Start and Stop
Frequenc ies
The AFG only allows for continuous repetitive sweeping. The INITiate
[:IMMediat e]
number of points in the sweep and the sweep time. For more information on sweeping, see Chapt er 7 u nder the
The following program specifies a start frequency and a stop frequency and continuously sweeps between 0 and 1 MHz. The program also queries the start frequency, stop frequency, c enter frequ ency, an d frequency span to show the relationship between them.
Using the flowchart as a guide, the steps of this program are:
1. Select the Reference Oscillator -
2. Select the Frequency Sweep Mode -
3. Set the Start Frequency -
4. Set the Stop Frequency -
command starts the sweepi ng at a fixed rate determined b y th e
[SOURce:]SWEep subsystem.
[SOURce:]ROS Cill ator:SO URce <sourc e>
[SOURce:]FREQuency:MODE SWEep
[SOURce:]FREQuenc y:STA Rt <start_f req >
[SOURce:]FREQuenc y:STOP <stop_f req>
5. Select the Output Function -
[SOURce:]FUNCt ion[: SHAP e] <shape>
6. Set the Signal Amplitude -
[SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] <amplitude>
7. Place the AFG in the Wait-for-arm State -
INITiate[:IMMediate]
85 HP E1340A Sweeping and Frequency-Shift Keying Chapter 4
HP IBASIC (SMPLSWP1)
1 !RE-SAVE“SMPLSWP1” 2 !This program sweeps a sine wav e from 0 Hz to 1 MHz by specifying 3 !start and stop frequencies. 4! 10 !Assign I/O path between IBASIC and the E1340A. 20 ASSIGN @Afg TO 80910 30 COM @Afg 40 ! 50 !Set up error checking 60 ON INTR 8 CALL Errmsg 70 ENABLE INTR 8;2 80 OUTPUT @Afg;“*CLS” 90 OUTPUT @Afg; “*SRE 32” 100 OUTPUT @Afg; “*ESE 60” 110 ! 120 !Call the subprogram which resets the AFG. 130 CALL Rst 140 ! 150 !Set AFG parameters 160 OUTPUT @A fg;“SOUR:ROSC:SO UR INT;”;!reference oscillator 170 OUTPUT @A fg; “:SOUR:F REQ:MODE SWE;”;!frequency mode 180 OUTPUT @A fg; “:SOUR:F REQ:STAR 0;”;!start frequ en cy 190 OUTPUT @Afg; “:SOUR:FREQ :S TO P 1E6; ”;!stop freque nc y 200 OUTPUT @A fg; “:SOUR:FUNC:SHAP SIN;”; !function 210 OUTPUT @A fg; “:SOUR:VOLT:LEV:IMM:A MPL 5V” !ampli tude 220 OUTPUT @A fg;“INIT:IMM” !wait-for-arm state 230 ! 240 !Call subprogram which queri e s sweep parameters 250 CALL Query 260 ! 270 WAI T .1 !allow interrupt to be serviced 280 OFF INTR 8 290 END 300 ! 310 SUB Query 320 Query: !Subprogram which queries sweep parameters 330 COM @Afg 340 OUTPUT @Afg;“SOUR:FREQ:STAR?” 350 ENTER @Afg;Sweep1$ 360 OUTPUT @Afg;“SOUR:FREQ:ST O P?” 370 ENTER @Afg;Sweep2$ 380 OUTPUT @Afg;“SOUR:FREQ:CENT?” 390 ENTER @Afg;Sweep3$
Contin ued on next page
Chapter 4 HP E1340A Sweeping and Frequency-Shift Keying 86
400 OUTPUT @Afg;“SOUR:FREQ: SPA N ?” 410 ENTER @Afg;Sweep4$ 420 PRINT “START = ”;Sweep1$,“STOP = ”;Sweep2$ 430 PRINT 440 PRINT “CENTER = ”;Sweep3$,“SPAN = ”;Sweep4$ 450 SUBEND 460 ! 470 SUB Rst
540 SUB Errmsg
The start, stop, center, and span values returned a r e:
START = +0.000000000E+000 STOP = +1.000000000E+006 CENTER = +5.000000000E+005 SPAN = +1.000000000E+006
C and QuickBASIC
Programs
The C program SMPLSWP1. C is in d irectory “CPROG”, and the QuickBASIC pr ogra m SMPLSWP1. BAS is in directory “QBPROG” on the exampl e program d isk HP P/N E134 0-10036.
87 HP E1340A Sweeping and Frequency-Shift Keying Chapter 4
Sweeping Using
Start and Span
Frequencies
The following program sp ec ifies a start frequency and a frequency span t o continuously sweep from 1 kHz to 21 kHz. The program also queries the start frequency, stop frequency, c enter frequ ency, an d frequency span to show the relationship between them. Using the flowchart as a guide, the steps of this program are:
1. Select the Frequency Sweep Mode -
[SOURce:]FREQuency:MODE SWEep
2. Set the Start Frequency -
[SOURce:]FREQuenc y:STA Rt <start_f req >
3. Set the Frequency Span -
[SOURce:]FRE Quency:S PAN <freq_span >
4. Set the Output Funct io n -
[SOURce:]FUNCt ion[: SHAP e] <shape>
5. Set the Signal Amplitude -
[SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] <amplitude>
6. Place the AFG in the Wait-for-arm State -
INITiate[:IMMediate]
HP IBASIC (SMPLSWP2)
1 !RE-SAVE“SMPLSWP2” 2 !This program sweeps a sine wave from 1 kHz to 21 kHz by 3 !specifying a start frequency and a frequency span. 4! 10 !Assign I/O path between IBASIC and the E1340A. 20 ASSIGN @Afg TO 80910 30 COM @Afg 40 ! 50 !Set up error checking 60 ON INTR 8 CALL Errmsg 70 ENABLE INTR 8;2 80 OUTPUT @Afg;“*CLS” 90 OUTPUT @Afg; “*SRE 32” 100 OUTPUT @Afg; “*ESE 60” 110 ! 120 !Call the subprogram which resets the AFG. 130 CALL Rst 140 ! 150 !Set AFG parameters 160 OUTPUT @Afg; “SOUR:FRE Q:MO DE SWE; ”;!frequ en cy mode 170 OUTPUT @A fg; “:SOUR:FREQ:STAR 1E3;”;!start freq ue nc y 180 OUTPUT @Afg; “:SOUR:FREQ :S PAN 20E3;”;!frequency span 190 OUTPUT @A fg; “:SOUR:FUNC:SHAP SIN;”; !function
Contin ued on next page
Chapter 4 HP E1340A Sweeping and Frequency-Shift Keying 88
200 OUTPUT @A fg; “:SOUR:VOLT:LEV:IMM:A MPL 5V” !ampli tude 210 OUTPUT @A fg;“INIT:IMM” !wait-for-arm state 220 ! 230 !Call subprogram which queri e s sweep parameters 240 CALL Query 250 ! 260 WAI T .1 !allow interrupt to be serviced 270 OFF INTR 8 280 END 290 ! 300 SUB Query 310 Query: !Subprogram which queries sweep parameters 320 COM @Afg 330 OUTPUT @Afg;“SOUR:FREQ:STAR?” 340 ENTER @Afg;Sweep1$ 350 OUTPUT @Afg;“SOUR:FREQ:ST O P?” 360 ENTER @Afg;Sweep2$ 370 OUTPUT @Afg;“SOUR:FREQ:CENT?” 380 ENTER @Afg;Sweep3$ 390 OUTPUT @Afg;“SOUR:FREQ: SPA N ?” 400 ENTER @Afg;Sweep4$ 410 PRINT “START = ”;Sweep1$,“STOP = ”;Sweep2$ 420 PRINT 430 PRINT “CENTER = ”;Sweep3$,“SPAN = ”;Sweep4$ 440 SUBEND 450 ! 460 SUB Rst
530 SUB Errmsg
The start, stop, center, and span values returned a r e:
START = +1.000000000E+003 STOP = +2.100000000E+004 CENTER = +1.100000000E+004 SPAN = +2.000000000E+004
C and QuickBASIC
Programs
The C program SMPLSWP2. C is in d irectory “CPROG”, and the QuickBASIC pr ogra m SMPLSWP2. BAS is in directory “QBPROG” on the exampl e program d isk HP P/N E134 0-10036.
89 HP E1340A Sweeping and Frequency-Shift Keying Chapter 4
Sweep Points Vs.
Sweep Time
To demonstrate the relationship between the number of points (frequencies) in a frequency sweep and the time of the sweep, the following program uses 100 frequency points to continuously sweep from 5 kHz to 15 kHz in 0.5 seconds. (See “Program Comments” to determine the sweep time.)
Using the flowchart as a guide, the steps of this program are:
1. Select the Frequency Sweep Mode -
[SOURce:]FREQuency:MODE SWEep
2. Set the Start Frequency -
[SOURce:]FREQuenc y:STA Rt <start_f req >
3. Set the Stop Frequency -
[SOURce:]FREQuenc y:STOP <stop_f req>
4. Set the Number of Points (frequencies) in the Frequency Sweep -
[SOURce:]SWEep:POINts <number>
5. Set the Sweep Repetition Time -
[SOURce:]SWEep:T I ME <number>
6. Set the Output Funct io n -
[SOURce:]FUNCt ion[: SHAP e] <shape>
HP IBASIC (SWP_PVST)
7. Set the Signal Amplitude -
[SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] <amplitude>
8. Place the AFG in the Wait-for-arm State -
INITiate[:IMMediate]
1 !RE-SAVE“SWP_P VST ” 2 !This program sweeps a sine wave from 5 kHz to 15 kHz 3 !in 0.5 seconds to demonstrate how to set the sweep time. 4! 10 !Assign I/O path between IBASIC and the E1340A. 20 ASSIGN @Afg TO 80910 30 COM @Afg 40 ! 50 !Set up error checking 60 ON INTR 8 CALL Errmsg 70 ENABLE INTR 8;2 80 OUTPUT @Afg;“*CLS” 90 OUTPUT @Afg; “*SRE 32” 100 OUTPUT @Afg; “*ESE 60” 110 ! 120 !Call the subprogram which resets the AFG. 130 CALL Rst
Contin ued on next page
Chapter 4 HP E1340A Sweeping and Frequency-Shift Keying 90
140 ! 150 !Set AFG parameters 160 OUTPUT @Afg; “SOUR:FRE Q:MO DE SWE; ”;!frequ en cy mode 170 OUTPUT @A fg; “:SOUR:FREQ:STAR 5E3;”;!start freq ue nc y 180 OUTPUT @Afg; “:SOUR:FREQ :S TO P 15E3; ”;!stop fre que nc y 190 OUT P UT @Afg;“:SOUR:SWE:PO IN 100;”; !sweep points 200 OUT P U T @Afg; “:SOUR:SW E:TIM E .495;”; !sweep time 210 OUTPUT @A fg; “:SOUR:FUNC:SHAP SIN;”; !function 220 OUTPUT @A fg; “:SOUR:VOLT:LEV:IMM:A MPL 5V” !ampli tude 230 OUTPUT @A fg;“INIT:IMM” !wait-for-arm state 240 ! 250 WAI T .1 !allow interrupt to be serviced 260 OFF INTR 8 270 END 280 ! 290 SUB Rst
360 SUB Errmsg
C and QuickBASIC
Programs
The C program SWP_PVST.C is in directory “CPROG”, and the QuickBASIC pro gra m SWP_P VST.BAS is in direc tory “QBPRO G ” on the exampl e program d isk HP P/N E1340-10036.
91 HP E1340A Sweeping and Frequency-Shift Keying Chapter 4
Frequency-Shift Keying
Frequency-shift keying (FSK) changes the frequency of the output waveform or sample rate based on the signal level of the frequen cy-shift keying co ntrol source. FSK frequ enc ies can ra nge from 0.0 Hz to 20 MHz. The frequency-shift keying control source is applied to the front panel “Aux In” BNC Connector.
The comman d subsystems associated with frequency-shift keying in clude:
[SOURce:]ROSCillator
[SOURce:]FREQuency
- FSK mode and related c omma nds
Program Exa mple The following program shows the basic steps involved in setting up and
using the frequency-shift keying function of the AFG. A 5V, 1 kHz square wave control signal is applied to the AFG’s front panel “FSK” port. Output frequenci es of 20 kHz and 10 k H z occur as the level of the 1 kHz signal changes.
Using the flowchart as a guide, the steps of this program are:
1. Select the Reference Oscillator -
[SOURce:]ROS Cill ator:SO URce <sourc e>
2. Select the Frequency-shift Keying Mode -
[SOURce:]FREQuency:MODE FSK
3. Select the FSK Frequencies -
[SOURce:]FREQuency:FSKey <frequency1>,<frequency2>
4. Set the Output Funct io n -
[SOURce:]FUNCt ion[: SHAP e] <shape>
5. Set the Signal Amplitude -
[SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] <amplitude>
6. Place the AFG in the Wait-for-arm State -
INITiate[:IMMediate]
Chapter 4 HP E1340A Sweeping and Frequency-Shift Keying 92
HP IBASIC (FSK1)
1 !RE-SAVE“FSK1” 2 !This program sets up frequency-shift keying using the AFG’s "Aux In" 3 !port as the control source. A high signal on the port selec ts the 4 !first frequency. A low signal on the port selects the second frequency. 5! 10 !Assign I/O path between IBASIC and the E1340A. 20 ASSIGN @Afg TO 80910 30 COM @Afg 40 ! 50 !Set up error checking 60 ON INTR 8 CALL Errmsg 70 ENABLE INTR 8;2 80 OUTPUT @Afg;“*CLS” 90 OUTPUT @Afg; “*SRE 32” 100 OUTPUT @Afg; “*ESE 60” 110 ! 120 !Call the subprogram which resets the AFG. 130 CALL Rst 140 ! 150 !Set AFG parameters 160 OUTPUT @A fg;“SOUR:ROSC:SO UR INT;”;!reference oscillator 170 OUTPUT @A fg; “:SOUR:F REQ:MODE FSK ;”;!frequency mode 180 OUTPUT @Afg; “:SOUR:FREQ :F SK 10E3, 20E3; ”;!FSK frequ en cie s 190 OUTPUT @A fg; “:SOUR:FUNC:SHAP SIN;”;!functi on 200 OUTPUT @A fg; “:SOUR:VOLT:LEV:IMM:A MPL 5V” !ampli tude 210 OUTPUT @A fg;“INIT:IMM” !wait-for-arm state 220 ! 230 WAI T .1 !allow interrupt to be serviced 240 OFF INTR 8 250 END 260 ! 270 SUB Rst
340 SUB Errmsg
FSK frequencies are: +1.000000000 E+004 ,+2. 0000 0000 0E+00 4
C and QuickBASIC
Programs
The C program F SK1.C is in direct ory “CPROG ”, and the QuickBASIC program FSK1.BAS is in directory “QBPROG” on the example program disk HP P/N E1340-10 036.
93 HP E1340A Sweeping and Frequency-Shift Keying Chapter 4
Program Comments
The following information is associated with sweeping and frequency-shift keying. Include d are de tails on t he operation of these functions, and on the various modes, ranges, etc., used in the programs in this c hapt er.
Reference
Oscillator Sources
AFG Frequenc y
Modes
There are two reference oscillator sources f or t he AFG which are selected
[SOURce:]ROSCillator:SOURce command:
by the
EXTernal: The AFG’s front panel “Aux In” BNC . INTernal: The internal 42.94967296 MHz oscillator.
INTernal ref eren ce os c il lat or gives a fre quency resolut ion of .01 Hz.
The
INTernal is the default reference oscillator source. Thus, in m a n y programs,
the source is not specified.
There are three frequency “modes” available in the AFG. The modes selected by the
CW|FIXed: Single frequency mode. FSKey: Frequency shift keying mode. SWEep: Frequency sweep mode.
[SOURce:]FREQuency:MODE command are:
Frequenc y Poi nts The number of frequencies g enerated (points) in a frequ ency sweep can be
from 2 to 1,073,741,824. Th e defau lt nu mber is 1001. Th e number of points is set with the only.
SOURce:SWEep:PO INts command and applies to sweeps
Specifying a
Sweep Time
The sweep time (set by SOURce:SWEep:TI ME) is t h e period from the generation of the first frequency in the sweep or list to the generation of the last fr equency (see below).
The duration (t) of each frequency is :
specified s weep time /(frequency p oints - 1)
For multiple sweeps or repetitions through the list, the duration of the last frequency (f repetitions, the duration of f
Sweep time
) is also t. To maintain a constant ra te between sweeps or
n
must be accounted for as follows:
n
specified
= Sweep repetition time
* ((points - 1)/points)
desired
Chapter 4 HP E1340A Sweeping and Frequency-Shift Keying 94
HP E1340A Arming and Marker Outputs
Chapter Contents
Chapter 5
This chapter shows you how to arm and gate the HP E1340A AFG in order to start and advance standard and a rbitra ry waveforms. This chapter also shows how generate the different marker outputs at the "Aux Out" BNC connector. The sections of this chapter include:
The ARM Configurat i on . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 95
Initiating Waveforms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 96
Arm ing the AFG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 96
Setting the Arm Source . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 97
Setting the Arm and Waveform Cycle Count. . . . . . . . . . Page 99
Gating the Waveforms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 101
Aborting Wavef or ms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 102
Marker Ou tputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 103
Pro g ram Commen t s. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pag e 107
The ARM Configuration
The HP E1340A AFG uses an ARM triggering configuration to output t he standard and arbitrary waveforms. When initiated, an arm signal enables the AFG to output the waveforms each time an arm signal is received.
The ARM States The AFG operates within three states: Idle, Wait-for-arm, and Instrument
Action.
When power is applied, or following a reset or an abort, the AFG is in the Idle state. The AFG is set to the Wait-for-arm state with the
INITiate[:IMMediate] command.
The AFG starts instrument action when it receives an arm from the specified arm source.
After the instrument action (waveform is output) occurs, the AFG returns to the Wait-for-arm state until the next arm occurs. When the specified arm count has been reached, the AFG returns to the Idle state.
95 HP E1340A Arming and Marker Outputs Chapter 5
Initiating Waveforms
After the AFG has been configured to output the desired waveform, the AFG is set to the Wait-for-arm state with the command :
INITiate[:IMMediate]
Arming the AFG
INITia te
executed before a waveform is output :
If INITi ate[ :IMM edi ate] is executed when the AFG is not in the Idle state, error 213, "Init ignored " is generat ed.
In order for the AFG to output a waveform, it must be armed. The information in this section covers the commands a n d programm ing sequence us ed to arm the AFG f or fixed frequency waveform generation.
is an uncoupled command and is gene r a lly the last command
100 SUB Sine_wave 110 Sine_wave: !Subprogram which outputs a sine wave 120 COM @Afg 130 OUTPUT @Afg;“SOUR:FREQ:FIX 1E3;”;!frequency 140 OUTPUT @Afg;“:SOUR:FUNC:S HAP SIN; ”; !function 150 OUTPUT @Afg;“:SOUR:VO LT :LEV:IMM:AMPL 5 V ”!ampli tude 160 OUTPUT @Afg;“INIT:IMM” !wait-for-arm state 170 SUBEND
Arming Commands The commands which arm the AFG a llow you to specify the following:
the arm source
the slope of an external arm signal
the number of arms per INITi ate[: IMMedi ate] command
the number of waveform cycles per arm
The arming commands i nclude:
ARM
[:STARt|SEQuence[1]]
[:LAYer[1]]
:COUNt <
:LAYer2
:COUNt < :SLOPe < :SOURce <
The arming commands for continuous waveforms are coupled commands.
number> number>
edge >
source>
Chapter 5 HP E1340A Arming and Marker Outputs 96
Note Detailed informat ion on the commands introduced in this chapter can be
found in Chapt er 7 - “Command Ref eren ce”. The commands in this chapter are shown in their entirety (optional headers included) to help you locate them in the reference.
Setting th e
Arm Source
The following program sh ows how to sel ect the source which arms the AFG. The progra m selects the AFG’s "Aux In" BNC connector as the arming source. When the AFG receiv es as arming signal, it outputs a 10 kHz, 1 Vpp squar e wa v e.
The steps of this program are:
1. Select the FIXed Frequency Mode -
[SOURce:]FREQuency:MODE <mode>
2. Set the Output Frequ en cy -
[SOURce:]FRE Quency[: CW|:FI Xed] <frequency>
3. Set the Output Funct io n -
[SOURce:]FUNCt ion[: SHAP e] <shape>
4. Set the Signal Amplitude -
[SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] <amplitude>
5. Set the Arm Source -
ARM[:STARt] :LAYer2:SOURce <source>
6. Set the Edge of the External Arm Signal -
ARM[:STARt]:LAYer2:SLOPe <edge>
7. Place the AFG in the Wait-for-arm State -
INITiate[:IMMediate]
97 HP E1340A Arming and Marker Outputs Chapter 5
HP IBASIC (EXT_ARM)
1 !RE-SAVE“EXT_ARM” 2 !This program arms the AFG with an external signal appl i ed to th e 3 !AFG’s "Aux In" port. W hen arm ed, the AF G out puts 100 cycles 4 !of a 10 kHz, 1 Vpp square wave. 5! 10 !Assign I/O path between IBASIC and the E1340A. 20 ASSIGN @Afg TO 80910 30 COM @Afg 40 ! 50 !Set up error checking 60 ON INTR 8 CALL Errmsg 70 ENABLE INTR 8;2 80 OUTPUT @Afg;“*CLS” 90 OUTPUT @Afg; “*SRE 32” 100 OUTPUT @Afg; “*ESE 60” 110 ! 120 !Call the subprogram which resets the AFG. 130 CALL Rst 140 ! 150 !Set AFG parameters 160 OUTPUT @A fg; “SOUR:FRE Q:MO DE F I X;”;!frequenc y mod e 170 OUTPUT @A fg; “:SOUR:F REQ:FIX 1E3;”;!fre quency 180 OUTPUT @Afg; “:SOUR:FUNC:S HAP SQ U;”; !func tion 190 OUTPUT @Afg; “:SOUR:VO LT :LEV:IMM:AMPL 1VPP ;”; !amplit ude 200 OUTPUT @Afg; “:ARM:STAR: LAY2:SOUR EXT;”; !arm source 210 OUTPUT @A fg; “:ARM:STAR:LAY2:COUN INF; ”; !arm count 220 OUTPUT @Afg;“:ARM:STAR: LAY1: COUN 1E3” !cycle count 230 OUTPUT @A fg;“INIT:IMM” !wait-for-arm state 240 ! 250 WAI T .1 !allow interrupt to be serviced 260 OFF INTR 8 270 END 280 ! 290 SUB Rst
360 SUB Errmsg
C and QuickBASIC
Programs
The C program EXT_ARM.C is in directory “CPROG”, and the QuickBASIC pro gra m EXT_ ARM. BAS is in dire c t ory “QBPROG” on the exampl e program d isk HP P/N E1340-10036.
Chapter 5 HP E1340A Arming and Marker Outputs 98
Setting the Arm
and Wavef o rm
Cycle Count
The following program sh ows you h ow to set the nu mb er of arms the AFG is to receive before returning to the Idle state, and how to set the number of waveform cycles (repetitions) per arm.
The program sets a five cycle burst that occurs each time the AFG receives an external arm. The r e will be about a 50 msec delay b et ween a trans istion on the "Aux In" connector and the output switchin g.
The steps of this program are:
1. Set the Output (Burst) Fr eq u enc y -
[SOURce:]FRE Quency[: CW|:FI Xed] <frequency>
2. Set the Output Funct io n -
[SOURce:]FUNCt ion[: SHAP e] <shape>
3. Set the Signal Amplitude -
[SOURce:]VOLTage[:LEVel][:IMMediate][:AMPLitude] <amplitude>
4. Set the Arm Source -
ARM[:STARt] :LAYer2:SOURce <source>
5. Set the Edge of the External Arm Signal -
ARM[:STARt]:LAYer2:SLOPe <edge>
6. Set the Arm Count -
ARM[:STARt]:LAYer2:COUNt <number>
7. Set th e Numb er of Wave form Cycles (Burst Count) -
ARM[:STARt][:LAYer[1]]:COUNt <number>
8. Place the AFG in the Wait-for-arm State -
INITiate[:IMMediate]
99 HP E1340A Arming and Marker Outputs Chapter 5
HP IBASIC (BURST)
1 !RE-SAVE“BURST” 2 !This program sets the arm count to infini ty and the waveform 3 !repetition count to 5. The arm source is set to external and a 4 !1 kHz square wave is applied to "Aux In" connector. The AFG outputs 5 !a 5 cycle burst on each positive edge of the external arm signal. 6! 10 !Assign I/O path between IBASIC and the E1340A. 20 ASSIGN @Afg TO 80910 30 COM @Afg 40 ! 50 !Set up error checking 60 ON INTR 8 CALL Errmsg 70 ENABLE INTR 8;2 80 OUTPUT @Afg;“*CLS” 90 OUTPUT @Afg; “*SRE 32” 100 OUTPUT @Afg; “*ESE 60” 110 ! 120 !Call the subprogram which resets the AFG. 130 CALL Rst 140 ! 150 !Set AFG parameters 160 OUTPUT @Afg;“SOUR:FREQ: FI X 10E3;”;!frequency 170 OUTPUT @A fg; “:SOUR:FUNC:SHAP SIN;”; !function 180 OUTPUT @Afg; “:SOUR:VO LT :LEV:IMM:AMPL 2.5V PP; ”; !ampli tude 190 OUTPUT @Afg; “:ARM:STAR: LAY2:SOUR EXT;”; !arm source 200 OUTPUT @A fg; “:ARM:STAR:LAY2:SLOP POS ;”; !arm slope 210 OUTPUT @A fg; “:ARM:STAR:LAY2:COUN INF; ”; !arm count 220 OUTPUT @A fg; “:ARM:STAR:LAY1:COUN 5” !cyc le co unt 230 OUTPUT @A fg;“INIT:IMM” !wait-for-arm state 240 ! 250 WAI T .1 !allow interrupt to be serviced 260 OFF INTR 8 270 END 280 SUB Rst
360 SUB Errmsg
C and QuickBASIC
Programs
The C program BURST.C is in directory “CPROG”, and the QuickBASIC program BURST.BAS is in directory “QBPROG” on the example program disk HP P/N E1340-10 036.
Chapter 5 HP E1340A Arming and Marker Outputs 100
Loading...