اطلاعیه

Collapse
No announcement yet.

کار با سنسور دمای smt160

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    کار با سنسور دمای smt160

    با سلام
    من برای یک ماشین جوجه کشی نیاز به اندازه گیری دما با دقت 0.1 درجه دارم ،که از سنسور smt160 میخوام استفاده کنم.
    همونطور که میدونید این سنسور با تغییر دما دیوتی سایکل خروجیش تغییر میکنه.
    برای اندازه گیری دیوتی سایکل با mega 16 برنامه نوشتم. اما دقت اصلا نداره.تو سایت هم گشتم و چند مدل برنامه پیدا کردم (با کپچر-اینتراپت خروجی و bitwait) اما اونها هم دقت لازم رو نداشتن.
    از طرفی هم میدونم که با میکرو میشه دقت 0.05 درجه رو با این سنسور اندازه گرفت چون تو کاتالوگ سنسور نوشته مناسب برای میکرو کنترلر ها.اما با این برنامه ها دقتش حتی از 0.5 درجه هم کمتر میشه.
    لطفا کمکم کنید،میدونم مشکل تو برنامست اما نمیدونم کجاش!!!

    #2
    پاسخ : کار با سنسور دمای smt160

    سلام
    با چه زبونی برنامه نوشتی؟
    اگه میشه برنامه ای که نوشتی بذار تا ی نگاه بندازیم :read:

    دیدگاه


      #3
      پاسخ : کار با سنسور دمای smt160

      سلام با بسکام نوشتم و اینم نمونه برنامه ها
      برنامه نوشته شده با استفاده از capture
      $regfile = "m16def.dat"
      $crystal = 8000000
      Config Portb.2 = Output
      Config Lcdpin = Pin , Db4 = Portd.0 , Db5 = Portd.1 , Db6 = Portd.2 , Db7_
      = Portd.3 , Rs = Portd.4 , E = Portd.5 : Cls : Cursor Off
      Config Lcd = 16 * 2
      Config Timer1 = Timer , Prescale = 1 , Capture Edge = Rising
      Dim Count As Byte , High_level As Word , Period As Word , Temp As Single
      Dim End_dc As Byte
      On Icp1 Duty_cycle Nosave
      '--------------------------------------------------------
      Enable Interrupts
      Do
      Enable Icp1
      Up:
      If End_dc = 0 Then Rjmp Up
      Disable Icp1
      '-------------------------
      Temp = High_level / Period
      Temp = Temp - 0.320 : Temp = Temp / 0.0047
      Cls : Lcd "temp=" ; Temp : Waitms 500
      End_dc = 0 : Count = 0
      Loop
      End
      '--------------------------------------------------------
      Duty_cycle:
      PUSH R16:Push R24:PUSH R25:PUSH R26:PUSH R27
      IN R24,SREG: PUSH R24
      Incr Count
      If Count = 5 Then
      Timer1 = 0 : Tccr1b.ices1 = 0 'falling
      rjmp duty_cycle_end
      End If
      '------------------------
      If Count = 6 Then
      High_level = Capture1 : Tccr1b.ices1 = 1 'rising
      rjmp duty_cycle_end
      End If
      '------------------------
      If Count = 7 Then
      End_dc = 1 : Period = Capture1
      End If
      Duty_cycle_end:
      POP R24:!OUT SREG ,R24
      POP R27:POP R26:POP R25:POP R24:POP R16
      Return

      دیدگاه


        #4
        پاسخ : کار با سنسور دمای smt160

        اینم روش دوم برنامه نوشته شده که ازش جواب نگرفتم:
        '--------------------------------main-------------------------------------------
        $regfile = "m8def.dat"
        $crystal = 8000000
        '-------------------------------lcd---------------------------------------------
        Config Lcdpin = Pin , Db4 = Portd.0 , Db5 = Portd.1 , Db6 = Portd.2 , Db7_
        = Portd.3 , Rs = Portd.4 , E = Portd.5
        '--------------------------------dim-------------------------------------------
        Dim Yazdkit_reset As Word
        Dim Yazdkit_set As Word
        Dim Temp As Single
        Dim Duty As Single
        Dim X As Integer

        '-------------------------------------------------------------------------------
        Config Timer1 = Timer , Prescale = 1
        Enable Timer1
        '--------------------------------main------------------------------------------
        Config Pinb.2 = Input
        '------------------------------------------------------------------------------
        Cursor Off
        Cls
        Locate 1 , 5
        Lcd "Hello"
        Locate 2 , 1
        Lcd "WWW.YAZDKIT.COM"
        Wait 2
        Cls

        Smt160:
        Do
        Gosub Read_data_sm160
        Locate 1 , 1
        Lcd "T= " ; Temp ; "c ";
        Wait 1
        Loop

        '-------------------------------------------------------------------------------
        Read_data_sm160:
        Bitwait Pinb.2 , Set
        Bitwait Pinb.2 , Reset
        Bitwait Pinb.2 , Set
        Bitwait Pinb.2 , Reset
        Bitwait Pinb.2 , Set
        Bitwait Pinb.2 , Reset
        Stop Timer1


        Bitwait Pinb.2 , Set
        Timer1 = 0
        Start Timer1
        Bitwait Pinb.2 , Reset
        'Xl = Timer1
        Yazdkit_set = Timer1


        Timer1 = 0
        Start Timer1
        Bitwait Pinb.2 , Set
        'Xf = Timer1
        Yazdkit_reset = Timer1

        X = Yazdkit_set + Yazdkit_reset
        Duty = Yazdkit_set / X

        Duty = Duty - 0.32
        Waitms 1
        Temp = Duty / 0.0047
        Waitms 1
        Locate 1 , 1
        Stop Timer1
        Return

        دیدگاه


          #5
          پاسخ : کار با سنسور دمای smt160

          این هم با استفاده از پایه های اینتراپت میکرو که باز هم دقت نداشت.
          باید با کدویژن کار کنم درسته؟آخه کدویژن دقیق تره!!!
          $regfile = "m8def.dat"
          $crystal = 8000000
          Config Lcdpin = Pin , Db4 = Pinb.4 , Db5 = Pinb.5 , Db6 = Pinb.6 , Db7 = Pinb.7 , E = Pinb.3 , Rs = Pinb.2
          Config Lcd = 16 * 2
          Cursor Off
          Dim X As Integer
          Dim Xf As Word
          Dim Xl As Word
          Dim Temp As Single
          Dim L As Byte
          Dim Lop2 As Byte
          Dim Lop1 As Byte
          Dim Cn As Byte
          Dim Cl As Byte
          Dim F As Single

          Cls

          Config Int0 = Rising
          Config Int1 = Falling
          Config Timer1 = Timer , Prescale = 1
          Enable Interrupts
          Enable Timer1
          Enable Int0
          Enable Int1
          On Int0 Int0_int
          On Int1 Int1_int





          Do
          X = Xl + Xf
          F = Xl / X
          F = F - 0.32
          Temp = F / 0.0047
          Locate 1 , 1
          Lcd Temp ; "c "
          '
          Loop

          Int1_int:
          Stop Timer1
          Xl = Timer1
          Timer1 = 0
          Start Timer1


          Return

          Int0_int:
          Stop Timer1
          Xf = Timer1
          Timer1 = 0
          Start Timer1

          Return

          End

          دیدگاه

          لطفا صبر کنید...
          X