7.10 Example Arb Program
ARB.BAS
ARB.BAS is a program written in Microsoft Quick Basic, which calculates the points of a sinewave and downloads them to the 4071 as an arbitrary waveform. The program can generate the waveform in all of the supported formats (Floating Point, Integer, Hexadecimal, and Binary) and shows how SYNC Out can be asserted during waveform points.
This program can serve as a good starting point for writing you own waveform generation programs. You can replace the sin(x) function with your own mathematical function and pick which data format you wish to use by calling the appropriate subroutine. (Binary format is the most efficient since it requires the least amount of bytes per data point, and can therefore be downloaded faster).
A complete listing of ARB.BAS begins on the following page. The source file for this program can also be found on the accompanying compact disk.
Program Listing - ARB.BAS
'******************************************************************************
'* | BK | Precision Model 4071 | * |
'* |
|
| * |
'* | Arbitrary | Waveform Data Generator Example | * |
'* |
|
| * |
'******************************************************************************
'Program Description
'This program generates a sinewave and downloads the data points to the
'4071 for generation with the Arbitrary Waveform Generator.
'It can generate the data in a variety of different number formats.
'Each format has its own subroutine below.
'
'Ask the user which serial port is attached to the 4071
INPUT "Is the 4071 on Com port 1 or 2? (1/2) >"; a$
'Open Com port, Disable CD,CTS,DCD, give 5 sec max. to open,
'Set Rx buffer to 2K, Disable RTS, set Tx buff to 1K, Random = i/o,
'Set random access buffer size to 2K
IF a$ = "1" THEN
OPEN "COM1:9600,n,8,1,CD0,CS0,DS0,OP5000,RB2048,RS,TB1024" FOR RANDOM AS #1 LEN = 2048 GOTO EndPortSel
END IF
IF a$ = "2" THEN
OPEN "COM2:9600,n,8,1,CD0,CS0,DS0,OP5000,RB2048,RS,TB1024" FOR RANDOM AS #1 LEN = 2048 GOTO EndPortSel
END IF |
|
GOTO ArbExit | ' Abort program if neither Com1 nor Com2 was selected |
EndPortSel: |
|
'
'Note: The 4071 does not need to be in Arbitrary Waveform generation mode
'to accept data points over the serial port. We switch to Arbitrary
'waveform mode here as an example of remotely controlling the operation
'of the unit, and to have the waveform generated after the download.
'For more information on Remote Control, See the 4071 User’s Manual
'Put the 4071 in Arbitrary Waveform mode, set parameters
PRINT #1, "G F11 F240Z F35Y" ' G = Set Arbitrary Mode
'F11 = Set Continuous (not Triggered) mode
'F240Z = Set sampling clock to 40 MHz
'F35Y = Set output level to 5V
62
BK Precision 4071 User Manual Rev.2.2