سلام دوستان عزیز ...
میرم سر اصل مطلب ... من یک مدار ساختم ... مشکل اینجاست قبل از اتصال سنسور به مدار که به جای نمایش عدد صفر .... سه یا چهار عدد متفاوتو به سرعت نشون میده ...
وقتی سنسور هم وصل ... مثلا دما 20 درجه باشه ... یک دفعه میزنه 20 یک دفعه ....یک دفعه 32 ... و 18 ....
مشکل از کجاست به نظرتون که دو دمای اشتباه هم میده ؟؟؟
میرم سر اصل مطلب ... من یک مدار ساختم ... مشکل اینجاست قبل از اتصال سنسور به مدار که به جای نمایش عدد صفر .... سه یا چهار عدد متفاوتو به سرعت نشون میده ...
وقتی سنسور هم وصل ... مثلا دما 20 درجه باشه ... یک دفعه میزنه 20 یک دفعه ....یک دفعه 32 ... و 18 ....
مشکل از کجاست به نظرتون که دو دمای اشتباه هم میده ؟؟؟
کد:
$regfile = "m32def.dat" $crystal = 1000000 Config Lcd = 16 * 2 Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0 Config Adc = Single , Prescaler = Auto , Reference = Internal Config Portc = Output Config Portd = Output Config Portb = Output Config Pina.0 = Input Config Pina.1 = Input Config Pina.5 = Input 'Up Config Pina.6 = Input 'Down Config Pina.7 = Input 'Mode Config Pina.4 = Input Set Porta.5 Set Porta.6 Set Porta.7 Set Porta.4 Main_key Alias Pina.4 Up_key Alias Pina.5 Down_key Alias Pina.6 Mode_key Alias Pina.7 Config Clock = Soft Time$ = "23:59:50" Deflcdchar 0 , 12 , 18 , 18 , 12 , 32 , 32 , 32 , 32 Deflcdchar 1 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ' replace ? with number (0-7) Deflcdchar 2 , 32 , 8 , 21 , 13 , 5 , 10 , 20 , 32 ' replace ? with number (0-7) Deflcdchar 3 , 1 , 32 , 1 , 1 , 1 , 2 , 4 , 32 ' replace ? with number (0-7) Deflcdchar 4 , 16 , 17 , 16 , 29 , 13 , 2 , 4 , 32 ' replace ? with number (0-7) Deflcdchar 5 , 32 , 32 , 32 , 21 , 17 , 17 , 14 , 32 ' replace ? with number (0-7) Dim A As Word Dim B As Word Dim C As Single Dim Uptemp As Single Dim Downtemp As Single Dim Day As Single Dim Menu As Single Dim Fans As Single Dim Motors As Single Dim Heaters As Single Day = 0 Uptemp = 38 Downtemp = 36 Fans = 00 Heaters = 00 Motors = 00 Declare Sub U_temp() Declare Sub D_temp() Declare Sub U_motor() Declare Sub U_fan() Declare Sub U_heater() Cursor Off Normal: Enable Interrupts Waitms 500 Start Adc Do If Mode_key = 0 Then Cls Disable Interrupts Incr Menu If Menu > 5 Then Menu = 0 Goto Normal End If Waitms 200 End If Select Case Menu Case 0: A = Getadc(0) B = Getadc(1) C = A - B C = C / 4 Waitms 700 Home : Lcd "Temp =" ; C ; Chr(0) ; "c " Locate 2 , 1 : Lcd ; Chr(5) ; Chr(4) ; ":" ; Time$ ; Chr(3) ; Chr(2) ; ":" ; Day ; If Time$ = "00:00:00" Then Day = Day + 1 If C < Downtemp Then Set Portb.0 If C >= Uptemp Then Reset Portb.0 If Fans = 1 Then Reset Portb.1 If Heaters = 1 Then Reset Portb.0 If Motors = 1 Then Reset Portb.2 Case 1: Gosub U_temp Case 2: Gosub D_temp Case 3: Gosub U_motor Case 4: Gosub U_fan Case 5: Gosub U_heater End Select Loop End Sub U_temp() Home : Lcd "UP TEMP = " ; Uptemp ; " " Waitms 200 If Up_key = 0 Then If Uptemp < 60 Then Incr Uptemp End If If Down_key = 0 Then If Uptemp > 0 Then Decr Uptemp End If ' If Main_key = 0 Then Goto Shoro End Sub '*********************************** Sub D_temp() Home : Lcd "DOWN TEMP = " ; Downtemp ; " " Waitms 200 If Up_key = 0 Then If Downtemp < 60 Then Incr Downtemp End If If Down_key = 0 Then If Downtemp > 0 Then Decr Downtemp End If 'If Main_key = 0 Then Goto Shoro End Sub '************************************* Sub U_motor() Home : Lcd "MOTOR OFF = " ; Motors ; " " Waitms 200 If Up_key = 0 Then If Motors < 1 Then Incr Motors End If If Down_key = 0 Then If Motors > 0 Then Decr Motors End If ' If Main_key = 0 Then Goto Shoro End Sub '********************************** Sub U_fan() Home : Lcd "FAN OFF = " ; Fans ; " " Waitms 200 If Up_key = 0 Then If Fans < 1 Then Incr Fans End If If Down_key = 0 Then If Fans > 0 Then Decr Fans End If ' If Main_key = 0 Then Goto Shoro End Sub '*********************************** Sub U_heater() Home : Lcd "HEATER OFF = " ; Heaters ; " " Waitms 200 If Up_key = 0 Then If Heaters < 1 Then Incr Heaters End If If Down_key = 0 Then If Heaters > 0 Then Decr Heaters End If ' If Main_key = 0 Then Goto Shoro End Sub
دیدگاه