Digitalni Thermostat v2 (DS18B20)

Sve vezano za mikrokontrolere

Moderators: pedja089, stojke369, [eDo], trax

User avatar
Feko
Stariji član
Stariji član
Posts: 4394
Joined: 23-07-2008, 06:18
Location: Hrvatska, Slavonija, Selo moje malo...

Re: Digitalni Thermostat v2 (DS18B20)

Post by Feko »

Ništa ja nisam skužio kako tebi idu pinovi šta 16-15, 1-14
Ako nisi zeznuo napajanje i masu dakle prvi drugi pa i treći pin..moguće da je display još u životu :roll:
Ivcha
Posts: 8
Joined: 20-03-2013, 02:08

Re: Digitalni Thermostat v2 (DS18B20)

Post by Ivcha »

Zamenio sam sledece pinove. sa leve strane displej sa desne ploca

16 - 1
15 - 2
1 - 3
2 - 4
3 - 5
4 - 6
5 - 7
6 - 8
7 - 9
8 - 10
9 - 11
10 - 12
11 - 13
12 - 14
13 - 15
14 - 16

Kada ukljucim plocu imam samo svetlo na displeju.
Da li bi trebalo da se ispise neki tekst i ukoliko senzor nije povezan ?
User avatar
Kukinjos
Pravi forumaš
Pravi forumaš
Posts: 1724
Joined: 28-03-2012, 18:01
Location: Split

Re: Digitalni Thermostat v2 (DS18B20)

Post by Kukinjos »

Izgleda da nisi ništa spalio, po tablici koju si napisao. Moram priznat da se nikako ne mogu prestat čudit kako si uspio tako zamiješat pinove, shvatio bi da si okrenuo za 180 stupnjeva, ali ti si pomaknuo u lijevo sve za dva pina i k tome okrenuo za 180 pinove 1 i 2 (16 i 15). Kakva zavrzlama ti je bila u glavi :lol: ?
Ako si sad sve spojio, pomicanjem potenciometra P1 bi morao dobit tekst, ili barem tamne kvadrate u gornjem redu, što bi bio znak da je display preživio....
Cezare, star sam i nemoćan, ali poslušaj moj savjet ....
Ivcha
Posts: 8
Joined: 20-03-2013, 02:08

Re: Digitalni Thermostat v2 (DS18B20)

Post by Ivcha »

Nisam nista okrenuo tako idu pinovi na displeju. Sad cu da ga vezem na paralelni port na kompjuteru pa cu da testiram da li radi
Ivcha
Posts: 8
Joined: 20-03-2013, 02:08

Re: Digitalni Thermostat v2 (DS18B20)

Post by Ivcha »

Resio sam problem. Lose bilo podnozje pic-a. Krenuo sam sve izpocetka napravio novi pcb sve na tenane, vezao displej kako treba. Sad radi ekstra. Samo jedna stvar nedostaje u dokumentaciji objasnjeje oko jumpera na plocci za sta sluzi i u kojoj poziciji kako radi...
User avatar
Feko
Stariji član
Stariji član
Posts: 4394
Joined: 23-07-2008, 06:18
Location: Hrvatska, Slavonija, Selo moje malo...

Re: Digitalni Thermostat v2 (DS18B20)

Post by Feko »

Pa u orginalnoj shemi iz elektora je objašnjeno. Jedan položaj je kad termostat radi u sistemu grijanja a drugi u sistemu hlađenja. Kod hlađenja se uređaj/kompresor/ventilator ili šta već uključuje na višoj temperaturi i kad spusti za stupanj/dva ovisno kolika je namještena histereza, isključuje se...dakle obrnuti proces od grijanja.
Ivcha
Posts: 8
Joined: 20-03-2013, 02:08

Re: Digitalni Thermostat v2 (DS18B20)

Post by Ivcha »

Koji izlaz je za grejanje RA2 ili RA3
User avatar
Feko
Stariji član
Stariji član
Posts: 4394
Joined: 23-07-2008, 06:18
Location: Hrvatska, Slavonija, Selo moje malo...

Re: Digitalni Thermostat v2 (DS18B20)

Post by Feko »

To sad više ne znam..moraš probati. Vjerojatno po shemi je jumper defaultno postavljen na sistem grijanja.
Kad termostat proradi to provjeriš u par sekundi. :wink:
Damir_Gsm
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 284
Joined: 16-01-2013, 10:09
Location: Macedonia

Re: Digitalni Thermostat v2 (DS18B20)

Post by Damir_Gsm »

r2 ide na otpor i to je grijanje.Ja licno koristim prekidace koje vadim iz stranicnog fleta ajfona koji sluzi za ukljucivanje vibraciju/zvona.Posto sam serviser telefona imam ih koliko mi treba pa sam eto to iskoristio.Inace termostat jako dobro radi,ali evo desilo mi se jednom da kad ga namestim na 38 stepena ne radi.Dodje do 38 i pokaze sve nule zabrblja nesto i pocne iz pocetka.Kad je recimo na 30 podesen radi bez problema :(
Pojma nemam sta je bilo u pitanju.Rasturio sam ga polemio novu pcb preprogramovao pica i sad radi.
pozz
Damir
User avatar
Feko
Stariji član
Stariji član
Posts: 4394
Joined: 23-07-2008, 06:18
Location: Hrvatska, Slavonija, Selo moje malo...

Re: Digitalni Thermostat v2 (DS18B20)

Post by Feko »

Vjerojatno je bilo dovoljno preprogramirati pic. To pretpostavljam može biti samo greška u programu :roll:
Damir_Gsm
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 284
Joined: 16-01-2013, 10:09
Location: Macedonia

Re: Digitalni Thermostat v2 (DS18B20)

Post by Damir_Gsm »

stvarno ne znam.E sad interesantno mi to sto nekad zna da zabrblja na ove zicane grijace.Pojma nemam zasto.Mada maksimum na koji sam ja testriao je 300w.Kako i da je,za te pare radi ko saat :lol:
Ivcha
Posts: 8
Joined: 20-03-2013, 02:08

Re: Digitalni Thermostat v2 (DS18B20)

Post by Ivcha »

Ja uredjaj pravim za kontrolu grejaca duplikatora. Grejac je od 1800W, mislim da ce moci da radi s obzirom da je triak bta16 na 16 Ampera nebi trebalo da ima problema. Greac greje vodu u posudu od prohroma na kojoj se stavljena cevcica koja u kojoj ide senzor. Interesuje me samo cime bi bilo najbolje zaliti senzor. Razmislam da za to upotrebim Silikon ili Pur-Penu, da li neko od vas ima bolju ideju?
User avatar
Kukinjos
Pravi forumaš
Pravi forumaš
Posts: 1724
Joined: 28-03-2012, 18:01
Location: Split

Re: Digitalni Thermostat v2 (DS18B20)

Post by Kukinjos »

Nemoj s pur-pjenom loš je vodić topline. Ako je to zatvorena cjevčica od inoxa, ja bih na dno stavio onu bijelu termo pastu za hladnjake tranzistora i u nju gurnuo senzor, ostatak bi napunio silikonom.
Cezare, star sam i nemoćan, ali poslušaj moj savjet ....
User avatar
electron
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 225
Joined: 28-02-2009, 19:20
Location: Serbia

Re: Digitalni Thermostat v2 (DS18B20)

Post by electron »

Dali je neko radio slicnu stvar, ali dvokanalni sa Lcd , pic, 2x1820 ili 2x18b20 u picbasicu?
Na nekom sam forumu nasao da je neki nas tip sa ovih prostora radio za auto, ali mi cimnula struja i ode sve u....(Naravoucenije: ubacio sam UPS) :idea:
Cini mi se da je Zoran... :cry:
User avatar
electron
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 225
Joined: 28-02-2009, 19:20
Location: Serbia

Re: Digitalni Thermostat v2 (DS18B20)

Post by electron »

Nasao sam neki kod, dali je neko radio ovo da malo iskomentarise:

Code: Select all

'* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
'* Universal thermostat -25/+75 C.  by R.T.G. van Steenis                  *
'* Digital thermostat (080090-11) from Elektor july_august 2008            *
'* Compiler : PicBasic Pro 2.44                                            *
'* B0 = Mode switch in (In)            A0 = LCD Enable    (Out)            *
'* B1 = + switch in    (In)            A1 = LCD RS        (Out)            *
'* B2 = - switch in    (In)            A2 = "Warm" Output (Out)            *
'* B3 = Not connected  (Out)           A3 = "Cold" Output (Out)            *
'* B4 = LCD Bit 4      (Out)           A4 = DQ DS1820     (In)             *
'* B5 = LCD Bit 5      (Out)                                               *
'* B6 = LCD Bit 6      (Out)                                               *
'* B7 = LCD Bit 7      (Out                                                *
'*                                                                         *
'*                 modify by Niculescu Dan                                 * 
'*                                                                         *
'*         DUAL THERMO 2xDS18B20 ; PIC 16F628A  ; LCD 2x16                 *
'* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

TRISA= %11110000                        ' RA0..3=Outputs RA4=Input
TRISB= %00000111 			          ' RB0..RB2=Inputs, RB3..RB7=Outputs
CMCON=7                                 ' Disable comparators

DEFINE LCD_DREG PORTB                   ' LCD on port B
DEFINE LCD_DBIT 4                       ' Data bits B4..B7
DEFINE LCD_RSREG PORTA                  ' RS on PORTA
DEFINE LCD_RSBIT 1                      ' RS on A1 
DEFINE LCD_EREG PORTA                   ' E on PORTA
DEFINE LCD_EBIT 0                       ' E on A0
DEFINE LCD_BITS 4                       ' LCD 4 bit mode
DEFINE LCD_LINES 2                      ' 2 line LCD display

Temperature1     Var	Word		' Temperature storage Sensor1
Temperature2     Var	Word		' Temperature storage Sensor2
TempC            Var    Word
Float            Var    Word
TargetTemp	     Var	Word		' Desired Temperature
Hyst		     Var	Word		' Hystereris
V		     Var	Word		' Var. for display
V2		     Var	Word		' Var. for display
B1               Var    Byte        ' Byte for TargetTemp calculation 
B2               Var    Byte        ' Byte for TargetTemp calculation
Sign		     Var	Byte		' +/- sign
Mode 		     Var	Byte		' 0=Temp. display, 1=Set Temp, 2=Set Hysteresis
DQ		     Var	PORTA.4	' One-wire data pin
Twist            Var    Bit
Twist2           Var    Bit
Dummy            Var    Byte

DS18B20_9bit 	CON %00011111 ; 93.75ms, 0.5°C
DS18B20_10bit 	CON %00111111 ; 187.5ms, 0.25°C 
DS18B20_11bit 	CON %01011111 ; 375ms,   0.125°C
DS18B20_12bit 	CON %01111111 ; 750ms,   0.0625°C  (default)
DS18B20_1_12bit 	CON %01111111 ; 750ms,   0.0625°C  
DS18B20_2_12bit 	CON %01111111 ; 750ms,   0.0625°C  

DATA 46, 224, 20                        ' Temp MSB, TEMP LSB, Hysteresis DIV 10

PORTA.2=0                               ' Warm Output Low
PORTA.3=0                               ' Cold Output Low
Mode=0                                  ' Temperature display mode  
Twist = 0
Twist2 = 0

Pause 500
LCDOUT $FE, 1, $FE, $0C                 ' Clear display, cursor off
Pause 250

Read 0, B1                              ' Read TargetTemp MSB
Read 1, B2                              ' Read TargetTemp LSB
TargetTemp=B1*256+B2                    ' Calculate TargetTemp value (Default=20.0 C.)
Read 2, B1                              ' Read Hysteresis 
Hyst=10*B1                              ' Calculate Hysteresis value (Default= 2.0 C.)  

 OWOut DQ, 1, [$55, $28,  $DD, $06, $49, $1, $0, $0, $D4, $4E, $FF, $FF, $7F] ' Init Sensor 1
 OWOut DQ, 1, [$55, $28,  $DD, $06, $49, $1, $0, $0, $D4, $48] 
 OWOut DQ, 1, [$55, $28,  $DD, $06, $49, $1, $0, $0, $D4, $B8] 
 OWOut DQ, 1, [$55, $28,  $DD, $06, $49, $1, $0, $0, $D4, $BE] 
Pause 1000
 OWIn DQ, 0, [Temperature1.Byte0, Temperature2.Byte1]
LcdOut $FE, $80,  "Senzor1 INIT OK" 
Pause 500


 OWOut DQ, 1, [$55, $28,  $EB, $EA, $48, $1, $0, $0, $FF, $4E, $FF, $FF, $7F] ' Init Sensor 2
 OWOut DQ, 1, [$55, $28,  $EB, $EA, $48, $1, $0, $0, $FF, $48] 
 OWOut DQ, 1, [$55, $28,  $EB, $EA, $48, $1, $0, $0, $FF, $B8] 
 OWOut DQ, 1, [$55, $28,  $EB, $EA, $48, $1, $0, $0, $FF, $BE] 
Pause 1000
 OWIn DQ, 0, [Temperature2.Byte0, Temperature2.Byte1] 
LcdOut $FE, $C0,  "Senzor2 INIT OK" 
Pause 1000


MainLoop: 
 If PORTB.0=0 then                      ' Mode switch pressed
  Pause 50                              ' Debounce 
LcdOut $FE, 1
 LcdOut $FE, $8F, "*"                   ' Show that command is accepted 
  If PORTB.0=0 then MainLoop            ' Wait until button is released  
  Mode=Mode+1                           ' Increment mode
  If Mode=2 then                        ' Save Target Temperature (Mode1 -> Mode2)
   Write 0, TargetTemp / 256		    ' TargetTemp MSB
   Write 1, TargetTemp MOD 256          ' TargetTemp LSB
  EndIf
  If Mode > 2 Then                      ' Save Hysteresis (Mode 2 -> Mode 0) 
   Mode=0               		    ' Only 0, 1, 2 are valid
   Write 2, Hyst / 10                   ' Divide Hyst value to fit in Byte
  EndIf
 EndIf

 If Mode =1 then
  LcdOut $FE, $80, "SET TEMPERATURE "   ' Show function
  V=TargetTemp                          ' TargetTemp in V  
  Gosub SelectSign                      ' Select +/blank/- 
  Gosub DTemp                           ' Display Target Temperature
  If (PORTB.1=0) Or (PORTB.2=0) then    ' Up or Down button pushed
   If PORTB.2=0 then                    ' Down button 
    If TargetTemp > 7500 then           ' Not lower than -25 C. (10000-MinTemp * 100)
     TargetTemp=TargetTemp-25           ' Decrease temperuture with 0.25 C.
    EndIf
   EndIf
   If PORTB.1=0 then                    ' Up button
    If TargetTemp < 17500 then          ' Not higher than 75 C. (10000+MaxTemp * 100)
     TargetTemp=TargetTemp+25           ' Increase temperature with 0.25 C.
    EndIf
   EndIf
   GoSub SetTargetTemp                  ' Display TargetTemp and delay 0.25 Sec.
  EndIf
 EndIf 

 If Mode=2 then                         ' Set Hysteresis  
  LcdOut $FE, $80, "SET HYSTERESIS "    ' Show function
  Sign=" "                              ' No sign  
  V= 10000+Hyst                         ' Set value for V  
  Gosub DTemp                           ' Display Hysteresis
  If (PORTB.1=0) Or (PORTB.2=0) then    ' Up or down button pushed  
   Sign=" "                             ' No sign for Hysteresis
   If PORTB.2=0 then                    ' Down button
    If Hyst > 10 then Hyst=Hyst-10      ' Not less than 0.1 C.
   EndIf
   If PORTB.1=0 then                    ' Up button
    If Hyst < 1000 then Hyst=Hyst+10    ' Not more than 10.0 C.
   EndIf 
   V= 10000+Hyst                        ' Set value for V
   Gosub DTemp                          ' Display Hysteresis 
   Pause 250                            ' Delay 0.25 Sec.
  EndIf
 EndIf 

 If Mode > 0 then Mainloop              ' Setting TargetTemperature or Hysteresis


Output DQ             			    ' Make Pin Output
 DQ=0					          ' OneWire line Low
 PauseUs 480                            ' Keep down for 480 µS  
 Input DQ                               ' Make Pin Input
 PauseUs 70                             ' Wait 70 µS
 If DQ=1 then                           ' No presence pulse from DS1820   
  LcdOut $FE, $1, "** No sensor! **"    ' Show message
  Pause 500                             ' Wait 0.5 Sec. 
  Goto MainLoop                         ' Check again
 EndIf

'===================================================================================================

Main :
Part1:	
 OWOut DQ, 1, [$55, $28,  $DD, $06, $49, $1, $0, $0, $D4, $44] ' Start temp. conversion Sensor1

WaitLoop: 
While not DQ
Wend

OWOut DQ, 1,  [$55, $28,  $DD, $06, $49, $1, $0, $0, $D4, $BE]
Pause 500
OWIn DQ, 0, [Temperature1.Byte0, Temperature1.Byte1]
If Temperature1.15 then       
  Temperature1= ~Temperature1 +1
  Twist = 1
Endif
 
Dummy = 625 * Temperature1
TempC = DIV32 10 
TempC = (Temperature1 & $7FF) >> 4
Float = ((Temperature1.Lowbyte & $0F ) * 25 )>>2
Temperature1 = TempC*100 + Float
If Twist then
  V= 10000 - Temperature1               ' 25 C=12500  0 C=10000  -10 C=9000 
  Twist = 0
 else
  V= 10000 + Temperature1
 EndIf
 If V >= 10000 then                     ' Above 0 C.      
  Temperature1=V-10000                   
 Else                                   
  Temperature1=10000-V                  ' Below 0 C. 
 EndIf
 GoSub SelectSign                       ' +/blank/- Sign 
 GoSub DisplayTemp                      ' Temperature to LCD

'===================================================================================================
Part2 :	
 OWOut DQ, 1, [$55, $28, $EB, $EA, $48, $1, $0, $0, $FF, $44]  ' Start temp. conversion Sensor2

WaitLoop2: 
While not DQ
Wend

OWOut DQ, 1,  [$55, $28, $EB, $EA, $48, $1, $0, $0, $FF, $BE]
Pause 500
OWIn DQ, 0, [Temperature2.Byte0, Temperature2.Byte1]
If Temperature2.15 then       
  Temperature2= ~Temperature2 +1
  Twist2 = 1
Endif
 
Dummy = 625 * Temperature2
TempC = DIV32 10 
TempC = (Temperature2 & $7FF) >> 4
Float = ((Temperature2.Lowbyte & $0F ) * 25 )>>2
Temperature2 = TempC*100 + Float
If Twist2 then
  V2= 10000 - Temperature2              ' 25 C=12500  0 C=10000  -10 C=9000 
  Twist2 = 0
 else
  V2= 10000 + Temperature2
 EndIf
 If V2 >= 10000 then                    ' Above 0 C.      
  Temperature2=V2-10000                   
 Else                                   
  Temperature2=10000-V2                 ' Below 0 C. 
 EndIf

 GoSub SelectSign                       ' +/blank/- Sign 
 GoSub DisplayTemp                      ' Temperature to LCD


Goto MainLoop				    ' Do it forever

' SUBROUTINES:
'===================================================================================================
SelectSign:
 If v = 10000 then                      ' Temperature = 0 C.
  Sign=" " 				          ' No sign
 Else 
  If v < 10000 then              	    ' <> 0
   Sign="-"				          ' Temperature below 0 C. 	
  Else
   Sign="+"				          ' Temperature above 0 C.
  EndIf
 EndIf

 If v2 = 10000 then                     ' Temperature = 0 C.
  Sign=" " 				          ' No sign
 Else 
  If v2 < 10000 then              	    ' <> 0
   Sign="-"				          ' Temperature below 0 C. 	
  Else
   Sign="+"				          ' Temperature above 0 C.
  EndIf
 EndIf

Return


'===================================================================================================
DisplayTemp:
 If V >= 10000 then                     ' Above 0 C.      
  Temperature1=V-10000                   
 Else                                   
  Temperature1=10000-V                  ' Below 0 C. 
 EndIf


 If V2 >= 10000 then                    ' Above 0 C.      
  Temperature2=V2-10000                   
 Else                                   
  Temperature2=10000-V2                 ' Below 0 C. 
 EndIf


LcdOut $FE, $80,  "INT : ", Sign," ", DEC (Temperature1 / 100), ".", DEC2 Temperature1, " ",223,"C " 
LcdOut $FE, $C0,  "EXT : ", Sign," ", DEC (Temperature2 / 100), ".", DEC2 Temperature2, " ",223,"C " 
Return

'===================================================================================================
SetTargetTemp:
 V=TargetTemp
 Gosub SelectSign
 Gosub DTemp 
 Pause 250
Return
'===================================================================================================
DTemp :
 If V >= 10000 then                     ' Above 0 C.      
  Temperature1=V-10000                   
 Else                                   
  Temperature1=10000-V                  ' Below 0 C. 
 EndIf
LcdOut $FE, $C0, Sign," ", DEC (Temperature1 / 100), ".", DEC2 Temperature1, " ",223,"C " 
Return

'============================================= END OF PROGRAM ======================================
User avatar
electron
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 225
Joined: 28-02-2009, 19:20
Location: Serbia

Re: Digitalni Thermostat v2 (DS18B20)

Post by electron »

Ja sam ga probao, ali mi na LCD ispisuje,

INT: -0.06 αC
EXT: -0.06 αC
U cemu je problem? :?:
User avatar
electron
Pravo uznapredovao :)
Pravo uznapredovao :)
Posts: 225
Joined: 28-02-2009, 19:20
Location: Serbia

Re: Digitalni Thermostat v2 (DS18B20)

Post by electron »

Caka je koliko vidim u seriskim brojevima od DS senzora, iscitao sam serijske brojeve od DS sa ovim programom:

Code: Select all

'*****************************************************************************
'*                  LCD Defines for EasyPic5 & 16F887                                *
'*****************************************************************************

  
   clear
   DEFINE OSC 8                '8MHz << NOTICE UPPERCASE ON DEFINE

 'END of timer/oscillator defines

 OSCCON = %01110001          'Int CLK 8MHz
 ANSEL = %00000000           'All digital
 ANSELH = %00000000
 OPTION_REG.7 = 1            'Weak pull-ups enabled



           DEFINE  LCD_DREG    PORTD  'I/O port na kome se nalazi LCD
           DEFINE  LCD_DBIT    4       
           DEFINE  LCD_RSREG   PORTD
           DEFINE  LCD_RSBIT   1      'Register select pin
           DEFINE  LCD_EREG    PORTD
           DEFINE  LCD_EBIT    0      'Enable pin
           DEFINE  LCD_BITS    4      '4-bitni data bus 
           DEFINE  LCD_LINES   2       'LCD ima dva reda karaktera
           
    
    
    DQ Var PORTA.4 ' One-wire data pin
 i Var Byte
 Temp Var Byte
 ReadRom Con $33
 ID VAR BYTE[8] ' Array storage variable for 64-bit ROM code


 Begin:
 PAUSE 500 ' Wait .5 second
 LCDOUT $FE, 1, $FE, $0C ' Clear display, cursor off

 Start_Convert
 OWOUT DQ, 1, [$33] ' Issue Read ROM command

 ID_Loop:
 OWIN DQ, 0, [STR ID\8]' Read 64-bit device data into the 8-byte array "ID"
 for i = 0 to 7
 LcdOut HEX ID[i] 
 next i
 END
Ubacio ih u kod od termostata i radi
Post Reply