Sub ComposeMeasString(i As Integer, strCommandString As String, strCommand As String) 'This routine generates the Command String for a measurement which can be send to the uTracer 'The values for Anode, Screen, Grid and filament settings are supplied by intNmeas which points 'to a measurement in the globally defined Matrix dblMeasMx Dim intA As Integer 'integer representation of Anode voltage Dim intS As Integer 'integer representation of Screen voltage Dim intG As Integer 'integer representation of Grid voltage Dim intF As Integer 'integer representation of Fillament voltage Dim strA As String 'string represenation of Hex Anode voltage Dim strS As String 'string represenation of Hex Screen voltage Dim strG As String 'string represenation of Hex Grid voltage Dim strF As String 'string represenation of Hex Fillamenf voltage Dim dblTemp As Double 'temporary variable Dim dblA As Double 'temporary variable Dim dblB As Double 'temporary variable 'Anode Dim dblAnodeR1 As Double Dim dblAnodeR2 As Double dblAnodeR1 = 6800# dblAnodeR2 = 470000# dblTemp = (1024# / 5#) * (dblAnodeR1 / (dblAnodeR1 + dblAnodeR2)) * _ (dblMeasMX(i, intVa) + dblVsupSystem) * dblCalVar1 intA = Int(dblTemp) strA = "0000" Mid$(strA, 5 - Len(Hex$(intA))) = Hex$(intA) frmCom.lblValueVa.Caption = Decimals(dblMeasMX(i, intVa), 1) frmCom.lblIntegerVa.Caption = intA frmCom.lblStringVa.Caption = strA 'Screen Dim dblScreenR1 As Double Dim dblScreenR2 As Double dblScreenR1 = 6800# dblScreenR2 = 470000# dblTemp = (1024# / 5#) * (dblScreenR1 / (dblScreenR1 + dblScreenR2)) * _ (dblMeasMX(i, intVs) + dblVsupSystem) * dblCalVar2 intS = Int(dblTemp) strS = "0000" Mid$(strS, 5 - Len(Hex$(intS))) = Hex$(intS) frmCom.lblValueVs.Caption = Decimals(dblMeasMX(i, intVs), 1) frmCom.lblIntegerVs.Caption = intS frmCom.lblStringVs.Caption = strS 'Control grid 'the 0.00001 was added because sometimes Int(-1024*0.50) would return -1! intG = Int(((-1024# * dblMeasMX(i, intVg) * dblCalVar6) / 50#) + 0.00001) strG = "0000" Mid$(strG, 5 - Len(Hex$(intG))) = Hex$(intG) frmCom.lblValueVg.Caption = Decimals(dblMeasMX(i, intVg), 2) frmCom.lblIntegerVg.Caption = intG frmCom.lblStringVg.Caption = strG 'Filament dblTemp = 1024# * (dblMeasMX(i, intVf) * dblMeasMX(i, intVf)) / (dblVsupSystem * dblVsupSystem) intF = Int(dblTemp) strF = "0000" Mid$(strF, 5 - Len(Hex$(intF))) = Hex$(intF) frmCom.lblValueVf.Caption = Decimals(dblMeasMX(i, intVf), 2) frmCom.lblIntegerVf.Caption = intF frmCom.lblStringVf.Caption = strF frmCom.Refresh strCommandString = strCommand + strA + strS + strG + strF End Sub Sub DeComposeString(i As Integer, strResultString As String) 'This routine analyzes the result string which is returned by the uTracer after a measurement point. 'The routine devides the total string into 8 sub-strings, displays the strings and the integer and decimal 'equivalents in the communication frame. It furthermore distils the anode and screen grid currents from 'the data and stores it in the Measurement Matrix Dim strStat As String Dim intStat As String Dim strWord As String Dim lngWord As String Dim dblWord1 As Double Dim dblWord2 As Double Dim dblWord3 As Double Dim dblWord4 As Double Dim dblWord5 As Double Dim dblWord6 As Double Dim dblWord7 As Double Dim dblWord8 As Double Dim n As Integer Dim intGainTab(7) As Integer Dim dblGainIa As Double Dim dblGainIs As Double Dim intGainIa As Integer Dim intGainIs As Integer Dim intGainIndexIa As Integer Dim intGainIndexIs As Integer Dim intMaxGain As Integer Dim intAverageTab(7) As Integer Dim dblAveraging As Double intGainTab(0) = 1 intGainTab(1) = 2 intGainTab(2) = 5 intGainTab(3) = 10 intGainTab(4) = 20 intGainTab(5) = 50 intGainTab(6) = 100 intGainTab(7) = 200 intAverageTab(0) = 1 intAverageTab(1) = 1 intAverageTab(2) = 1 intAverageTab(3) = 1 intAverageTab(4) = 2 intAverageTab(5) = 2 intAverageTab(6) = 4 intAverageTab(7) = 8 'Set Here the Pulse Length Dim dblSamplePulseLength As Double dblSamplePulseLength = 0.001 'All parameters related to the Anode current measurement Dim dblAnodeRs As Double Dim dblIa As Double Dim dblIaComp As Double dblAnodeRs = 17.8 'All parameters related to the Screen current measurement Dim dblScreenRs As Double Dim dblIs As Double Dim dblIsComp As Double dblScreenRs = 17.8 'All parameters related to the Anode voltage measurement Dim dblVa As Double Dim dblAnodeDivR1 As Double Dim dblAnodeDivR2 As Double dblAnodeDivR1 = 6800# dblAnodeDivR2 = 470000# 'All parameters related to the Screen voltage measurement Dim dblVs As Double Dim dblScreenDivR1 As Double Dim dblScreenDivR2 As Double dblScreenDivR1 = 6800# dblScreenDivR2 = 470000# 'All parameters related to the power supply voltage Dim dblVsup As Double Dim dblVsupR1 As Double Dim dblVsupR2 As Double dblVsupR1 = 1800 dblVsupR2 = 6800 'All parameters related to the general negative power supply Dim dblVmin As Double Dim dblVminR1 As Double Dim dblVminR2 As Double dblVminR1 = 2000# dblVminR2 = 47000# strStat = Mid$(strResultString, 1, 2) intStat = Val("&H" + strStat) frmCom.lblStat.Caption = strStat 'note the hex status byte 11 corresponds to 17 dec If intStat = 17 Then blnComplianceError = True End If For n = 1 To 9 strWord = Mid$(strResultString, 3 + 4 * (n - 1), 4) lngWord = Val("&H" + strWord) Select Case n Case 1 'dblIa is the anode current frmCom.lblStr1.Caption = strWord frmCom.lblInt1.Caption = lngWord dblIa = (CDbl(lngWord) * (5# / 1024#) * 1000#) * dblCalVar3 / dblAnodeRs dblMeasMX(i, intIa) = dblIa Case 2 'dblIaComp is the anode current before PGA frmCom.lblStr2.Caption = strWord frmCom.lblInt2.Caption = lngWord dblIaComp = (CDbl(lngWord) * (5# / 1024#) * 1000#) * dblCalVar3 / dblAnodeRs frmCom.lblVal2.Caption = Decimals(dblIaComp, 1) Case 3 'dblIs is the screen current frmCom.lblStr3.Caption = strWord frmCom.lblInt3.Caption = lngWord dblIs = (CDbl(lngWord) * (5# / 1024#) * 1000#) * dblCalVar4 / dblScreenRs dblMeasMX(i, intIs) = dblIs Case 4 'dblIsComp is the screen current before PGA frmCom.lblStr4.Caption = strWord frmCom.lblInt4.Caption = lngWord dblIsComp = (CDbl(lngWord) * (5# / 1024#) * 1000#) * dblCalVar4 / dblScreenRs frmCom.lblVal4.Caption = Decimals(dblIsComp, 1) Case 5 'The anode voltage after the measurement pulse frmCom.lblStr5.Caption = strWord frmCom.lblInt5.Caption = lngWord dblVa = CDbl(lngWord) * (5# / 1024#) * _ ((dblAnodeDivR1 + dblAnodeDivR2) / (dblAnodeDivR1 * dblCalVar1)) - dblVsupSystem frmCom.lblVal5.Caption = Decimals(dblVa, 1) Case 6 'The screen voltage after the measurement pulse frmCom.lblStr6.Caption = strWord frmCom.lblInt6.Caption = lngWord dblVs = CDbl(lngWord) * (5# / 1024#) * _ ((dblScreenDivR1 + dblScreenDivR2) / (dblScreenDivR1 * dblCalVar2)) - dblVsupSystem frmCom.lblVal6.Caption = Decimals(dblVs, 1) Case 7 'The supply voltage frmCom.lblStr7.Caption = strWord frmCom.lblInt7.Caption = lngWord dblVsup = CDbl(lngWord) * (5# / 1024#) * ((dblVsupR1 + dblVsupR2) / dblVsupR1) * dblCalVar5 dblVsupMeas = dblVsup frmCom.lblVal7.Caption = Decimals(dblVsup, 1) Case 8 'The negative power supply voltage frmCom.lblStr8.Caption = strWord frmCom.lblInt8.Caption = lngWord dblVmin = (CDbl(lngWord) / 1024#) - 1# dblVmin = 5# * ((dblVminR1 + dblVminR2) / dblVminR1) * dblVmin + 5# frmCom.lblVal8.Caption = Decimals(dblVmin, 1) Case 9 'the returned gains frmCom.lblIaRetGainHex.Caption = Mid$(strWord, 1, 2) intGainIndexIa = Val(Mid$(strWord, 1, 2)) intGainIa = intGainTab(intGainIndexIa) frmCom.lblIaRetGainDec.Caption = intGainIa dblGainIa = CDbl(intGainIa) frmCom.lblIsRetGainHex.Caption = Mid$(strWord, 3, 2) intGainIndexIs = Val(Mid$(strWord, 3, 2)) intGainIs = intGainTab(intGainIndexIs) frmCom.lblIsRetGainDec.Caption = intGainIs dblGainIs = CDbl(intGainIs) End Select Next n If cboAverage.ListIndex = 6 Then 'auto averaging 'first find maximum gain If intGainIndexIa > intGainIndexIs Then intMaxGain = intGainIndexIa Else intMaxGain = intGainIndexIs End If dblAveraging = CDbl(intAverageTab(intMaxGain)) Else 'standard averaging dblAveraging = CDbl(2 ^ cboAverage.ListIndex) End If dblMeasMX(i, intIa) = dblMeasMX(i, intIa) / dblAveraging frmCom.lblVal1.Caption = Decimals(dblMeasMX(i, intIa), 1) dblMeasMX(i, intIs) = dblMeasMX(i, intIs) / dblAveraging frmCom.lblVal3.Caption = Decimals(dblMeasMX(i, intIs), 1) frmCom.lblActualAverage.Caption = dblAveraging dblMeasMX(i, intIa) = dblMeasMX(i, intIa) / dblGainIa dblMeasMX(i, intIs) = dblMeasMX(i, intIs) / dblGainIs If chkcorrection.Value = 1 Then dblMeasMX(i, intVa) = dblVa - (dblMeasMX(i, intIa) / 1000#) * dblAnodeRs - (0.6 * dblCalVar7) dblMeasMX(i, intVs) = dblVs - (dblMeasMX(i, intIs) / 1000#) * dblScreenRs - (0.6 * dblCalVar7) End If frmCom.Refresh End Sub Sub SetFilament(dblHeaterVoltage As Double, blnFault As Boolean) 'This routine sends the command string to turn the filament on. 'The routine gets the value for the filament voltage from the first row from the 'mesurement matrix, because it is this line which contains the bias conditions 'for the first measurement point. To get the first row, routine ComposeMatrix 'is called although only the first row is used. The routine is called again in 'the "DoMeasurement" routine so that the user can stil make chages in the bias 'settings between the moment the filemant is swicthed on, and the actual measurement. Dim intF As Integer Dim strF As String Dim strCommandString As String Dim dblTemp As Double 'Compose the command string (we only need the filament voltage) frmCom.lblValueVa.Caption = 0# frmCom.lblIntegerVa.Caption = 0 frmCom.lblStringVa.Caption = "0000" frmCom.lblValueVs.Caption = 0# frmCom.lblIntegerVs.Caption = 0 frmCom.lblStringVs.Caption = "0000" frmCom.lblValueVg.Caption = 0# frmCom.lblIntegerVg.Caption = 0 frmCom.lblStringVg.Caption = "0000" 'Filament dblTemp = 1024# * (dblHeaterVoltage * dblHeaterVoltage) / (dblVsupSystem * dblVsupSystem) intF = Int(dblTemp) strF = "0000" Mid$(strF, 5 - Len(Hex$(intF))) = Hex$(intF) frmCom.lblValueVf.Caption = dblHeaterVoltage frmCom.lblIntegerVf.Caption = intF frmCom.lblStringVf.Caption = strF frmCom.Refresh strCommandString = "40" + "0000" + "0000" + "0000" + strF 'send the string and deal with errors if any Call SndString(strCommandString, blnFault) End Sub Sub SndSettings(blnFault As Boolean) 'This routine sends the command string containing the settings Dim strCommandString As String Dim strIaGain As String Dim strIsGain As String Dim strAverage As String Dim intIaGain As Integer Dim intIsGain As Integer Dim intAverage As Integer Dim strCompl As String Dim strCompliance(9) As String strCompliance(0) = "8F" '200 mA CVRR=0 n=15 strCompliance(1) = "8C" '175 mA CVRR=0 n=12 strCompliance(2) = "AD" '150 mA CVRR=1 n=13 strCompliance(3) = "AB" '125 mA CVRR=1 n=11 strCompliance(4) = "84" '100 mA CVRR=0 n=4 strCompliance(5) = "81" ' 75 mA CVRR=0 n=1 strCompliance(6) = "A4" ' 50 mA CVRR=1 n=4 strCompliance(7) = "A2" ' 25 mA CVRR=1 n=2 strCompliance(8) = "00" ' designated compliance off strIaGain = "00" 'by happy coincidence the Listindex number of the combo box corresponds to the gain setting intIaGain = cboIaRange.ListIndex Mid$(strIaGain, 3 - Len(Hex$(intIaGain))) = Hex$(intIaGain) frmCom.lblIaGain.Caption = strIaGain strIsGain = "00" 'by happy coincidence the Listindex number of the combo box corresponds to the gain setting intIsGain = cboIsRange.ListIndex Mid$(strIsGain, 3 - Len(Hex$(intIsGain))) = Hex$(intIsGain) frmCom.lblIsGain.Caption = strIsGain intAverage = 2 ^ cboAverage.ListIndex strAverage = "00" Mid$(strAverage, 3 - Len(Hex$(intAverage))) = Hex$(intAverage) frmCom.lblAverage.Caption = strAverage strCompl = strCompliance(cboCompliance.ListIndex) frmCom.lblCompliance.Caption = strCompl frmCom.Refresh strCommandString = "00" + "00" + "00" + "00" + "00" + strCompl + strAverage + strIsGain + strIaGain 'send the string and deal with errors if any Call SndString(strCommandString, blnFault) End Sub