# macros for Lakeshore model 340 temperature controller # # hp 21.07.2000 # # This macro only works if used together with hp_gpib.mac # If you are using this macro make sure hp_gpib.mac was loaded first! # # global GPIB_lakeshore340,settemp_mode,settemp_loop,settemp_wait,settemp_max_wait global TEMP_RG # { local i # GPIB_lakeshore340 = 24 # GPIB address # activate only one GPIB_lakeshore340 = -2 # serial address # of these two lines if (GPIB_lakeshore340>0) {i=0} else {i=1} GPIB_sleep[i][fabs(GPIB_lakeshore340)] = 0.1 # time to wait after put and get operation GPIB_eol_character[fabs(GPIB_lakeshore340)] = 13 # gives character send after each put command (only GPIB) } # settemp_mode = 1 # 0 ==> only change the setpoint # # 1 ==> change and wait until temperature reaches setpoint settemp_loop = 5 # time to wait between temperature check settemp_wait = 1 # time to wait after temperature was reached settemp_max_wait = 20 # max time waiting for temperature to reach setpoint T_LO_SP = 0.0 # low setpoint limit T_HI_SP = 300.0 # high setpoint limit # # # # If you want to do your measuretemp during the counting and not after the counting try # the following two commands: # def measure1 '' def user_waitcount 'measuretemp' # # temperature measurement is now performed while the system is waiting for the counters to get ready. # To change back to the original state use the following two commands: # # def measure1 'measuretemp' # def user_waitcount '' # # please check measure1 and user_waitcount with the command prdef before changing them. # # # # ################################################################################ # # lakeshore340_help # # hp 28.07.2000 # # redefines the original macro from standart.mac to fit our needs # ################################################################################ # def lakeshore340_help ' { printf("\nlakeshore340_help (hp) 28.07.2000\n\n") # printf("The following commands for the lakeshore model 340 were defined\n") printf("in the file hp_lakeshore340.mac:\n\n") printf("lakeshore340_help : show this text\n") printf("lakeshore340_read_curve : reads a calibration curve from the lakeshore and\n") printf(" displays it, may also be used to write it to a file\n") printf("lakeshore340_write_curve : reads a calibration curve from the hard disk and writes\n") printf(" it to the lakeshore\n") printf("lakeshore340_settings : Configures the most important features of the lakeshore 340,\n") printf(" also allows writing or reading parameters from or to a file\n") printf("lakeshore340_set_pid : Configures PID parameters and heater range\n") printf("lakeshore340_set_control : Configures Control sensor and limits\n") printf("lakeshore340_set_mode : Configures mode (manual PID, ZONE Table, auto tuning, ...)\n") printf("lakeshore340_set_zone : Configures one of the ten zones parameters (PID, Heater, ...)\n") # printf("\nThe following macros are also defined for but not for direct use by the user:\n") printf("_lakeshore340_curve_name_defs, _lakeshore340_settings_define, _lakeshore340_settings_io\n") printf("_lakeshore340_settings_write_par, _lakeshore340_read_curve_head\n") printf("In addition the following macros from standart.mac have been redefined:\n") printf("showtemp,measuretemp,_settemp,measure1,user_waitcount\n") printf("For information about these macros look into the code, file hp_lakeshore340.mac\n") # printf("\nThe following global variables are used in the lakeshore340 macros:\n") printf("(the actual values are displayed after the equal sign)\n") printf("settemp_mode = %i 0 ==> te macro will only change the setpoint\n",settemp_mode) printf(" 1 ==> te macro will also wait for setpoint to be reached\n") printf("settemp_loop = %i time to wait between checking temperature if setpoint was reached\n",settemp_loop) printf("settemp_wait = %i time to wait after new setpoint was reached\n",settemp_wait) printf("settemp_max_wait = %i max time waiting for temperature to reach setpoint\n",settemp_max_wait) } ' # # # # ################################################################################ # # _lakeshore340_settings_define # # hp 25.07.2000 # # generates a list of important parameters for the lakesore 340 model # # lakeshore340_par[x][number], meaning of x is descrobed below: # [0] description of one value of parameter, never use a "=" in it! # [1] value, do not set! # [2] GPIB Command, always without question mark, this will be added automatically for requests # [3] e.g. SETTLE returns 2 values, therefore this number gives the position which value is # interesting for you, counting starts with 0 # [4] additional parameter with has to be added after GPIB command, e.g. "RAMP 1", ==> parameter = "1" # [5] additional explanation which should be displayed, use printf format # [6] set this to "BUSY?" if the command recommands it in the manual # # do not forget to set lakeshore340_n to the maximum number of parameters (end of macro) # do not change the order of the definitions this will also affect other macros like # for example lakeshore340_set_pid # ################################################################################ # def _lakeshore340_settings_define ' { local n,i # n = 0 lakeshore340_par[5][n] = "\nSETTLE: Specifies the allowable band around the setpoint\nand the time the reading must stay within the band.\nThereafter a statusbit is set.\n" lakeshore340_par[2][n] = "SETTLE" lakeshore340_par[3][n] = 0 lakeshore340_par[3][n+1] = 1 lakeshore340_par[0][n] = "SETTLE Threshold" lakeshore340_par[0][n+1] = "SETTLE time (s)" # n = 2 lakeshore340_par[5][n] = "\nRAMP: Switches Ramp on and off and defines the maximum\ntemperature change per minute which is allowed if the\nsetpoint is changed.\n" lakeshore340_par[2][n] = "RAMP" lakeshore340_par[4][n] = "1" lakeshore340_par[3][n] = 0 lakeshore340_par[3][n+1] = 1 lakeshore340_par[0][n] = "RAMP off/on (0/1)" lakeshore340_par[0][n+1] = "RAMP rate (K per min.)" # n = 4 lakeshore340_par[5][n] = "\nPID: Changes the PID parameters, if you are not familiar\nwith PID parameters look into the lakeshore model 340\nmanual for a short introduction.\n" lakeshore340_par[2][n] = "PID" lakeshore340_par[4][n] = "1" lakeshore340_par[3][n] = 0 lakeshore340_par[3][n+1] = 1 lakeshore340_par[3][n+2] = 2 lakeshore340_par[0][n] = "PID Proportional term" lakeshore340_par[0][n+1] = "PID Iintegral term" lakeshore340_par[0][n+2] = "PID Differential term" # n = 7 lakeshore340_par[5][n] = "\nRANGE: Defines the output of the heater. Normally 0 is off and 5\nis maximum output 50 W, 4 is one order of magnitude less\nthen 5 and so on. for exact values depending on the resistence\nof the heater see table 6-3 on page 6-9 of the\nlakeshore model 340\nmanual.\n" lakeshore340_par[2][n] = "RANGE" lakeshore340_par[3][n] = 0 lakeshore340_par[0][n] = "RANGE heater (0 off, 5 50 W)" # n = 8 lakeshore340_par[5][n] = "\nCMODE: Control mode of the lakeshore\n1 = Manual PID 2 = PIDs taken from ZONE table 3 = Open Loop,\n4 = Auto tune PID 5 = Auto tune PI 6 = Auto tune P\n(4 to 6 auto tuning is not working)\n" lakeshore340_par[2][n] = "CMODE" lakeshore340_par[4][n] = "1" lakeshore340_par[3][n] = 0 lakeshore340_par[0][n] = "CMODE controle mode (1 - 6)" # n = 9 lakeshore340_par[5][n] = "\nCLIMIT: Configure limits for setpoint, maximum positive\n and negative change in output, maximum current\n(1 = 0.25 A, 2 = 0.5 A, 3 = 1.0 A, 4 = 2.0 A) and maximum\nheater range\n" lakeshore340_par[2][n] = "CLIMIT" lakeshore340_par[4][n] = "1" lakeshore340_par[3][n] = 0 lakeshore340_par[3][n+1] = 1 lakeshore340_par[3][n+2] = 2 lakeshore340_par[3][n+3] = 3 lakeshore340_par[3][n+4] = 4 lakeshore340_par[0][n] = "CLIMIT setpoint limit" lakeshore340_par[0][n+1] = "CLIMIT positive slope (in %)" lakeshore340_par[0][n+2] = "CLIMIT negative slope (in %)" lakeshore340_par[0][n+3] = "CLIMIT max current (1-4)" lakeshore340_par[0][n+4] = "CLIMIT max heater range (0-5)" # n = 14 lakeshore340_par[5][n] = "\nCSET: Configures Control parameters: sensor which is\nused for temperature control, units (1 = Kelvin,\n2 = Celsius and 3 = sensor units), control loop switched\non or off, control loop on or off after power-up\n" lakeshore340_par[2][n] = "CSET" lakeshore340_par[4][n] = "1" lakeshore340_par[3][n] = 0 lakeshore340_par[3][n+1] = 1 lakeshore340_par[3][n+2] = 2 lakeshore340_par[3][n+3] = 3 lakeshore340_par[0][n] = "CSET input sensor (A or B)" lakeshore340_par[0][n+1] = "CSET units (1-3)" lakeshore340_par[0][n+2] = "CSET off or on (0-1)" lakeshore340_par[0][n+3] = "CSET powerup enable (0-1)" # n = 18 lakeshore340_par[5][n] = "\nINCRV: configures the number of the curve (1-60) used\nfor sensors A to D\n" lakeshore340_par[2][n] = "INCRV" lakeshore340_par[4][n] = "A" lakeshore340_par[6][n] = "BUSY?" lakeshore340_par[3][n] = 0 lakeshore340_par[0][n] = "INCRV conf. curve number sensor A" lakeshore340_par[2][n+1] = "INCRV" lakeshore340_par[4][n+1] = "B" lakeshore340_par[6][n+1] = "BUSY?" lakeshore340_par[3][n+1] = 0 lakeshore340_par[0][n+1] = "INCRV conf. curve number sensor B" lakeshore340_par[2][n+2] = "INCRV" lakeshore340_par[4][n+2] = "C" lakeshore340_par[6][n+2] = "BUSY?" lakeshore340_par[3][n+2] = 0 lakeshore340_par[0][n+2] = "INCRV conf. curve number sensor C" lakeshore340_par[2][n+3] = "INCRV" lakeshore340_par[4][n+3] = "D" lakeshore340_par[6][n+3] = "BUSY?" lakeshore340_par[3][n+3] = 0 lakeshore340_par[0][n+3] = "INCRV conf. curve number sensor D" # n = 22 lakeshore340_par[5][n] = "\nINTYPE: Configures input type parameters for the sensors.\nSee lakeshore model 340 manual page 9-22 for a short explanation\n" lakeshore340_par[2][n] = "INTYPE" lakeshore340_par[4][n] = "A" lakeshore340_par[6][n] = "BUSY?" lakeshore340_par[3][n] = 0 lakeshore340_par[3][n+1] = 1 lakeshore340_par[3][n+2] = 2 lakeshore340_par[3][n+3] = 3 lakeshore340_par[3][n+4] = 4 lakeshore340_par[0][n] = "INTYPE A type" lakeshore340_par[0][n+1] = "INTYPE A units (0-2)" lakeshore340_par[0][n+2] = "INTYPE A coefficient (0-2)" lakeshore340_par[0][n+3] = "INTYPE A excitation (0-12)" lakeshore340_par[0][n+4] = "INTYPE A range (0-12)" n = 27 lakeshore340_par[2][n] = "INTYPE" lakeshore340_par[4][n] = "B" lakeshore340_par[6][n] = "BUSY?" lakeshore340_par[3][n] = 0 lakeshore340_par[3][n+1] = 1 lakeshore340_par[3][n+2] = 2 lakeshore340_par[3][n+3] = 3 lakeshore340_par[3][n+4] = 4 lakeshore340_par[0][n] = "INTYPE B type" lakeshore340_par[0][n+1] = "INTYPE B units (0-2)" lakeshore340_par[0][n+2] = "INTYPE B coefficient (0-2)" lakeshore340_par[0][n+3] = "INTYPE B excitation (0-12)" lakeshore340_par[0][n+4] = "INTYPE B range (0-12)" n = 32 lakeshore340_par[2][n] = "INTYPE" lakeshore340_par[4][n] = "C" lakeshore340_par[6][n] = "BUSY?" lakeshore340_par[3][n] = 0 lakeshore340_par[3][n+1] = 1 lakeshore340_par[3][n+2] = 2 lakeshore340_par[3][n+3] = 3 lakeshore340_par[3][n+4] = 4 lakeshore340_par[0][n] = "INTYPE C type" lakeshore340_par[0][n+1] = "INTYPE C units (0-2)" lakeshore340_par[0][n+2] = "INTYPE C coefficient (0-2)" lakeshore340_par[0][n+3] = "INTYPE C excitation (0-12)" lakeshore340_par[0][n+4] = "INTYPE C range (0-12)" n = 37 lakeshore340_par[2][n] = "INTYPE" lakeshore340_par[4][n] = "D" lakeshore340_par[6][n] = "BUSY?" lakeshore340_par[3][n] = 0 lakeshore340_par[3][n+1] = 1 lakeshore340_par[3][n+2] = 2 lakeshore340_par[3][n+3] = 3 lakeshore340_par[3][n+4] = 4 lakeshore340_par[0][n] = "INTYPE D type" lakeshore340_par[0][n+1] = "INTYPE D units (0-2)" lakeshore340_par[0][n+2] = "INTYPE D coefficient (0-2)" lakeshore340_par[0][n+3] = "INTYPE D excitation (0-12)" lakeshore340_par[0][n+4] = "INTYPE D range (0-12)" # n = 42 lakeshore340_par[5][n] = "\nZONE: Up to 10 temperature zones can be defined. In each ZONE the\ndefined PID values are used\n" for(i=1;i<=10;i++) { n = 36+6*i lakeshore340_par[2][n] = "ZONE" lakeshore340_par[4][n] = sprintf("1,%u",i) lakeshore340_par[3][n] = 0 lakeshore340_par[3][n+1] = 1 lakeshore340_par[3][n+2] = 2 lakeshore340_par[3][n+3] = 3 lakeshore340_par[3][n+4] = 4 lakeshore340_par[3][n+4] = 5 lakeshore340_par[0][n] = sprintf("ZONE %u max temp",i) lakeshore340_par[0][n+1] = sprintf("ZONE %u P",i) lakeshore340_par[0][n+2] = sprintf("ZONE %u I",i) lakeshore340_par[0][n+3] = sprintf("ZONE %u D",i) lakeshore340_par[0][n+4] = sprintf("ZONE %u manual output",i) lakeshore340_par[0][n+5] = sprintf("ZONE %u heater range (0-5)",i) } # n = 102 lakeshore340_n = n } ' # # # # ################################################################################ # # showtemp # # hp 26.07.2000 # # redefines the original macro from standart.mac to fit our needs # ################################################################################ # def showtemp ' measuretemp printf("Temperature Setpoint = %g K\n",TEMP_SP) printf("Temperature control sensor = %g K\n",TEMP_RG) printf("Temperature sample sensor = %g K\n",TEMP_CS) ' # # # # ################################################################################ # # measuretemp # # hp 21.07.2000 # # measuretemp for Lakeshore model 340 temperature controller # ################################################################################ # def measuretemp ' { local dummy # dummy = sprintf("KRDG? B"); hp_gpib_put GPIB_lakeshore340 dummy hp_gpib_get GPIB_lakeshore340 TEMP_CS = GPIB_val DEGC = TEMP_CS-273.15 # dummy = sprintf("KRDG? A") hp_gpib_put GPIB_lakeshore340 dummy hp_gpib_get GPIB_lakeshore340 TEMP_RG = GPIB_val } ' # # # # ################################################################################ # # _settemp # # hp 21.07.2000 # hp 26.07.2000 added waiting for temperature to be reached # # _settemp for Lakeshore model 340 temperature controller # ################################################################################ # def _settemp ' { local i,dummy,bit dummy = sprintf("SETP 1,%g",TEMP_SP);hp_gpib_put GPIB_lakeshore340 dummy DEGC_SP = TEMP_SP-273.15 # if (settemp_mode>0) { printf("Waiting for setpoint to be reached, checking temperature every\n") printf("%g seconds, maximum wait %g seconds, after reaching the setpoint\n",settemp_loop,settemp_max_wait) printf("the program will wait for %g more seconds.\n",settemp_wait) i = 0 while (i>=0) { dummy = "*STB?";hp_gpib_put GPIB_lakeshore340 dummy bit = int(GPIB_val) if ((bit>=4) && (bit<=7)) { printf("setpoint was reached at %s\n",date()) i = -1 } else { if ((i*settemp_loop) > settemp_max_wait) { printf("setpoint was not reached but maximum wait time ist exceeded\n") i = -1 } else { if (int(i/10) == (i/10)) printf("Actual time and date: %s\n",date()) printf("waiting since %g seconds ...\n",i*settemp_loop) sleep (settemp_loop) i++ } } } if (settemp_wait>0) { printf("waiting final %g seconds ...\n",settemp_wait) sleep (settemp_wait) } } } ' # # # # ################################################################################ # # lakeshore340_set_zone # # hp 28.07.2000 # # sets only selected parameters from lakeshore340_settings (here parameters for 1 zone) # ################################################################################ # def lakeshore340_set_zone ' { local lake_mode,lakeshore340_n,lakeshore340_par[] local hp_zone,i printf("\nlakeshore340_set_zone (hp) 28.07.2000\n\n") lake_mode = 2 i = getval("Which zone is to be set (1-10)?",1) hp_zone = 36+6*i _lakeshore340_settings_define if (i != 1) printf(lakeshore340_par[5][42]) _lakeshore340_settings_io hp_zone hp_zone+5 _lakeshore340_settings_write_par hp_zone hp_zone+5 } ' # # # # ################################################################################ # # lakeshore340_set_pid # # hp 27.07.2000 # hp 31.07.2000 now setting values command line is possible # # sets only selected parameters from lakeshore340_settings (here only PID and RANGE is set) # ################################################################################ # def lakeshore340_set_pid ' { local n,lake_mode,lakeshore340_n,lakeshore340_par[] printf("\nlakeshore340_set_pid (hp) 27.07.2000\n") _lakeshore340_settings_define if ($# == 0) { lake_mode = 2 _lakeshore340_settings_io 4 7 _lakeshore340_settings_write_par 4 7 } else if ($# == 4) { n = 4 lakeshore340_par[1][n] = $1 lakeshore340_par[1][n+1] = $2 lakeshore340_par[1][n+2] = $3 lakeshore340_par[1][n+3] = $4 _lakeshore340_settings_write_par 4 7 } else { lake_mode = 1 printf("usage: lakeshore340_set_pid P I D Heater_Range\n") _lakeshore340_settings_io 4 7 } } ' # # # # ################################################################################ # # lakeshore340_set_ramp # # hp 31.07.2000 # # sets only selected parameters from lakeshore340_settings (here only MODE is set) # ################################################################################ # def lakeshore340_set_ramp ' { local n,lake_mode,lakeshore340_n,lakeshore340_par[] printf("\nlakeshore340_set_ramp (hp) 31.07.2000\n") _lakeshore340_settings_define if ($# == 0) { lake_mode = 2 _lakeshore340_settings_io 2 3 _lakeshore340_settings_write_par 2 3 } else if ($# == 2) { n = 2 lakeshore340_par[1][n] = $1 lakeshore340_par[1][n+1] = $2 _lakeshore340_settings_write_par 2 3 } else { lake_mode = 1 printf("\nusage: lakeshore340_set_ramp val1 val2 (on/off (0/1)) (change in K/min)\n") _lakeshore340_settings_io 2 3 } } ' # # # # ################################################################################ # # lakeshore340_set_mode # # hp 27.07.2000 # hp 31.07.2000 now setting values command line is possible # # sets only selected parameters from lakeshore340_settings (here only MODE is set) # ################################################################################ # def lakeshore340_set_mode ' { local i,n,lake_mode,lakeshore340_n,lakeshore340_par[] printf("\nlakeshore340_set_mode (hp) 27.07.2000\n") _lakeshore340_settings_define if ($# == 0) { lake_mode = 2 _lakeshore340_settings_io 8 _lakeshore340_settings_write_par 8 } else { i = int($1) if ((i>=0) && (i<=6)) { n = 8 lakeshore340_par[1][n] = $1 _lakeshore340_settings_write_par 8 } else { lake_mode = 1 printf("\nusage: lakeshore340_set_mode value (must be 1 to 6)\n") _lakeshore340_settings_io 8 } } } ' # # # # ################################################################################ # # lakeshore340_set_control # # hp 27.07.2000 # # sets only selected parameters from lakeshore340_settings (here only CSET and CLIMIT is set) # ################################################################################ # def lakeshore340_set_control ' { local lake_mode,lakeshore340_n,lakeshore340_par[] printf("\nlakeshore340_set_control (hp) 27.07.2000\n") lake_mode = 2 _lakeshore340_settings_define _lakeshore340_settings_io 9 17 _lakeshore340_settings_write_par 9 17 } ' # # # # ################################################################################ # # lakeshore340_settings # # hp 25.07.2000 # # reads and displays all important parameters of the lakeshore 340 model # ################################################################################ # def lakeshore340_settings ' { local i,ii,j,lake_mode,dummy,val[],lakeshore340_n,lakeshore340_par[],hp_filename local hp_status printf("\nlakeshore340_read_settings (hp) 25.07.2000\n\n") # if ($# != 1) { eprint "Usage: lakeshore340_settings mode" eprint "mode = 1: read values from lakeshore and display them" eprint "mode = 2: change values interactively and write them to lakeshore" eprint "mode = 3: change values interactively and write them to file" eprint "mode = 4: read values from lakeshore and write them to file" eprint "mode = 5: change values interactively and write them to lakeshore and file" eprint "mode = 6: read values from file and write them to lakeshore" exit } else { lake_mode = int($1) } if ((lake_mode<1) || (lake_mode>6)) { printf("mode %i is not valid. Type lakeshore340_settings to get a list of modes\n",lake_mode) exit } if ((lake_mode>=3) && (lake_mode<=6)) { hp_filename = getval("Name of lakeshore parameter file:","test.dat") printf("\n") if (hp_filename == "") exit if (lake_mode == 6) { if (!file_info(hp_filename)) { printf("file %c%s%c does not exist! Program aborted.\n",34,hp_readfile,34) exit } } else { if (file_info(hp_filename)) { dummy = sprintf("rm %s",hp_filename) unix(dummy) } } hp_status = open(hp_filename) if (hp_status) { printf("File %s could not be opend!\n",hp_filename) exit } } # _lakeshore340_settings_define # _lakeshore340_settings_io 0 lakeshore340_n-1 # if ((lake_mode>=3) && (lake_mode<=6)) { hp_status = close(hp_filename) } # if ((lake_mode == 2) || (lake_mode == 5) || (lake_mode == 6)) { _lakeshore340_settings_write_par 0 lakeshore340_n-1 } } ' # # # # ################################################################################ # # _lakeshore340_settings_io # # hp 25.07.2000 # # subroutine for input and output of parameters from lakeshore340_settings # ################################################################################ # def _lakeshore340_settings_io ' { local i,ii,j,n1,n2,len,max_len,dummy,val[] max_len = 35 if (($# != 1) && ($# != 2)) { eprint "Wrong number of parameters in _lakeshore340_settings_io" exit } if ($# == 1) n1 = n2 = $1 if ($# == 2) { n1 = $1 n2 = $2 } if ((n1<0) || (n1>=lakeshore340_n) || (n2<0) || (n2>=lakeshore340_n) || (n1>n2)) { eprint "Parameter out of range in _lakeshore340_settings_io" exit } # for (i=n1;i<=n2;i++) { # if ((lake_mode >=1) && (lake_mode<=5)) { if (lakeshore340_par[2][i]) { if (lakeshore340_par[4][i]) { dummy = sprintf("%s%s %s",lakeshore340_par[2][i],"?",lakeshore340_par[4][i]) } else { dummy = sprintf("%s%s",lakeshore340_par[2][i],"?") } hp_gpib_put GPIB_lakeshore340 dummy hp_gpib_get GPIB_lakeshore340 split(GPIB_val,val,",") } ii = lakeshore340_par[3][i] lakeshore340_par[1][i] = val[ii] } # if (lake_mode == 6) { if (i == 0) { dummy = getline(hp_filename,0) } else { dummy = getline(hp_filename) } split(dummy,val,"=") len = length(val[1]) lakeshore340_par[1][i] = substr(val[1],1,len-1) } # len = length(lakeshore340_par[0][i]) if (len= 3) && (lake_mode <=5)) { fprintf(hp_filename,"%s=%s\n",lakeshore340_par[0][i],lakeshore340_par[1][i]) } } } ' # # # # ################################################################################ # # _lakeshore340_settings_write_par # # hp 27.07.2000 # # subroutine for input and output of parameters from lakeshore340_settings # ################################################################################ # def _lakeshore340_settings_write_par ' { local i,ii,j,n1,n2,dummy if (($# != 1) && ($# != 2)) { eprint "Wrong number of parameters in _lakeshore340_settings_write_par" exit } if ($# == 1) n1 = n2 = $1 if ($# == 2) { n1 = $1 n2 = $2 } if ((n1<0) || (n1>=lakeshore340_n) || (n2<0) || (n2>=lakeshore340_n) || (n1>n2)) { eprint "Parameter out of range in _lakeshore340_settings_write_par" exit } printf("\nwriting parameters into memory of lakeshore, this may take a while ...\n\n") for (i=n1;i<=n2;i++) { if (lakeshore340_par[2][i]) { j = i while(j>=0) { j++ if (j>=lakeshore340_n) { j = -1*lakeshore340_n } else { if (lakeshore340_par[2][j]) j = -1*j } } j = -1*j; if (lakeshore340_par[4][i]) { dummy = sprintf("%s %s",lakeshore340_par[2][i],lakeshore340_par[4][i]) ii = i } else { dummy = sprintf("%s %s",lakeshore340_par[2][i],lakeshore340_par[1][i]) ii=i+1 } while (ii0) { printf("waiting since %u seconds ...\n",ii) sleep(2);ii = ii+2 if (ii>20) { printf("waiting aborted, problems with lakeshore?\n") GPIB_val = -1 } else { hp_gpib_get GPIB_lakeshore340 } } } } } } ' # # # # ################################################################################ # # lakeshore340_write_curve # # hp 21.07.2000 # # reads one sensor calibration curve from harddisk and # writes it into the lakeshore 340 model # ################################################################################ # def lakeshore340_write_curve ' { local i,j,ii,dummy,_hp_n,hp_readfile,curve_name[],curve_units[] local curve_coeff[],curve[],textline,feld[] # _lakeshore340_curve_name_defs # printf("lakeshore340_write_curve (hp) 21.07.2000\n\n") if ($# != 2) { _hp_n=getval("Number of curve to be written?",21) hp_readfile = getval("Filename of temperature curve?","test.dat") } else { _hp_n = $1 hp_readfile = "$2" } if ((_hp_n<21) || (hp_n> 60)) { eprint "curve number out of range in lakeshore340_read_curve." eprint "only curves 21 to 60 may be written by the user." exit } if (!file_info(hp_readfile)) { eprint "File: ",hp_readfile,"does not exist!" exit } # printf("Readings from actual curve in lakeshore 340 temperature controller:\n") _lakeshore340_read_curve_head _hp_n printf("\nPlease enter your new values now:\n") split(GPIB_val,curve,",") for(i=0;i<5;i++) { if (i==2) { printf("For the following question you may choose between (enter number):\n") for(j=1;j<=5;j++) printf("%u: %s ",j,curve_units[j]) printf("\n") } else if (i==4) { printf("For the following question you may choose between (enter number):\n") for(j=1;j<=2;j++) printf("%u: %s ",j,curve_coeff[j]) printf("\n") } curve[i] = getval(curve_name[i],curve[i]) } # printf("\nThe following values will be written to curve %u:\n",_hp_n) for(i=0;i<5;i++) { if (i==2) { ii = int(curve[i]) printf("%s %s (%u)\n",curve_name[i],curve_units[ii],curve[i]) } else if (i==4) { ii = int(curve[i]) printf("%s %s (%u)\n",curve_name[i],curve_coeff[ii],curve[i]) } else { printf("%s %s\n",curve_name[i],curve[i]) } } if (!yesno("Is this correct?",0)) { eprint "You answered no, programm terminated." exit } # dummy = sprintf("CRVHDR %u,%s,%s,%u,%g,%u",_hp_n,curve[0],curve[1],curve[2],curve[3],curve[4]) hp_gpib_put GPIB_lakeshore340 dummy # open(hp_readfile) textline = getline(hp_readfile,0) i = 0 while(textline != -1) { split(textline,feld," ") dummy = sprintf("CRVPT %u,%u,%f,%f,N",_hp_n,++i,feld[0],feld[1]) printf("%s\n",dummy) hp_gpib_put GPIB_lakeshore340 dummy textline = getline(hp_readfile) } close(hp_readfile) # printf("\nCurve %u was written to lakeshore model 340 temperature controller.\n",_hp_n) # printf("\nWarning: The curve was not saved to the flash memory of the lakeshore.\n") printf("To do so execute the command: hp_gpib_put %u CRVSAV\n",GPIB_lakeshore340) printf("This will save all changes you made to curves since the lakeshore was switched on!\n") printf("Otherwise all changes will be lost after lakeshore is switched off!\n") # printf("\nIf you use the command lakeshore340_read_curve number to check your written\n") printf("curve, the program will show you a mixed up curve header. I do not know the\n") printf("reason, it looks like there is a mistake in the CRVHDR? command of the lakeshore.\n") printf("To make sure the curve was written correctly check it manually on the front\n") printf("panel of the lakeshore model 340 temperature controller.\n") } ' # # # # ################################################################################ # # lakeshore340_read_curve # # hp 21.07.2000 # hp 24.07.2000 added write to file # # reads one sensor calibration curve from the lakeshore 340 model # ################################################################################ # def lakeshore340_read_curve ' { local i,ii,dummy,_hp_n,pts[],hp_writefile,hp_status # if (($# != 1) && ($# != 2)) { eprint "usage: lakeshore340_read_curve curve_number [filename]" eprint "If optional filename is given curve will be written to harddisk." exit } _hp_n = $1 if ((hp_n<0) || (hp_n> 60)) { eprint "curve number out of range in lakeshore340_read_curve" exit } if ($# == 2) { hp_writefile = "$2" hp_status = open(hp_writefile)+1 if (hp_status<=0) { eprint "Error: Could not open file ",hp_writefile exit } } # _lakeshore340_read_curve_head _hp_n # i = 0;ii=1 while(ii>0) { i++ dummy = sprintf("CRVPT? %u,%u",_hp_n,i); hp_gpib_put GPIB_lakeshore340 dummy hp_gpib_get GPIB_lakeshore340 split(GPIB_val,pts,",") ii = pts[0]+pts[1] if (i>200) ii = o if (ii>0) { printf("%u: %s %s\n",i,pts[0],pts[1]) if (hp_status) fprintf(hp_writefile,"%s %s\n",pts[0],pts[1]) } else { i-- } } printf("\nCurve contains %u calibration points.\n",i) if (hp_status) close(hp_writefile) } ' # # # # ################################################################################ # # _lakeshore340_read_curve_head # # hp 21.07.2000 # # reads and displays information about a curve head # ################################################################################ # def _lakeshore340_read_curve_head ' { local i,ii,dummy,curve[],hp_crvn,curve_units[],curve_coeff[] # _lakeshore340_curve_name_defs # if ($# != 1) { eprint "usage: _lakeshore340_read_curve_head curve_number" exit } hp_crvn = $1 if ((hp_crvn<0) || (hp_crvn> 60)) { eprint "curve number out of range in _lakeshore340_read_curve_head" exit } # dummy = sprintf("CRVHDR? %u",hp_crvn);hp_gpib_put GPIB_lakeshore340 dummy hp_gpib_get GPIB_lakeshore340 split(GPIB_val,curve,",") printf("\nNumber of displayed curve : %u\n",hp_crvn) for(i=0;i<5;i++) { if (i==2) { ii = int(curve[i]) printf("%s %s (%u)\n",curve_name[i],curve_units[ii],curve[i]) } else if (i==4) { ii = int(curve[i]) printf("%s %s (%u)\n",curve_name[i],curve_coeff[ii],curve[i]) } else { printf("%s %s\n",curve_name[i],curve[i]) } } } ' # # # # ################################################################################ # # _lakeshore340_curve_name_defs # # hp 21.07.2000 # # definitions for other macros in this file # ################################################################################ # def _lakeshore340_curve_name_defs ' # curve_name[0] = "Name of the curve :" curve_name[1] = "Curve serial number :" curve_name[2] = "Data format :" curve_name[3] = "Maximum temperature in Kelvin :" curve_name[4] = "Coefficient :" # curve_units[1] = "mV/K" curve_units[2] = "V/K" curve_units[3] = "Ohm/K" curve_units[4] = "log(Ohm)/K" curve_units[5] = "log(Ohm)/log(K)" # curve_coeff[1] = "negative" curve_coeff[2] = "positive" ' # # # #