Translate

Membuat Alat Untuk Kendali Suhu / kelembapan Tanaman Anthurium dan Jamur

Membuat Alat Untuk Kendali Suhu / kelembapan Tanaman Anthurium dan Jamur


            Pada kesempatan berbahagia ini saya akan menjelaskan mengenai bagaimana cara membuat alat yang digunakan untuk mengendalikan kesejukan, intensitas cahaya dan waktu penyiraman secara otomatis untuk tanaman hias, jamur dan tanaman culture jaringan. Alat ini dilengkapi dengan 4 buah kipas DC yang ukurannya besar, kemudian ada kran air  otomatis menggunakan servo. di atas alat ini terdapat sebuat atap yng bisa buka tutup sehingga intensitas cahaya bisa masuk ke dalam alat dan bisa diterima oleh tanaman, yang harus diperhatikan yaitu tanaman hias harus berada di suhu 18 sampai 31 derajat celcius dan kelembapannya antara 60 sampai 80 persen. waktu untuk pencahayaan maksimal 8 jam per hari dari jam 8 sampai jam 4 sore, maka dari itu alat ini akan melakukan hal itu semua secara otomatis, waktu penyiraman alat ini yaitu pada jam 7 dan jam 5 sore. untuk lebih jelasnya berikut program dan skemanya.



a. Minimum System ATMega  





b. RTC (Real Time Clock)





c. Micro Servo





d. Sensor DHT11





 e, Program Bascom AVR

$regfile = "m16def.dat"
$crystal = 12000000
$baud = 9600

Config Lcdpin = Pin , Rs = Portc.2 , E = Portc.3 , Db4 = Portc.4
Config Lcdpin = Pin , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7
Config Lcd = 16 * 2

Config Timer1 = Pwm , Pwm = 8 , Prescale = 64 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up

Cls
Cursor Off

Config Sda = Portc.1
Config Scl = Portc.0

Const Ds1307w = &HD0
Const Ds1307r = &HD1

Dim Oke As Integer
Dim Mark As Byte

Dim _sec As Byte
Dim _min As Byte
Dim _hour As Byte
Dim _day As Byte
Dim _month As Byte
Dim _year As Byte
Dim _weekday As Byte

Dim Sa(3) As String * 2
Dim Sb(3) As String * 2

Declare Sub Getdatetime
Declare Sub Settime
Declare Sub Getsec
Declare Sub Disptime
Declare Sub Dispdate
Declare Sub Format_00
Declare Sub Setdate
Declare Sub Subset

Dim I As Byte
Dim Flagset As Bit                                          '0 = Waktu, 1 = Tanggal
Dim Flagreset As Bit
Dim Line1 As String * 1

Dim Weekday As Byte
Dim Jam_puluhan As Integer
Dim Jam_satuan As Integer
Dim Min_puluhan As Integer
Dim Min_satuan As Integer
Dim Sec_puluhan As Integer
Dim Sec_satuan As Integer

Declare Sub Get_th(t As Byte , H As Byte)
Config Serialin = Buffered , Size = 128
Config Serialout = Buffered , Size = 128
Dht_put Alias Portb.2
Dht_get Alias Pinb.2
Dht_io_set Alias Ddrb.2
Dim T As Byte
Dim H As Byte
Dim Crc As Byte
Dim Mybyte As Byte
Dim Sensor_data As String * 40
Dim Tmp_str8 As String * 8
Dim Count As Byte
Enable Interrupts
Set Dht_io_set
Set Dht_put

Ddrd.7 = 1

'_sec = 00
'_hour = 17
'_min = 50
'Settime

'_day = 07
'_month = 11
'_year = 15
'Setdate

I = 13
Line1 = Chr(13)

'tutup
'Servo(1) = 105

'buka
'Servo(1) = 170

Mark = 0

Do

Call Get_th(t , H)

Lowerline
Lcd "TMP: " ; T ; "C" ; " / " ; H ; "%"

If T > 31 Then
Portd.7 = 1
Else
Portd.7 = 0
End If

Getdatetime

Upperline
Disptime

Waitms 200

If _hour >= 16 Then
Pwm1a = 135
Elseif _hour >= 8 Then
Pwm1a = 220

End If

If _hour = 7 And Mark = 0 Then
Pwm1a = 10
Wait 10
Pwm1b = 175
Mark = 1
Elseif _hour = 17 And Mark = 1 Then
Pwm1a = 10
Wait 10
Pwm1b = 175
Mark = 0
End If

Loop

Sub Getdatetime:

I2cstart                                                    ' Generate start code
I2cwbyte Ds1307w                                            ' send address

I2cwbyte 0                                                  ' start address in 1307

I2cstart                                                    ' Generate start code
I2cwbyte Ds1307r                                            ' send address

I2crbyte _sec , Ack
I2crbyte _min , Ack                                         ' MINUTES
I2crbyte _hour , Ack                                        ' Hours
I2crbyte _weekday , Ack                                     ' Day of Week
I2crbyte _day , Ack                                         ' Day of Month
I2crbyte _month , Ack                                       ' Month of Year
I2crbyte _year , Nack                                       ' Year

I2cstop

_sec = Makedec(_sec) : _min = Makedec(_min) : _hour = Makedec(_hour)
_day = Makedec(_day) : _month = Makedec(_month) : _year = Makedec(_year)
End Sub

Sub Settime:
_sec = Makebcd(_sec) : _min = Makebcd(_min) : _hour = Makebcd(_hour)

I2cstart                                                    ' Generate start code
I2cwbyte Ds1307w                                            ' send address
I2cwbyte 0                                                  ' starting address in 1307
I2cwbyte _sec                                               ' Send Data to SECONDS
I2cwbyte _min                                               ' MINUTES
I2cwbyte _hour                                              ' Hours
I2cstop

End Sub

Sub Setdate

_day = Makebcd(_day) : _month = Makebcd(_month) : _year = Makebcd(_year)

I2cstart                                                    ' Generate start code
I2cwbyte Ds1307w                                            ' send address
I2cwbyte 4                                                  ' starting address in 1307
I2cwbyte _day                                               ' Send Data to SECONDS
I2cwbyte _month                                             ' MINUTES
I2cwbyte _year                                              ' Hours
I2cstop

End Sub

Sub Dispdate
Sa(1) = Str(_day)
Sa(2) = Str(_month)
Sa(3) = Str(_year)
Format_00
Lcd "Date: " ; Sb(1) ; "-" ; Sb(2) ; "-" ; Sb(3)
End Sub

Sub Disptime
Sa(1) = Str(_hour)
Sa(2) = Str(_min)
Sa(3) = Str(_sec)
Format_00
Lcd "Time: " ; Sb(1) ; ":" ; Sb(2) ; ":" ; Sb(3)
End Sub

Sub Format_00
For I = 1 To 3 Step 1
Sb(i) = Format(sa(i) , "00")
Next I
End Sub

Sub Get_th(t As Byte , H As Byte)
 Count = 0
 Sensor_data = ""
 Set Dht_io_set
 Reset Dht_put
 Waitms 25
 Set Dht_put
 Waitus 40
 Reset Dht_io_set
 Waitus 40
 If Dht_get = 1 Then
    H = 1
    Exit Sub
 End If
  Waitus 80
  If Dht_get = 0 Then
    H = 2
    Exit Sub
  End If
  While Dht_get = 1 : Wend
   Do
    While Dht_get = 0 : Wend
    Waitus 30
     If Dht_get = 1 Then
       Sensor_data = Sensor_data + "1"
       While Dht_get = 1 : Wend
       Else
       Sensor_data = Sensor_data + "0"
    End If
    Incr Count
   Loop Until Count = 40
   Set Dht_io_set
   Set Dht_put
   Tmp_str8 = Left(sensor_data , 8)
   H = Binval(tmp_str8)
   Tmp_str8 = Mid(sensor_data , 17 , 8)
   T = Binval(tmp_str8)
   Tmp_str8 = Right(sensor_data , 8)
   Crc = Binval(tmp_str8)
   Mybyte = T + H
   If Mybyte <> Crc Then
      H = 3
   End If
End Sub




f. VIDEO HASILNYA












No comments:

Post a Comment