10 ! RE-SAVE "TEST_83480" 20 ! This program prompts the user to set up a source and then 30 ! test for compliance with STM-16, with 15% margin. 40 ! 50 ! It assumes an optical module is in Channel 1; otherwise, 60 ! the average power measurement will be invalid. 70 ! 80 DIM Query$[15],Command$[15],Q$[9000] 90 COM /Err/ Hpib,Scope 100 COM /S/ @S 110 Hpib=7 120 CLEAR Hpib 130 Scope=7 140 Saddr=Hpib*100+Scope !Sets the I/O address. 150 Readme_init 160 ASSIGN @S TO Saddr 170 CLEAR Saddr 180 ! 190 OUTPUT @S;"*RST" ! Set the scope to a known state. 200 OUTPUT @S;":CHAN1:FILTer ON" ! Turn on built-in filter. 210 OUTPUT @S;":TIMebase:UNITs BITS" ! Select timebase units to be bit period. 220 OUTPUT @S;":TIMebase:BRATe 2.48832E+09" ! Set bit rate (in Hz) for STM-16. 230 OUTPUT @S;":AUToscale" ! Get a good trigger level and vertical scale. 240 OUTPUT @S;":TIMebase:SCALe 2" ! Show 2 bit periods on screen. 250 OUTPUT @S;":MTESt:STANdard STM16" ! Select a standard mask. 260 OUTPUT @S;":MTESt:MMARgin:STATe ON" ! Turn on mask margin. 270 OUTPUT @S;":MTESt:MMARgin:PERCent 15" ! Set amount of mask margin. 280 OUTPUT @S;":MTESt:TEST ON" ! Enable mask testing. 290 Waitfor(@S) ! Wait for scope to finish the operation. 300 WAIT 1 ! Wait a bit more, since scope needs extra time. 310 OUTPUT @S;":MTESt:ALIGn" ! Scale mask to trace. 320 Waitfor(@S) ! Wait for scope to finish the operation. 330 OUTPUT @S;":TIMebase:UNITs TIME" ! Select timebase units to be bit period. 340 Begin$=FNQuery$(@S,":MTESt:SCALe:X1?") ! Set the position to the beginning of the mask. 350 OUTPUT @S;":TIMEBASE:POSITION "&Begin$ 360 End$=FNQuery$(@S,":MTESt:SCALe:XDELta?") ! and the scale to the width of the mask. 370 OUTPUT @S;":TIMEBASE:SCALe "&VAL$(VAL(End$)/10) 380 OUTPUT @S;":TIMebase:UNITs BITS" ! Select timebase units to be bit period. 390 OUTPUT @S;":MTESt:RUMode SAMPles,300000" ! Test for 300k samples. 400 OUTPUT @S;":RUN" ! 410 Reg=VAL(FNQuery$(@S,":MTER?")) ! Clear the Mask Test Event Register. 420 REPEAT ! Wait until the Mask RUNTIL is achieved. 430 Reg=VAL(FNQuery$(@S,":MTER?")) 440 UNTIL BIT(Reg,0) 450 Fwavs=VAL(FNQuery$(@S,":MTESt:COUNt:FWAVeforms?")) 460 IF Fwavs<2 THEN 470 PRINT "MASK TEST PASSED" 480 Fail=0 490 ELSE 500 PRINT "MASK TEST FAILED" 510 Fail=1 520 PRINT FNQuery$(@S,":MTESt:COUNt:FSAMples?");"samples failed." 530 END IF 540 Readme_pwr 550 OUTPUT @S;":MTESt:TEST OFF" ! Disable mask testing. 560 OUTPUT @S;":RUN" ! Re-enable data acquisition. 570 Avgpower=VAL(FNQuery$(@S,":MEASure:APOWer? DECibel, CHANnel1")) ! Measure channel 1 580 ! average power in dBm 590 SELECT Avgpower 600 CASE <-2 610 PRINT "AVERAGE POWER TEST FAILED" 620 Fail=1 630 PRINT "Average power is ";Avgpower;"dBm." 640 CASE >9.99E+37 650 PRINT "AVERAGE POWER TEST DATA INVALID" 660 CASE ELSE 670 PRINT "AVERAGE POWER TEST PASSED" 680 END SELECT 690 Readme_cal 700 OUTPUT @S;":DISPlay:CGRade ON" ! Turn on color grade database. 710 ! assure meaningful results. 720 OUTPUT @S;":MEASure:CGRade:ERCalibrate" ! Calibrate input offset. 730 Waitfor(@S) 740 Readme_extinct 750 OUTPUT @S;":CDISplay" ! Clear calibration data from database. 760 REPEAT 770 WAIT .1 ! Allow some time for the instrument to acquire some data. 780 OUTPUT @S;":MEASure:CGRade:PEAK?" ! Find out the number of hits in the densest pixel. 790 ENTER @S;Peakvalue 800 UNTIL Peakvalue>50 AND Peakvalue<9.999E+37 ! Loop until the amount returned is valid and large enough to 810 Eratio=VAL(FNQuery$(@S,":MEASure:CGRade:ERATio? DECibel")) ! Measure database 820 ! extinction ratio in dB. 830 SELECT Eratio 840 CASE <5 850 PRINT "EXTINCTION RATIO TEST FAILED" 860 Fail=1 870 PRINT "Extinction ratio is ";Eratio;"dB." 880 CASE >9.99E+37 890 PRINT "EXTINCTION RATIO TEST DATA INVALID" 900 CASE ELSE 910 PRINT "EXTINCTION RATIO TEST PASSED" 920 END SELECT 930 IF Fail THEN 940 PRINT "TEST FAILED" 950 ELSE 960 PRINT "TEST PASSED" 970 END IF 980 LOCAL Saddr ! Return DCA to user's control. 990 Readme_end 1000 END 1010 ! 1020 SUB Readme_init 1030 CLEAR SCREEN 1040 PRINT " This program tests for compliance with STM-16, with 15%" 1050 PRINT " margin. You can easily edit it to customize it for your" 1060 PRINT " needs. " 1070 PRINT 1080 PRINT " The expected configuration is;" 1090 PRINT " The scope is at address 7" 1100 PRINT " The HPIB is at address 7" 1110 PRINT 1120 PRINT " If the configuration is different, break program and set " 1130 PRINT " the addresses as required, using the variables Hpib and " 1140 PRINT " Scope. Then run again." 1150 PRINT 1160 PRINT " Connect your source and set it for STM-16 (2.48832 Gbit/s)." 1170 PRINT 1180 PRINT " The recommended source is an HP 70841B Pattern Generator." 1190 PRINT 1200 PRINT " Connect Clock Out to Trigger 2." 1210 PRINT " Connect the signal to be tested to Input 1." 1220 PRINT 1230 PRINT " The recommended pattern is 2^31-1." 1240 PRINT 1250 PRINT " Press Continue when ready to resume operation." 1260 PRINT 1270 PAUSE 1280 CLEAR SCREEN 1290 SUBEND 1300 ! 1310 SUB Readme_cal 1320 PRINT 1330 PRINT " We will now measure extinction ratio. For best accuracy," 1340 PRINT " it is recommended that you allow the instrument to warm up" 1350 PRINT " for at least 10 minutes." 1360 PRINT " After the warm-up is complete, turn off the laser to allow " 1370 PRINT " calibration of the input offset." 1380 PRINT 1390 PRINT " Press Continue to resume operation when the warmup is complete" 1400 PRINT " and the laser is turned off." 1410 PRINT 1420 PAUSE 1430 CLEAR SCREEN 1440 SUBEND 1450 ! 1460 SUB Readme_end 1470 PRINT 1480 PRINT " The program has ended. Thanks for trying our compliance " 1490 PRINT " testing program." 1500 PRINT 1510 PRINT " Now you can edit the program to customize it for your needs." 1520 PRINT 1530 PRINT " GOODBYE. " 1540 SUBEND 1550 ! 1560 SUB Readme_extinct 1570 PRINT 1580 PRINT " The input offset is now calibrated; turn the laser back" 1590 PRINT " on." 1600 PRINT 1610 PRINT " Press Continue to resume operation when the laser is back" 1620 PRINT " on." 1630 PRINT 1640 PAUSE 1650 CLEAR SCREEN 1660 SUBEND 1670 ! 1680 SUB Waitfor(@Path) 1690 OUTPUT @Path;"*OPC?" 1700 ENTER @Path;Completion$ 1710 SUBEND 1720 ! 1730 SUB Readme_pwr 1740 PRINT 1750 PRINT " We will now measure Average Power." 1760 PRINT 1770 PRINT " Press Continue to resume operation." 1780 PRINT 1790 PAUSE 1800 CLEAR SCREEN 1810 SUBEND 1820 ! 1830 DEF FNQuery$(@Path,Cmd$) 1840 OUTPUT @Path;Cmd$ 1850 ENTER @Path;Result$ 1860 RETURN Result$ 1870 FNEND 1880 !