User`s manual
340 Output_function: !Subprogram which uses SCPI commands to set the
350 !40 MHz reference oscillator, to set divide-by-n
360 !frequency synthesis, to set the output frequency/
370 !function/amplitude, and to start the waveform.
380 COM @Afg,Base_addr
390 OUTPUT @Afg;"SOUR:ROSC:SOUR INT2;"; !reference oscillator (40 MHz)
400 OUTPUT @Afg;":TRIG:STAR:SOUR INT2;"; !frequency generator
410 OUTPUT @Afg;":SOUR:FREQ2:FIX 1E6;"; !frequency
420 OUTPUT @Afg;":SOUR:FUNC:SHAP SQU;"; !function
430 OUTPUT @Afg;":SOUR:VOLT:LEV:IMM:AMPL 5V" !amplitude
440 OUTPUT @Afg;"INIT:IMM" !wait-for-arm state
450 OUTPUT @Afg;"STAT:OPC:INIT OFF;*OPC?" !wait for INIT to complete
460 ENTER @Afg;Complete
470 SUBEND
480 !
490 SUB Divide_by_n(Reference_osc,Frequency,Points)
500 Divide_by_n: !Subprogram which changes the output frequency by writing
510 !to the register which controls divide-by-n frequency
520 !synthesis.
530 COM @Afg,Base_addr
540 INTEGER Divider
550 CONTROL 16,25;3 !access A24 space with READIO and WRITEIO
560 !
570 !Read register 63. Write to register 63 setting the SHOLD bit (bit 7)
580 !so sample signals are ignored.
590 Sample_hold=READIO(-16,Base_addr+IVAL("63",16))
600 Sample_hold=BINIOR(Sample_hold,128) !set bit 7
610 WRITEIO -16,Base_addr+IVAL("63",16);Sample_hold
620 !
630 !Set the reference oscillator divider based on the new frequency.
640 !Also load the new divider value if n is greater than 3.
650 Divider=Reference_osc/Frequency/Points
660 SELECT Divider
670 CASE 1
680 Sample_hold=BINAND(Sample_hold,248)+0
690 CASE 2
700 Sample_hold=BINAND(Sample_hold,248)+1
710 CASE 3
720 Sample_hold=BINAND(Sample_hold,248)+2
730 CASE ELSE
740 Sample_hold=BINAND(Sample_hold,248)+3
750 Divider=Divider/2-1
760 WRITEIO -16,Base_addr+IVAL("7D",16);SHIFT(Divider,8)
770 WRITEIO -16,Base_addr+IVAL("7F",16);BINAND(Divider,255)
780 END SELECT
790 !
800 WRITEIO -16,Base_addr+IVAL("63",16);Sample_hold
810 !
820 !Clear sample/hold bit which activates new frequency
Continued on Next Page
Appendix C Register-Based Programming 493