open "COM2:9600,N,8,1,CS0,DS0,CD0,ME,FE" as 1 10 cls print print "Commands" print "" print " q - Specification Test command - if recording data the LEDs will flash" print " a - Read Page - zero, parameters, 32 bytes returned" print " v - read all DS1615 data into the file data.txt" print " z - Read Temperature - command, use 'a' to see the result" print " c - Clear Memory and set the reading interval to 1 minute" print " e - end" do a$=inkey$ loop until len(a$)>0 if len(a$)>0 then if a$="e" then print "Finished" stop elseif a$="q" then ' send the Specification Test command - if recording data the LEDs will flash print "Specification Test" print #1,chr$(&H44); elseif a$="a" then cls ' Read Page - zero, parameters, 32 bytes returned print #1,chr$(&H33);chr$(0);chr$(0); aa$=input$(34,#1) print "-- page 0 ---" print "day ";hex$(asc(mid$(aa$,4,1)));" time ";hex$(asc(mid$(aa$,3,1))); print ":";right$("0"+hex$(asc(mid$(aa$,2,1))),2); print ":";right$("0"+hex$(asc(mid$(aa$,1,1))),2) for i=1 to 32 step 2 if i=17 then print 0.5*(asc(mid$(aa$,i+1,1)))-40 print hex$(i-1),bin$(asc(mid$(aa$,i,1))),bin$(asc(mid$(aa$,i+1,1))) next i do ' wait for a key press loop until instat elseif a$="v" then cls open "data.txt" for output as #2 l=1 print #1,chr$(&H33);chr$(&H00);chr$(&H00); 'base data 0 aa$=input$(32,#1) for i=1 to 32 print #2,asc(mid$(aa$,i,1)) next i ba$=input$(2,#1) 'crc print l l=l+1 print #1,chr$(&H33);chr$(&H00);chr$(&H20); 'base data 1 aa$=input$(32,#1) for i=1 to 32 print #2,asc(mid$(aa$,i,1)) next i ba$=input$(2,#1) 'crc print l l=l+1 print #1,chr$(&H33);chr$(&H02);chr$(&H18); 'serial number aa$=input$(8,#1) for i=1 to 8 print #2,asc(mid$(aa$,i,1)) next i ba$=input$(2,#1) 'crc print l l=l+1 for k=&H220 to &H27F step 32 hi%=k shift right hi%,8 low%=k and &HFF print #1,chr$(&H33);chr$(hi%);chr$(low%); 'alarms aa$=input$(32,#1) for i=1 to 32 print #2,asc(mid$(aa$,i,1)) next i ba$=input$(2,#1) 'crc print l l=l+1 next k for k=&H800 to &H87F step 32 hi%=k shift right hi%,8 low%=k and &HFF print #1,chr$(&H33);chr$(hi%);chr$(low%); 'histogram aa$=input$(32,#1) for i=1 to 32 print #2,asc(mid$(aa$,i,1)) next i ba$=input$(2,#1) 'crc print l l=l+1 next k for k=&H1000 to &H17FF step 32 hi%=k shift right hi%,8 low%=k and &HFF print #1,chr$(&H33);chr$(hi%);chr$(low%); 'temperature aa$=input$(32,#1) for i=1 to 32 print #2,asc(mid$(aa$,i,1)) next i ba$=input$(2,#1) 'crc print l l=l+1 next k close #2 print #1,chr$(&H33);chr$(&H10);chr$(&H20); aa$=input$(32,#1) delay .1 ba$=input$(2,#1) 'crc print #1,chr$(&H33);chr$(&H10);chr$(&H20); ba$=input$(32,#1) aa$=aa$+ba$ for i=1 to 64 step 4 print hex$(i-1), 0.5*(asc(mid$(aa$,i,1)))-40, print 0.5*(asc(mid$(aa$,i+1,1)))-40,0.5*(asc(mid$(aa$,i+2,1)))-40, print 0.5*(asc(mid$(aa$,i+3,1)))-40 ' print hex$(i-1),bin$(asc(mid$(aa$,i,1))),bin$(asc(mid$(aa$,i+1,1))); ' print bin$(asc(mid$(aa$,i+2,1))),bin$(asc(mid$(aa$,i+3,1))) next i elseif a$="z" then ' Read Temperature - command print #1,chr$(&H55); elseif a$="x" then ' Write Byte - to address address%=&H0E idata%=&H10 print #1,chr$(&H22);chr$(address%);chr$(idata%); elseif a$="c" then print "interval 1 minute" print #1,chr$(&H22);chr$(&H0E);chr$(&H50); ' clr=1 se=1 print #1,chr$(&HA5); ' Clear Memory - command delay 0.5 print #1,chr$(&H22);chr$(&H0D);chr$(&H01); ' interval 1 minute else print #1,a$; end if end if goto 10