f
Warning: Cannot modify header information - headers already sent by (output started at /home/anderian/ftp/www_forum/db/mysql4.php:1) in /home/anderian/ftp/www_forum/includes/sessions.php on line 548

Warning: Cannot modify header information - headers already sent by (output started at /home/anderian/ftp/www_forum/db/mysql4.php:1) in /home/anderian/ftp/www_forum/includes/sessions.php on line 549

Warning: Cannot modify header information - headers already sent by (output started at /home/anderian/ftp/www_forum/db/mysql4.php:1) in /home/anderian/ftp/www_forum/includes/page_header.php on line 343
And-Tech :: Zobacz temat - Pomiar temp. Ds18b20

Strona korzysta z plików cookie w celu realizacji usług zgodnie z Politykš prywatnoœci.

Możesz okreœlić warunki przechowywania lub dostępu do cookie w Twojej przeglšdarce lub konfiguracji usługi.

And-Tech Strona Główna And-Tech
Forum firmy And-Tech

FAQFAQ  SzukajSzukaj  UżytkownicyUżytkownicy  GrupyGrupy
RejestracjaRejestracja  ZalogujZaloguj  AlbumAlbum  DownloadDownload

Poprzedni temat «» Następny temat
Pomiar temp. Ds18b20
Autor Wiadomość
pawelec5

Dołączył: 29 Lut 2012
Posty: 8
Wysłany: Sob Mar 03, 2012 11:58 pm   Pomiar temp. Ds18b20

Witam. Posiadam Atmege644p i pisze program do sterowania domem. Potrzebuję 12 czujników temp. Z powodu braku miejsca w pamięci musiałem się ograniczyć już do 11.
Aby poprawnie to wszystko działało napisałem to w te sposób. Może ktoś ma pomysł rozwiązać to w inny dużo krótszy sposób.

Dim Nazwa_ds(12) As String * 12
Dim Wartosc_ds(12) As String * 6
Nazwa_ds(1) = "Solar "
Nazwa_ds(2) = "Bojler "
Nazwa_ds(3) = "Salon_podl "
Nazwa_ds(4) = "Salon "
Nazwa_ds(5) = "Piec "
Nazwa_ds(6) = "Temp Zewn "
Nazwa_ds(7) = "Zas. Podl "
Nazwa_ds(8) = "Kuch_Podl "
Nazwa_ds(9) = "Laz_1_Podl "
Nazwa_ds(10) = "Laz_2_Podl "
Nazwa_ds(11) = "Cyrkulacja "
'Nazwa_ds(12) = " " Koryt_podl


Readeeprom Ilosc_ds_eeprom , 10
Zmienna = Ilosc_ds_eeprom
Select Case Zmienna

Case Is = 1 :
Readeeprom Ds_eeprom_solar , 20
Case Is = 2 :
Readeeprom Ds_eeprom_solar , 20
Readeeprom Ds_eeprom_bojler , 40
Case Is = 3 :
Readeeprom Ds_eeprom_solar , 20
Readeeprom Ds_eeprom_bojler , 40
Readeeprom Ds_eeprom_salon_podl1 , 60
Case Is = 4 :
Readeeprom Ds_eeprom_solar , 20
Readeeprom Ds_eeprom_bojler , 40
Readeeprom Ds_eeprom_salon_podl1 , 60
Readeeprom Ds_eeprom_salon , 80
Case Is = 5 :
Readeeprom Ds_eeprom_solar , 20
Readeeprom Ds_eeprom_bojler , 40
Readeeprom Ds_eeprom_salon_podl1 , 60
Readeeprom Ds_eeprom_salon , 80
Readeeprom Ds_eeprom_piec , 100
Case Is = 6 :
Readeeprom Ds_eeprom_solar , 20
Readeeprom Ds_eeprom_bojler , 40
Readeeprom Ds_eeprom_salon_podl1 , 60
Readeeprom Ds_eeprom_salon , 80
Readeeprom Ds_eeprom_piec , 100
Readeeprom Ds_eeprom_temp_zew , 120
Case Is = 7 :
Readeeprom Ds_eeprom_solar , 20
Readeeprom Ds_eeprom_bojler , 40
Readeeprom Ds_eeprom_salon_podl1 , 60
Readeeprom Ds_eeprom_salon , 80
Readeeprom Ds_eeprom_piec , 100
Readeeprom Ds_eeprom_temp_zew , 120
Readeeprom Ds_eeprom_zas_podl , 140
Case Is = 8 :
Readeeprom Ds_eeprom_solar , 20
Readeeprom Ds_eeprom_bojler , 40
Readeeprom Ds_eeprom_salon_podl1 , 60
Readeeprom Ds_eeprom_salon , 80
Readeeprom Ds_eeprom_piec , 100
Readeeprom Ds_eeprom_temp_zew , 120
Readeeprom Ds_eeprom_zas_podl , 140
Readeeprom Ds_eeprom_kuch_podl , 160
Case Is = 9 :
Readeeprom Ds_eeprom_solar , 20
Readeeprom Ds_eeprom_bojler , 40
Readeeprom Ds_eeprom_salon_podl1 , 60
Readeeprom Ds_eeprom_salon , 80
Readeeprom Ds_eeprom_piec , 100
Readeeprom Ds_eeprom_temp_zew , 120
Readeeprom Ds_eeprom_zas_podl , 140
Readeeprom Ds_eeprom_kuch_podl , 160
Readeeprom Ds_eeprom_laz_1_podl , 180
Case Is = 10 :
Readeeprom Ds_eeprom_solar , 20
Readeeprom Ds_eeprom_bojler , 40
Readeeprom Ds_eeprom_salon_podl1 , 60
Readeeprom Ds_eeprom_salon , 80
Readeeprom Ds_eeprom_piec , 100
Readeeprom Ds_eeprom_temp_zew , 120
Readeeprom Ds_eeprom_zas_podl , 140
Readeeprom Ds_eeprom_kuch_podl , 160
Readeeprom Ds_eeprom_laz_1_podl , 180
Readeeprom Ds_eeprom_laz_2_podl , 200
Case Is = 11 :
Readeeprom Ds_eeprom_solar , 20
Readeeprom Ds_eeprom_bojler , 40
Readeeprom Ds_eeprom_salon_podl1 , 60
Readeeprom Ds_eeprom_salon , 80
Readeeprom Ds_eeprom_piec , 100
Readeeprom Ds_eeprom_temp_zew , 120
Readeeprom Ds_eeprom_zas_podl , 140
Readeeprom Ds_eeprom_kuch_podl , 160
Readeeprom Ds_eeprom_laz_1_podl , 180
Readeeprom Ds_eeprom_laz_2_podl , 200
'Readeeprom Ds_eeprom_kor_podl , 220
Readeeprom Ds_eeprom_cyrkul , 240
'( Case Is = 12 :
Readeeprom Ds_eeprom_solar , 20
Readeeprom Ds_eeprom_bojler , 40
Readeeprom Ds_eeprom_salon_podl1 , 60
Readeeprom Ds_eeprom_salon , 80
Readeeprom Ds_eeprom_piec , 100
Readeeprom Ds_eeprom_temp_zew , 120
Readeeprom Ds_eeprom_zas_podl , 140
Readeeprom Ds_eeprom_kuch_podl , 160
Readeeprom Ds_eeprom_laz_1_podl , 180
Readeeprom Ds_eeprom_laz_2_podl , 200
Readeeprom Ds_eeprom_kor_podl , 220
Readeeprom Ds_eeprom_cyrkul , 240
')

End Select


------------------------------odczyt id-----------------------------------------------------------


Id1(1) = 1wsearchfirst()
Id2(1) = 1wsearchnext()
Id3(1) = 1wsearchnext()
Id4(1) = 1wsearchnext()
Id5(1) = 1wsearchnext()
Id6(1) = 1wsearchnext()
Id7(1) = 1wsearchnext()
Id8(1) = 1wsearchnext()
Id9(1) = 1wsearchnext()
Id10(1) = 1wsearchnext()
Id11(1) = 1wsearchnext()
' Id12(1) = 1wsearchnext()




'----1 ds---------------------------------
If Ilosc_ds >= 1 Then

For C = 1 To 8 Step 1
Ds_1 = Ds_1 + Hex(id1(c))
Next C

End If


'----2 ds---------------------------------
If Ilosc_ds >= 2 Then

For C = 1 To 8 Step 1
Ds_2 = Ds_2 + Hex(id2(c))
Next C

End If


'----3 ds---------------------------------
If Ilosc_ds >= 3 Then

For C = 1 To 8 Step 1
Ds_3 = Ds_3 + Hex(id3(c))
Next C

End If


'----4 ds---------------------------------
If Ilosc_ds >= 4 Then

For C = 1 To 8 Step 1
Ds_4 = Ds_4 + Hex(id4(c))
Next C

End If


'----5 ds---------------------------------
If Ilosc_ds >= 5 Then

For C = 1 To 8 Step 1
Ds_5 = Ds_5 + Hex(id5(c))
Next C

End If


'----6 ds---------------------------------
If Ilosc_ds >= 6 Then

For C = 1 To 8 Step 1
Ds_6 = Ds_6 + Hex(id6(c))
Next C

End If


'----7 ds---------------------------------
If Ilosc_ds >= 7 Then

For C = 1 To 8 Step 1
Ds_7 = Ds_7 + Hex(id7(c))
Next C

End If


'----8 ds---------------------------------
If Ilosc_ds >= 8 Then

For C = 1 To 8 Step 1
Ds_8 = Ds_8 + Hex(id8(c))
Next C

End If


'----9 ds---------------------------------
If Ilosc_ds >= 9 Then

For C = 1 To 8 Step 1
Ds_9 = Ds_9 + Hex(id8(c))
Next C

End If


'----10 ds---------------------------------
If Ilosc_ds >= 10 Then

For C = 1 To 8 Step 1
Ds_10 = Ds_10 + Hex(id10(c))
Next C

End If


'----11 ds---------------------------------
If Ilosc_ds >= 11 Then

For C = 1 To 8 Step 1
Ds_11 = Ds_11 + Hex(id11(c))
Next C

End If


'----12 ds---------------------------------
' If Ilosc_ds >= 12 Then

' For C = 1 To 8 Step 1
' Ds_12 = Ds_12 + Hex(id12(c))
' Next C
'
' End If


Wait 1

End Sub


-------------------Pomiar_temp-----------------------------------------------------------------------


Sub Pomiar_temp

'--wysyłamy do wszystkich termometrów polecenie dokonania pomiaru temperatury---

1wreset
1wwrite Skip_rom
1wwrite Convert_t
Waitms 500 ' 750

'-----------------------------'wywołujemy 1 DS----------------------------------

1wreset
1wverify Id1(1)

'---------------------a potem doczytujemy z niego dane--------------------------

If Ilosc_ds >= 1 Then

1wwrite Read_scratchpad
Lsb = 1wread()
Msb = 1wread()
T = Msb * 256 't-single
T = T + Lsb
T = T / 16
If Msb.7 = 1 Then T = T - 4096
Ss = Fusing(t , "#.#") 's-string
Ss = Format(ss , "+00000")

Select Case Ds_1
Case Ds_eeprom_solar : T_solar = T
T_solar_lcd = Ss
Case Ds_eeprom_bojler : T_bojler = T
T_bojler_lcd = Ss
Case Ds_eeprom_salon_podl1 : T_salon_podl = T
T_salon_podl_lcd = Ss
Case Ds_eeprom_salon : T_salon = T
T_salon_lcd = Ss
Case Ds_eeprom_piec : T_piec = T
T_piec_lcd = Ss
Case Ds_eeprom_temp_zew : T_temp_zew = T
T_temp_zew_lcd = Ss
Case Ds_eeprom_zas_podl : T_zas_podl = T
T_zas_podl_lcd = Ss
Case Ds_eeprom_kuch_podl : T_kuch_podl = T
T_kuch_podl_lcd = Ss
Case Ds_eeprom_laz_1_podl : T_laz_1_podl = T
T_laz_1_podl_lcd = Ss
Case Ds_eeprom_laz_2_podl : T_laz_2_podl = T
T_laz_2_podl_lcd = Ss
'Case Ds_eeprom_kor_podl : T_kor_podl = T
' T_kor_podl_lcd = Ss
Case Ds_eeprom_cyrkul : T_cyrkul = T
T_cyrkul_lcd = Ss
End Select


End If

'-----------------------------'wywołujemy 2 DS----------------------------------

1wreset
1wverify Id2(1)

'-------------------powtarzamy sekwencję dla drugiego układu--------------------

If Ilosc_ds >= 2 Then

1wwrite Read_scratchpad
Lsb = 1wread()
Msb = 1wread()
T = Msb * 256
T = T + Lsb
T = T / 16
If Msb.7 = 1 Then T = T - 4096
Ss = Fusing(t , "#.#") 's-string
Ss = Format(ss , "+00000")

Select Case Ds_2
Case Ds_eeprom_solar : T_solar = T
T_solar_lcd = Ss
Case Ds_eeprom_bojler : T_bojler = T
T_bojler_lcd = Ss
Case Ds_eeprom_salon_podl1 : T_salon_podl = T
T_salon_podl_lcd = Ss
Case Ds_eeprom_salon : T_salon = T
T_salon_lcd = Ss
Case Ds_eeprom_piec : T_piec = T
T_piec_lcd = Ss
Case Ds_eeprom_temp_zew : T_temp_zew = T
T_temp_zew_lcd = Ss
Case Ds_eeprom_zas_podl : T_zas_podl = T
T_zas_podl_lcd = Ss
Case Ds_eeprom_kuch_podl : T_kuch_podl = T
T_kuch_podl_lcd = Ss
Case Ds_eeprom_laz_1_podl : T_laz_1_podl = T
T_laz_1_podl_lcd = Ss
Case Ds_eeprom_laz_2_podl : T_laz_2_podl = T
T_laz_2_podl_lcd = Ss
' Case Ds_eeprom_kor_podl : T_kor_podl = T
' T_kor_podl_lcd = Ss
Case Ds_eeprom_cyrkul : T_cyrkul = T
T_cyrkul_lcd = Ss

End Select

End If

'-----------------------------'wywołujemy 3 DS----------------------------------

1wreset
1wverify Id3(1)

'----------------------------powtarzamy sekwencję-------------------------------

If Ilosc_ds >= 3 Then

1wwrite Read_scratchpad
Lsb = 1wread()
Msb = 1wread()
T = Msb * 256
T = T + Lsb
T = T / 16
If Msb.7 = 1 Then T = T - 4096
Ss = Fusing(t , "#.#") 's-string
Ss = Format(ss , "+00000")

Select Case Ds_3
Case Ds_eeprom_solar : T_solar = T
T_solar_lcd = Ss
Case Ds_eeprom_bojler : T_bojler = T
T_bojler_lcd = Ss
Case Ds_eeprom_salon_podl1 : T_salon_podl = T
T_salon_podl_lcd = Ss
Case Ds_eeprom_salon : T_salon = T
T_salon_lcd = Ss
Case Ds_eeprom_piec : T_piec = T
T_piec_lcd = Ss
Case Ds_eeprom_temp_zew : T_temp_zew = T
T_temp_zew_lcd = Ss
Case Ds_eeprom_zas_podl : T_zas_podl = T
T_zas_podl_lcd = Ss
Case Ds_eeprom_kuch_podl : T_kuch_podl = T
T_kuch_podl_lcd = Ss
Case Ds_eeprom_laz_1_podl : T_laz_1_podl = T
T_laz_1_podl_lcd = Ss
Case Ds_eeprom_laz_2_podl : T_laz_2_podl = T
T_laz_2_podl_lcd = Ss
' Case Ds_eeprom_kor_podl : T_kor_podl = T
' T_kor_podl_lcd = Ss
Case Ds_eeprom_cyrkul : T_cyrkul = T
T_cyrkul_lcd = Ss
End Select

End If

... z powodu długiego źródła nie będę podawał reszty DS...

-------------------------------pierwsze podłączenie czujników - setup----------------------------

Sub Setup_ds

Zmienna = Ilosc_ds

Cls
If Ust_ds = 1 Then
Lowerline : Lcd "KONTYNNUACJA"
Thirdline : Lcd "USTAWIEN DS"
Ust_ds = 0
Else
Lowerline : Lcd "USTAWIENIA DS"
Wait 1

Do
Locate 1 , 1 : Lcd "ILE CZUJNIKOW"
Locate 2 , 1 : Lcd "PROGRAMUJEMY?"
Locate 4 , 1 : Lcd ; Zmienna ; " "

Debounce Pinb.1 , 0 , Up_set , Sub
Debounce Pinb.0 , 0 , Down_set , Sub

If Zmienna > 12 Then Zmienna = 1
If Zmienna < 1 Then Zmienna = 12

'zabezpieczenie wyjdzie jezeli nic sie nei zrobi po...
Time_out = Time_out + 1
If Time_out > 1000 Then Sw_ok = 1
Loop Until Sw3 = 0

Ilosc_ds_2 = Zmienna
End If

'-----------------------przypisanie DS do konkretnych wejść---------------------
Zmienna = 0

'------------------------------1 CZUJNIK-SOLAR----------------------------------

Cls
Do
Upperline
Lcd "LEZELI SA PODLACZONE"
Lowerline
Lcd "ODLACZ WSZYSTKIE DS"
Fourthline
Lcd "nasisnij OK"
Loop Until Sw3 = 0

Do
Call Test_ilosc_ds

If Ilosc_ds <> 0 And Zmienna = 0 Then 'kontrola czy są wszystkie ds odłączone
Cls
Do
Upperline : Lcd "ODLACZ WSZYSTKIE DS "
Fourthline : Lcd "nasisnij OK"
Loop Until Sw3 = 0
End If

If Ilosc_ds = 0 Then
Zmienna = 1
Cls

Do
Upperline : Lcd "PODLACZ DS SOLAR"
Fourthline : Lcd "nasisnij OK"
Loop Until Sw3 = 0

End If



If Ilosc_ds = 1 And Zmienna = 1 Then
Cls
Lowerline
Lcd "----OK---"
End If

Loop Until Ilosc_ds = 1 And Zmienna = 1

Zmienna = 0

'ZAPIS NUMERU DS DO PAMIECI JAKO DS_EEPROM_SOLAR
Call Odczyt_id_ds
' Print #1 , "Ds_1 " ; Ds_1
Ds_eeprom_solar = Ds_1
' Print #1 , " zapis do pamieci Ds_eeprom_solar " ; Ds_1
Writeeeprom Ds_eeprom_solar , 20

'------------------------------2 CZUJNIK-BOJLER----------------------------------
If Ilosc_ds_2 >= 2 Then

' Print #1 , " "
' Print #1 , "Po podłączeniu 2 czujnika"
' Print #1 , " "

Cls
Zmienna = 0
Do
Call Test_ilosc_ds


If Ilosc_ds = 1 Then
Cls
Do
Upperline
Lcd "PODLACZ DS BOJLER"
Thirdline
Lcd "nasisnij OK"
Locate 4 , 11 : Lcd "ILOSC DS " ; Ilosc_ds
Loop Until Sw3 = 0
Zmienna = 1
End If

If Ilosc_ds = 2 And Zmienna = 1 Then

Call Odczyt_id_ds

' Print #1 , "Ds_1 " ; Ds_1
' Print #1 , "Ds_2 " ; Ds_2
' Print #1 , " "


Select Case Ds_1

Case Ds_eeprom_solar ': Print #1 , " Ds1 jako solar"

Case Else : Ds_eeprom_bojler = Ds_1
' Print #1 , "ds_1 jako bojler"
Writeeeprom Ds_eeprom_bojler , 40

End Select


Select Case Ds_2

Case Ds_eeprom_solar ': Print #1 , " Ds2 jako solar"

Case Else : Ds_eeprom_bojler = Ds_2
' Print #1 , "ds_2 jako bojler"
Writeeeprom Ds_eeprom_bojler , 40
End Select



End If

Loop Until Ilosc_ds = 2 And Zmienna = 1

Else

Ds_eeprom_bojler = ""
Writeeeprom Ds_eeprom_bojler , 40

End If

'------------------------------3 CZUJNIK-SALON-PODL1----------------------------------
If Ilosc_ds_2 >= 3 Then

' Print #1 , " "
' Print #1 , "Po podłączeniu 3 czujnika"
' Print #1 , " "

Cls
Zmienna = 0
Do
Call Test_ilosc_ds

If Ilosc_ds = 2 Then
Cls
Do
Upperline
Lcd "PODLACZ DS SALON-PODL1"
Thirdline
Lcd "nasisnij OK"
Locate 4 , 11 : Lcd "ILOSC DS " ; Ilosc_ds
Loop Until Sw3 = 0
Zmienna = 1
End If

If Ilosc_ds = 3 And Zmienna = 1 Then

Call Odczyt_id_ds

' Print #1 , "Ds_1 " ; Ds_1
' Print #1 , "Ds_2 " ; Ds_2
' Print #1 , "Ds_3 " ; Ds_3
' Print #1 , " "


Select Case Ds_1

Case Ds_eeprom_solar ': Print #1 , " Ds1 jako solar"
Case Ds_eeprom_bojler ': Print #1 , " Ds1 jako bojler"

Case Else : Ds_eeprom_salon_podl1 = Ds_1
' Print #1 , "ds_1 jako salon_podlogowka"
Writeeeprom Ds_eeprom_salon_podl1 , 60

End Select


Select Case Ds_2

Case Ds_eeprom_solar ': Print #1 , " Ds2 jako solar"
Case Ds_eeprom_bojler ' : Print #1 , " Ds2 jako bojler"

Case Else : Ds_eeprom_salon_podl1 = Ds_2
' Print #1 , "ds_2 jako salon_podlogowka"
Writeeeprom Ds_eeprom_salon_podl1 , 60

End Select


Select Case Ds_3

Case Ds_eeprom_solar ' : Print #1 , " Ds3 jako solar"
Case Ds_eeprom_bojler ': Print #1 , " Ds3 jako bojler"

Case Else : Ds_eeprom_salon_podl1 = Ds_3
' Print #1 , "ds_3 jako salon_podlogowka"
Writeeeprom Ds_eeprom_salon_podl1 , 60

End Select

End If

Loop Until Ilosc_ds = 3 And Zmienna = 1

Else

Ds_eeprom_salon_podl1 = ""
Writeeeprom Ds_eeprom_salon_podl1 , 60

End If

' w tym miejscu jest najwiekszy problem z ilością pamięci...
 
     
Wyświetl posty z ostatnich:   
Odpowiedz do tematu
Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Nie możesz załączać plików na tym forum
Możesz ściągać załączniki na tym forum
Dodaj temat do Ulubionych
Wersja do druku

Skocz do:  

Powered by phpBB modified by Przemo © 2003 phpBB Group