📄 maui_cal.c
字号:
if(CalSetup.useInstruments && (!REWIND_TEST))
{
timestart = milliTime();
uiPrintf("\nSetting up Power Meter");
devPM = pmInit(CalSetup.pmGPIBaddr, CalSetup.pmModel);
if ((CalSetup.pmModel == PM_E4416A) && !(SETUP_PM_MODEL2_ONCE))
{
gpibWrite(devPM, "*rst\n");
Sleep(100);
//gpibWrite(devPM, "*cls;*rcl 7\n");
pmPreset(devPM, -20, -4e-6, 860e-6, 2.6e-3, 3.43e-3);
Sleep(100);
gpibWrite(devPM, "*cls;:sens:det:func aver\n");
Sleep(100);
//exit(0);
SETUP_PM_MODEL2_ONCE = TRUE;
}
uiPrintf("\nSetting up Spectrum Analyzer");
devSA = spaInit(CalSetup.saGPIBaddr, SPA_E4404B);
uiPrintf("\nSetting up Attenuator\n");
#ifdef LINUX
devATT = attInit(CalSetup.attGPIBaddr, ATT_11713A_110);
#else
devATT = attInit(CalSetup.attGPIBaddr, ATT_11713A);
#endif
attSet(devATT, 81); //set to max
strcpy(testname[testnum],"instrument setup");
testtime[testnum++] = milliTime() - timestart;
}
if (CalSetup.calPower && CalSetup.do_iq_cal && (((swDeviceID & 0xFF) == 0x14)||((swDeviceID & 0xFF) >= 0x16))) {
// Set attenuator
if(CalSetup.useInstruments) {
attenVal = (A_INT32)(5 - CalSetup.attenDutGolden - (-35));
attSet(devATT, attenVal);
}
Sleep(200);
if ((CalSetup.Amode) && (CalSetup.calPower) && (!REWIND_TEST)) {
timestart = milliTime();
strcpy(testname[testnum],"IQ_cal for 11a");
configSetup.eepromLoad = 0;
art_setResetParams(devNumArr[MODE_11a], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
(A_BOOL)configSetup.eepromHeaderLoad, MODE_11A, configSetup.use_init);
dut_iq_cal(devNumArr[MODE_11a], MODE_11A, 5260);
testtime[testnum++] = milliTime() - timestart;
}
if ((CalSetup.Gmode) && (CalSetup.calPower) && (!REWIND_TEST)) {
timestart = milliTime();
strcpy(testname[testnum],"IQ_cal for 11g");
configSetup.eepromLoad = 0;
art_setResetParams(devNumArr[MODE_11g], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
(A_BOOL)configSetup.eepromHeaderLoad, MODE_11G, configSetup.use_init);
dut_iq_cal(devNumArr[MODE_11g], MODE_11G, 2442);
testtime[testnum++] = milliTime() - timestart;
}
if (REWIND_TEST) {
exitLoop = prepare_for_next_card(&(devNumArr[0]));
continue;
}
sendAck(devNumArr[MODE_11a], "Done with iq_cal", 0, 0, 0, CalSetup.customerDebug);
if(CalSetup.useInstruments) {
attSet(devATT, 81);
}
} else {
CalSetup.iqcal_i_corr[MODE_11a] = CalSetup.i_coeff_5G;
CalSetup.iqcal_q_corr[MODE_11a] = CalSetup.q_coeff_5G;
CalSetup.iqcal_i_corr[MODE_11g] = CalSetup.i_coeff_2G;
CalSetup.iqcal_q_corr[MODE_11g] = CalSetup.q_coeff_2G;
if (CalSetup.do_iq_cal) {
sendAck(devNumArr[MODE_11a], "Done with iq_cal", 0, 0, 0, CalSetup.customerDebug);
}
}
if ((CalSetup.cal_fixed_gain[MODE_11a] != INVALID_FG) && CalSetup.Amode){
if (CalSetup.cal_fixed_gain[MODE_11a] >= (pCurrGainLadder->numStepsInLadder-1)) {
uiPrintf("ERROR: Invalid CAL_FIXED_GAIN specified in calsetup.txt for mode ");
uiPrintf("11a [%d] : Valid range 0..%d\n", CalSetup.cal_fixed_gain[MODE_11a],
(pCurrGainLadder->numStepsInLadder-1));
exit(0);
}
optGainLadderIndex[MODE_11a] = (pCurrGainLadder->numStepsInLadder -1) - CalSetup.cal_fixed_gain[MODE_11a];
uiPrintf("\nusing cal fixed gain for mode 11a from calsetup.txt ... FG%d\n", CalSetup.cal_fixed_gain[MODE_11a]);
NEED_GAIN_OPT_FOR_MODE[MODE_11a] = TRUE;
} else if (CalSetup.calPower && CalSetup.Amode && (!REWIND_TEST)) {
if ( ((swDeviceID & 0xFF) == 0x12) || ((swDeviceID & 0xFF) == 0x13) || ((swDeviceID & 0xFF) == 0x15) ) {
tmpVal = art_getFieldForMode(devNumArr[MODE_11a], "rf_rfgain_step", MODE_11A, 0);
if(tmpVal == 0x3f) {
NEED_GAIN_OPT_FOR_MODE[MODE_11a] = TRUE;
}
} else { // for derby 2.0
tmpVal = art_getFieldForMode(devNumArr[MODE_11a], "rf_mixvga_ovr", MODE_11A, 0);
if(tmpVal == 1) {
NEED_GAIN_OPT_FOR_MODE[MODE_11a] = TRUE;
}
}
if(NEED_GAIN_OPT_FOR_MODE[MODE_11a] && CalSetup.Amode && CalSetup.useInstruments) {
uiPrintf("\noptimum fixed gain for mode 11a found to be ... ");
timestart = milliTime();
strcpy(testname[testnum],"Optimum fixed gain for 11a");
configSetup.eepromLoad = 0;
art_setResetParams(devNumArr[MODE_11a], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
(A_BOOL)configSetup.eepromHeaderLoad, MODE_11A, configSetup.use_init);
optGainLadderIndex[MODE_11a] = optimal_fixed_gain(devNumArr[MODE_11a], pCurrGainLadder, MODE_11a);
uiPrintf(" : %d dB\n", pCurrGainLadder->optStep[optGainLadderIndex[MODE_11a]].stepGain);
testtime[testnum++] = milliTime() - timestart;
} else {
optGainLadderIndex[MODE_11a] = pCurrGainLadder->defaultStepNum;
}
}
if ((CalSetup.cal_fixed_gain[MODE_11b] != INVALID_FG) && CalSetup.Bmode) {
if (CalSetup.cal_fixed_gain[MODE_11b] >= pCurrGainLadder->numStepsInLadder) {
uiPrintf("ERROR: Invalid CAL_FIXED_GAIN specified in calsetup.txt for mode ");
uiPrintf("11b [%d] : Valid range 0..%d\n", CalSetup.cal_fixed_gain[MODE_11b],
(pCurrGainLadder->numStepsInLadder-1));
exit(0);
}
optGainLadderIndex[MODE_11b] = (pCurrGainLadder->numStepsInLadder -1) - CalSetup.cal_fixed_gain[MODE_11b];
NEED_GAIN_OPT_FOR_MODE[MODE_11b] = TRUE;
uiPrintf("\nusing cal fixed gain for mode 11b from calsetup.txt ... FG%d\n", CalSetup.cal_fixed_gain[MODE_11b]);
} else if (CalSetup.calPower && CalSetup.Bmode && (!REWIND_TEST)){
if ( ((swDeviceID & 0xFF) == 0x12) || ((swDeviceID & 0xFF) == 0x13) || ((swDeviceID & 0xFF) == 0x15) ) {
tmpVal = art_getFieldForMode(devNumArr[MODE_11b], "rf_rfgain_step", MODE_11B, 0);
if(tmpVal == 0x3f) {
NEED_GAIN_OPT_FOR_MODE[MODE_11b] = TRUE;
}
} else { // for derby 2.0
tmpVal = art_getFieldForMode(devNumArr[MODE_11b], "rf_mixvga_ovr", MODE_11B, 0);
if(tmpVal == 1) {
NEED_GAIN_OPT_FOR_MODE[MODE_11b] = TRUE;
}
}
if(NEED_GAIN_OPT_FOR_MODE[MODE_11b] && CalSetup.Bmode && CalSetup.useInstruments) {
uiPrintf("\noptimum fixed gain for mode 11b found to be ... ");
timestart = milliTime();
strcpy(testname[testnum],"Optimum fixed gain for 11b");
configSetup.eepromLoad = 0;
art_setResetParams(devNumArr[MODE_11b], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
(A_BOOL)configSetup.eepromHeaderLoad, MODE_11B, configSetup.use_init);
optGainLadderIndex[MODE_11b] = optimal_fixed_gain(devNumArr[MODE_11b], pCurrGainLadder, MODE_11b);
uiPrintf(" : %d dB\n", pCurrGainLadder->optStep[optGainLadderIndex[MODE_11b]].stepGain);
testtime[testnum++] = milliTime() - timestart;
} else {
optGainLadderIndex[MODE_11b] = pCurrGainLadder->defaultStepNum;
}
}
if ((CalSetup.cal_fixed_gain[MODE_11g] != INVALID_FG) && CalSetup.Gmode){
if (CalSetup.cal_fixed_gain[MODE_11g] >= pCurrGainLadder->numStepsInLadder) {
uiPrintf("ERROR: Invalid CAL_FIXED_GAIN specified in calsetup.txt for mode ");
uiPrintf("11g [%d] : Valid range 0..%d\n", CalSetup.cal_fixed_gain[MODE_11g],
(pCurrGainLadder->numStepsInLadder-1));
exit(0);
}
optGainLadderIndex[MODE_11g] = (pCurrGainLadder->numStepsInLadder -1) - CalSetup.cal_fixed_gain[MODE_11g];
NEED_GAIN_OPT_FOR_MODE[MODE_11g] = TRUE;
uiPrintf("\nusing cal fixed gain for mode 11g from calsetup.txt ... FG%d\n", CalSetup.cal_fixed_gain[MODE_11g]);
} else if (CalSetup.calPower && CalSetup.Gmode && (!REWIND_TEST)){
if ( ((swDeviceID & 0xFF) == 0x12) || ((swDeviceID & 0xFF) == 0x13) || ((swDeviceID & 0xFF) == 0x15) ) {
tmpVal = art_getFieldForMode(devNumArr[MODE_11g], "rf_rfgain_step", MODE_11G, 0);
if(tmpVal == 0x3f) {
NEED_GAIN_OPT_FOR_MODE[MODE_11g] = TRUE;
}
} else { // for derby 2.0
tmpVal = art_getFieldForMode(devNumArr[MODE_11g], "rf_mixvga_ovr", MODE_11G, 0);
if(tmpVal == 1) {
NEED_GAIN_OPT_FOR_MODE[MODE_11g] = TRUE;
}
}
if(NEED_GAIN_OPT_FOR_MODE[MODE_11g] && CalSetup.Gmode && CalSetup.useInstruments) {
uiPrintf("\noptimum fixed gain for mode 11g found to be ... ");
timestart = milliTime();
strcpy(testname[testnum],"Optimum fixed gain for 11g");
configSetup.eepromLoad = 0;
art_setResetParams(devNumArr[MODE_11g], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
(A_BOOL)configSetup.eepromHeaderLoad, MODE_11G, configSetup.use_init);
optGainLadderIndex[MODE_11g] = optimal_fixed_gain(devNumArr[MODE_11g], pCurrGainLadder, MODE_11g);
uiPrintf(" : %d dB\n", pCurrGainLadder->optStep[optGainLadderIndex[MODE_11g]].stepGain);
testtime[testnum++] = milliTime() - timestart;
} else {
optGainLadderIndex[MODE_11g] = pCurrGainLadder->defaultStepNum;
}
}
if(CalSetup.Amode && CalSetup.useInstruments && (CalSetup.testTempMargin[MODE_11a]) && (!REWIND_TEST)) {
uiPrintf("\nTesting temp margin for 11a...\n");
timestart = milliTime();
strcpy(testname[testnum],"Temp margin test 11a");
//cornerCal(devNum);
configSetup.eepromLoad = 0;
art_setResetParams(devNumArr[MODE_11a], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
(A_BOOL)configSetup.eepromHeaderLoad, MODE_11A, configSetup.use_init);
test_for_temp_margin(devNumArr[MODE_11a], MODE_11a);
testtime[testnum++] = milliTime() - timestart;
}
if(CalSetup.Bmode && CalSetup.useInstruments && (CalSetup.testTempMargin[MODE_11b]) && (!REWIND_TEST)) {
uiPrintf("\nTesting temp margin for 11b...\n");
timestart = milliTime();
strcpy(testname[testnum],"Temp margin test 11b");
//cornerCal(devNum);
configSetup.eepromLoad = 0;
art_setResetParams(devNumArr[MODE_11b], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
(A_BOOL)configSetup.eepromHeaderLoad, MODE_11B, configSetup.use_init);
test_for_temp_margin(devNumArr[MODE_11b], MODE_11b);
testtime[testnum++] = milliTime() - timestart;
}
if(CalSetup.Gmode && CalSetup.useInstruments && (CalSetup.testTempMargin[MODE_11g]) && (!REWIND_TEST)) {
uiPrintf("\nTesting temp margin for 11g...\n");
timestart = milliTime();
strcpy(testname[testnum],"Temp margin test 11g");
//cornerCal(devNum);
configSetup.eepromLoad = 0;
art_setResetParams(devNumArr[MODE_11g], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
(A_BOOL)configSetup.eepromHeaderLoad, MODE_11G, configSetup.use_init);
test_for_temp_margin(devNumArr[MODE_11g], MODE_11g);
testtime[testnum++] = milliTime() - timestart;
}
if(CalSetup.useInstruments) {
attSet(devATT, 81);
}
uiPrintf("\nManufacturing Test start ...\n");
if (CalSetup.useFastCal && CalSetup.calPower && CalSetup.useInstruments)
{
gpibONL(guDevAtt, 0); // take att offline. relinquish for GU.
gpibONL(guDevPM, 0); // take att offline. relinquish for GU.
sendAck(devNumArr[MODE_11a], "DUT relinquished instrument control. Go ahead GU.", 0, 0, 0, CalSetup.customerDebug);
}
// 11a calibration
if((CalSetup.calPower && CalSetup.Amode) && (!REWIND_TEST)){
timestart = milliTime();
strcpy(testname[testnum],"11a cal");
configSetup.eepromLoad = 0;
art_setResetParams(devNumArr[MODE_11a], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
(A_BOOL)configSetup.eepromHeaderLoad, MODE_11A, configSetup.use_init);
if (NEED_GAIN_OPT_FOR_MODE[MODE_11a])
{
//setGainLadderForMaxGain(pCurrGainLadder);
setGainLadderForIndex(pCurrGainLadder, optGainLadderIndex[MODE_11a]);
programNewGain(pCurrGainLadder, devNumArr[MODE_11a], 0);
}
dutCalibration(devNumArr[MODE_11a]);
initializeGainLadder(pCurrGainLadder);
programNewGain(pCurrGainLadder, devNumArr[MODE_11a], 0);
testtime[testnum++] = milliTime() - timestart;
}
// 11g calibration
if(CalSetup.calPower && CalSetup.Gmode && (!REWIND_TEST)){
configSetup.eepromLoad = 0;
art_setResetParams(devNumArr[MODE_11g], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
(A_BOOL)configSetup.eepromHeaderLoad, MODE_11G, configSetup.use_init);
timestart = milliTime();
strcpy(testname[testnum],"11g cal");
if (NEED_GAIN_OPT_FOR_MODE[MODE_11g])
{
//initializeGainLadder(pCurrGainLadder);
//setGainLadderForMaxGain(pCurrGainLadder);
setGainLadderForIndex(pCurrGainLadder, optGainLadderIndex[MODE_11g]);
programNewGain(pCurrGainLadder, devNumArr[MODE_11g], 0);
}
dutCalibration_2p4(devNumArr[MODE_11g], MODE_11g);
initializeGainLadder(pCurrGainLadder);
programNewGain(pCurrGainLadder, devNumArr[MODE_11g], 0);
testtime[testnum++] = milliTime() - timestart;
}
// 11b calibration
if(CalSetup.calPower && CalSetup.Bmode && (!REWIND_TEST)){
configSetup.eepromLoad = 0;
art_setResetParams(devNumArr[MODE_11b], configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
(A_BOOL)configSetup.eepromHeaderLoad, MODE_11B, configSetup.use_init);
timestart = milliTime();
strcpy(testname[testnum],"11b cal");
if (NEED_GAIN_OPT_FOR_MODE[MODE_11b])
{
//initializeGainLadder(pCurrGainLadder);
//setGainLadderForMaxGain(pCurrGainLadder);
setGainLadderForIndex(pCurrGainLadder, optGainLadderIndex[MODE_11b]);
programNewGain(pCurrGainLadder, devNumArr[MODE_11b], 0);
}
dutCalibration_2p4(devNumArr[MODE_11b], MODE_11b);
initializeGainLadder(pCurrGainLadder);
programNewGain(pCurrGainLadder, devNumArr[MODE_11b], 0);
testtime[testnum++] = milliTime() - timestart;
}
if(CalSetup.calPower && (!REWIND_TEST))
{
timestart = milliTime();
strcpy(testname[testnum],"program eeprom");
configSetup.eepromLoad = 0;
//force the reload of eep file to ensure correct settings programmed into eeprom
processEepFile(devNumArr[MODE_11a], configSetup.cfgTable.pCurrentElement->eepFilename, &configSetup.eepFileVersion);
processEepFile(devNumArr[MODE_11g], configSetup.cfgTable.pCurrentElement->eepFilename, &configSetup.eepFileVersion);
if (CalSetup.eeprom_map == CAL_FORMAT_GEN2) {
CalSetup.TrgtPwrStartAddr = 0x1A5;
}
// ear_start_addr now points to the end of cal data. adjust it for target powers :
// (8 11a ch + 211b ch + 3 11g ch)*2 words per ch
CalSetup.EARStartAddr = CalSetup.TrgtPwrStartAddr + 16 + 4 + 6 + 8*pTestGroupSet->numTestGroupsDefined;
program_eeprom((configSetup.validInstance == 1) ? devNumArr[MODE_11a] : devNumArr[MODE_11g]);
testtime[testnum++] = milliTime() - timestart;
}
if(CalSetup.reprogramTargetPwr && (!REWIND_TEST)) {
program_Target_Power_and_Test_Groups(devNumArr[MODE_11a]);
}
if (CalSetup.useFastCal && CalSetup.calPower && CalSetup.useInstruments && (!REWIND_TEST))
{
sendAck(devNumArr[MODE_11a], "Request Golden Unit To Relinquish Instrument Control", 0, 0, 0, CalSetup.customerDebug);
waitForAck(CalSetup.customerDebug);
gpibRSC(0, 1); // DUT to acquire system control (1);
uiPrintf("\nSetting up Power Meter");
devPM = pmInit(CalSetup.pmGPIBaddr, CalSetup.pmModel);
uiPrintf("\nSetting up Spectrum Analyzer");
devSA = spaInit(CalSetup.saGPIBaddr, SPA_E4404B);
uiPrintf("\nSetting up Attenuator");
devATT = attInit(CalSetup.attGPIBaddr, ATT_11713A);
attSet(devATT, 81); //set to max
}
if (!REWIND_TEST) {
configSetup.loadEar = loadEARState;
art_configureLibParams(devNumArr[MODE_11a]);
art_configureLibParams(devNumArr[MODE_11g]);
art_resetDevice(devNumArr[MODE_11a], rxStation, bssID, 5220, 0);
art_resetDevice(devNumArr[MODE_11g], rxStation, bssID, 2412, 0);
art_writeField(devNumArr[MODE_11a], "mc_eeprom_size_ovr", 3);
art_writeField(devNumArr[MODE_11g], "mc_eeprom_size_ovr", 3);
dutTest(&(devNumArr[0]));
}
exitLoop = prepare_for_next_card(&(devNumArr[0]));
}
}
void dutCalibration(A_UINT32 devNum)
{
A_UINT32 MACID_H, MACID_L;
art_changeField(devNum, "rf_ovr", 0);
if (CalSetup.eeprom_map >= CAL_FORMAT_GEN3) {
dutCalibration_gen3(devNum, MODE_11a);
return;
}
// reset device in order to read eeprom content
art_resetDevice(devNum, rxStation, bssID, 5220, 0);
// read MAC ID
MACID_H = art_eepromRead(devNum,0x1f);
MACID_L = art_eepromRead(devNum,0x1e);
MACID_L = (MACID_L << 16) | art_eepromRead(devNum,0x1d);
// power and gainf datasets setup and measurement
if (!setup_raw_datasets()) {
uiPrintf("Could not setup raw datasets. Exiting...\n");
closeEnvironment();
exit(0);
}
if (CalSetup.readFromFile)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -