'----------------------------------------------------------------------- $regfile = "89c4051.dat" $crystal = 18432000 $baud = 19200 '$large '$sim Dim A As Byte Dim Starter As Byte Dim H(20) As Byte Dim I As Byte Dim I1 As Byte Dim I2 As Byte Dim I3 As Byte Dim Idt As Word Dim Indx As Byte Dim Sum As Word Dim Sum1 As Word Dim Onoff As Byte Dim Buf As Byte Dim Al As Byte Dim Er As Byte Dim C As Byte Ledr Alias P1.2 'red Ledy Alias P1.3 'yellow Ledy1 Alias P3.5 'yellow Pwr Alias P1.4 'power on pin Dt Alias P3.0 'data (input) Declare Sub Gsminit Declare Sub Gsminfo Declare Sub Gsmout Declare Sub Gsmerror Declare Sub Gsmhot Declare Sub Cooler Declare Sub Waitdt Declare Sub Blinkall(c As Byte) P1 = 255 P3 = 255 Onoff = 1 Call Gsminit Er = 0 Autostart: If Er < 3 Then Call Gsminfo If Er = 3 Then Call Gsmerror Call Blinkall(10) 'power on Reset Pwr 'host checking - single pulse Call Waitdt 'host did not start If Er > 0 Then Er = 3 Goto Autostart End If 'temperature table initialization For I = 20 Downto 1 A = Getad2051() A = Lookup(a , Dta) H(i) = A Next I 'fan turned out Reset P1.7 Reset P1.6 Reset P1.5 Set Ledr Set Ledy Starter = 0 Onoff = 0 Al = 0 Do 'checking host and temperature Call Waitdt Loop Until Er > 0 Or Al > 240 'power off Set Pwr If Al > 240 Then Er = 0 Call Gsmhot End If 'cooling Do Call Cooler Waitms 250 Loop Until Al = 0 If Er < 2 Then Goto Autostart Call Gsmout 'infinite temperature checking and cooling Do Call Cooler Waitms 250 Loop End '------------------------------------------------------------------------------- Sub Gsminit Print "ATE0" ; Chr(13) ; 'No echo Wait 1 Print "AT+CPMS=ME,ME,ME" ; Chr(13) ; 'Memory settings Wait 1 '( For Indx = 1 To 100 Step 1 If Ledy1 = 1 Then Reset Ledy1 Else Set Ledy1 End If Print "AT+CMGD=" ; Indx ; Chr(13) ; 'Deleting 30 messages Waitms 100 Next Indx ') Set Ledy1 End Sub '------------------------------------------------------------------------------- Sub Gsminfo Print "AT+CMGS=21" ; Chr(13) ; 'SMS init info Wait 1 Print "07918405210077F711000B918405514747F70000A907D2F29C1E96D301" ; Chr(26) ; Wait 1 End Sub '------------------------------------------------------------------------------- Sub Gsmout Print "AT+CMGS=24" ; Chr(13) ; 'SMS init info Wait 1 Print "07918405210077F711000B918405514747F70000A90BC13AFD2DAFBB41653719" ; Chr(26); Wait 1 End Sub '------------------------------------------------------------------------------- Sub Gsmerror Print "AT+CMGS=26" ; Chr(13) ; 'SMS init info Wait 1 Print "07918405210077F711000B918405514747F70000A90DC13AFD2DAFBB4165B9FC2D07" ; Chr(26); Wait 1 End Sub '------------------------------------------------------------------------------- Sub Gsmhot Print "AT+CMGS=25" ; Chr(13) ; 'SMS init info Wait 1 Print "07918405210077F711000B918405514747F70000A90CC13AFD2DAFBB41E8373D04" ; Chr(26); Wait 1 End Sub '------------------------------------------------------------------------------- Sub Waitdt Er = 1 'wait for low level on dt Idt = 0 Do If Dt = 0 Then Er = 0 Reset Ledy1 Waitms 1 Set Ledy1 Idt = 11111 Else Incr Idt End If Waitms 5 'checking temperature Call Cooler Loop Until Idt > 10000 If Er = 0 Then Er = 2 'wait for high level on dt Idt = 0 Do If Dt = 1 Then Er = 0 Idt = 1111 Else Incr Idt End If Waitms 5 'checking temperature Call Cooler Loop Until Idt > 1000 End If End Sub '------------------------------------------------------------------------------- Sub Cooler A = Getad2051() A = Lookup(a , Dta) For I = 19 Downto 1 I1 = I + 1 Buf = H(i) H(i1) = Buf Next I H(1) = A Sum = 0 For I = 1 To 20 Sum1 = Sum Sum = Sum1 + H(i) Next I A = Sum / 20 If A < &H23 Then Set Ledr Set Ledy Reset P1.7 Reset P1.6 Reset P1.5 Starter = 0 Al = 0 Else If A < &H24 Then Set Ledr Reset Ledy If Starter = 0 Then Set P1.7 Set P1.6 Set P1.5 Starter = 1 Wait 1 End If Reset P1.7 Reset P1.6 Set P1.5 Al = 0 Else If A < &H25 Then Reset Ledr Reset Ledy If Starter = 0 Then Set P1.7 Set P1.6 Set P1.5 Starter = 1 Wait 1 End If Reset P1.7 Set P1.6 Set P1.5 Al = 1 Else If A < &H26 Then Reset Ledr Set Ledy If Starter = 0 Then Starter = 1 End If Set P1.7 Set P1.6 Set P1.5 Al = 2 Else Incr Al Set Ledy If Onoff = 0 Then Onoff = 1 Reset Ledr Else Onoff = 0 Set Ledr End If If Starter = 0 Then Starter = 1 End If Set P1.7 Set P1.6 Set P1.5 End If End If End If End If End Sub '------------------------------------------------------------------------------- Sub Blinkall(c As Byte) For I3 = 1 To C Step 1 If Ledy1 = 0 Then Set Ledr Set Ledy Set Ledy1 Else Reset Ledr Reset Ledy Reset Ledy1 End If Wait 1 Next I3 End Sub '------------------------------------------------------------------------------- 'this table converts the value into a packed BCD value 'this value can be used to display the value on 2 7-segment displays Dta: Data 0 ' 0 0.000 Data 1 ' 1 0.047 Data 1 ' 2 0.093 Data 2 ' 3 0.138 Data 2 ' 4 0.184 Data 3 ' 5 0.229 Data 3 ' 6 0.273 Data 3 ' 7 0.317 Data 4 ' 8 0.361 Data 4 ' 9 0.404 Data 5 ' 10 0.447 Data 5 ' 11 0.489 Data 6 ' 12 0.531 Data 6 ' 13 0.573 Data 6 ' 14 0.614 Data 7 ' 15 0.655 Data 7 ' 16 0.696 Data 8 ' 17 0.736 Data 8 ' 18 0.776 Data 8 ' 19 0.815 Data 9 ' 20 0.854 Data 9 ' 21 0.893 Data &H10 ' 22 0.931 Data &H10 ' 23 0.969 Data &H10 ' 24 1.006 Data &H11 ' 25 1.044 Data &H11 ' 26 1.080 Data &H11 ' 27 1.117 Data &H12 ' 28 1.153 Data &H12 ' 29 1.189 Data &H12 ' 30 1.224 Data &H13 ' 31 1.260 Data &H13 ' 32 1.295 Data &H13 ' 33 1.329 Data &H14 ' 34 1.363 Data &H14 ' 35 1.397 Data &H14 ' 36 1.431 Data &H15 ' 37 1.464 Data &H15 ' 38 1.497 Data &H15 ' 39 1.530 Data &H16 ' 40 1.562 Data &H16 ' 41 1.594 Data &H16 ' 42 1.626 Data &H17 ' 43 1.657 Data &H17 ' 44 1.688 Data &H17 ' 45 1.719 Data &H18 ' 46 1.750 Data &H18 ' 47 1.780 Data &H18 ' 48 1.810 Data &H19 ' 49 1.840 Data &H19 ' 50 1.869 Data &H19 ' 51 1.898 Data &H19 ' 52 1.927 Data &H20 ' 53 1.956 Data &H20 ' 54 1.984 Data &H20 ' 55 2.012 Data &H21 ' 56 2.040 Data &H21 ' 57 2.068 Data &H21 ' 58 2.095 Data &H21 ' 59 2.122 Data &H22 ' 60 2.149 Data &H22 ' 61 2.176 Data &H22 ' 62 2.202 Data &H22 ' 63 2.228 Data &H23 ' 64 2.254 Data &H23 ' 65 2.279 Data &H23 ' 66 2.305 Data &H23 ' 67 2.330 Data &H24 ' 68 2.355 Data &H24 ' 69 2.379 Data &H24 ' 70 2.404 Data &H24 ' 71 2.428 Data &H25 ' 72 2.452 Data &H25 ' 73 2.476 Data &H25 ' 74 2.499 Data &H25 ' 75 2.523 Data &H26 ' 76 2.546 Data &H26 ' 77 2.569 Data &H26 ' 78 2.591 Data &H50 ' 79 5.000 Data &H49 ' 80 4.953 Data &H49 ' 81 4.907 Data &H48 ' 82 4.862 Data &H48 ' 83 4.816 Data &H47 ' 84 4.771 Data &H47 ' 85 4.727 Data &H47 ' 86 4.683 Data &H46 ' 87 4.639 Data &H46 ' 88 4.596 Data &H45 ' 89 4.553 Data &H45 ' 90 4.511 Data &H44 ' 91 4.469 Data &H44 ' 92 4.427 Data &H44 ' 93 4.386 Data &H43 ' 94 4.345 Data &H43 ' 95 4.304 Data &H42 ' 96 4.264 Data &H42 ' 97 4.224 Data &H42 ' 98 4.185 Data &H41 ' 99 4.146 Data &H41 ' 100 4.107 Data &H40 ' 101 4.069 Data &H40 ' 102 4.031 Data &H40 ' 103 3.994 Data &H39 ' 104 3.956 Data &H39 ' 105 3.920 Data &H39 ' 106 3.883 Data &H38 ' 107 3.847 Data &H38 ' 108 3.811 Data &H38 ' 109 3.776 Data &H37 ' 110 3.740 Data &H37 ' 111 3.705 Data &H37 ' 112 3.671 Data &H36 ' 113 3.637 Data &H36 ' 114 3.603 Data &H36 ' 115 3.569 Data &H35 ' 116 3.536 Data &H35 ' 117 3.503 Data &H35 ' 118 3.470 Data &H34 ' 119 3.438 Data &H34 ' 120 3.406 Data &H34 ' 121 3.374 Data &H33 ' 122 3.343 Data &H33 ' 123 3.312 Data &H33 ' 124 3.281 Data &H32 ' 125 3.250 Data &H32 ' 126 3.220 Data &H32 ' 127 3.190 Data &H31 ' 128 3.160 Data &H31 ' 129 3.131 Data &H31 ' 130 3.102 Data &H31 ' 131 3.073 Data &H30 ' 132 3.044 Data &H30 ' 133 3.016 Data &H30 ' 134 2.988 Data &H29 ' 135 2.960 Data &H29 ' 136 2.932 Data &H29 ' 137 2.905 Data &H29 ' 138 2.878 Data &H28 ' 139 2.851 Data &H28 ' 140 2.824 Data &H28 ' 141 2.798 Data &H28 ' 142 2.772 Data &H27 ' 143 2.746 Data &H27 ' 144 2.721 Data &H27 ' 145 2.695 Data &H27 ' 146 2.670 Data &H26 ' 147 2.645 Data &H26 ' 148 2.621 Data &H26 ' 149 2.596 Data &H26 ' 150 2.572 Data &H25 ' 151 2.548 Data &H25 ' 152 2.524 Data &H25 ' 153 2.501 Data &H25 ' 154 2.477 Data &H24 ' 155 2.454 Data &H24 ' 156 2.431 Data &H24 ' 157 2.409