Termometro

Aqui una foto donde tenemos dos sondas y una esta en la calle y otra dentro de casa.

Nos marca la minima y la maxima.

max-min

OTRA FOTO

actual

Esquema, pica sofre la foto para descargar mas grande.

***************************************

CODIGO HEX

:10000000262A10302D2133302D21AA302D21BA304F
:100010002D2100302D2108302D2100302D213D30A3
:100020002D21080010302D2138302D219D302D211B
:10003000BA302D2100302D2108302D2100302D2106
:1000400010302D2108004430BC204530BC204E30FB
:10005000BC205430BC205230BC204F30BC2020305B
:10006000BC202030BC2008004130BC204630BC20E1
:100070005530BC204530BC205230BC204130BC2023
:100080002030BC202030BC2008003A08C1003808CD
:10009000C000E7212030BC203B08C1003908C00067
:1000A000E72108003E08C1003C08C000E7212030DD
:1000B000BC203F08C1003D08C000E72108008400C3
:1000C0000008A500840A0008A600840A0008A7000A
:1000D000840A0008A8000800840025088000840A1B
:1000E00026088000840A27088000840A28088000E7
:1000F00008006730BC207030BC205430BC20683011
:10010000BC206530BC207230BC206D30BC2020305B
:10011000BC205630BC202030BC203130BC202E30DA
:10012000BC203730BC202E30BC203030BC20080032
:100130000130C52008000230C5200800033904380A
:10014000C520080007390838C52008003F39403865
:10015000C52008008038C52008008316FF308600BF
:100160008312051085140515060805117F398510C1
:1001700083168601831208009000E720851005147D
:10018000051510088600051108009000E72085106D
:100190000510051510088600051108004108031D0B
:1001A000D4282B30960008002D30960008009000CF
:1001B000100E0F39F63E0318073E3A3E9400100821
:1001C0000F39F63E0318073E3A3E930008008316A7
:1001D000FF308600831205108514051506080511E9
:1001E0008039031DE72885108316860183120800D5
:1001F000A5309100910BFA2808009200F820920B8C
:10020000FE28080085011E30FD203830C520003052
:10021000A22098200430A22002309E200800000076
:100220000000A20B0F2908000830A0000512831659
:10023000051283120130A2000F21831605168312C6
:100240000000000005081039FF3EA10C0B30A20091
:100250000F21A00B162921080800A1000830A000DA
:1002600005128316051283120130A2000F21A10C82
:10027000031805160D30A2000F21831605168312F0
:100280000000A00B30290800051283160512831206
:100290007730A2000F218316051683120C30A200BE
:1002A0000F210000000005081039A3003B30A20018
:1002B0000F2123080800410803190800C003C009E2
:1002C00008004421031D8E296D2955302D21012060
:1002D000742955302D211220742917186529971873
:1002E0006929CC302D217429BE302D210930A3007D
:1002F0004030840014218000840AA30B7A29442111
:10030000CC302D2144302D211421031D8429410896
:1003100003198D29013E031D8E2900340134442127
:1003200033302D210830A3003030840014218000A8
:10033000840AA30B96290800FF30B800B900BB005F
:10034000BC00BD00BF00BA01BE0108002808031DA3
:10035000B1294108031D080026084002031C0800BB
:10036000B82941080319B8292608400203180800D3
:100370004008A6004108A80008002708031DC82956
:100380004108031DCF2925084002031CCF2908007E
:1003900041080319080025084002031C0800400812
:1003A000A5004108A70008002030BC204330BC2035
:1003B00008000830A300303084000008D72014085B
:1003C000BC201308BC20840AA30BDD290800CE2022
:1003D0001608BC204008CD003530950001304D0591
:1003E000031DF429303095000310CD0CCC010422FC
:1003F00030304A07BC2030304B07BC202E30BC20A8
:100400001508BC20D42108004C08F13E4C07C90057
:1004100049074907FD3ECA004D0E0F39CA07CA07F2
:100420004C07FB3CCB00CB07CB07CB074D080F3964
:10043000CB070A30CB07CA03031C1A2ACA07C90311
:10044000031C1E2AC907031C222A080083018B01F2
:100450008A01850186018316F83085000030860008
:100460008117831281150114811401159C2101301B
:1004700098000221982061210030AA207920403084
:10048000AA208F21D92164006300640063009820B2
:10049000011081100130970061215B2138305F200D
:1004A000A621BD2138306C200030AA20181C5B2A00
:1004B0002320E7215E2A981C5E2A452002309700FF
:1004C00061215B213C305F20A621BD213C306C20A6
:1004D0004030AA20181C6F2A3420E721722A981C69
:1004E000722A5220640063000310980D181D4A2AD6
:0604F000013098004A2AC9
:02400E00FD3F74
:00000001FF

probado y funciona

Lo primero montamos el circuito y ponemos un ds1820
y en la linea de abajo de la pantalla lcd nos sale
el codigo de el ds1820, le copiamos y ponemos el otro
ds1820, reset y sale otro codigo en hex ,
este es el codigo del de este sonda.

vamos a codigo fuente del pic y metemos estos codigos
en las lineas

dswriterom0聽聽聽 este es afuera
dswriterom1聽聽聽 este es dentro

y los emsamblamos y lo grabamos.

;聽聽聽 gpTherm
;聽聽聽 Copyright (C) 2000-2001 Thomas
;聽聽聽 This program is free software; you can redistribute it and/or modify
;聽聽聽 it under the terms of the GNU General Public License as published by
;聽聽聽 the Free Software Foundation; either version 2 of the License, or
;聽聽聽 (at your option) any later version.
;
;聽聽聽 This program is distributed in the hope that it will be useful,
;聽聽聽 but WITHOUT ANY WARRANTY; without even the implied warranty of
;聽聽聽 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.聽 See the
;聽聽聽 GNU General Public License for more details.
;
;聽聽聽 You should have received a copy of the GNU General Public License
;聽聽聽 along with this program; if not, write to the Free Software
;聽聽聽 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA聽 02111-1307聽 USA
;
;聽聽聽 OSC 4MHz -> 1us por ciclo
;聽聽聽 (0) DS1820 ROM 1033aaba0008003d聽聽聽 DENTRO
;聽聽聽 (1) DS1820 ROM 10389dba00080010聽AFUERA
;
;聽聽聽 este programa esta basado en el trabajo de
;
;聽聽聽 Steve Lawther (Schema)
;聽聽聽 Nikolai Golovchenko (bin2dec999 function)
;聽聽聽 Peter Ouwehand (LCD Code)
;聽聽聽 Steve.Marchant (DS 1820 Code)
;
;聽聽聽 and all the other guys publishing samples
;聽聽聽 for pic user
;
;聽聽聽 bugfixes
;聽聽聽 Sat Nov 17 19:20:31 MET 2001 bug in sign calculation fixed
;聽聽聽 Sat Nov 24 16:46:36 MET 2001 minmax calculation
;聽聽聽 Wed Nov 28 21:53:34 MET 2001 bug in modeswitch code
;聽聽聽 Sun Dec聽 9 20:10:18 MET 2001 support for 4×16 display
;聽聽聽 Mon Dec 10 20:36:54 MET 2001 ifdef for switching between 2×16 and 4×16
;聽聽聽 Mon Jan 28 21:12:34 MET 2002 bug in max calculation fixed
;聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
;
;
#define LCD_2X16聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; uncomment for 2 line display!!!!
;#define LCD_4X16聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; uncomment for 4 line display!!!!
;
聽list p=16f84
聽include p16f84.inc
聽__CONFIG _CP_OFF & _WDT_ON & _XT_OSC
;
VERSIONMAJOR聽聽聽 EQU聽聽聽聽 1
VERSIONMINOR聽聽聽 EQU聽聽聽聽 7
VERSIONRELEASE聽 EQU聽聽聽聽 0
;
LCD_DATA聽聽聽聽聽聽聽 EQU聽聽聽聽 PORTB聽聽聽聽聽聽聽聽聽 ; LCD data lines interface
LCD_DATA_TRIS聽聽 EQU聽聽聽聽 TRISB
LCD_CTRL聽聽聽聽聽聽聽 EQU聽聽聽聽 PORTA聽聽聽聽聽聽聽聽聽 ; LCD control lines interface
;
; LCD PORTA control bits
;
LCD_RS聽聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0聽聽聽聽聽聽聽聽聽聽聽聽聽 ; LCD Register-Select control line
LCD_RW聽聽聽聽聽聽聽聽聽 EQU聽聽聽聽 1聽聽聽聽聽聽聽聽聽聽聽聽聽 ; LCD Read/Write control line
LCD_E聽聽聽聽聽聽聽聽聽聽 EQU聽聽聽聽 2聽聽聽聽聽聽聽聽聽聽聽聽聽 ; LCD Enable control line
LCD_LINE0聽聽聽聽聽聽 EQU聽聽聽聽 0x00聽聽聽聽聽聽聽聽聽聽 ; LCD Line Address
LCD_LINE1聽聽聽聽聽聽 EQU聽聽聽聽 0x40聽聽聽聽聽聽聽聽聽聽 ; LCD Line Address
LCD_LINE2聽聽聽聽聽聽 EQU聽聽聽聽 0x10聽聽聽聽聽聽聽聽聽聽 ; LCD Line Address
LCD_LINE3聽聽聽聽聽聽 EQU聽聽聽聽 0x50聽聽聽聽聽聽聽聽聽聽 ; LCD Line Address
;
; LCD PORTB data bits
;
LCD_DB7聽聽聽聽聽聽聽聽 EQU聽聽聽聽 7聽聽聽聽聽聽聽聽聽聽聽聽聽 ; LCD dataline 7 (MSB)
LCD_DB6聽聽聽聽聽聽聽聽 EQU聽聽聽聽 6聽聽聽聽聽聽聽聽聽聽聽聽聽 ; LCD dataline 6
LCD_DB5聽聽聽聽聽聽聽聽 EQU聽聽聽聽 5聽聽聽聽聽聽聽聽聽聽聽聽聽 ; LCD dataline 5
LCD_DB4聽聽聽聽聽聽聽聽 EQU聽聽聽聽 4聽聽聽聽聽聽聽聽聽聽聽聽聽 ; LCD dataline 4
LCD_DB3聽聽聽聽聽聽聽聽 EQU聽聽聽聽 3聽聽聽聽聽聽聽聽聽聽聽聽聽 ; LCD dataline 3
LCD_DB2聽聽聽聽聽聽聽聽 EQU聽聽聽聽 2聽聽聽聽聽聽聽聽聽聽聽聽聽 ; LCD dataline 2
LCD_DB1聽聽聽聽聽聽聽聽 EQU聽聽聽聽 1聽聽聽聽聽聽聽聽聽聽聽聽聽 ; LCD dataline 1
LCD_DB0聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0聽聽聽聽聽聽聽聽聽聽聽聽聽 ; LCD dataline 0 (LSB)
;
; LCD variables
;
LCD_TEMP聽聽聽聽聽聽聽 EQU聽聽聽聽 0x10聽聽聽聽聽聽聽聽聽聽 ; lcd subroutines internal use
LCD_DELAY聽聽聽聽聽聽 EQU聽聽聽聽 0x11聽聽聽聽聽聽聽聽聽聽 ; Used in DELAYxxx routines
LCD_X_DELAY聽聽聽聽 EQU聽聽聽聽 0x12聽聽聽聽聽聽聽聽聽聽 ; Used in X_DELAYxxx routines
LCD_ASCHEXLO聽聽聽 EQU聽聽聽聽 0x13聽聽聽聽聽聽聽聽聽聽 ; lo ascii hex from lcdaschex routine
LCD_ASCHEXHI聽聽聽 EQU聽聽聽聽 0x14聽聽聽聽聽聽聽聽聽聽 ; hi ascii hex from lcdaschex routine
LCD_ASCHALF聽聽聽聽 EQU聽聽聽聽 0x15聽聽聽聽聽聽聽聽聽聽 ; 5 or 0 for half Celsius Degrees
LCD_ASCSIGN聽聽聽聽 EQU聽聽聽聽 0x16聽聽聽聽聽聽聽聽聽聽 ; sign, 0 -> ‘+’ 255 ‘-‘ else ‘ ‘
LCD_ACTDS聽聽聽聽聽聽 EQU聽聽聽聽 0x17聽聽聽聽聽聽聽聽聽聽 ; 0->one (no rom), 1->first,2->second
; display modes
BTN_ACTMODE聽聽聽聽 EQU聽聽聽聽 0x18聽聽聽聽聽聽聽聽聽聽 ; variable for actual display mode
BTN_MODENORMAL聽 EQU聽聽聽聽 0聽聽聽聽聽聽聽聽聽聽聽聽聽 ; bit for display temperature screen
BTN_MODEMINMAX聽 EQU聽聽聽聽 1聽聽聽聽聽聽聽聽聽聽聽聽聽 ; bit display minmax screen
;
; DS 1820 variables
;
DS_BIT聽聽聽聽聽聽聽聽聽 EQU聽聽聽聽 4聽聽聽聽聽聽聽聽聽聽聽聽聽 ; porta4 is connected to the ds1820 bus
DS_RWTMP0聽聽聽聽聽聽 EQU聽聽聽聽 0x20
DS_RWTMP1聽聽聽聽聽聽 EQU聽聽聽聽 0x21
DS_DLYTMP聽聽聽聽聽聽 EQU聽聽聽聽 0x22
DS_TMP0聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x23
DS_TMP1聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x24
; area for tmp min and max variables
DS_MINTMP聽聽聽聽聽聽 EQU聽聽聽聽 0x25
DS_MAXTMP聽聽聽聽聽聽 EQU聽聽聽聽 0x26
DS_SIGNMINTMP聽聽 EQU聽聽聽聽 0x27
DS_SIGNMAXTMP聽聽 EQU聽聽聽聽 0x28
; ds1820 rom
DS_ROM0聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x30聽聽聽聽聽聽聽聽聽聽 ; ds1820 1 byte rom family code
DS_ROM1聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x31聽聽聽聽聽聽聽聽聽聽 ; ds1820 6 byte rom serial number
DS_ROM2聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x32聽聽聽聽聽聽聽聽聽聽
DS_ROM3聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x33聽聽聽聽聽聽聽聽聽聽
DS_ROM4聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x34
DS_ROM5聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x35
DS_ROM6聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x36
DS_ROM7聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x37聽聽聽聽聽聽聽聽聽聽 ; ds1820 1 byte rom crc code
; area for min and max variables
DS_MIN0聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x38
DS_MAX0聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x39
DS_SIGNMIN0聽聽聽聽 EQU聽聽聽聽 0x3a
DS_SIGNMAX0聽聽聽聽 EQU聽聽聽聽 0x3b
DS_MIN1聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x3c
DS_MAX1聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x3d
DS_SIGNMIN1聽聽聽聽 EQU聽聽聽聽 0x3e
DS_SIGNMAX1聽聽聽聽 EQU聽聽聽聽 0x3f
; ds1820 ram
DS_RAM0聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x40聽聽聽聽聽聽聽聽聽聽 ; ds1820 ram temperature lsb (temp)
DS_RAM1聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x41聽聽聽聽聽聽聽聽聽聽 ; ds1820 ram temperature msb (sign)
DS_RAM2聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x42聽聽聽聽聽聽聽聽聽聽 ; ds1820 ram TH user1
DS_RAM3聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x43聽聽聽聽聽聽聽聽聽聽 ; ds1820 ram TL user2
DS_RAM4聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x44聽聽聽聽聽聽聽聽聽聽 ; ds1820 ram reserved
DS_RAM5聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x45聽聽聽聽聽聽聽聽聽聽 ; ds1820 ram reserved
DS_RAM6聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x46聽聽聽聽聽聽聽聽聽聽 ; ds1820 ram count remain
DS_RAM7聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x47聽聽聽聽聽聽聽聽聽聽 ; ds1820 ram count per celsius
DS_RAM8聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x48聽聽聽聽聽聽聽聽聽聽 ; ds1820 ram crc
;
; CONVERSION Variables
;
Hund聽聽聽聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x49
Tens聽聽聽聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x4a
Ones聽聽聽聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x4b
NumH聽聽聽聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x4c
NumL聽聽聽聽聽聽聽聽聽聽聽 EQU聽聽聽聽 0x4d
;
聽goto main
;
dswriterom0聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 聽; romtable para mi primer ds1820
聽movlw聽聽聽聽聽聽 0x10聽聽聽聽聽聽聽聽聽聽聽聽聽 聽; retrieve yours? see main DENTRO
聽call聽聽聽聽聽聽聽 dswrite聽聽; 1033aaba0008003d
聽movlw聽聽聽聽聽聽 0x33
聽call聽聽聽聽聽聽聽 dswrite
聽movlw聽聽聽聽聽聽 0xaa
聽call聽聽聽聽聽聽聽 dswrite
聽movlw聽聽聽聽聽聽 0xba
聽call聽聽聽聽聽聽聽 dswrite
聽movlw聽聽聽聽聽聽 0x00
聽call聽聽聽聽聽聽聽 dswrite
聽movlw聽聽聽聽聽聽 0x08
聽call聽聽聽聽聽聽聽 dswrite
聽movlw聽聽聽聽聽聽 0x00
聽call聽聽聽聽聽聽聽 dswrite
聽movlw聽聽聽聽聽聽 0x3d
聽call聽聽聽聽聽聽聽 dswrite
聽return
;
dswriterom1
聽movlw聽聽聽聽聽聽 0x10聽聽聽聽聽聽聽聽聽聽聽 聽; romtable para mi segundo ds1820
聽call聽聽聽聽聽聽聽 dswrite聽聽聽聽聽聽聽 聽; retrieve yours? see main聽 AFUERA
聽movlw聽聽聽聽聽聽 0x38聽聽; 10389dba00080010
聽call聽聽聽聽聽聽聽 dswrite聽聽; ultimo de la linea en aparecer en el
聽movlw聽聽聽聽聽聽 0x9d聽聽; display
聽call聽聽聽聽聽聽聽 dswrite
聽movlw聽聽聽聽聽聽 0xba
聽call聽聽聽聽聽聽聽 dswrite
聽movlw聽聽聽聽聽聽 0x00
聽call聽聽聽聽聽聽聽 dswrite
聽movlw聽聽聽聽聽聽 0x08
聽call聽聽聽聽聽聽聽 dswrite
聽movlw聽聽聽聽聽聽 0x00
聽call聽聽聽聽聽聽聽 dswrite
聽movlw聽聽聽聽聽聽 0x10
聽call聽聽聽聽聽聽聽 dswrite
聽return
;聽 linea superior
dsprinttitle0
聽movlw聽聽 ‘D’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘E’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘N’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘T’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘R’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘O’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘ ‘
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘ ‘
聽call聽聽聽 lcdputchar
聽return
;聽聽 linea inferior
dsprinttitle1
聽movlw聽聽 ‘A’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘F’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘U’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘E’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘R’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘A’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘ ‘
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘ ‘
聽call聽聽聽 lcdputchar
聽return
;
dsprintminmax0
聽movf聽聽聽 DS_SIGNMIN0,W
聽movwf聽聽 DS_RAM1
聽movf聽聽聽 DS_MIN0,W
聽movwf聽聽 DS_RAM0
聽call聽聽聽 lcdprintdsdata
聽movlw聽聽 ‘ ‘
聽call聽聽聽 lcdputchar
聽movf聽聽聽 DS_SIGNMAX0,W
聽movwf聽聽 DS_RAM1
聽movf聽聽聽 DS_MAX0,W
聽movwf聽聽 DS_RAM0
聽call聽聽聽 lcdprintdsdata
聽return
;
dsprintminmax1
聽movf聽聽聽 DS_SIGNMIN1,W
聽movwf聽聽 DS_RAM1
聽movf聽聽聽 DS_MIN1,W
聽movwf聽聽 DS_RAM0
聽call聽聽聽 lcdprintdsdata
聽movlw聽聽 ‘ ‘
聽call聽聽聽 lcdputchar
聽movf聽聽聽 DS_SIGNMAX1,W
聽movwf聽聽 DS_RAM1
聽movf聽聽聽 DS_MAX1,W
聽movwf聽聽 DS_RAM0
聽call聽聽聽 lcdprintdsdata
聽return
;
dsminmax2tmp
聽movwf聽聽 FSR
聽movf聽聽聽 INDF,W
聽movwf聽聽 DS_MINTMP
聽incf聽聽聽 FSR,F
聽movf聽聽聽 INDF,W
聽movwf聽聽 DS_MAXTMP
聽incf聽聽聽 FSR,F
聽movf聽聽聽 INDF,W
聽movwf聽聽 DS_SIGNMINTMP
聽incf聽聽聽 FSR,F
聽movf聽聽聽 INDF,W
聽movwf聽聽 DS_SIGNMAXTMP
聽return
;
dstmp2minmax
聽movwf聽聽 FSR
聽movf聽聽聽 DS_MINTMP,W
聽movwf聽聽 INDF
聽incf聽聽聽 FSR,F
聽movf聽聽聽 DS_MAXTMP,W
聽movwf聽聽 INDF
聽incf聽聽聽 FSR,F
聽movf聽聽聽 DS_SIGNMINTMP,W
聽movwf聽聽 INDF
聽incf聽聽聽 FSR,F
聽movf聽聽聽 DS_SIGNMAXTMP,W
聽movwf聽聽 INDF
聽return
;
dsprintcopyright
聽movlw聽聽 ‘g’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘p’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘T’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘h’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘e’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘r’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘m’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘ ‘
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘V’
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘ ‘
聽call聽聽聽 lcdputchar
聽movlw聽聽 VERSIONMAJOR + 0x30
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘.’
聽call聽聽聽 lcdputchar
聽movlw聽聽 VERSIONMINOR + 0x30
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘.’
聽call聽聽聽 lcdputchar
聽movlw聽聽 VERSIONRELEASE + 0x30
聽call聽聽聽 lcdputchar
聽return
;
lcdclear
聽movlw聽聽 0x01
聽call聽聽聽 lcdputcmd
聽return
;
lcdhome
聽movlw聽聽 0x02
聽call聽聽聽 lcdputcmd
聽return
;
lcdemode
聽andlw聽聽 0x03聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; strip upper bits
聽iorlw聽聽 0x04聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; function set
聽call聽聽聽 lcdputcmd
聽return
;
lcddmode
聽andlw聽聽 0x07聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; strip upper bits
聽iorlw聽聽 0x08聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; function set
聽call聽聽聽 lcdputcmd
聽return
;
lcdscga
聽andlw聽聽 0x3f聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; strip upper bits
聽iorlw聽聽 0x40聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; function set
聽call聽聽聽 lcdputcmd
聽return
;
lcdsdda
聽iorlw聽聽 0x80聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; function set
聽call聽聽聽 lcdputcmd
聽return
;
lcdgaddr
聽bsf聽聽聽聽 STATUS,RP0聽聽聽聽聽聽聽聽聽 ; select register page 1
聽movlw聽聽 0xff聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; set PORTB for input
聽movwf聽聽 LCD_DATA_TRIS
聽bcf聽聽聽聽 STATUS, RP0聽聽聽聽聽聽聽聽 ; select Register page 0
聽bcf聽聽聽聽 LCD_CTRL, LCD_RS聽聽聽 ; set LCD for command mode
聽bsf聽聽聽聽 LCD_CTRL, LCD_RW聽聽聽 ; setup to read busy flag
聽bsf聽聽聽聽 LCD_CTRL, LCD_E聽聽聽聽 ; LCD E-line high
聽movf聽聽聽 LCD_DATA, W聽聽聽聽聽聽聽聽 ; read busy flag + RAM address
聽bcf聽聽聽聽 LCD_CTRL, LCD_E聽聽聽聽 ; LCD E-line Low
聽andlw聽聽 0x7f聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; strip upper bit
聽bcf聽聽聽聽 LCD_CTRL, LCD_RW
聽bsf聽聽聽聽 STATUS, RP0聽聽聽聽聽聽聽聽 ; select register page 1
聽clrf聽聽聽 LCD_DATA_TRIS聽聽聽聽聽聽 ; set PORTB for output
聽bcf聽聽聽聽 STATUS, RP0聽聽聽聽聽聽聽聽 ; select register page 0
聽return
;
lcdputchar
聽movwf聽聽 LCD_TEMP聽聽聽聽聽聽聽聽聽聽聽 ; character to send is in W
聽call聽聽聽 lcdbusy聽聽聽聽聽聽聽聽聽聽聽聽 ; wait for LCD to be ready
聽bcf聽聽聽聽 LCD_CTRL, LCD_RW聽聽聽 ; set LCD in read mode
聽bsf聽聽聽聽 LCD_CTRL, LCD_RS聽聽聽 ; set LCD in data mode
聽bsf聽聽聽聽 LCD_CTRL, LCD_E聽聽聽聽 ; LCD E-line High
聽movf聽聽聽 LCD_TEMP, W
聽movwf聽聽 LCD_DATA聽聽聽聽聽聽聽聽聽聽聽 ; send data to LCD
聽bcf聽聽聽聽 LCD_CTRL, LCD_E聽聽聽聽 ; LCD E-line Low
聽return
;
lcdputcmd
聽movwf聽聽 LCD_TEMP聽聽聽聽聽聽聽聽聽聽聽 ; command to send is in W
聽call聽聽聽 lcdbusy聽聽聽聽聽聽聽聽聽聽聽聽 ; wait for LCD to be ready
聽bcf聽聽聽聽 LCD_CTRL, LCD_RW聽聽聽 ; set LCD in read mode
聽bcf聽聽聽聽 LCD_CTRL, LCD_RS聽聽聽 ; set LCD in command mode
聽bsf聽聽聽聽 LCD_CTRL, LCD_E聽聽聽聽 ; LCD E-line High
聽movf聽聽聽 LCD_TEMP, W
聽movwf聽聽 LCD_DATA聽聽聽聽聽聽聽聽聽聽聽 ; send data to LCD
聽bcf聽聽聽聽 LCD_CTRL, LCD_E聽聽聽聽 ; LCD E-line Low
聽return
;
lcdascsign
聽movf聽聽聽 DS_RAM1,W
聽btfss聽聽 STATUS,Z
聽goto聽聽聽 lcdascsignminus
聽movlw聽聽 ‘+’
聽movwf聽聽 LCD_ASCSIGN
聽return
lcdascsignminus
聽movlw聽聽 ‘-‘
聽movwf聽聽 LCD_ASCSIGN
聽return
;
lcdaschex
聽movwf聽聽 LCD_TEMP
聽swapf聽聽 LCD_TEMP,W
聽andlw聽聽 B’00001111′
聽addlw聽聽 -0x0a
聽btfsc聽聽 STATUS,C
聽addlw聽聽 0x07
聽addlw聽聽 0x3a
聽movwf聽聽 LCD_ASCHEXHI
聽movf聽聽聽 LCD_TEMP,W
聽andlw聽聽 B’00001111′
聽addlw聽聽 -0x0a
聽btfsc聽聽 STATUS,C
聽addlw聽聽 0x07
聽addlw聽聽 0x3a
聽movwf聽聽 LCD_ASCHEXLO
聽return
;
lcdbusy
聽bsf聽聽聽聽 STATUS,RP0聽聽聽聽聽聽聽聽 ; Select Register page 1
聽movlw聽聽 0xff聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; Set PORTB for input
聽movwf聽聽 LCD_DATA_TRIS
聽bcf聽聽聽聽 STATUS,RP0聽聽聽聽聽聽聽聽 ; Select Register page 0
聽bcf聽聽聽聽 LCD_CTRL,LCD_RS聽聽聽 ; Set LCD for command mode
聽bsf聽聽聽聽 LCD_CTRL,LCD_RW聽聽聽 ; Setup to read busy flag
聽bsf聽聽聽聽 LCD_CTRL,LCD_E聽聽聽聽 ; LCD E-line High
聽movf聽聽聽 LCD_DATA,W聽聽聽聽聽聽聽聽 ; Read busy flag + DDram address
聽bcf聽聽聽聽 LCD_CTRL,LCD_E聽聽聽聽 ; LCD E-line Low
聽andlw聽聽 0x80聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; Check Busy flag, High = Busy
聽btfss聽聽 STATUS,Z
聽goto聽聽聽 lcdbusy
聽bcf聽聽聽聽 LCD_CTRL,LCD_RW
聽bsf聽聽聽聽 STATUS,RP0聽聽聽聽聽聽聽聽 ; Select Register page 1
聽clrf聽聽聽 LCD_DATA_TRIS聽聽聽聽聽 ; Set PORTB for output
聽bcf聽聽聽聽 STATUS,RP0聽聽聽聽聽聽聽聽 ; Select Register page 0
聽return
;
lcddelay500us
聽movlw聽聽 D’165′聽聽聽聽聽聽聽聽聽 ; +1聽聽聽聽聽聽聽聽聽聽聽 1 cycle
聽movwf聽聽 LCD_DELAY聽聽聽聽聽聽 ; +2聽聽聽聽聽聽聽聽聽聽聽 1 cycle
聽decfsz聽 LCD_DELAY,F聽聽聽聽 ; step 1聽聽聽聽聽聽聽 1 cycle
聽goto聽聽聽 $-1聽聽聽聽聽聽聽聽聽聽聽聽 ; step 2聽聽聽聽聽聽聽 2 cycles
聽return聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; +3聽聽聽聽聽聽聽聽聽聽聽 2 cycles
;
lcdxdelay500us聽聽聽聽聽
聽movwf聽聽 LCD_X_DELAY聽聽聽聽 ; +1聽聽聽聽聽聽聽聽聽聽聽 1 cycle
聽call聽聽聽 lcddelay500us聽聽 ; step1聽聽聽聽聽聽聽聽 wait 500uSec
聽decfsz聽 LCD_X_DELAY, F聽 ; step2聽聽聽聽聽聽聽聽 1 cycle
聽goto聽聽聽 $-2聽聽聽聽聽聽聽聽聽聽聽聽 ; step3聽聽聽聽聽聽聽聽 2 cycles
聽return
;
lcdinit
聽clrf聽聽聽 LCD_CTRL聽聽聽聽聽聽聽 ; ALL PORT output should output Low.
聽movlw聽聽 0x1e
聽call聽聽聽 lcdxdelay500us聽 ; 30 * 0.5mS = 15mS
聽movlw聽聽 0x38聽聽聽聽聽聽聽聽聽聽聽 ; 8-bit-interface, 2-lines
聽call聽聽聽 lcdputcmd
聽movlw聽聽 0x00聽聽聽聽聽聽聽聽聽聽聽 ; disp.off, curs.off, no-blink
聽call聽聽聽 lcddmode
聽call聽聽聽 lcdclear
聽movlw聽聽 0x04聽聽聽聽聽聽聽聽聽聽聽 ; disp.on, curs.off
聽call聽聽聽 lcddmode
聽movlw聽聽 0x02聽聽聽聽聽聽聽聽聽聽聽 ; auto-inc (shift-cursor)
聽call聽聽聽 lcdemode
聽return
;
dssetlow macro
聽bcf聽聽聽聽 PORTA,DS_BIT聽聽聽 ; dq bit ready lo
聽bsf聽聽聽聽 STATUS,RP0
聽bcf聽聽聽聽 TRISA,DS_BIT聽聽聽 ; dq bit now o/p
聽bcf聽聽聽聽 STATUS,RP0
聽endm
;
dssethigh macro
聽bsf聽聽聽聽 STATUS,RP0
聽bsf聽聽聽聽 TRISA,DS_BIT聽聽聽 ; dq bit now i/p
聽bcf聽聽聽聽 STATUS,RP0
聽endm
;
pause macro dlyf
聽movlw聽聽 (dlyf / D’5′) – D’1′
聽movwf聽聽 DS_DLYTMP
聽call聽聽聽 dly5n
聽endm
;
dly5n聽
聽nop
聽nop
聽decfsz聽 DS_DLYTMP,F
聽goto聽聽聽 dly5n
聽return
;
dsread
聽movlw聽聽 D’8′
聽movwf聽聽 DS_RWTMP0
dsrxlp
聽dssetlow
聽pause聽聽 D’10’
聽dssethigh
聽nop
聽nop
聽movf聽聽聽 PORTA,W
聽andlw聽聽 B’00010000′
聽addlw聽聽 0xff聽聽聽聽聽聽聽聽聽
聽rrf聽聽聽聽 DS_RWTMP1,F
聽pause聽聽 D’60’
聽decfsz聽 DS_RWTMP0,F
聽goto聽聽聽 dsrxlp
聽movf聽聽聽 DS_RWTMP1,W
聽return
;
dswrite
聽movwf聽聽 DS_RWTMP1聽聽聽聽聽聽 ; data to tx
聽movlw聽聽 D’8′
聽movwf聽聽 DS_RWTMP0聽聽聽聽聽聽 ; loop counter
dstxlp
聽dssetlow
聽pause聽聽 D’10’
聽rrf聽聽聽聽 DS_RWTMP1,F
聽btfsc聽聽 STATUS,C
聽bsf聽聽聽聽 PORTA,DS_BIT聽聽聽 ; dq high if bit was 1
聽pause聽聽 D’70’
聽dssethigh
聽nop
聽decfsz聽 DS_RWTMP0,F
聽goto聽聽聽 dstxlp
聽return
;
dsreset
聽dssetlow
聽pause聽聽 D’600′
聽dssethigh
聽pause聽聽 D’65’聽聽聽聽聽聽聽聽聽聽 ;wait 67us for response bit
聽nop
聽nop
聽movf聽聽聽 PORTA,W
聽andlw聽聽 1 << DS_BIT
聽movwf聽聽 DS_TMP0聽聽聽聽聽聽聽聽 ;save w
聽pause聽聽 D’300′
聽movf聽聽聽 DS_TMP0,W聽聽聽聽聽聽 ;restore stored w for return value
聽return
;
; if DS_RAM1 is 255 -> “-“, than the temperature is
; complement(DS_RAM0 – 1)
;
dsminusconvertion
聽movf聽聽聽 DS_RAM1,W
聽btfsc聽聽 STATUS,Z
聽return
聽decf聽聽聽 DS_RAM0,F
聽comf聽聽聽 DS_RAM0,F
聽return
;
dstemperature
聽call聽聽聽 dsreset
聽btfss聽聽 STATUS,Z聽聽聽聽聽聽聽 ; zero flag set means resp. ok
聽goto聽聽聽 badtmp

聽;movlw聽聽 0x00聽聽聽聽聽聽聽聽聽聽 ;uncomment for disabling romtable usage
聽;movwf聽聽 LCD_ACTDS聽聽聽聽聽 ;works only with one connected ds1820

聽goto聽聽聽 switchbegin聽聽聽聽 ; switch betweeen different LCD_ACTDS values
switch0
聽movlw聽聽 0x55聽聽聽聽聽聽聽聽聽聽聽 ; match rom first ds1820
聽call聽聽聽 dswrite
聽call聽聽聽 dswriterom0
聽goto聽聽聽 switchend
switch1
聽movlw聽聽 0x55聽聽聽聽聽聽聽聽聽聽聽 ; match rom second ds1820
聽call聽聽聽 dswrite
聽call聽聽聽 dswriterom1
聽goto聽聽聽 switchend
switchbegin
聽btfsc聽聽 LCD_ACTDS,0
聽goto switch0
聽btfsc聽聽 LCD_ACTDS,1
聽goto switch1
聽movlw聽聽 0xcc聽聽聽聽聽聽聽聽聽聽聽 ; default branch skip rom
聽call聽聽聽 dswrite聽聽聽聽聽聽聽
聽goto聽聽聽 switchend
switchend

聽movlw聽聽 0xbe聽聽聽聽聽聽聽聽聽聽聽 ; read scratch pad
聽call聽聽聽 dswrite

聽movlw聽聽 0x09聽聽聽聽聽聽聽聽聽聽聽 ; set counter to 9
聽movwf聽聽 DS_TMP0
聽movlw聽聽 DS_RAM0聽聽聽聽聽聽聽聽 ; indirect addressing
聽movwf聽聽 FSR聽聽聽聽聽聽聽聽聽聽聽聽 ; put first byte (DS_RAM0) into FSR
dstemperatureloop
聽call聽聽聽 dsread
聽movwf聽聽 INDF聽聽聽聽聽聽聽聽聽聽聽 ; store read byte into INDF pointers target
聽incf聽聽聽 FSR,F聽聽聽聽聽聽聽聽聽聽 ; increment FSR (now DS_RAM0 + n)
聽decfsz聽 DS_TMP0,F
聽goto聽聽聽 dstemperatureloop

聽call聽聽聽 dsreset聽聽聽聽聽聽聽聽 ; ok, that’s all
聽movlw聽聽 0xcc聽聽聽聽聽聽聽聽聽聽聽 ; skip prom, it is ok for multible ds1820, too
聽call聽聽聽 dswrite
聽movlw聽聽 0x44聽聽聽聽聽聽聽聽聽聽聽 ; start convert
聽call聽聽聽 dswrite
tempnotready聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; bugfix to ds1820.asm around
聽call聽聽聽 dsread聽聽聽聽聽聽聽聽聽 ;
聽btfss聽聽 STATUS,Z聽聽聽聽聽聽聽 ; – wait here till conversion has been done
聽goto聽聽聽 tempnotready聽聽聽 ;
聽;
聽;聽聽聽聽聽聽 IF DSSIGN NOT 255 OR 0 THEN ERROR
聽;
聽movf聽聽聽 DS_RAM1,W
聽btfsc聽聽 STATUS,Z
聽goto聽聽聽 oktmp
聽addlw聽聽 0x01
聽btfss聽聽 STATUS,Z
聽goto聽聽聽 badtmp
oktmp
聽retlw聽聽 0x00
badtmp
聽retlw聽聽 0x01聽聽
;
dsreadrom
聽call聽聽聽 dsreset
聽movlw聽聽 0x33聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; read rom command
聽call聽聽聽 dswrite
聽movlw聽聽 0x08聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; set counter to 8
聽movwf聽聽 DS_TMP0
聽movlw聽聽 DS_ROM0聽聽聽聽聽聽聽聽聽聽聽聽 ; indirect addressing
聽movwf聽聽 FSR聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; put first byte (DS_ROM0) into FSR
dsreadromloop
聽call聽聽聽 dsread
聽movwf聽聽 INDF聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; store read byte into INDF pointers target
聽incf聽聽聽 FSR,F聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; increment FSR (now DS_ROM0 + n)
聽decfsz聽 DS_TMP0,F
聽goto dsreadromloop
聽return
;
dsminmaxinit
聽movlw聽聽 0xff聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; sign, 0 -> ‘+’ 255 ‘-‘
聽movwf聽聽 DS_MIN0
聽movwf聽聽 DS_MAX0
聽movwf聽聽 DS_SIGNMAX0
聽movwf聽聽 DS_MIN1
聽movwf聽聽 DS_MAX1
聽movwf聽聽 DS_SIGNMAX1
聽clrf聽聽聽 DS_SIGNMIN0
聽clrf聽聽聽 DS_SIGNMIN1
聽return
;
; the are four decisions possible
;聽聽 max act
; 0 0聽聽 0聽聽聽聽 = max and act are +, newmax is the bigger value of both
; 1 0聽聽 255聽聽 = max is +, act value is not bigger
; 2 255 0聽聽聽聽 = max is -, act value is bigger
; 3 255 255聽聽 = max and act are -, newmax is the smaller value of both
;
dscalcmax
聽movf聽聽聽 DS_SIGNMAXTMP,W
聽btfss聽聽 STATUS,Z
聽goto聽聽聽 maxisminus
maxisplus
聽movf聽聽聽 DS_RAM1,W
聽btfss聽聽 STATUS,Z
聽return聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; case 1
聽movf聽聽聽 DS_MAXTMP,W聽聽聽聽聽聽聽聽 ; case 0
聽subwf聽聽 DS_RAM0,W
聽btfss聽聽 STATUS,C
聽return
聽goto聽聽聽 copyacttomax
maxisminus
聽movf聽聽聽 DS_RAM1,W
聽btfsc聽聽 STATUS,Z
聽goto聽聽聽 copyacttomax聽聽聽聽聽聽聽 ; case 2
聽movf聽聽聽 DS_MAXTMP,W聽聽聽聽聽聽聽聽 ; case 3
聽subwf聽聽 DS_RAM0,W
聽btfsc聽聽 STATUS,C
聽return
copyacttomax
聽movf聽聽聽 DS_RAM0,W
聽movwf聽聽 DS_MAXTMP
聽movf聽聽聽 DS_RAM1,W
聽movwf聽聽 DS_SIGNMAXTMP
聽return
;
; the are four decisions possible
;聽聽 min act
; 0 0聽聽 0聽聽聽聽 = min and act are +, newmin is the smaller value of both
; 1 0聽聽 255聽聽 = min is +, act value is smaller
; 2 255 0聽聽聽聽 = min is -, act value is not smaller
; 3 255 255聽聽 = min and act are -, newmin is the bigger value of both
;
dscalcmin
聽movf聽聽聽 DS_SIGNMINTMP,W
聽btfss聽聽 STATUS,Z
聽goto聽聽聽 minisminus
minisplus
聽movf聽聽聽 DS_RAM1,W
聽btfss聽聽 STATUS,Z
聽goto聽聽聽 copyacttomin聽聽聽聽聽聽聽 ; case 1
聽movf聽聽聽 DS_MINTMP,W聽聽聽聽聽聽聽聽 ; case 0
聽subwf聽聽 DS_RAM0,W
聽btfss聽聽 STATUS,C
聽goto聽聽聽 copyacttomin
聽return
minisminus
聽movf聽聽聽 DS_RAM1,W
聽btfsc聽聽 STATUS,Z
聽return聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; case 2
聽movf聽聽聽 DS_MINTMP,W聽聽聽聽聽聽聽聽 ; case 3
聽subwf聽聽 DS_RAM0,W
聽btfss聽聽 STATUS,C
聽return
copyacttomin
聽movf聽聽聽 DS_RAM0,W
聽movwf聽聽 DS_MINTMP
聽movf聽聽聽 DS_RAM1,W
聽movwf聽聽 DS_SIGNMINTMP
聽return
;聽聽 aqui se escribe lo despues de la temperatura C潞
lcdprintcelsius
聽movlw聽聽 ‘ ‘聽聽聽聽聽聽聽聽聽聽 ; primer caracter聽聽 espacio blanco
聽call聽聽聽 lcdputchar
聽movlw聽聽 B’01000011’聽聽 ; segundo caracter聽 C
聽call聽聽聽 lcdputchar
聽return
;
lcdprintrom
聽movlw聽聽 0x08聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; set counter to 8
聽movwf聽聽 DS_TMP0
聽movlw聽聽 DS_ROM0聽聽聽聽聽聽聽聽聽聽聽聽 ; indirect addressing
聽movwf聽聽 FSR聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; put first byte (DS_ROM0) into FSR
lcdprintromloop
聽movf聽聽聽 INDF,W聽聽聽聽聽聽聽聽聽聽聽聽聽 ; load INDF pointers target into w
聽call聽聽聽 lcdaschex聽聽聽聽聽聽聽聽聽聽 ; call hex->ascii conversion
聽movf聽聽聽 LCD_ASCHEXHI,W
聽call聽聽聽 lcdputchar
聽movf聽聽聽 LCD_ASCHEXLO,W
聽call聽聽聽 lcdputchar
聽incf聽聽聽 FSR,F聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; increment FSR (now DS_ROM0 + n)
聽decfsz聽 DS_TMP0,F
聽goto聽聽聽 lcdprintromloop
聽return
;
lcdprintdsdata
聽call聽聽聽 lcdascsign聽聽聽聽聽聽聽聽聽 ; calculate the sign from DS_SIGN
聽movf聽聽聽 LCD_ASCSIGN,W
聽call聽聽聽 lcdputchar

聽movf聽聽聽 DS_RAM0,W
聽movwf聽聽 NumL
聽movlw聽聽 ‘5’
聽movwf聽聽 LCD_ASCHALF聽聽聽聽聽聽聽聽 ; insert asc ‘5’ into aschalf
聽movlw聽聽 0x01
聽andwf聽聽 NumL,W
聽btfss聽聽 STATUS,Z
聽goto聽聽聽 skipit
聽movlw聽聽 ‘0’
聽movwf聽聽 LCD_ASCHALF聽聽聽聽聽聽聽聽 ; insert asc ‘0’ into aschalf
skipit

聽bcf聽聽聽聽 STATUS,C聽聽聽聽聽聽聽聽聽聽聽 ; clear carry, to avoid rrf problems
聽rrf聽聽聽聽 NumL,F聽聽聽聽聽聽聽聽聽聽聽聽聽 ; divide ds1820 temp through 2
聽clrf聽聽聽 NumH
聽call聽聽聽 bin2dec999
聽movlw聽聽 0x30
聽addwf聽聽 Tens,W
聽call聽聽聽 lcdputchar
聽movlw聽聽 0x30
聽addwf聽聽 Ones,W
聽call聽聽聽 lcdputchar
聽movlw聽聽 ‘.’
聽call聽聽聽 lcdputchar
聽movf聽聽聽 LCD_ASCHALF,W
聽call聽聽聽 lcdputchar
聽call聽聽聽 lcdprintcelsius
聽return
;
;Binary to decimal conversion (0..999)
;
;Input: NumH:NumL
;Output Hund:Tens:Ones
;
;If Input > 999 Output will roll over, e.g.
;for input=5678 output=678.
;
;
;Size: 34 instructions
;Execution聽 time聽 (max) including return:
;22+5*9-1+5*6-1+4*3-1+2 = 108 cycles
;
;5-July-2000 by Nikolai Golovchenko
bin2dec999
聽movf聽聽聽 NumH,W
聽addlw聽聽 D’241′
聽addwf聽聽 NumH,W
聽movwf聽聽 Hund聽聽聽聽聽 ;b_2 = 2a_2 – 15
聽addwf聽聽 Hund,W
聽addwf聽聽 Hund,W
聽addlw聽聽 D’253′
聽movwf聽聽 Tens
聽swapf聽聽 NumL,W
聽andlw聽聽 0x0f
聽addwf聽聽 Tens,F
聽addwf聽聽 Tens,F聽聽 ;b_1 = 6a_2 + 2a_1 – 48
聽addwf聽聽 NumH,W
聽sublw聽聽 D’251′
聽movwf聽聽 Ones
聽addwf聽聽 Ones,F
聽addwf聽聽 Ones,F
聽addwf聽聽 Ones,F
聽movf聽聽聽 NumL,W
聽andlw聽聽 0x0f
聽addwf聽聽 Ones,F聽聽 ;b_0 = a_0 – 4(a_2 + a_1) – 20
聽movlw聽聽 D’10’
bin2dec999a聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; 9 cycles max
聽addwf聽聽 Ones,F
聽decf聽聽聽 Tens,F
聽btfss聽聽 STATUS,C
聽goto聽聽聽 bin2dec999a
bin2dec999b聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; 6 cycles max
聽addwf聽聽 Tens,F
聽decf聽聽聽 Hund,F
聽btfss聽聽 STATUS,C
聽goto聽聽聽 bin2dec999b
bin2dec999c聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; 3 cycles max
聽addwf聽聽 Hund,F
聽btfss聽聽 STATUS,C
聽goto聽聽聽 bin2dec999c
聽return
;
main
聽clrf聽聽聽 STATUS
聽clrf聽聽聽 INTCON
聽clrf聽聽聽 PCLATH
聽clrf聽聽聽 PORTA
聽clrf聽聽聽 PORTB
聽bsf聽聽聽聽 STATUS, RP0
聽movlw聽聽 0xf8
聽movwf聽聽 TRISA
聽movlw聽聽 0x00
聽movwf聽聽 TRISB
聽bsf聽聽聽聽 OPTION_REG, NOT_RBPU
聽bcf聽聽聽聽 STATUS, RP0

聽bsf聽聽聽聽 OPTION_REG,PSA聽聽聽聽聽聽 ; enable watchdog
聽bsf聽聽聽聽 OPTION_REG,PS0聽聽聽聽聽聽 ; set prescaler to 1:128 = 2.3 seconds
聽bsf聽聽聽聽 OPTION_REG,PS1
聽bsf聽聽聽聽 OPTION_REG,PS2

聽call聽聽聽 dsminmaxinit聽聽聽聽聽聽聽聽 ; reset minmax values

聽movlw聽聽 1 << BTN_MODENORMAL
聽movwf聽聽 BTN_ACTMODE

聽call聽聽聽 lcdinit
聽call聽聽聽 lcdclear
聽call聽聽聽 dstemperature聽聽聽聽聽聽聽 ; read the temperature once and put into trash

聽movlw聽聽 LCD_LINE0
聽call聽聽聽 lcdsdda
聽call聽聽聽 dsprintcopyright
聽movlw聽聽 LCD_LINE1
聽call聽聽聽 lcdsdda
聽call聽聽聽 dsreadrom聽聽聽聽聽聽聽聽聽聽聽 ; use these routines to determine
聽call聽聽聽 lcdprintrom聽聽聽聽聽聽聽聽聽 ; the rom codes of your ds1820
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; remember to connect only one ds1820 for
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; rom detection
聽; wait approx. 5 sec
聽clrwdt聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; clear watchdog timer
聽sleep聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; wait…
聽clrwdt聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; clear watchdog timer
聽sleep聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; wait…

聽call聽聽聽 lcdclear聽聽聽聽聽聽聽聽聽聽聽聽 ; clear display
聽bcf聽聽聽聽 OPTION_REG,PS0聽聽聽聽
聽bcf聽聽聽聽 OPTION_REG,PS1聽聽聽聽聽聽 ; set prescaler to 1:16 = 0.25 seconds
loop

聽movlw聽聽 1聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; set bit 1 of LCD_ACTDS
聽movwf聽聽 LCD_ACTDS聽聽聽聽聽聽聽聽聽
聽call聽聽聽 dstemperature聽聽聽聽聽聽聽 ; get temperature values of first ds1820
聽call聽聽聽 dsminusconvertion
聽movlw聽聽 DS_MIN0聽聽聽聽聽聽聽聽聽聽聽聽聽 ; minmax calculation
聽call聽聽聽 dsminmax2tmp聽聽聽聽聽聽聽聽 ; since we have not enough ram space
聽call聽聽聽 dscalcmax聽聽聽聽聽聽聽聽聽聽聽 ; on 16f84, we can only have 2
聽call聽聽聽 dscalcmin聽聽聽聽聽聽聽聽聽聽聽 ; minmax calculation areas
聽movlw聽聽 DS_MIN0
聽call聽聽聽 dstmp2minmax
聽ifdef LCD_2X16聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; code to print values on 2×16 display
聽movlw聽聽 LCD_LINE0聽聽聽聽聽聽聽聽聽聽聽 ; put output to line 1 of the lcd display
聽call聽聽聽 lcdsdda
聽btfss聽聽 BTN_ACTMODE,BTN_MODENORMAL
聽goto聽聽聽 modeminmax0
聽call聽聽聽 dsprinttitle0
聽call聽聽聽 lcdprintdsdata
聽goto聽聽聽 modeend0
modeminmax0
聽btfss聽聽 BTN_ACTMODE,BTN_MODEMINMAX
聽goto聽聽聽 modeend0
聽call聽聽聽 dsprintminmax0
modeend0
聽endif
聽ifdef LCD_4X16聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; code to print values on 4×16 display
聽movlw聽聽 LCD_LINE0
聽call聽聽聽 lcdsdda
聽call聽聽聽 dsprinttitle0
聽call聽聽聽 lcdprintdsdata
聽movlw聽聽 LCD_LINE1
聽call聽聽聽 lcdsdda
聽call聽聽聽 dsprintminmax0
聽endif
聽movlw聽聽 2聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; set bit 2 of LCD_ACTDS
聽movwf聽聽 LCD_ACTDS聽聽聽聽聽聽聽聽聽
聽call聽聽聽 dstemperature聽聽聽聽聽聽聽 ; get temperature values of second ds1820
聽call聽聽聽 dsminusconvertion
聽movlw聽聽 DS_MIN1聽聽聽聽聽聽聽聽聽聽聽聽聽 ; minmax calculation
聽call聽聽聽 dsminmax2tmp
聽call聽聽聽 dscalcmax
聽call聽聽聽 dscalcmin
聽movlw聽聽 DS_MIN1
聽call聽聽聽 dstmp2minmax
聽ifdef LCD_2X16聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; code to print values on 2×16 display
聽movlw聽聽 LCD_LINE1聽聽聽聽聽聽聽聽聽聽聽 ; put output to line 2 of the lcd display
聽call聽聽聽 lcdsdda
聽btfss聽聽 BTN_ACTMODE,BTN_MODENORMAL
聽goto聽聽聽 modeminmax1
聽call聽聽聽 dsprinttitle1
聽call聽聽聽 lcdprintdsdata
聽goto聽聽聽 modeend1
modeminmax1
聽btfss聽聽 BTN_ACTMODE,BTN_MODEMINMAX
聽goto聽聽聽 modeend1
聽call聽聽聽 dsprintminmax1
modeend1
聽endif
聽ifdef LCD_4X16聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; code to print values on 4×16 display
聽movlw聽聽 LCD_LINE2
聽call聽聽聽 lcdsdda
聽call聽聽聽 dsprinttitle1
聽call聽聽聽 lcdprintdsdata
聽movlw聽聽 LCD_LINE3
聽call聽聽聽 lcdsdda
聽call聽聽聽 dsprintminmax1
聽endif

聽; more ds1820 may follow if the lcd display has enough lines

聽clrwdt聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; clear watchdog timer
聽sleep聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; wait 0.50 seconds, for screen switching

聽; rotate through the display modes
聽bcf聽聽聽聽 STATUS,C
聽rlf聽聽聽聽 BTN_ACTMODE,F
聽btfss聽聽 BTN_ACTMODE,BTN_MODEMINMAX + 1
聽goto聽聽聽 loop聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ; there are still modes available
聽movlw聽聽 1 << BTN_MODENORMAL ; no modes left, start with first mode
聽movwf聽聽 BTN_ACTMODE

聽goto聽聽聽 loop聽聽聽聽聽聽聽聽聽聽聽聽聽聽
end