10 REM Dual Thermistor Thermometer Program 20 REM Written by J. Olivares for Jerry L Pettis VAMC 30 REM Neurobiology Research Group 40 string 35,16 : REM Allocate memory for string varibles 50 $(0)="Dual Thermometer" 60 $(1)="Ver 1.3d, 961212" 70 rem ******* Define constants ******** 80 F=1.16 : rem measurment latency 90 G1=26.7645 : rem ch1 gain 100 G2=26.6596 : rem ch2 gain 110 I1=5.006e-5 : rem ch 1 thermistor current 120 I2=5.000E-5 : rem ch 2 thermistor current 130 L=50 : rem data acq counter 140 m=512 : rem memory start address (use 4096 for development, else 512) 141 OFS=1.082 : rem conditioning circuit offset 150 rem ***** define varibles ****** 160 rem ***** data acquisition varibles ***** 161 rem ADUAVE1, ADUAVE2 are analog to digital averages 162 rem VADU1, VADU2 are the ADU voltages 163 rem VTH1, VTH2 are the thermistor voltages 164 rem R1, R2 are the thermistor resistaces 165 rem TEMP1, TEMP2 are the calculated temperatures 166 rem v1 and v2 are channel 1 and channel 2 raw ADU 167 rem va1 and va2 are ADU totalizers 168 rem ***** other varibles ***** 170 rem a is the entered temp read from memory 180 rem B is select flag used in interactive run mode 190 rem D is interval minus measurment latency 200 rem E interval entered by user 210 rem F is measurment latency 220 rem j is thermistor data acquisition loop counter 230 rem L is thermistor data acquisition loop specifier 240 rem m is memory start address 260 rem S is start indicator flag used in interactive run mode 270 rem T is time interval storage 280 rem x is mode flag used in initialization 310 rem c0 is memory address pointer 320 rem c1 is memory address pointer initializer 330 rem ck is calibration check flag 340 rem temp is temperature entered by user from Hg thermometer 350 rem ******* Port and mode initialization ******* 360 print $(0) : REM display program version number on PC if connected 370 print $(1) 380 GOSUB 1830 : REM display program version on LCD display 390 rem setup port1 bits 0,1,2 and 3 as inputs, active high. 400 port1=port1.or.15 410 rem probe 1 selection 420 IF (PORT1.AND.2)=2 THEN GOSUB 1630 ELSE GOSUB 1660 430 rem probe 2 selection 440 IF (PORT1.AND.4)=4 THEN GOSUB 1720 ELSE GOSUB 1750 450 rem mode selection check, read position of rear panel switch, sw1 460 IF (PORT1.AND.8)=8 THEN GOSUB 480 ELSE GOSUB 1510 470 rem ****Interactive Mode selection**** 480 print "Interactive Mode" 490 input "Enter 0 for Calibration, 1 for Interactive Run Mode: ",x 500 IF X=0 GOTO 520 510 GOTO 1390 520 print "Calibration Mode selected" 530 print 531 input"Enter 0 for calibration, or 1 for calibration check:",ck 532 print 540 input "Enter 0 for Data Storage, 1 for Data Transmission: ",x 550 IF X=0 GOTO 580 560 GOTO 810 570 rem ****Data storage mode**** 580 print"Calibration mode selection" 600 IF CK=1 GOTO 700 610 v0=0:input "Enter temperature or 0 to exit:",temp 620 IF TEMP=0 THEN PRINT "Leaving Data storage" : C1=C0 : GOTO 540 630 GOSUB 1050 640 push temp:st@(m+c0) 650 push ADUAVE1:st@(m+c0+6) 651 REM push R1:st@(m+c0+12) 660 push ADUAVE2:st@(m+c0+12) 661 REM push R2:st@(m+c0+24) 662 print " Temp ADU1 ADU2" 670 print using(##.#),Temp, 671 print using(####.####),ADUAVE1,ADUAVE2 680 c0=c0+18 690 GOTO 610 691 REM ******Calibration Check Mode********* 700 v0=0:input "Enter temperature or 0 to exit:",temp 710 IF TEMP=0 THEN PRINT "Leaving Data storage" : C1=C0 : GOTO 540 720 GOSUB 1050 730 push temp:st@(m+c0) 740 push TEMP1:ST@(m+c0+6) 750 push TEMP2:st@(m+c0+12) 760 print using(##.#),temp,:print using(##.####), TEMP1, TEMP2 770 c0=c0+18 780 GOTO 700 790 rem ****Data Trasmission Mode**** 800 print 810 print "Open Log file and strike the ENTER key to send Data" 820 PRINT "and strike it again when capture flie is closed" 830 rem pause to wait for user input 840 IF GET=0 GOTO 840 850 IF CK=1 GOTO 941 851 print " Temp ADU1 ADU2" 860 for j=0 to (c1-1) step 18 870 ld@(m+j): pop temp 880 ld@(m+j+6): pop ADUAVE1 881 REM ld@(m+j+12): pop R1 890 ld@(m+j+12): pop ADUAVE2 891 REM ld@(m+j+24): pop R2 900 print using(##.#),temp, 901 print using(####.####),ADUAVE1,ADUAVE2 910 next j 920 rem pause for a keystroke to let user halt data capture 930 IF GET=0 GOTO 930 940 GOTO 540 941 print "Temp(Hg) Temp1 Temp2" 950 for j=0 to (c1-1) step 18 960 ld@(m+j): pop temp 970 ld@(m+j+6): pop TEMP1 980 ld@(m+j+12): pop TEMP2 990 print using(##.#),temp,:print using(##.####),TEMP1,TEMP2 1000 next j 1010 rem pause for a keystroke to let user halt data capture 1020 IF GET=0 GOTO 1020 1030 GOTO 540 1040 rem Thermistor data acq and adv 1050 va1=0 : va2=0 : REM zero adu totalizers 1060 for j=1 to L 1070 call 0F020H 1080 pop v2,v1 1090 va1=va1+v1 1100 va2=va2+v2 1110 next j 1120 ADUAVE1=va1/L 1130 VADU1=(ADUAVE1*5)/4095 1140 VTH1=(VADU1+OFS)/G1 1150 R1=VTH1/I1 1160 IF (PORT1.AND.2)=2 THEN GOTO 1230 ELSE GOTO 1170 1161 rem ch1, small probe temp calculation 1170 Y1=4699.6769+(SQR(18833008-(487858.32*LOG(R1)))) 1180 Z1=2*(LOG(R1)+6.6698755) 1190 TEMP1=Y1/Z1-273.15 1220 GOTO 1260 1221 rem ch1, large probe temp calculation 1230 Y1=4771.8261+(SQR(19177194-(528425.76*LOG(R1)))) 1240 Z1=2*(LOG(R1)+6.7996879) 1250 TEMP1=Y1/Z1-273.15 1260 ADUAVE2=va2/L 1270 VADU2=(ADUAVE2*5)/4095 1280 VTH2=(VADU2+OFS)/G2 1290 R2=VTH2/I2 1300 IF (PORT1.AND.4)=4 THEN GOTO 1350 ELSE GOTO 1310 1301 rem ch2, small probe temp calculation 1310 Y2=4877.4718+(SQR(19693011-(586709.21*LOG(R2)))) 1320 Z2=2*(LOG(R2)+6.9825376) 1330 TEMP2=Y2/Z2-273.15 1340 RETURN 1341 rem ch2, large probe temp calculation 1350 Y2=4945.7087+(SQR(20022918-(623982.29*LOG(R2)))) 1360 Z2=2*(LOG(R2)+7.1109657) 1370 TEMP2=Y2/Z2-273.15 1380 return 1390 print "Interactive Run Mode" 1400 input "Enter 0 for single step, 1 for continuous: ",B 1410 IF B=1 GOSUB 2000 : REM 1420 GOSUB 2040 : REM 1430 S=0 : REM set time start flag to 0 1440 print " Time Temp1 Temp 2" 1450 GOSUB 1050 : REM 1460 IF S=0 GOSUB 1930 : REM 1470 print using(#####.#),Time,:print using(##.###), TEMP1 ,TEMP2 1480 IF B=1 GOTO 1970 : REM 1490 IF GET=0 GOTO 1490 : REM 1500 GOTO 1450 1510 Print "Stand alone Mode" 1520 GOSUB 1050 1530 port1=0 : rem set up communication with LCD 1540 print chr(254), chr(1),: rem LCD initialization 1550 for x=1 to 10 : next x : rem delay for LCD to receive init. 1560 print "Ch 1 =", 1570 print using(##.###),TEMP1, 1580 print chr(254), chr(192), 1590 print "Ch 2 =", 1600 print using(##.###),TEMP2, 1610 dby(22)=0 1620 GOTO 1520 1630 print "Probe 1: Type A selected" 1650 return 1660 print "Probe 1: Type B selected" 1710 return 1720 print "Probe 2: Type A selected" 1740 return 1750 print "Probe 2: Type B selected" 1800 return 1810 rem Display Program version number on LCD to clear 1820 rem indeterminant states created during power up 1830 port1=0 1840 print chr(254), chr(1),: rem LCD initialization 1850 for x=1 to 10 : next x : rem delay for LCD to receive initialization 1860 print $(0), : REM display program name defined at begining 1870 print chr(254), chr(192), $(1), : REM display program version and date 1880 for x=1 to 2000 : next x : rem delay for displaying 1890 port1=0 : rem to clear LCD 1900 port1=1 : rem to establish communicaton with PC 1910 return 1920 REM time generation 1930 TIME=0 : T=0 : CLOCK 1 : S=1 : REM inti varibles, start clock, set flag 1940 dby(71)=0 : REM zero the fractional portion of time 1950 return 1960 REM create infinte loop 1970 T=TIME+D : REM add interval delay to time 1980 DO : X=1 : UNTIL T