Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 06, 2016, 01:03:00 13:03


Login with username, password and session length


Pages: [1]
Print
Author Topic: Thermometer with DS1820  (Read 6183 times)
0 Members and 1 Guest are viewing this topic.
tekniker_erhan
Junior Member
**
 Muted
Offline Offline

Posts: 39

Thank You
-Given: 48
-Receive: 102


« on: May 13, 2009, 05:59:34 17:59 »

File pass:tekniker_erhan

Thermometer with DS1820











« Last Edit: May 13, 2009, 07:09:27 19:09 by tekniker_erhan » Logged
jwildes
V.I.P
Junior Member
*****
Offline Offline

Posts: 44

Thank You
-Given: 258
-Receive: 5


« Reply #1 on: May 13, 2009, 10:13:14 22:13 »

Dear Friend,

First, thanks for you share this project with us.
I would like to know what compiler you used with this .bas file.
And what language is used too....turkish, russian, etc.

Best regards,

Jwildes
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 976

Thank You
-Given: 197
-Receive: 344



« Reply #2 on: May 13, 2009, 11:07:44 23:07 »

Looking at it I would say picbasic pro becuse it's a PBP file

Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
jwildes
V.I.P
Junior Member
*****
Offline Offline

Posts: 44

Thank You
-Given: 258
-Receive: 5


« Reply #3 on: May 14, 2009, 04:08:17 04:08 »

I tested it with a DS1822....because DS1820 is no longer available and i dont have one here...but the temperature value is 212°C for 25.3°C.
I try translate the comments for turkish to english but haven't sucess...
If someone can translate to english will be helpful.
I will try with PBP Pro to change some words and see if compiler ok...

Best regards.

Jwildes
Logged
ajak
Active Member
***
Offline Offline

Posts: 116

Thank You
-Given: 198
-Receive: 77


« Reply #4 on: May 14, 2009, 07:06:31 07:06 »

Here i try to translate it.. Some comments were translated but some is not..
Code:
'************************************************* ***************
'* Name: * DS1820'li room termometresi.BAS
'* Author: Erhan YILMAZ *
'* Notice: *
'*: All Rights Reserved *
'* Date: 13.05.2009 *
'* Version: 1.0 *
'* Notes: *
'*: *
'************************************************* ***************
@ DEVICE PIC16F84A
@ DEVICE PIC16F84A, XT_OSC
@ DEVICE PIC16F84A, WDT_OFF
@ DEVICE PIC16F84A, PWRT_ON
@ DEVICE PIC16F84A, PROTECT_OFF
define OSC 4
Define LCD_DREG PORTB
Define LCD_DBIT 4
Define LCD_RSREG PORTB
Define LCD_RSBIT 0
Define LCD_EREG PORTB
Define LCD_EBIT 1
LCDOUT $ FE, $ 40,12,18,18,12,0,0,0,0 'rating iþareti
LCDOUT $ FE, $ 48,4,14,4,4,4,4,14,0 'Ý characters

command byte 'Script Variables
has a byte 'loop sayac Variables
temp var word 'temperature measurement Variables
There PORTB.2 DQ 'DS1820 pin connection
DQ_DIR have TRISB.2 'DS1820 input / output pin routing
Lcdout $ fe, 1, "ROOM TERMOMETRES", 1 '
                               
by pressing:
Gosub init1820 'DS1820 hazýrla
command = $ cc 'command sent ROM
Gosub DS1820_yaz

command = $ 44 'Start Dönüþümü
Gosub DS1820_yaz

Gosub init1820 'DS1820 hazýrla again

command = $ cc 'command sent ROM
Gosub DS1820_yaz

command = $ be 'Read temperature results
Gosub DS1820_yaz
Gosub DS1820_oku
Lcdout $ FE, $ C0, "TEMPERATURE =", dec (temp>> 1 ),".", dec (temp.0 * 5), 0, ""
Goto basla
'And not connected DS1820'yi hazýrlar and sensor controls
init1820:
Low DQ
Pauseus 500
DQ_DIR = 1
Pauseus 100
If DQ = 1 Then
Lcdout $ FE, $ C0, "DS1820 NO"
Pause 500
Goto basla
Endif
Pauseus 400
Return
'DS1820'ye command sends byte'ný
DS1820_yaz:
For i = 1 to 8
If komut.0 = 0 Then
Gosub sifir_yaz
Else
Gosub bir_yaz
Endif
command = command>> 1
Next i
Return
'DS1820'ye logic 0 sends information
sifir_yaz:
Low DQ
Pauseus 60
DQ_DIR = 1
Return
'DS1820'ye logic 1 sends information
bir_yaz:
Low DQ
@ Nop
DQ_DIR = 1
Pauseus 60
Return
'DS1820'den 16-bit temperature reading information
DS1820_oku:
For i = 1 to 16
temp = temp>> 1
Gosub bit_oku
Next i
Return
'DS1820'den 1 bit reads
bit_oku:
temp.15 = 1
Low DQ
@ Nop
DQ_DIR = 1
If DQ = 0 Then
temp.15 = 0
Endif
Pauseus 60
Return
End
Logged
tekniker_erhan
Junior Member
**
 Muted
Offline Offline

Posts: 39

Thank You
-Given: 48
-Receive: 102


« Reply #5 on: May 14, 2009, 02:00:55 14:00 »

codes here with english descriptions
Code:
'****************************************************************
'*  Name    : DS1820'li oda termometresi.BAS                    *
'*  Author  : ERHAN YILMAZ                                      *
'*  Notice  :                                                   *
'*          : All Rights Reserved                               *
'*  Date    : 13.05.2009                                        *
'*  Version : 1.0                                               *
'*  Notes   :                                                   *
'*          :                                                   *
'****************************************************************
' Picbasic Pro program to read DS1820 1-wire temperature sensor
'  and display temperature on LCD
@ DEVICE PIC16F84A
@ DEVICE PIC16F84A,XT_OSC
@ DEVICE PIC16F84A, WDT_OFF
@ DEVICE PIC16F84A, PWRT_ON
@ DEVICE PIC16F84A, PROTECT_OFF
define  OSC 4
Define  LCD_DREG        PORTB
Define  LCD_DBIT        4
Define  LCD_RSREG       PORTB
Define  LCD_RSBIT       0
Define  LCD_EREG        PORTB
Define  LCD_EBIT        1
LCDOUT $FE,$40,12,18,18,12,0,0,0,0 'degree sign
LCDOUT $FE,$48,4,14,4,4,4,4,14,0   'İ character

' Allocate variables
komut var     byte    ' Storage for command       
i       var     byte   ' Storage for loop counter       
temp    var     word   '' Storage for temperature     
DQ      var     PORTB.2' Alias DS1820 data pin         
DQ_DIR  var     TRISB.2' Alias DS1820 data direction pin
;Lcdout $fe, 1, "ROOM THERMOMETER"' english               
Lcdout $fe, 1, "ODA TERMOMETRES",1' Turkish
'Mainloop to read the temperature and display on LCD                               
basla:
Gosub init1820          ' init the DS1820
komut = $cc            ' Issue Skip ROM command
Gosub DS1820_yaz

komut = $44           ' Start temperature conversion
Gosub DS1820_yaz

Gosub init1820           ' Do another init

komut = $cc           ' Issue Skip ROM command
Gosub DS1820_yaz

komut = $be            ' Read the temperature
Gosub DS1820_yaz
Gosub DS1820_oku
' Display the decimal temperature
Lcdout $FE,$C0,"SICAKLIK=",dec(temp >> 1),".",dec(temp.0 * 5),0," "
Goto basla
     
' Initialize DS1820 and check for presence
init1820:
Low DQ          ' Set the data pin low to init
Pauseus 500      ' Wait > 480us
DQ_DIR = 1        ' Release data pin (set to input for high)
Pauseus 100         ' Wait > 60us
If DQ = 1 Then
'Lcdout $FE,$C0, "DS1820 not present"'english
Lcdout $FE,$C0, "   DS1820 YOK   "'Turkish
Pause 500
Goto basla   ' Try again
Endif
Pauseus 400    ' Wait for end of presence pulse
Return

' Write "command" byte to the DS1820
DS1820_yaz:
For i = 1 to 8    ' 8 bits to a byte
If komut.0 = 0 Then
Gosub sifir_yaz      ' Write a 0 bit
Else
Gosub bir_yaz        ' Write a 1 bit
Endif
komut = komut >> 1   ' Shift to next bit
Next i
Return

'Write a 0 bit to the DS1820
sifir_yaz:
Low DQ
Pauseus 60      ' Low for > 60us for 0
DQ_DIR = 1       ' Release data pin (set to input for high) 
Return

'Write a 1 bit to the DS1820
bir_yaz:
Low DQ          ' Low for < 15us for 1       
@ nop           ' Delay 1us at 4MHz         
DQ_DIR = 1       ' Release data pin (set to input for high) 
Pauseus 60       ' Use up rest of time slot     
Return

'Read a bit from the DS1820
DS1820_oku:
For i = 1 to 16         ' 16 bits to a word
temp = temp >> 1        ' Shift down bits
Gosub bit_oku           ' Get the bit to the top of temp
Next i
Return

'DS1820'den 1 bit okur
bit_oku:
temp.15 = 1       ' Preset read bit to 1       
Low DQ            ' Start the time slot     
@ nop              ' Delay 1us at 4MHz
DQ_DIR = 1        ' Release data pin (set to input for high)
If DQ = 0 Then
temp.15 = 0       ' Set bit to 0
Endif
Pauseus 60         ' Wait out rest of time slot     
Return
End

Logged
jwildes
V.I.P
Junior Member
*****
Offline Offline

Posts: 44

Thank You
-Given: 258
-Receive: 5


« Reply #6 on: May 25, 2009, 07:49:49 19:49 »

Hi Guys,

I compile the last code sent by Erhan with PBP Pro 250....it's work fine....
I translate to portuguese too....good jog Erhan...
Now i'd like to change the sensor...1820 to 1822....any tip?

Jwildes
Logged
tekniker_erhan
Junior Member
**
 Muted
Offline Offline

Posts: 39

Thank You
-Given: 48
-Receive: 102


« Reply #7 on: May 26, 2009, 12:31:58 12:31 »

These codes are sample for one wire interface and comunication, You can use what you want with codes ds1820,ds1822,ds18b20,ds1990a etc. The difference between ds1820 and ds1822 temperature calculations and resolution
For use ds1822 change this line
Code:
Lcdout $FE,$C0,"SICAKLIK=",dec(temp >> 1),".",dec(temp.0 * 5),0,"
with this line
Code:
Lcdout $FE,$C0,"SICAKLIK=",dec(temp >> 4),".",dec(temp.3 * 5),0," "

I have not tried codes, but as theoretical
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC