281
Chapter 6 Application Programs
Example: BASIC for Windows
4
6
1440 PRINT "Using the Status Registers"
1450 !
1460 OUTPUT @Fgen;"appl:sin 10e3,1,0" ! 10kHz Sine wave; 1Vpp
1470 OUTPUT @Fgen;"trig:sour bus" ! Bus Trigger in Burst
1480 OUTPUT @Fgen;"burst:ncycles 50000" ! 50000 cycles x 0.1ms = 5s
1490 OUTPUT @Fgen;"burst:stat on" ! Turn ON burst mode
1500 OUTPUT @Fgen;"*ese 1" ! Operation complete enabled
1510 OUTPUT @Fgen;"*sre 32" ! Operation complete sets SRQ
1520 Check_errors ! Routine checks for errors
1530 OUTPUT @Fgen;"*trg;*opc" ! Trigger burst
1540 ! *OPC signals end of *TRG
1550 !
1560 ! Now wait for Operation Complete to signal Burst complete
1570 !
1580 WHILE 1
1590 OUTPUT @Fgen;"*stb?" ! Request Status Byte
1600 ENTER @Fgen;Stb ! Read Status Byte
1610 IF (BIT(Stb,6)) THEN ! Test for Master Summary Bit
1620 PRINT "Done"
1630 STOP
1640 END IF
1650 END WHILE
1660 END
1670 !
1680 ! Subprogram to check for instrument errors.
1690 !
1700 SUB Check_errors
1710 DIM Description$[100]
1720 INTEGER Err_num
1730 COM /Instrument/@Fgen,@Bin
1740 !
1750 ! Query the error queue until a "0, No Error" is found
1760 !
1770 WHILE 1
1780 OUTPUT @Fgen;"SYSTem:ERRor?" ! Request Error message
1790 ENTER @Fgen;Err_num,Description$ ! Error number,Description
1800 IF NOT Err_num THEN SUBEXIT ! If error = 0 then exit
1810 PRINT Err_num,Description$ ! Print Error,Description
1820 END WHILE
1830 SUBEND