def script(self): #self.TestProcedure.ICD.writePrbFpga(0x1002, 0x12) ##d. Read FPGA address 0x3000 and verify the response is 0x12. val = self.TestProcedure.ICD.readPrbFpga(0x3000) self.verify("FPGA 0x3000", 0x12, val) if val != 0x12: self.verify("ERROR", 0x12, val) #*********instrument setup*************************************** print "Creating instrument..." sa = spec_anal("GPIB::8", 'SPEC_ANAL') #**************************************************************** # temperatures = range(32,44) temperatures = [27, 32, 37, 42] stabilization_mins = 10 chamber = watlowF4ipy.WatlowF4_temp_window(3, debug=True) for temperature in temperatures: chamber.set_temperature_and_time(temperature, temperature - 0.3, temperature + 0.3, stabilization_mins) while chamber.dwelltime_endpoint_reached() == False: #pause before checking the flag again time.sleep(2) # calibrate once on channel 0 self.TestProcedure.ICD.calibrateCc1020() self.DumpCalResult() inv_flag = 0x01 DoCalFlag = 0x01 MaxCalTries = 0x03 ExitDelaySecs = 0x01 # Scan and link on Channel 0, with data inversion active # Initialize the CC1000 Calibration Config Table self.TestProcedure.ICD.writePrbFpga(0x1026, 0x00) devList = self.icdcmd.scan(17, 2) print "type(devList):", type(devList) self.icdcmd.connect((UInt32)(2102003)) # self.icdcmd.connect((UInt32) (2100130)) # self.icdcmd.connect((UInt32) (2149582066)) time.sleep(1) # Initialize the Cal config table self.initCalConfigTable() # Write the test control table self.writeCalControlTable(DoCalFlag, MaxCalTries, ExitDelaySecs) # Load the CCTestPatch firmware image to S-ICD RAM # self.writeCCTestPatch() # Write the calibration configuration table for a specific frequency self.writeCalConfigTable(1) self.icdcmd.ping() # Start the test, the test patch will wait 10 seconds to allow for a break link self.icdcmd.writeUint16(Key.INT_VEC_TCMP0, 0x6A08) # break link with the S-ICD wfdeState = WaitForDisconnectedEventState(Key.DONT_CARE, 0x0) try: self.icdcmd.EventWaiter.execState(wfdeState, TimeSpan.FromSeconds(2)) except Exception, ex: print str(ex) print "Calibrating..." time.sleep(10) sa.set_ref_level_dB(-30) sa.set_span_kHz(100000) sa.set_resolutionBW_kHz(10) sa.set_sweep_time_milliseconds(2000) DoCalFlag = 0x00 MaxCalTries = 0x03 ExitDelaySecs = 0x1E vco_loop_count = 2 # Loop through all candidate frequencies and calibrate for idx in range(0, vco_loop_count): test_time = time.clock() print "Loop Index = ", idx print "Test time = %.2d:%06.3f" % (test_time / 60, test_time % 60.0) if idx == 0: sa.set_center_frequency_MHz(360) else: sa.set_center_frequency_MHz(440) # get initial frequency values for channel 0 val_2 = 0x35 #self.TestProcedure.ICD.readPrbFpga(0x305E) val_1 = 0xF0 #self.TestProcedure.ICD.readPrbFpga(0x3060) val_0 = 0x21 #self.TestProcedure.ICD.readPrbFpga(0x3062) freq_a_init = val_2 * 65536 + val_1 * 256 + val_0 print "PRB FREQ_A = ", freq_a_init val_2 = 0x35 #self.TestProcedure.ICD.readPrbFpga(0x3066) val_1 = 0xFA #self.TestProcedure.ICD.readPrbFpga(0x3068) val_0 = 0xCB #self.TestProcedure.ICD.readPrbFpga(0x306A) freq_b_init = val_2 * 65536 + val_1 * 256 + val_0 print "PRB FREQ_B = ", freq_b_init # Scan and link on Channel 0, with data inversion active self.TestProcedure.ICD.writePrbFpga(0x1026, 0x00) devList = self.icdcmd.scan(17, 2) print "type(devList):", type(devList) print "devList ", devList self.TestProcedure.ICD.writePrbFpga(0x3012, inv_flag) val = self.TestProcedure.ICD.readPrbFpga(0x1026) print "Channel Selection = ", val val = self.TestProcedure.ICD.readPrbFpga(0x3012) print "Data inversion = ", val self.icdcmd.connect((UInt32)(2102003)) # self.icdcmd.connect((UInt32) (2100130)) # self.icdcmd.connect((UInt32) (2149582066)) time.sleep(1) # Read CC1020 AFC register and verify correction logic val_0 = 0 val_1 = 0 for iter in range(0, 10): val_0 = self.TestProcedure.ICD.readCC1020( int(CC1020Register.AFC)) if val_0 > 127: val_0 = val_0 - 256 print "PRB AFC = ", val_0 val_1 = val_1 + val_0 print "PRB Average AFC = ", val_1 / 10.0 # val_2 = self.TestProcedure.ICD.readCC1020( int(CC1020Register.FREQ_2A)) val_1 = self.TestProcedure.ICD.readCC1020( int(CC1020Register.FREQ_1A)) val_0 = self.TestProcedure.ICD.readCC1020( int(CC1020Register.FREQ_0A)) freq_a = val_2 * 65536 + val_1 * 256 + val_0 print "PRB FREQ_A = ", freq_a val_2 = self.TestProcedure.ICD.readCC1020( int(CC1020Register.FREQ_2B)) val_1 = self.TestProcedure.ICD.readCC1020( int(CC1020Register.FREQ_1B)) val_0 = self.TestProcedure.ICD.readCC1020( int(CC1020Register.FREQ_0B)) freq_b = val_2 * 65536 + val_1 * 256 + val_0 print "PRB FREQ_B = ", freq_b # compute frequency offset val = (freq_a - 1) / 2 - (freq_a_init - 1) / 2 print "PRB AFC_A = ", val val = (freq_b - 1) / 2 - (freq_b_init - 1) / 2 print "PRB AFC_B = ", val # set the filter to widest bandwidth to get an unsaturated RSSI val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.FILTER)) print "PRB CC1020 FILTER = ", val self.TestProcedure.ICD.writeCC1020(int(CC1020Register.FILTER), 0x80) time.sleep(0.080) # read RSSI 10 times and compute the average val_0 = 0 val_1 = 0 for iter in range(0, 10): val_0 = self.TestProcedure.ICD.readCC1020( int(CC1020Register.RSSI)) print "PRB RSSI = ", val_0 val_1 = val_1 + val_0 print "PRB Average RSSI = ", val_1 / 10.0 # restore the filter setting self.TestProcedure.ICD.writeCC1020(int(CC1020Register.FILTER), 0x22) time.sleep(0.080) # Dump the Tx/Rx cal results if idx == 0: self.DumpSicdCalResults() # Write the test control table self.writeCalControlTable(DoCalFlag, MaxCalTries, ExitDelaySecs) # Write the configuration table for VCO low/high frequency # low: TEST5 = 0x3F, TEST3 = 0x10 # high: TEST5 = 0x30, TEST3 = 0x17 if idx == 0: self.icdcmd.writeByte((UInt32)(0x0200), 0xE1) self.icdcmd.writeByte((UInt32)(0x021D), 0x3F) self.icdcmd.writeByte((UInt32)(0x021F), 0x10) else: self.icdcmd.writeByte((UInt32)(0x0200), 0xE1) self.icdcmd.writeByte((UInt32)(0x021D), 0x30) self.icdcmd.writeByte((UInt32)(0x021F), 0x17) self.icdcmd.ping() print "VCO frequency starts in 10 seconds and lasts for 30 seconds..." # Start the test, the test patch will wait 10 seconds to allow for a break link self.icdcmd.writeUint16(Key.INT_VEC_TCMP0, 0x6A08) # break link with the S-ICD wfdeState = WaitForDisconnectedEventState(Key.DONT_CARE, 0x0) try: self.icdcmd.EventWaiter.execState(wfdeState, TimeSpan.FromSeconds(2)) except Exception, ex: print str(ex) time.sleep(16.0) sa.set_marker_findpeak() time.sleep(2.000) freq_0 = 0 freq_1 = 0 pwr_0 = 0 pwr_1 = 0 for iter in range(0, 8): freq_0 = sa.get_marker_frequency() print " PRB Tx frequency = ", freq_0 pwr_0 = sa.get_marker_power_level() print " PRB Tx power = ", pwr_0 freq_1 = freq_1 + freq_0 pwr_1 = pwr_1 + pwr_0 time.sleep(2.200) print " PRB Ave Frequency = ", freq_1 / 8.0 print " PRB Ave Power = ", pwr_1 / 8.0 time.sleep(14.0)
def script(self): # Read FPGA address 0x3000 and verify the response is 0x12. val = self.TestProcedure.ICD.readPrbFpga(0x3000) self.verify("FPGA 0x3000", 0x12, val) if val != 0x12: self.verify("ERROR", 0x12, val) #*********instrument setup*************************************** print "Creating instrument..." sa = spec_anal("GPIB::8", 'SPEC_ANAL') #**************************************************************** #*********plotter setup****************************************** plots = plotter(sa, test_dir) #**************************************************************** # read the MATCH value from EEPROM and write to the PRB #need to add read here... # calibrate once on channel 0 self.TestProcedure.ICD.calibrateCc1020() val = self.TestProcedure.ICD.readPrbFpga(0x2012) print " PRB badCal = ", val val = self.TestProcedure.ICD.readCC1020(int(CC1020Register.STATUS)) print " PRB STATUS register = ", val self.DumpCalResult() channel = 0 #5-45 5 degree steps temperatures = range(5, 46, 5) stabilization_mins = 10 chamber = watlowF4ipy.WatlowF4_temp_window(3, debug=True) for temperature in temperatures: chamber.set_temperature_and_time(temperature, temperature - 0.3, temperature + 0.3, stabilization_mins) while chamber.dwelltime_endpoint_reached() == False: #pause before checking the flag again time.sleep(2) sa.set_ref_level_dB(0) sa.set_span_kHz(400) sa.set_resolutionBW_kHz(3) sa.set_sweep_time_milliseconds(200) for index in range(0, self.loop_count): test_time = time.clock() print "Loop Index = ", index print "Test time = %.2d:%06.3f" % (test_time / 60, test_time % 60.0) # for index in range(0, 2): if index % 9 == 0: print "Candidate Frequency = 402.8183MHz, LSI" sa.set_center_frequency_MHz(402.8183) elif index % 9 == 1: print "Candidate Frequency = 403.5108MHz, HSI" sa.set_center_frequency_MHz(403.5108) elif index % 9 == 2: print "Candidate Frequency = 402.4942MHz, LSI" sa.set_center_frequency_MHz(402.4942) elif index % 9 == 3: print "Candidate Frequency = 404.6167MHz, HSI" sa.set_center_frequency_MHz(404.6167) elif index % 9 == 4: print "Candidate Frequency = 402.7209MHz, HSI" sa.set_center_frequency_MHz(402.7209) elif index % 9 == 5: print "Candidate Frequency = 402.4049MHz, HSI" sa.set_center_frequency_MHz(402.4049) elif index % 9 == 6: print "Candidate Frequency = 404.5197MHz, LSI" sa.set_center_frequency_MHz(404.5197) elif index % 9 == 7: print "Candidate Frequency = 402.7049MHz, LSI" sa.set_center_frequency_MHz(402.7049) else: print "Candidate Frequency = 403.5108MHz, HSI" sa.set_center_frequency_MHz(403.5108) time.sleep(1) # write the candidate frequency to PRB channel 0 registers self.writeFreqToPRB(index, 0) # write the candidate frequency to PRB channel 1 registers self.writeFreqToPRB(index, 1) # perform calibration and dump results self.TestProcedure.ICD.calibrateCc1020() # is badcal checked and reported? is there a wait until the cal interrupt? time.sleep(0.300) val = self.TestProcedure.ICD.readPrbFpga(0x2012) print " PRB badCal = ", val val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.STATUS)) print " PRB STATUS register = ", val self.DumpCalResult() # write the legacy frequency to PRB channel 0 registers self.writeFreqToPRB(1, channel) # perform calibration and dump results self.TestProcedure.ICD.calibrateCc1020() # is badcal checked and reported? is there a wait until the cal interrupt? time.sleep(0.300) val = self.TestProcedure.ICD.readPrbFpga(0x2012) print " PRB badCal = ", val val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.STATUS)) print " PRB STATUS register = ", val self.DumpCalResult() # perform an LBT instruction and log results # how do we issue an LBT and capture the interrupt packet? self.TestProcedure.ICD.writePrbFpga(0x1008, 0x10) time.sleep(0.400) val = self.TestProcedure.ICD.readPrbFpga(0x1020) print " PRB LIC = ", val val = self.TestProcedure.ICD.readPrbFpga(0x1026) print " PRB Channel Selection = ", val val = self.TestProcedure.ICD.readPrbFpga(0x1022) print " PRB Channel 0 RSSI = ", val val = self.TestProcedure.ICD.readPrbFpga(0x1024) print " PRB Channel 1 RSSI = ", val #note, after LBT the CC1020 registers contain the channel 1 values val_2 = self.TestProcedure.ICD.readCC1020( int(CC1020Register.FREQ_2A)) val_1 = self.TestProcedure.ICD.readCC1020( int(CC1020Register.FREQ_1A)) val_0 = self.TestProcedure.ICD.readCC1020( int(CC1020Register.FREQ_0A)) freq_a = val_2 * 65536 + val_1 * 256 + val_0 print " CC1020 FREQ_A = ", freq_a val_2 = self.TestProcedure.ICD.readCC1020( int(CC1020Register.FREQ_2B)) val_1 = self.TestProcedure.ICD.readCC1020( int(CC1020Register.FREQ_1B)) val_0 = self.TestProcedure.ICD.readCC1020( int(CC1020Register.FREQ_0B)) freq_b = val_2 * 65536 + val_1 * 256 + val_0 print " CC1020 FREQ_B = ", freq_b # place CC1020 into receive mode self.TestProcedure.ICD.writeCC1020(int(CC1020Register.MAIN), 0x01) #does the write/read routines wait until cc1020 not busy? time.sleep(0.080) val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.STATUS)) print " PRB STATUS register = ", val # log the filter setting val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.FILTER)) print " CC1020 FILTER = ", val time.sleep(0.080) # read RSSI 10 times and compute the average val_0 = 0 val_1 = 0 for iter in range(0, 10): val_0 = self.TestProcedure.ICD.readCC1020( int(CC1020Register.RSSI)) print " CC1020 RSSI = ", val_0 val_1 = val_1 + val_0 print " CC1020 Average RSSI = ", val_1 / 10.0 self.TestProcedure.ICD.writeCC1020(int(CC1020Register.MAIN), 0x1F) time.sleep(0.080) val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.MODEM)) print " CC1020 MODEM = ", val time.sleep(0.080) val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.DEVIATION)) print " CC1020 DEVIATION = ", val time.sleep(0.080) self.TestProcedure.ICD.writeCC1020(int(CC1020Register.MAIN), 0xC1) time.sleep(0.080) val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.STATUS)) print " PRB STATUS register = ", val time.sleep(1) val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.MAIN)) print " CC1020 MAIN = ", val # add SA commands to measure frequency and power for the peak output- read ten times and record the average sa.set_marker_findpeak() time.sleep(2.000) # read peak 10 times and compute the average freq_0 = 0 freq_1 = 0 pwr_0 = 0 pwr_1 = 0 for iter in range(0, 10): freq_0 = sa.get_marker_frequency() print " PRB Tx frequency = ", freq_0 pwr_0 = sa.get_marker_power_level() print " PRB Tx power = ", pwr_0 freq_1 = freq_1 + freq_0 pwr_1 = pwr_1 + pwr_0 print " PRB Ave Frequency = ", freq_1 / 10.0 print " PRB Ave Power = ", pwr_1 / 10.0 self.TestProcedure.ICD.writeCC1020( int(CC1020Register.DEVIATION), 0xD9) time.sleep(0.080) val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.MODEM)) print " CC1020 MODEM = ", val time.sleep(0.080) val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.DEVIATION)) print " CC1020 DEVIATION = ", val time.sleep(1) # read peak 10 times and compute the average sa.set_marker_findpeak() time.sleep(2.000) freq_0 = 0 freq_1 = 0 pwr_0 = 0 pwr_1 = 0 for iter in range(0, 10): freq_0 = sa.get_marker_frequency() print " PRB Tx frequency = ", freq_0 pwr_0 = sa.get_marker_power_level() print " PRB Tx power = ", pwr_0 freq_1 = freq_1 + freq_0 pwr_1 = pwr_1 + pwr_0 print " PRB Ave Frequency = ", freq_1 / 10.0 print " PRB Ave Power = ", pwr_1 / 10.0 self.TestProcedure.ICD.writeCC1020( int(CC1020Register.DEVIATION), 0x59) time.sleep(0.080) val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.MODEM)) print " CC1020 MODEM = ", val time.sleep(0.080) val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.DEVIATION)) print " CC1020 DEVIATION = ", val time.sleep(0.500) self.TestProcedure.ICD.writeCC1020(int(CC1020Register.MAIN), 0x1F) time.sleep(0.080) for index in range(0, self.loop_count): if index % 9 == 0: print "Candidate Frequency = 402.8183MHz, LSI" sa.set_center_frequency_MHz(402.8183) elif index % 9 == 1: print "Candidate Frequency = 403.5108MHz, HSI" sa.set_center_frequency_MHz(403.5108) elif index % 9 == 2: print "Candidate Frequency = 402.4942MHz, LSI" sa.set_center_frequency_MHz(402.4942) elif index % 9 == 3: print "Candidate Frequency = 404.6167MHz, HSI" sa.set_center_frequency_MHz(404.6167) elif index % 9 == 4: print "Candidate Frequency = 402.7209MHz, HSI" sa.set_center_frequency_MHz(402.7209) elif index % 9 == 5: print "Candidate Frequency = 402.4049MHz, HSI" sa.set_center_frequency_MHz(402.4049) elif index % 9 == 6: print "Candidate Frequency = 404.5197MHz, LSI" sa.set_center_frequency_MHz(404.5197) elif index % 9 == 7: print "Candidate Frequency = 402.7049MHz, LSI" sa.set_center_frequency_MHz(402.7049) else: print "Candidate Frequency = 403.5108MHz, HSI" sa.set_center_frequency_MHz(403.5108) # write the legacy frequency to PRB channel 0 registers self.writeFreqToPRB(1, 0) # write the candidate frequency to PRB channel 1 registers self.writeFreqToPRB(index, 1) # perform calibration and dump results self.TestProcedure.ICD.calibrateCc1020() # is badcal checked and reported? is there a wait until the cal interrupt? time.sleep(0.300) val = self.TestProcedure.ICD.readPrbFpga(0x2012) print " PRB badCal = ", val val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.STATUS)) print " PRB STATUS register = ", val self.DumpCalResult() # perform an LBT to place channel 1 frequency into CC1020 self.TestProcedure.ICD.writePrbFpga(0x1008, 0x10) time.sleep(1) # turn off the CC1020 and place into PN9 mode self.TestProcedure.ICD.writeCC1020(int(CC1020Register.MAIN), 0x1F) time.sleep(0.080) self.TestProcedure.ICD.writeCC1020(int(CC1020Register.MODEM), 0x54) time.sleep(0.080) # turn on CC1020 in transmit mode self.TestProcedure.ICD.writeCC1020(int(CC1020Register.MAIN), 0xC1) time.sleep(0.080) val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.STATUS)) print " PRB STATUS register = ", val val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.MODEM)) print " CC1020 MODEM = ", val time.sleep(0.080) val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.DEVIATION)) print " CC1020 DEVIATION = ", val time.sleep(0.500) time.sleep(2) sa.set_OBW_times_to_average(30) sa.set_occupied_bandwidth_pct(99) sa.turn_OBW_averages_on() (a, obw, c) = sa.measure_occupied_bandwidth() print " PRB OBW = ", obw d = sa.get_data() name = 'Occupied Bandwidth (PN9 pattern)' x_units = 'frequency(MHz)' y_units = 'signal power(' + sa.get_units() + ')' plots.make_plot(name, d, x_units, y_units) self.TestProcedure.ICD.writeCC1020( int(CC1020Register.DEVIATION), 0xD9) time.sleep(0.080) val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.MODEM)) print " CC1020 MODEM = ", val time.sleep(0.080) val = self.TestProcedure.ICD.readCC1020( int(CC1020Register.DEVIATION)) print " CC1020 DEVIATION = ", val time.sleep(0.500) time.sleep(2) (a, obw, c) = sa.measure_occupied_bandwidth() print " PRB OBW = ", obw d = sa.get_data() name = 'Occupied Bandwidth (PN9 pattern)' x_units = 'frequency(MHz)' y_units = 'signal power(' + sa.get_units() + ')' plots.make_plot(name, d, x_units, y_units) self.TestProcedure.ICD.writeCC1020( int(CC1020Register.DEVIATION), 0x59) time.sleep(0.080) self.TestProcedure.ICD.writeCC1020(int(CC1020Register.MAIN), 0x1F) sa.reset() self.passed = True self.TestProcedure.ICD.writeCC1020(int(CC1020Register.MAIN), 0x1F) print "Test complete, run prbRssiScript"