/* 5-31-94 modified from SCA_PAS2.c to run on this computer */ /* C.VU add case ***_PRINTIT to each panel for printing */ /* of that panel out to network printer */ /* 6-6-94 add a walking pulse selection in noise test to allow */ /* synchronize pulsing of PASA with the SCA_WRITE clk */ /*8-12-94 change the noise test to be the same as SCA_TEST.C */ /* to see if the noise calculation in both FEE_&SCA.C */ /* and SCA_TEST.C are the same on the same SCA chip , */ /* YES ,It is the same this program can be used to test */ /* the noise on the FEE bd too */ /* */ /* 4-7-95 ONLY this program seem to work with the FEE_SAS ver1 BD */ /* */ /* 5-3-96 All LW23a word from NA49 tester Program is change to */ /* LW word in This program . */ /*_________________________________________________________________ SCA_Test.c * Version 1.0 * SCA_Test.c provides a user interface to National Instrument's 10/7/93 * LabWindows on a IBM-PC clone. High-level Data Acquisition Library * functions calls are used to control LBL's new IC tester hardware. * Digital control and data acquisition is accomplished through a PC-DIO-96 * Digital Board and analog data acquisition is accomplished through a * MIO-16H-25 Analog Board. * * This version of the IC Tester software is designed to test project * NA-49's 16-channel SCA chips. Other variations of this software are * designed to test 4-channel preamps, 16-channel preamps, and 16-channel * shaper-amp, and combined 16-channel preamp/shaper-amp chips. * * The IC tester for the SCA chips is controlled through digital ports * 6..11 on the PC-DIO-96 board. Ports 6,7,8, and 11 are output only. * Writing to these output ports configures the IC tester for the desired * tests. Ports 9 and 10, on the PC-DIO-96 board. are used as a bi- * directional data bus. Digital SCA data are read through digital ports * 9 and 10. Handshaking is disabled. * * Electrical characteristics of the IC under test, are read from input * (ADC) channel 0 of the MIO-16H-25 Analog Board. Channel 0 is configured * for differential double ended input, bipolar (-10 to +10 volts), a gain * of 1, and with no external conversion pulses or triggering. * * Revision History: * ----------------- * 2/09/93 Maury McEvoy Fixed bug in SCA_MemEnable. * 3/12/93 Maury McEvoy Added multiple data display panels. * 3/16/93 Maury McEvoy Changed the logic that selects the processing * for the "hit panel", from case statements to if * statements, to make changes less error prone. * 3/22/93 Maury McEvoy Changed relative file paths to absolute. * 3/24/93 Maury McEvoy Added separate Cross Talk and Sawtooth panels. * 3/25/93 Maury McEvoy Moved diagnostic tests to a Diagnostic panel. * 3/25/93 Maury McEvoy Added 0.5 second delay when setting DAC 1. * 6/11/93 Maury McEvoy The spike at cell=0 was biasing the per-channel * sigma. Removed cell 0 from the calculation. * 6/28/93 Maury McEvoy Added FIRST_GOOD_CELL parameter to facilitate * adjusting the number of cells to omit from the * per-channel mean and sigma calculations. * 9/15/93 Maury McEvoy Power off seqence has been changed to remove * power from "all" pins, not just chip power. * 9/17/93 Maury McEvoy Added two DC tests. * 10/07/93 Chinh Vu Voltage values in voltSCA array were updated. * 10/07/93 Maury McEvoy Added output file "LOG_CHAN.DAT" to log data * for Chinh to evaluate ICs. * 10/7/98 Chinh Vu this program is from FEE_TEST.C * 10/8/98 Chinh Vu All *.DAT files is change to directory where * the main file resided. * * S/W Validation Results: * ----------------------- * 3/12/93 Maury McEvoy Average pedestal data (SCAo), DC data (SCA), * and sigma (sigmaSCAo) displays are working. */ /*_ INCLUDES _______________________________________________________________ * * Never modify the contents of the "SCA_Test.h" include file. It is * generated automatically by the User Interface Editor. */ #include "FEE.h" /* Include file for Switched Capacitor Array Chip */ #include "FEE_Test.h" /* Panel parameters from the User Interface Editor */ #include "ni_defs.h" /* Info specific to National Instrument's boards */ #include "FEE_Glob.h" /* Global parameters */ static int testDataOn; /* Controls generation of H/W test data */ static int Select[16]; static int Test[512][32]; static double SCA[NUM_CELLS][NUM_CHAN]; /* SCA readout value */ static double SCAo[NUM_CELLS][NUM_CHAN]; /* Mean SCA Pedestal value */ static double sigmaSCAo[NUM_CELLS][NUM_CHAN]; /* Sigma of Pedestal value */ static double SCAo_chan [NUM_CHAN]; /* Mean Pedestal value/channel */ static double sigmaSCAo_chan[NUM_CHAN]; /* Sigma SCA Pedestal value/chan */ static double SCA_chan [NUM_CHAN]; /* Mean SCA value/channel */ static double sigmaSCA_chan[NUM_CHAN]; /* Sigma SCA value/chan */ static double offset[NUM_CELLS][NUM_CHAN]; /* Least squares offset */ static double slope[NUM_CELLS][NUM_CHAN]; /* Least squares slope */ static double voltSCA[NUM_LIN]; /* Voltage settings for linearity test */ static double CrossTalkTemp[NUM_CELLS][NUM_CHAN]; /* CrossTalk data from switching chan alone */ static double crossTalk[NUM_CELLS][NUM_CHAN]; /* CrossTalk data */ static double crossTalkDy[NUM_CELLS][NUM_CHAN]; /* CrossTalk data -dy */ static double even_odd[NUM_CELLS][NUM_CHAN]; /* DC into even/odd cells */ static double sawtooth[NUM_CELLS][NUM_CHAN]; /* Sawtooth input signal */ /*_ FUNCTION DECLARATIONS ________________________________________________ */ /*_ SCA FUNCTIONS _______________________________________________________*/ int ClearCounters(); /* Clear Counters and prepare for new event */ int Comp_MemEnable(); /* Enable computer to jig memory transfers */ int HitPanel_1( int ); /* Process events for home Panel_1 */ int HitPanel_DIAG( int ); /* Process events for diagnostic Panel_DIAG */ int HitPanel_SAW( int ); /* Process events for sawtooth Panel_SAW */ int HitPanel_SCAo( int ); /* Process events for pedestal Panel_SCAo */ int HitPanel_SCA( int ); /* Process events for Panel_SCA */ int HitPanel_TLK( int ); /* Process events for cross talk Panel_TLK */ int IncAddrCntr(); /* Increment jig memory's address counter */ void LogSCA(); /* Log SCA matrix data to a disk file */ void LogSCAo(); /* Log SCA pedestal and sigma data to disk */ int MeasurePedestal(); /* Measure mean & sigma of pedestal samples */ int Mem_CompEnable(); /* Enable jig memory to computer transfers */ int ReadCrossTalk(); /* Read cross talk data from test jig's mem. */ int ReadJigMem(); /* Read values from SCA test jig's memory */ int ReadSawtooth(); /* Read sawtooth data from test jig's memory */ int ReadSelectSca(); /* Read selected SCA data from test jig's memory */ int RunCal(); /* run internal calibration pulse */ int RunDcTest( int ); /* Run single DC test on SCA IC Tester */ int RunDcTests(); /* Run 16 DC tests on SCA IC Tester */ int RunDiagTest(); /* Run single Diagnostic test on IC Tester */ int RunFuncTest( int ); /* Run single Func test on SCA IC Tester */ int RunFuncTests(); /* Run 14 Func tests on SCA IC Tester */ int RunParamTest( int ); /* Run single Param tests on SCA IC Tester */ int RunParamTests(); /* Run 2 Param tests on SCA IC Tester */ int SCA_DataAcq(); /* Causes the SCA chip to acquire data */ int SCA_MemEnable(); /* Enable SCA to jig memory transfers */ int SCA_MemTest(); /* Enable SCA Test Data to jig transfers */ int SelDCsig(); /* Select DC signal into SCA chip */ int SelDCsigOddEven(); /* Select DC signal into odd/even SCA cells */ int SelectAllChanels(); /* Select all 16 input channels of SCA chip */ int SelectEvenChanels(); /* Select 8 even input channels of SCA chip */ int SelectOddChanels(); /* Select 8 odd input channels of SCA chip */ int SelectPulsedChanels(); /* Select pulsed channels of SAS chip */ int SelSAsig(); /* Select SA output signal into SCA chip */ int SelTriangSig(); /* Select triangular signal into SCA chip */ int Set_SCA_Volts(double); /* Sets DC level voltage to SCA inputs */ int StartNewEvent(); /* Set SCA trigger high */ int StrobeData(); /* Store Data in SCA test jig's memory */ int TestJigStatus(); /* Read test jig status. Not 0 ==> ready */ int WalkingPulse(); /* Selects non-overlapping SCA input pulses */ int WriteJigMem(); /* Write matrix values to SCA test jig's mem */ /*_ COMMON FUNCTIONS ____________________________________________________*/ void Check_Err( int ); /* Display/clear errors WAIT/NO_WAIT */ int DIO_Clear(); /* Clear the PC-DIO-96 board's ports */ int DIO_Init(); /* Init PC-DIO-96 lower 6 ports output */ int Display_ADC_Port_0(); /* Display status of ADC port 0 */ int Display_DIO_Port_6_11(); /* Display status of DIO-96 ports 11..6 */ int Get_Low_High_Limits( double [][3], double [][3], double [][3] ); void LogTestData( int, int, double[] ); /* Log data to disk file */ void ReadParameters( int ); /* Read Parameters from a disk file */ void RingBell( int ); /* Ring computer bell "n" times */ int Set_PA_Volts( double ); /* Sets the PA power supply voltage */ double Sigma( double[], double );/* Compute the Standard Deviation */ void WriteHeader( int ); /* Write Header to Data Logging file */ void WriteParameters( int ); /* Write Parameters to disk file */ void main() { int analogBoardType; /* 6 for a MIO-16H-25 board */ int digitalBoardType; /* 12 for a PC-DIO-96 board */ int itemSelected; /* ID of control that caused the event */ int handleHit; /* For panel or menu bar event */ errNum = 0; /* Initial value of error # */ Fmt( errStr, "" ); /* Initial value of error string */ errCount = 0; /* Initial value of error count */ testDataOn = 0; /* No test data is the default */ /* Open and display user panel */ errNum = OpenInterfaceManager(); Check_Err( WAIT ); Panel_1 = LoadPanel( "MPI_TEST.UIR", IC ); if ( Panel_1 < 0 ) { FmtOut("Unable to load the FEE_PROD\MPI_TEST.UIR resource file.\n"); return; } errNum = DisplayPanel( Panel_1 ); errNum = SetActivePanel( Panel_1 ); Check_Err( WAIT ); Panel_DIAG = LoadPanel( "MPI_TEST.UIR", DIAG ); if ( Panel_DIAG < 0 ) { FmtOut("Unable to load the FEE_PROD\MPI_TEST.UIR resource file.\n"); return; } Panel_SAW = LoadPanel( "MPI_TEST.UIR", SAW ); if ( Panel_SAW < 0 ) { FmtOut("Unable to load the FEE_PROD\MPI_TEST.UIR resource file.\n"); return; } errNum = RecallPanelState( Panel_SAW, "PanlSAW.DAT" ); Check_Err( WAIT ); Panel_SCAo = LoadPanel( "MPI_TEST.UIR", SCo ); if ( Panel_SCAo < 0 ) { FmtOut("Unable to load the FEE_PROD\MPI_TEST.UIR resource file.\n"); return; } errNum = RecallPanelState( Panel_SCAo, "PanlSCAo.DAT" ); Check_Err( WAIT ); Panel_SIG = LoadPanel( "MPI_TEST.UIR", SIG ); if ( Panel_SIG < 0 ) { FmtOut("Unable to load the FEE_PROD\MPI_TEST.UIR resource file.\n"); return; } errNum = RecallPanelState( Panel_SIG, "PanlSIG.DAT" ); Check_Err( WAIT ); Panel_SCA = LoadPanel( "MPI_TEST.UIR", SC ); if ( Panel_SCA < 0 ) { FmtOut("Unable to load the FEE_PROD\MPI_TEST.UIR resource file.\n"); return; } errNum = RecallPanelState( Panel_SCA, "PanlSCA.DAT" ); Check_Err( WAIT ); Panel_SCP = LoadPanel( "MPI_TEST.UIR", SCP ); if ( Panel_SCP < 0 ) { FmtOut("Unable to load the FEE_PROD\MPI_TEST.UIR resource file.\n"); return; } /* errNum = RecallPanelState( Panel_SCP, "PanlSCP.DAT" ); */ Check_Err( WAIT ); Panel_TLK = LoadPanel( "MPI_TEST.UIR", TLK ); if ( Panel_TLK < 0 ) { FmtOut("Unable to load the FEE_PROD\MPI_TEST.UIR resource file.\n"); return; } /* errNum = RecallPanelState( Panel_TLK, "PanlTLK.DAT" ); */ Check_Err( WAIT ); /*_ INITIALIZATION ____________________________________________________ */ Fmt( paramFileName, "SCA_PAR.TXT" ); fileExists = GetFileInfo( paramFileName, &fileSize ); if ( fileExists ) { parameterFile = OpenFile( paramFileName, READ_ONLY, NO_TRUNC, ASCII ); ReadParameters( parameterFile ); /* Read previous parameter values */ errNum = CloseFile(parameterFile); /* Close parameter text file */ /* Fmt( dataFileName, "SCA00000.DAT" ); */ } else { /* Initialize default parameters */ chipID = 1; Fmt( operatorName, "McEvoy/Vu" ); Fmt( dataFileName, "SCA00000.DAT" ); } /* SetCtrlVal( Panel_1, IC_CHIP_ID, chipID ); */ hwDebug = ON; /* ON => leave power to IC tester on. */ hwSimulation = OFF; /* Sim ON required to test S/W without H/W */ if ( hwSimulation ) SetCtrlVal(Panel_1, IC_OPERATOR_NAME, "H/W Simulation ON" ); else SetCtrlVal(Panel_1, IC_OPERATOR_NAME, operatorName ); Fmt( softwareVersion, "v2.3a" ); /* Set software version # */ Fmt( errorFileName , "SCA_ER00.TXT" ); Fmt( limitFileName , "MPI_TLIM.old" ); /* look only in the same directory */ /* Fmt( limitFileName , "MPI_TLIM.DAT" ); */ Fmt( dataMatrixName , "SCA_DMAT.DAT" ); Fmt( sigmaMatrixName, "SCA_SMAT.DAT" ); Fmt( logChannelName , "LOG_CHAN.DAT" ); dataLogFile = OpenFile( dataFileName , WRITE_ONLY, APPEND, ASCII ); dataMatrixFile = OpenFile( dataMatrixName , WRITE_ONLY, APPEND, ASCII ); sigmaMatrixFile = OpenFile( sigmaMatrixName, WRITE_ONLY, APPEND, ASCII ); logChannelFile = OpenFile( logChannelName , WRITE_ONLY, APPEND, ASCII ); WriteHeader( dataLogFile ); errorLogFile = OpenFile( errorFileName, WRITE_ONLY, APPEND, ASCII ); voltSCA[0]=3.390; voltSCA[1]=3.155; voltSCA[2]=2.920; /* For linearity tests */ voltSCA[3]=2.690; voltSCA[4]=2.460; voltSCA[5]=2.230; /* For linearity tests */ voltSCA[6]=2.005; voltSCA[7]=1.78; voltSCA[8]=1.56; /* For linearity tests */ voltSCA[9]=1.34; /* For linearity tests */ linearityPopup = FALSE; /* Determines if the linearity chart is displayed */ breakOnFail = FALSE; /* Permits operator to adjust lower & upper bounds */ errNum = Init_DA_Brds( AIO_BD, &analogBoardType ); /* Halts any operations */ Check_Err( WAIT ); errNum = Init_DA_Brds( DIO_BD, &digitalBoardType ); /* Halts any operations */ Check_Err( WAIT ); errNum = Get_Low_High_Limits( boundsDC, boundsFunc, boundsPara ); Check_Err( WAIT ); errNum = DIO_Init(); /* Init digital I/O ports */ Check_Err( WAIT ); errNum = DIO_Clear(); /* Clear PC-DIO-96 ports */ Check_Err( WAIT ); outp( PORT_7, 0x00 ); /* Turn Tester Power off */ outp( PORT_6, 0x03 ); /* allow counter to output data 9-14-93 */ outp(PORT_11, 0x00); /* Set bit 7 of Port 11 low to reset counter 9-14-93*/ /* start from here add to run 2 testers */ outp( PORT_0, 0x01 ); /* add in to allow run 2 testers by this program only */ outp( PORT_1, 0x00 ); /* add in to allow run 2 testers by this program only */ outp( PORT_2, 0x38 ); /* add in to allow run 2 testers by this program only */ outp( PORT_3, 0x00 ); /* add in to allow run 2 testers by this program only */ outp( PORT_4, 0x80 ); /* add in to allow run 2 testers by this program only */ outp( PORT_5, 0x01 ); /* add in to allow run 2 testers by this program only */ /* stop here */ Display_DIO_Ports_6_11(); quitTest = FALSE; /* TRUE when quit key is pressed */ /*_ Main Event Loop ______________________________________________________ */ while ( !quitTest ) { errNum = GetUserEvent( WAIT, &handleHit, &itemSelected ); Check_Err( WAIT ); /* Select function to process the "itemSelected" for the "hit" panel */ if ( handleHit == Panel_1 ) errNum = HitPanel_1( itemSelected ); else { if ( handleHit == Panel_SCAo ) errNum = HitPanel_SCAo( itemSelected ); else { if ( handleHit == Panel_SIG ) errNum = HitPanel_SIG( itemSelected ); else { if ( handleHit == Panel_SCA ) errNum = HitPanel_SCA( itemSelected ); else { if ( handleHit == Panel_SCP ) errNum = HitPanel_SCP( itemSelected ); else { if ( handleHit == Panel_TLK ) errNum = HitPanel_TLK( itemSelected ); else { if ( handleHit == Panel_SAW ) errNum = HitPanel_SAW( itemSelected ); else { if ( handleHit == Panel_DIAG ) errNum = HitPanel_DIAG( itemSelected ); else RingBell( 1 ); } } } } } } } } /* Program ended. Shut down the hardware and software. */ errNum = DIO_Clear(); /* Clear PC-DIO-96 ports */ errNum = Set_PA_Volts( 0.0 ); /* Remove power to SCA chip */ errNum = Init_DA_Brds( AIO_BD, &analogBoardType ); /* Halts analog operations */ errNum = Init_DA_Brds( DIO_BD, &digitalBoardType ); /* Halts digital operations */ errNum = CloseInterfaceManager(); /* Close user panel */ parameterFile = OpenFile( paramFileName, WRITE_ONLY, TRUNCATE, ASCII ); WriteParameters( parameterFile ); /* Write updated parameters */ errNum = CloseFile(parameterFile); /* Close parameter text file */ errNum = CloseFile(dataLogFile); /* Close data log text file */ errNum = CloseFile(dataMatrixFile); /* Close data matrix ASCII file */ errNum = CloseFile(sigmaMatrixFile); /* Close sigma matrix ASCII file */ errNum = CloseFile(errorLogFile); /* Close error log text file */ errNum = CloseFile(logChannelFile); /* Close channel log text file */ } /*_ Clear Counters __________________________________________________ * * Function ClearCounters sets the SCA trigger low. This clears all * counters on the test jig and prepares it for the next event. */ int ClearCounters() { outp(PORT_11, 0x00); /* Set bit 7 of Port 11 low */ outp(PORT_5, 0x01); /* Set bit 7 of Port 5 low */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_11, 0x00 ); return(0); } /*_ Computer to Memory Enable ______________________________________ * * Function Comp_MemEnable enables computer to jig memory transfers. */ int Comp_MemEnable() { int new, old; old = inp( PORT_6 ); /* Read port's old value */ new = (old & 0xFC) | 0x2; /* Set bits 1..0 to 1,0 */ outp(PORT_6, new); /* Enables computer to jig memory transfers */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_6, new ); return(0); } /*_ Process "itemSelected" on Home Panel "1" ______________________ * * Function HitPanel_1 responds to the "itemSelected" on Panel "1". */ int HitPanel_1( itemSelected ) int itemSelected; { int numBytes; /* Number of bytes written */ switch ( itemSelected ) { case IC_RUN_TEST: /* user pressed the RUN button */ outp( PORT_7, 0xA0 ); /* Turn Tester power on */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_7, 0xA0 ); errNum = Set_PA_Volts( Vp_nom ); /* Apply nominal power to SCA */ Check_Err( WAIT ); passedAllTests = TRUE; Fmt( dataMatrix , "%s<%d\t", chipID ); Fmt( sigmaMatrix, "%s<%d\t", chipID ); Fmt( logChannel , "%s<%d\t", chipID ); SetCtrlVal( Panel_1, IC_RUN_LED , ON ); SetCtrlVal( Panel_1, IC_LED_PASS, OFF ); SetCtrlVal( Panel_1, IC_LED_FAIL, OFF ); errNum = StartNewEvent(); /* to reset the SCA shift register */ errNum = ClearCounters(); /* after the power is applied to the SCA */ delay( 2 ); /* Delay 5.0 second after power on */ errNum = RunDcTests(); /* Run specified DC test(s) */ errNum = RunFuncTests(); /* Run specified Functional test(s) */ errNum = RunParamTests(); /* Run specified Parametric test(s) */ Fmt( dataMatrix , "%s[w11a]<%s\t", datestr() ); Fmt( dataMatrix , "%s[w8a]<%s\t" , timestr() ); Fmt( sigmaMatrix, "%s[w11a]<%s\t", datestr() ); Fmt( sigmaMatrix, "%s[w8a]<%s\t" , timestr() ); Fmt( logChannel , "%s[w11a]<%s\t", datestr() ); Fmt( logChannel , "%s[w8a]<%s\t" , timestr() ); if ( passedAllTests ) { SetCtrlVal(Panel_1, IC_LED_PASS, ON ); Fmt( dataMatrix , "%s[w6a]<%s[w6]\n", "PASSED" ); Fmt( sigmaMatrix, "%s[w6a]<%s[w6]\n", "PASSED" ); Fmt( logChannel , "%s[w6a]<%s[w6]\n", "PASSED" ); } else { SetCtrlVal(Panel_1, IC_LED_FAIL, ON ); Fmt( dataMatrix , "%s[w6a]<%s[w6]\n", "FAILED" ); Fmt( sigmaMatrix, "%s[w6a]<%s[w6]\n", "FAILED" ); Fmt( logChannel , "%s[w6a]<%s[w6]\n", "FAILED" ); } SetCtrlVal(Panel_1, IC_RUN_LED, OFF ); numBytes = WriteLine( dataMatrixFile , dataMatrix , -1 ); /* Write data row */ numBytes = WriteLine( sigmaMatrixFile, sigmaMatrix, -1 ); /* Write sigma row */ numBytes = WriteLine( logChannelFile , logChannel , -1 ); /* Write channel row */ RingBell( 1 ); if ( hwDebug == OFF ) { outp( PORT_7, 0x00 ); /* Turn Tester Power off */ outp( PORT_6, 0x03 ); /* allow counter to output data 9-14-93 */ outp(PORT_11, 0x00); /* Set bit 7 of Port 11 low to reset counter 9-14-93*/ /* Breakpoint (); */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_11, 0x00 ); errNum = Set_PA_Volts( 0.0 ); /* Remove power to SCA */ Check_Err( WAIT ); chipID++; /* Auto increment Chip ID */ /* SetCtrlVal( Panel_1, IC_CHIP_ID, chipID ); */ } break; case IC_OPERATOR_NAME: errNum = GetCtrlVal(Panel_1, IC_OPERATOR_NAME, operatorName); Check_Err( WAIT ); break; case IC_CHIP_ID: errNum = GetCtrlVal(Panel_1, IC_CHIP_ID, &chipID); Check_Err( WAIT ); break; /* comment on 5-31-94 */ /* case IC_INC_CHIP_ID: chipID++; SetCtrlVal( Panel_1, IC_CHIP_ID, chipID ); break; */ case IC_SCOPE_PLOT: /* user pressed the Scope button or F5 */ errNum = HidePanel( Panel_1 ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_SCP ); errNum = SetActivePanel( Panel_SCP ); /* Activate Panel_SCP */ Check_Err( WAIT ); break; case IC_SCAo_PLOT: /* user pressed the SCAo button or F2 */ errNum = HidePanel( Panel_1 ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_SCAo ); errNum = SetActivePanel( Panel_SCAo ); /* Activate Panel_SCAo */ Check_Err( WAIT ); break; case IC_SIGMA_PLOT: /* user pressed the Sigma button or F3 */ errNum = HidePanel( Panel_1 ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_SIG ); errNum = SetActivePanel( Panel_SIG ); /* Activate Panel_SCAo */ Check_Err( WAIT ); break; case IC_SCA_PLOT: /* user pressed the SCA button or F4 */ errNum = HidePanel( Panel_1 ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_SCA ); errNum = SetActivePanel( Panel_SCA ); /* Activate Panel_SCA */ Check_Err( WAIT ); break; case IC_TLK_PLOT: /* user pressed the TLK button or F4 */ errNum = HidePanel( Panel_1 ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_TLK ); errNum = SetActivePanel( Panel_TLK ); /* Activate Panel_TLK */ Check_Err( WAIT ); break; case IC_SAW_PLOT: /* user pressed the SAW button or F4 */ errNum = HidePanel( Panel_1 ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_SAW ); errNum = SetActivePanel( Panel_SAW ); /* Activate Panel_SAW */ Check_Err( WAIT ); break; case IC_DIAG_TEST: /* user pressed the DIAG button or F4 */ errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_DIAG ); errNum = SetActivePanel( Panel_DIAG ); /* Activate Panel_DIAG */ errNum = SetActiveCtrl( DIAG_TEST ); /* Activate Panel_DIAG */ Check_Err( WAIT ); break; case IC_PRINTIT: /* user pressed the PRINT button */ errNum = OutputScreen( -1, null ); break; case IC_QUIT: /* user pressed the QUIT button */ quitTest = TRUE; break; default: break; } return(0); } /*_ Process "itemSelected" on Diagnostic Panel_DIAG ___________________ * * Function HitPanel_DIAG responds to the "itemSelected" on Panel_DIAG. */ int HitPanel_DIAG( itemSelected ) int itemSelected; { int numBytes; /* Number of bytes written */ switch ( itemSelected ) { case DIAG_RUN_DIAG: /* user pressed the diagnostic RUN button */ outp( PORT_7, 0xA0 ); /* Turn Tester power on */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_7, 0xA0 ); errNum = Set_PA_Volts( Vp_nom ); /* Apply nominal power to SCA */ Check_Err( WAIT ); passedAllTests = TRUE; Fmt( dataMatrix , "%s<%d\t", chipID ); Fmt( sigmaMatrix, "%s<%d\t", chipID ); SetCtrlVal( Panel_1, IC_RUN_LED , ON ); SetCtrlVal( Panel_1, IC_LED_PASS, OFF ); SetCtrlVal( Panel_1, IC_LED_FAIL, OFF ); errNum = SCA_DataAcq(); /* 6/18/96 Move SCA chip data to jig memory */ /* delay( 5.0 ); */ /* Delay 5.0 second */ errNum = RunDiagTest(); /* Run specified diagnostic test */ Fmt( dataMatrix , "%s[w11a]<%s\t", datestr() ); Fmt( dataMatrix , "%s[w8a]<%s\t" , timestr() ); Fmt( sigmaMatrix, "%s[w11a]<%s\t", datestr() ); Fmt( sigmaMatrix, "%s[w8a]<%s\t" , timestr() ); if ( passedAllTests ) { SetCtrlVal(Panel_1, IC_LED_PASS, ON ); Fmt( dataMatrix , "%s[w6a]<%s[w6]\n", "PASSED" ); Fmt( sigmaMatrix, "%s[w6a]<%s[w6]\n", "PASSED" ); } else { SetCtrlVal(Panel_1, IC_LED_FAIL, ON ); Fmt( dataMatrix , "%s[w6a]<%s[w6]\n", "FAILED" ); Fmt( sigmaMatrix, "%s[w6a]<%s[w6]\n", "FAILED" ); } SetCtrlVal(Panel_1, IC_RUN_LED, OFF ); numBytes = WriteLine( dataMatrixFile , dataMatrix , -1 ); /* Write data row */ numBytes = WriteLine( sigmaMatrixFile, sigmaMatrix, -1 ); /* Write sigma row */ RingBell( 1 ); if ( hwDebug == OFF ) { outp( PORT_7, 0x00 ); /* Turn Tester Power off */ outp( PORT_6, 0x03 ); /* allow counter to output data 9-14-93 */ outp(PORT_11, 0x00); /* Set bit 7 of Port 11 low */ Breakpoint (); errNum = SetCtrlVal( Panel_1, IC_DIO_96_11, 0x00 ); errNum = Set_PA_Volts( 0.0 ); /* Remove power to SCA */ Check_Err( WAIT ); chipID++; /* Auto increment Chip ID */ SetCtrlVal( Panel_1, IC_CHIP_ID, chipID ); } break; case DIAG_HOME: /* user pressed the Home button or F5 */ errNum = HidePanel( Panel_DIAG ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_1 ); errNum = SetActivePanel( Panel_1 ); /* Activate Panel_1 */ Check_Err( WAIT ); break; default: break; } return(0); } /*_ Process "itemSelected" on Data Panel "SAW" ________________________ * * Function HitPanel_SAW responds to the "itemSelected" on Panel "SAW". */ int HitPanel_SAW( itemSelected ) int itemSelected; { switch ( itemSelected ) { case SAW_HOME: /* user pressed the Home button or F1 */ errNum = HidePanel( Panel_SAW ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_1 ); errNum = SetActivePanel( Panel_1 ); /* Activate Panel_1 */ Check_Err( WAIT ); break; case SAW_SCAo_PLOT: /* user pressed the SCAo button or F2 */ errNum = HidePanel( Panel_SAW ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_SCAo ); errNum = SetActivePanel( Panel_SCAo ); /* Activate Panel_SCAo */ Check_Err( WAIT ); break; case SAW_SIGMA_PLOT: /* user pressed the SCAo button or F3 */ errNum = HidePanel( Panel_SAW ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_SIG ); errNum = SetActivePanel( Panel_SIG ); /* Activate Panel_Sigma */ Check_Err( WAIT ); break; case SAW_PRINTIT: /* user pressed the PRINT button */ errNum = OutputScreen( -1, null ); break; default: break; } return(0); } /*_ Process "itemSelected" on Data Panel "SCA" ________________________ * * Function HitPanel_SCA responds to the "itemSelected" on Panel "SCA". */ int HitPanel_SCA( itemSelected ) int itemSelected; { switch ( itemSelected ) { case SC_HOME: /* user pressed the Home button or F1 */ errNum = HidePanel( Panel_SCA ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_1 ); errNum = SetActivePanel( Panel_1 ); /* Activate Panel_1 */ Check_Err( WAIT ); break; case SC_SCAo_PLOT: /* user pressed the SCAo button or F2 */ errNum = HidePanel( Panel_SCA ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_SCAo ); errNum = SetActivePanel( Panel_SCAo ); /* Activate Panel_SCAo */ Check_Err( WAIT ); break; case SC_PRINTIT: /* user pressed the PRINT button */ errNum = OutputScreen( -1, null ); break; case SC_SIGMA_PLOT: /* user pressed the SCAo button or F3 */ errNum = HidePanel( Panel_SCA ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_SIG ); errNum = SetActivePanel( Panel_SIG ); /* Activate Panel_Sigma */ Check_Err( WAIT ); break; default: break; } return(0); } /*_ Process "itemSelected" on Pedestal Panel "SCAo" _____________________ * * Function HitPanel_SCAo responds to the "itemSelected" on Panel "SCAo". */ int HitPanel_SCAo( itemSelected ) int itemSelected; { switch ( itemSelected ) { case SCo_HOME: /* user pressed the Home button or F1 */ errNum = HidePanel( Panel_SCAo ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_1 ); errNum = SetActivePanel( Panel_1 ); /* Activate Panel_1 */ Check_Err( WAIT ); break; case SCo_SCA_PLOT: /* user pressed the SCA button or F4 */ errNum = HidePanel( Panel_SCAo ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_SCA ); errNum = SetActivePanel( Panel_SCA ); /* Activate Panel_SCA */ Check_Err( WAIT ); break; case SCo_PRINTIT: /* user pressed the PRINT button */ errNum = OutputScreen( -1, null ); break; case SCo_SIGMA_PLOT: /* user pressed the Sigma button or F3 */ errNum = HidePanel( Panel_SCAo ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_SIG ); errNum = SetActivePanel( Panel_SIG ); /* Activate Panel_SCA */ Check_Err( WAIT ); break; default: break; } return(0); } /*_ Process "itemSelected" on Scope Panel "SCP" _______________________ * * Function HitPanel_SCP responds to the "itemSelected" on Panel "SCP". */ int HitPanel_SCP( itemSelected ) int itemSelected; { int cell; int dataSource; int x_min, x_max; int y_min, y_max; switch ( itemSelected ) { case SCP_HOME: /* user pressed the Home button or F1 */ errNum = HidePanel( Panel_SCP); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_1 ); errNum = SetActivePanel( Panel_1 ); /* Activate Panel_1 */ Check_Err( WAIT ); break; case SCP_PRINTIT: /* user pressed the PRINT button */ errNum = OutputScreen( -1, null ); break; default: errNum = DeletePlots( Panel_SCP, SCP_SCOPE_GRAPH ); errNum = DisplayPanel( Panel_SCP ); errNum = SetActivePanel( Panel_SCP ); /* Activate Panel_SCP */ GetCtrlVal( Panel_SCP, SCP_X_MIN, &x_min ); GetCtrlVal( Panel_SCP, SCP_X_MAX, &x_max ); GetCtrlVal( Panel_SCP, SCP_Y_MIN, &y_min ); GetCtrlVal( Panel_SCP, SCP_Y_MAX, &y_max ); ConfigureAxes( Panel_SCP, SCP_SCOPE_GRAPH, 0, x_min, x_max, 0, y_min, y_max); errNum = GetCtrlVal( Panel_SCP, SCP_DATA_SOURCE, &dataSource ); for ( cell=x_min; cell<=x_max; cell++ ) { switch ( dataSource ) { case 0: PlotStripChart( Panel_SCP, SCP_SCOPE_GRAPH, SCAo, NUM_CHAN, cell*NUM_CHAN, 0, 4 ); break; case 1: PlotStripChart( Panel_SCP, SCP_SCOPE_GRAPH, sigmaSCAo, NUM_CHAN, cell*NUM_CHAN, 0, 4 ); break; case 2: PlotStripChart( Panel_SCP, SCP_SCOPE_GRAPH, SCA, NUM_CHAN, cell*NUM_CHAN, 0, 4 ); break; case 3: PlotStripChart( Panel_SCP, SCP_SCOPE_GRAPH, crossTalkDy, NUM_CHAN, cell*NUM_CHAN, 0, 4 ); break; case 4: PlotStripChart( Panel_SCP, SCP_SCOPE_GRAPH, crossTalk, NUM_CHAN, cell*NUM_CHAN, 0, 4 ); break; case 5: PlotStripChart( Panel_SCP, SCP_SCOPE_GRAPH, sawtooth, NUM_CHAN, cell*NUM_CHAN, 0, 4 ); break; } if ( (cell % 127) == 0 ) delay( 2.0 ); } break; } return(0); } /*_ Process "itemSelected" on Pedestal Sigma Panel "SIG" ______________ * * Function HitPanel_SIG responds to the "itemSelected" on Panel "SIG". */ int HitPanel_SIG( itemSelected ) int itemSelected; { switch ( itemSelected ) { case SIG_HOME: /* user pressed the Home button or F1 */ errNum = HidePanel( Panel_SIG ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_1 ); errNum = SetActivePanel( Panel_1 ); /* Activate Panel_1 */ Check_Err( WAIT ); break; case SIG_SCA_PLOT: /* user pressed the SCA button or F4 */ errNum = HidePanel( Panel_SIG ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_SCA ); errNum = SetActivePanel( Panel_SCA ); /* Activate Panel_SCA */ Check_Err( WAIT ); break; case SIG_SCAo_PLOT: /* user pressed the Sigma button or F3 */ errNum = HidePanel( Panel_SIG ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_SCAo ); errNum = SetActivePanel( Panel_SCAo ); /* Activate Panel_SCA */ Check_Err( WAIT ); break; case SIG_PRINTIT: /* user pressed the PRINT button */ errNum = OutputScreen( -1, null ); break; default: break; } return(0); } /*_ Process "itemSelected" on Cross Talk Panel "TLK" __________________ * * Function HitPanel_TLK responds to the "itemSelected" on Panel "TLK". */ int HitPanel_TLK( itemSelected ) int itemSelected; { switch ( itemSelected ) { case TLK_HOME: /* user pressed the Home button or F1 */ errNum = HidePanel( Panel_TLK ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_1 ); errNum = SetActivePanel( Panel_1 ); /* Activate Panel_1 */ Check_Err( WAIT ); break; case TLK_SCAo_PLOT: /* user pressed the SCAo button or F2 */ errNum = HidePanel( Panel_TLK ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_SCAo ); errNum = SetActivePanel( Panel_SCAo ); /* Activate Panel_SCAo */ Check_Err( WAIT ); break; case TLK_SIGMA_PLOT: /* user pressed the SCAo button or F3 */ errNum = HidePanel( Panel_TLK ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_SIG ); errNum = SetActivePanel( Panel_SIG ); /* Activate Panel_Sigma */ Check_Err( WAIT ); break; case TLK_PRINTIT: /* user pressed the PRINT button */ errNum = OutputScreen( -1, null ); break; default: break; } return(0); } /*_ Increment Address Counter ____________________________________ * * Function IncAddrCntr advances the jig memory's address counter * one count. */ int IncAddrCntr() { outp(PORT_8, 0x01); /* Set bit 0 of Port 8 high */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_8, 0x01 ); return(0); } /*_________________________________ * * Log SCA test data to a disk file. */ void LogSCA() { int cell, chan; /* Loop indices */ int numBytes; /* Number of bytes written */ for ( cell=0; cell= FIRST_GOOD_CELL) { /* Skip spikes in first cells */ SCAo_chan[chan] += f; /* Sum of value/channel matrix */ sigmaSCAo_chan[chan]+=v2; /* Sum of value^2/channel matrix */ } } } } errNum = HidePanel( Panel_1 ); errNum = DeletePlots( Panel_SCAo, SCo_PED ); errNum = DeletePlots( Panel_SIG, SIG_SIGMA ); errNum = ClearGraphicsScreen( LT_GRAY ); errNum = DisplayPanel( Panel_SCAo ); errNum = SetActivePanel( Panel_SCAo ); /* Activate Panel_SCAo */ Check_Err( WAIT ); for ( chan=0; chan= 0 ) { errNum = SetActiveCtrl( IC_DC_TEST ); switch ( testNum ) { case ALL: /* changed to ..._DC-2; for debugging */ /* has to be ..._DC; */ for ( test=0; test= 0 ) { errNum = SetActiveCtrl( DIAG_TEST ); errNum = 0; /* Clear previous error indication */ SetCtrlVal( Panel_1, IC_ERR_NUM, errNum ); Fmt( errStr, "" ); /* Clear previous error indication */ SetCtrlVal( Panel_1, IC_ERR_STR, errStr ); errNum = SetCtrlVal( Panel_1, IC_TEST_NUM, testNum ); switch ( testNum ) { case 0: errNum = SelectAllChanels(); /* Select all 16 channels of SCA */ errNum = SelTriangSig(); /* Select triangular signal into SCA */ Set_SCA_Volts( 3.44 ); /* Sets DC level voltage to SCA inputs */ Display_DIO_Ports_6_11(); errNum = SCA_DataAcq(); /* Move SCA chip data to jig memory */ errNum = ReadJigMem(); /* LogSCA(); */ break; case 1: errNum = SelectAllChanels(); /* Select all 16 channels of SCA */ errNum = SelSAsig(); /* Select SA output signal into SCA */ Set_SCA_Volts( 3.44 ); /* Sets DC level voltage to SCA inputs */ Display_DIO_Ports_6_11(); errNum = SCA_DataAcq(); /* Move SCA chip data to jig memory */ errNum = ReadJigMem(); /* LogSCA(); */ break; case 2: errNum = WriteJigMem(); break; case 3: errNum = ReadJigMem(); /* for ( chan=0; chan 0)) { Fmt( errStr, "%s", " Data are not ZERO" ); SetCtrlVal( Panel_1, IC_ERR_STR, errStr ); errNum = errNum + 1; SetCtrlVal( Panel_1, IC_ERR_NUM, errNum ); } pattern = (pattern+1) % 4096; /* Generate H/W test pattern */ } } break; case 11: errNum = 0; pattern = 0; for ( cell=0; cell 0)&&(sigmaSCAo[cell][chan] <0.5)) { Fmt( errStr, "%s", " have sigma > 0.5000" ); SetCtrlVal( Panel_1, IC_ERR_STR, errStr ); errNum = errNum + 1; SetCtrlVal( Panel_1, IC_ERR_NUM, errNum ); } else {sigmaSCAo[cell][chan] = 0 ;} pattern = (pattern+1) % 4096; /* Generate H/W test pattern */ } } break; default: break; } } Display_DIO_Ports_6_11(); return(0); } /*_ RUN FUNC TEST ____________________________________________________ * * Function RunFuncTest runs a single Functional test on the SCA Chip. */ int RunFuncTest( testNum ) int testNum; { double dy; int cell, chan; /* Loop indices */ int pattern; /* Test pattern */ int temp,ScaNum; errNum = 0; /* Clear previous error indication */ SetCtrlVal( Panel_1, IC_ERR_NUM, errNum ); Fmt( errStr, "" ); /* Clear previous error indication */ SetCtrlVal( Panel_1, IC_ERR_STR, errStr ); errNum = SetCtrlVal( Panel_1, IC_TEST_NUM, testNum ); switch ( testNum ) { case 0: /* Check cross talk between channels when injecting a non-overlapping */ /* in time pulses to all 16 channels. The graphical display shows */ /* the cross talk. */ /* errNum = WalkingPulse(); */ /* Non-overlapping pulses all SCA channels */ /* errNum = SelDCsigOddEven(); */ /* Select DC signal inject into SCA */ /* Set_SCA_Volts( 1.84 ); */ /* Sets DC level voltage to SCA inputs */ Display_DIO_Ports_6_11(); /* outp( PORT_7,0x80); */ /* fee to allow FPGA advance mem counter */ delay (0.1); errNum = SCA_DataAcq(); /* Move SCA chip data to jig memory */ /* Breakpoint (); */ errNum = GetCtrlVal(Panel_1,IC_select_SCA, &temp); /* fee read selected SCA */ if (temp == 4) { for ( temp = 0;temp < 3 ; temp ++) { ScaNum = temp | 0x80 ; /* fee to keep bit 7 on (power to tester) */ outp(PORT_7, ScaNum); /* fee Set A13,A14 for selected SCA */ errNum = ReadCrossTalk(); } } else /* run selected SCA or last SCA */ ScaNum = temp | 0x80 ; /* fee to keep bit 7 on (power to tester) */ outp(PORT_7, ScaNum); /* fee Set A13,A14 for selected SCA */ errNum = ReadCrossTalk(); dy = -(500.0 - 650.0) / 15.0; for ( cell=0; cell= 0 ) { errNum = SetActiveCtrl( IC_FUNC_TEST ); switch ( testNum ) { case ALL: for ( test=0; test= 0 ) { errNum = SetActiveCtrl( IC_PARAM_TEST ); switch ( testNum ) { case ALL: for ( test=0; test error) */ Check_Err( WAIT ); return(0); } /*_ SCA Chip to Jig Memory Enable _________________________________ * * Function SCA_MemEnable enables SCA chip to jig memory transfers. */ int SCA_MemEnable() { int new, old; old = inp( PORT_6 ); /* Read port's old value */ /* new = (old & 0xFC); */ /* Set bits 1..0 to zero */ new = 0x8 ; /* fee enable card 0 & set bit 1,0 to 0 */ outp( PORT_6, new ); /* fee Enables SCA chip to jig memory transfers */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_6, new ); return(0); } /*_ SCA Test Data to Jig Memory Enable _________________________________ * * Function SCA_MemTest enables SCA Test Data to jig memory transfers. */ int SCA_MemTest() { int new, old; old = inp( PORT_6 ); /* Read port's old value */ new = (old & 0xFC) | 0x3; /* Set bits 1..0 to 1,1 */ outp( PORT_6, new ); /* Enables SCA chip to jig memory transfers */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_6, new ); return(0); } /*_ Select DC Signal Into SCA Chip _______________________________ * * Function SelDCsig Selects DC signal into SCA chip. */ int SelDCsig() { int new, old; old = inp( PORT_6 ); /* Read port's old value */ new = (old & 0xF3) | 0x8; /* Set bits 3..2 to 1,0 */ outp( PORT_6, new ); /* Select DC signal into SCA chip */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_6, new ); return(0); } /*_ Select DC Signal Into Odd/Even SCA Cells _________________________ * * Function SelDCsigOddEven Selects DC signal into odd/even SCA cells. */ int SelDCsigOddEven() { int new, old; old = inp( PORT_6 ); /* Read port's old value */ new = (old & 0xF3) | 0xC; /* Set bits 3..2 to 1,1 */ outp( PORT_6, new ); /* Select DC signal into odd/even SCA cells */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_6, new ); return(0); } /*_ Select all 16 Input Channels of SCA Chip __________________________ * * Function SelectAllChanels selects all 16 input channels of SCA chip. */ int SelectAllChanels() { int new, old; old = inp( PORT_7 ); /* Read port's old value */ new = (old & 0xFC) | 0x03; /* Set bits 1..0 to 1,1 */ outp( PORT_7, new ); /* Select all 16 input channels of SCA chip */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_7, new ); return(0); } /*_ Select 8 Even Input Channels of SCA Chip ___________________________ * * Function SelectEvenChanels selects 8 even input channels of SCA chip. */ int SelectEvenChanels() { int new, old; old = inp( PORT_7 ); /* Read port's old value */ new = (old & 0xFC) | 0x01; /* Set bits 1..0 to 0,1 */ outp( PORT_7, new ); /* Select 8 even input channels of SCA chip */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_7, new ); return(0); } /*_ Select 8 odd input channels of SCA chip __________________________ * * Function SelectOddChanels selects 8 odd input channels of SCA chip. */ int SelectOddChanels() { int new, old; old = inp( PORT_7 ); /* Read port's old value */ new = (old & 0xFC) | 0x00; /* Set bits 1..0 to 0,0 */ outp( PORT_7, new ); /* Select 8 odd input channels of SCA chip */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_7, new ); return(0); } /*_ Run SelectPulsedChanels ________________________________________ * * Function SelectPulsedChanels() select pulsed channels of SAS * fee * NOTED : channel select Shift Register is layout in order of * chan 0,2,4,6,8,10,12,14,15,13,11,9,7,5,3,1 . */ int SelectPulsedChanels() { int i,ch,TB,inc,start,end; int muxSetting,temp,Select_Chan; /* Tester DC out select 16-1 MUX */ double adcTotal,ID; int ID_Data,data,bit,CK,min; /* there are 16 channels per SAS (0..15) */ /* selected channels for each SAS will be the same */ for ( ch=0; ch<16; ch++ ) { for ( TB=0; TB<512; TB++ ) { Test[TB][ch] = 0; } } /* initialize Select Channel Array to all zero */ for ( ch=0; ch<16; ch++ ) { Select[ch] = 0; } errNum = GetCtrlVal(Panel_1,IC_Select_Chan, &temp); /* fee read selected channels */ /* Set the Select channel Array */ /* set the selected chan and the 8th from the selected */ if ( temp < 4 ) { start = temp ; inc = 3; end =start +5 ; } if ((3 < temp )&&(temp < 8 )) { start = temp + 4 ; inc = 3; end =start +5 ; } /* Set all the Even channels 0,2,4..14 */ if ( temp == 8 ) { start = 0 ; inc = 0; end =start + 8 ; } /* Set all the Odd channels 1,3,5..15 */ if ( temp == 9 ) { start = 8 ; inc = 0; end =start + 8 ; } /* Set all channels */ if ( temp == 10 ) { start = 0 ; inc = 0; end =start + 16 ; } /* Un-Set all the channels */ if ( temp == 11 ) { start = 16 ; inc = 0; end =start + 0 ; } /* initialize Select Channel Array to 1 for each selected channel */ for ( ch=start; ch< end; ch ++ ) { Select[ch] = 1; ch = ch + inc ; } outp( PORT_6,0x0B); /* enable card 0 for clocking GATED_CK1 & CK2 */ min = -1; for ( ch=15; ch > min; ch -- ) { if ( Select[ch] == 0 ) { data = 0xA0; CK = 0xB0; } else { data = 0xA8; CK = 0xB8; } outp(PORT_7,data); /* clock CK2 LOW */ outp(PORT_7,CK); /* clock CK2 HIGH */ outp(PORT_7,0xB0); /* clock CK2 LOW */ } /* Breakpoint (); */ } /*_ Select SA Output Signal Into SCA Chip ____________________________ * * Function SelSAsig Select SA output signal into SCA chip. */ int SelSAsig() { int new, old; old = inp( PORT_6 ); /* Read port's old value */ new = (old & 0xF3) | 0x04; /* Set bits 3..2 to 0,1 */ outp( PORT_6, new ); /* Select SA output signal into SCA chip */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_6, new ); return(0); } /*_ Select Triangular Signal into SCA Chip ____________________________ * * Function SelTriangSig selects a triangular signal into the SCA chip. */ int SelTriangSig() { outp( PORT_6, 0x00 ); /* Select triangular signal into the SCA */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_6, 0x00 ); return(0); } /*____________________________________ * * Sets DC level voltage to SCA inputs. */ int Set_SCA_Volts( DACvolts ) double DACvolts; { dacVolts = DACvolts; errNum = AO_VWrite( AIO_BD, CHAN_1, DACvolts ); errNum = SetCtrlVal( Panel_1, IC_INPUT, DACvolts ); if ( DACvolts > 0.1 ) delay( 0.5 ); /* Delay 0.5 seconds to let voltage stabilize */ if (errNum < 0) { Fmt( errStr, "%s", "Set_SCA_Volts()" ); return(-1); } return(0); } /*_ Start New Event ______________________________________________ * * Function StartNewEvent sets the SCA trigger hign. This starts * the new event. */ int StartNewEvent() { outp(PORT_11, 0x80); /* Set bit 7 of Port 11 high */ outp(PORT_5, 0x01); /* Set bit 7 of Port 5 high */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_11, 0x80 ); return(0); } /*_ Strobe Data __________________________________________________ * * Function StrobeData sets the SCA trigger low. This clears all * counters on the test jig and prepares it for the new event. */ int StrobeData() { int new,old; old = inp( PORT_8 ); /* fee Read port's old value */ new = (old & 0x0E); /* Set bits 0 to zero */ outp( PORT_8, new ); /* fee to allow add counter run */ /* outp(PORT_8, 0x00); */ /* Set bit 0 of Port 8 low */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_8, 0x00 ); return(0); } /*_ Test Jig Status ________________________________________________ * * Function TestJigStatus reads test jig status and re-tries until * either a non zero status is obtained or it times out. 0 ==> * ready. */ int TestJigStatus() { int iteration; /* Tries to get non-zero status */ int status; /* Status of the test jig. */ for ( iteration=0; iteration> 8); /* Shift right 8 (high-4 data bits) */ outp( PORT_10, high ); /* Write high 8-bits */ StrobeData(); /* Set Port 8 bit 0 low */ IncAddrCntr(); /* Set Port 8 bit 0 high */ } } outp( PORT_8, 0x01 ); /* Put jig Memory chip into read-mode */ errNum = SetCtrlVal( Panel_1, IC_DIO_96_8, 0x01 ); errNum += DIG_Prt_Config(DIO_BD, 9, DIO_NO_HNDSHK, DIO_DIR_IN); errNum += DIG_Prt_Config(DIO_BD, 10, DIO_NO_HNDSHK, DIO_DIR_IN); return(0); } /*~ COMMON FUNCTIONS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * The following common functions interface with National Instrument's * Graphical User Interface and I/O cards that drive LBL's IC Tester * Hardware for PA-4, PA-16, SA-16, PASA, and SCA ICs. These functions * run under Lab Windows C, which does not support User Libraries. */ /*_______________________________________________________ * * Update error status displays, if an error has occured. */ void Check_Err( wait ) int wait; { int numBytes; /* Number of bytes written */ if (errNum < 0) { errCount++; SetCtrlVal( Panel_1, IC_ERR_COUNT, errCount ); SetCtrlVal( Panel_1, IC_ERR_NUM , errNum ); SetCtrlVal( Panel_1, IC_ERR_STR , errStr ); RingBell( 2 ); Fmt( newError, "%s[w16]<%s\t" , "Error " ); Fmt( newError, "%s[w16a]<%s\t", "Fatal " ); Fmt( newError, "%s[a]<%i\t" , errNum ); Fmt( newError, "%s[w25a]<%s\t", errStr ); Fmt( newError, "%s[w11a]<%s\t", datestr() ); Fmt( newError, "%s[w8a]<%s\n" , timestr() ); numBytes = WriteLine( errorLogFile, newError, -1 ); /* Log error */ errNum = 0; /* Clear previous error indication */ Fmt( errStr, "" ); /* Clear previous error indication */ if ( wait ) { /* Generate a Pop-up "Do you want to proceed? */ } } } /*______________________________________________ * * Clear the PC-DIO-96 board's ports 0..8 and 11. */ int DIO_Clear() { outp(PORT_0,0); /* Clear DIO Port 0 */ outp(PORT_1,0); /* Clear DIO Port 1 */ outp(PORT_2,0); /* Clear DIO Port 2 */ outp(PORT_3,0); /* Clear DIO Port 3 */ outp(PORT_4,0); /* Clear DIO Port 4 */ outp(PORT_5,0); /* Clear DIO Port 5 */ outp(PORT_6,0); /* Clear DIO Port 6 */ outp(PORT_7,0); /* Clear DIO Port 7 */ outp(PORT_8,0); /* Clear DIO Port 8 */ outp(PORT_11,0); /* Clear DIO Port 11 */ return(0); } /*__________________________________________________________ * * Init the PC-DIO-96 board so ports 0..8 and 11 are outputs. * Ports 9 and 10 (bits 0..3) are bi-directional data bus. * Port 10 (bits 4..7) are input only. */ int DIO_Init() { int i; errNum += DIG_Prt_Config(DIO_BD, 0, DIO_NO_HNDSHK, DIO_DIR_OUT); errNum += DIG_Prt_Config(DIO_BD, 1, DIO_NO_HNDSHK, DIO_DIR_OUT); errNum += DIG_Prt_Config(DIO_BD, 2, DIO_NO_HNDSHK, DIO_DIR_OUT); errNum += DIG_Prt_Config(DIO_BD, 3, DIO_NO_HNDSHK, DIO_DIR_OUT); errNum += DIG_Prt_Config(DIO_BD, 4, DIO_NO_HNDSHK, DIO_DIR_OUT); errNum += DIG_Prt_Config(DIO_BD, 5, DIO_NO_HNDSHK, DIO_DIR_OUT); errNum += DIG_Prt_Config(DIO_BD, 6, DIO_NO_HNDSHK, DIO_DIR_OUT); errNum += DIG_Prt_Config(DIO_BD, 7, DIO_NO_HNDSHK, DIO_DIR_OUT); errNum += DIG_Prt_Config(DIO_BD, 8, DIO_NO_HNDSHK, DIO_DIR_OUT); errNum += DIG_Prt_Config(DIO_BD, 9, DIO_NO_HNDSHK, DIO_DIR_IN ); errNum += DIG_Prt_Config(DIO_BD, 10, DIO_NO_HNDSHK, DIO_DIR_IN ); errNum += DIG_Prt_Config(DIO_BD, 11, DIO_NO_HNDSHK, DIO_DIR_OUT); if (errNum < 0) { Fmt( errStr, "%s", "DIO_Init ports" ); return(-1); } return(0); } /*_______________________________________________ * * Display the status of ADC port 0 in volts. */ int Display_ADC_Port_0() { errNum += AI_VRead( AIO_BD, CHAN_0, GAIN_1, &valADC_0 ); errNum += SetCtrlVal( Panel_1, IC_ADC_0, valADC_0 ); if (errNum < 0) { Fmt( errStr, "%s", "Display_ADC_Ports()" ); return(-1); } return(0); } /*____________________________________________________ * * Display the status of the DIO-96 ports 11..6 in hex. */ int Display_DIO_Ports_6_11() { int i, value; Fmt( hexDIO, "%s", "" ); for ( i=11; i>=6; i-- ) { errNum = DIG_In_Port( DIO_BD, i, &value ); if (errNum < 0) { Fmt( errStr, "%s", "Display_DIO_Ports() - read" ); return(-1); } Fmt( hexDIO, "%s[w2a]<%x[p0]", value ); switch ( i ) { case 6 : errNum = SetCtrlVal( Panel_1, IC_DIO_96_6, value ); break; case 7 : errNum = SetCtrlVal( Panel_1, IC_DIO_96_7, value ); break; case 8 : errNum = SetCtrlVal( Panel_1, IC_DIO_96_8, value ); break; case 9 : errNum = SetCtrlVal( Panel_1, IC_DIO_96_9, value ); break; case 10 : errNum = SetCtrlVal( Panel_1, IC_DIO_96_10, value ); break; case 11 : errNum = SetCtrlVal( Panel_1, IC_DIO_96_11, value ); break; } if (errNum < 0) { Fmt( errStr, "%s", "Display_DIO_Ports_6_11() - write" ); return(-1); } } return(0); } /*_ GET LOW/HIGH LIMITS ________________________________________________________ * * Function Get_Low_High_Limits reads specified low and high limits for each of * the DC, Functional, and Parametric tests that Chinh Vu defined in his Memos * "Re: IC Automatic Test Station" dated 8/18/92, "16 Channel Preamp Test * Procedures" dated 9/10/92, and "16 Channel Shaper-amp Test Procedures" dated * 9/10/92. */ int Get_Low_High_Limits( double D[][3], double F[][3], double P[][3] ) { int fileLimits; /* File handle for low/high limits returned by OpenFile */ int numInDc; /* Number of hex integer to read for DC tests */ int numInFunc; /* Number of hex integer to read for Functional tests */ int numInParam; /* Number of hex integer to read for Parametric tests */ fileLimits = OpenFile( limitFileName, READ_ONLY, NO_TRUNC, ASCII ); ScanFile( fileLimits, "%s>%i", &numInDc ); if ( numInDc != (3*NUM_TESTS_DC) ) { errNum = -1; Fmt( errStr, "%s", "Error reading Limits settings for DC tests" ); return(-1); } ScanFile( fileLimits, "%s>%*f[x]", numInDc, D ); /* Read DC Limit settings */ ScanFile( fileLimits, "%s>%i", &numInFunc ); if ( numInFunc != (3*NUM_TESTS_FUNC) ) { errNum = -1; Fmt( errStr, "%s", "Error reading Limits settings for Functional tests" ); return(-1); } ScanFile( fileLimits, "%s>%*f[x]", numInFunc, F ); /* Read Functional Limit settings */ ScanFile( fileLimits, "%s>%i", &numInParam ); if ( numInParam != (3*NUM_TESTS_PARA) ) { errNum = -1; Fmt( errStr, "%s", "Error reading Limits settings for Parametric tests" ); return(-1); } ScanFile( fileLimits, "%s>%*f[x]", numInParam, P ); /* Read Parametric Limit settings */ CloseFile( fileLimits ); return(0); } /*______________________________ * * Log test data to a disk file. */ void LogTestData( int testType, int testNum, double data[] ) { int numBytes; /* Number of bytes written */ switch ( testType ) { case 0: Fmt( newData, "%s<%s\t", "DC" ); break; case 1: Fmt( newData, "%s<%s\t", "Func" ); break; case 2: Fmt( newData, "%s<%s\t", "Param" ); break; } Fmt( newData, "%s[a]<%d\t" , testNum ); Fmt( newData, "%s[a]<%d\t" , chipID ); Fmt( newData, "%s[a]<%f[p3]\t", data[0] ); Fmt( newData, "%s[a]<%f[p3]\t", data[1] ); Fmt( newData, "%s[a]<%f[p3]\t", data[2] ); Fmt( newData, "%s[a]<%f[p3]\t", adcSigma ); if ( (data[0] <= data[1]) && (data[1] <= data[2]) ) { Fmt( newData, "%s[a]<%s\t", " " ); passedTest = TRUE; } else { Fmt( newData, "%s[a]<%s\t", "FAILED" ); passedTest = FALSE; SetCtrlVal(Panel_1, IC_LED_FAIL, ON ); } passedAllTests &= passedTest; Fmt( newData, "%s[w9a]<%s\t", timestr() ); if ( hwDebug ) { Fmt( newData, "%s[w13a]<%s\t" , hexDIO ); Fmt( newData, "%s[a]<%f[p3]\t", valADC_3 ); Fmt( newData, "%s[a]<%f[p3]\t", valADC_2 ); Fmt( newData, "%s[a]<%f[p3]\t", valADC_1 ); Fmt( newData, "%s[a]<%f[p3]\t", valADC_0 ); Fmt( newData, "%s[a]<%f[p2]\t", dacVolts ); } Fmt( newData, "%s[a]<%d" , errCount ); Fmt( newData, "%s[w1a]<%s[w1]\n", ";" ); numBytes = WriteLine( dataLogFile, newData, -1 ); /* Log results */ if ( breakOnFail && !passedTest ) breakpoint(); /* Permits operator to adjust lower & upper bounds */ /* Write Data and Sigma Matrices */ Fmt( dataMatrix , "%s[a]<%f[p3]\t", data[1] ); Fmt( sigmaMatrix, "%s[a]<%f[p3]\t", adcSigma ); if ( testType == 0 ) Fmt( logChannel , "%s[a]<%f[p3]\t", data[1] ); } /*_________________________________ * * Read Parameters from a disk file. */ void ReadParameters( int parameterFile ) { int numSpec; /* Number of format specifiers written */ numSpec = ScanFile( parameterFile, "%s>%d", &chipID ); /* Read parameter */ numSpec = ScanFile( parameterFile, "%s>%s", operatorName ); /* Read parameter */ numSpec = ScanFile( parameterFile, "%s>%s", dataFileName ); /* Read parameter */ } /*______________________________ * * Ring computer bell "n" times. */ void RingBell( int n ) { int i; for ( i=0; i