Code:
@ DEVICE PIC16F684, INTRC_OSC_NOCLKOUT, WDT_OFF, PWRT_ON, BOD_OFF, MCLR_ON, PROTECT_ON
DEFINE OSC 4
TRISA= %00010000
TRISC= %00110000
CMCON0 = %00000111 ' Disable analog comparators.
VRCON = %00000000 ' Disable Comparator Voltage Reference
ANSEL = %00010000 ' Set pin (AN2) to analog input, the rest to digital
ADCON0 = %10001101 ' Set up A/D converter - Right Just., VDD REF., CH 3, ON
ADCON1 = %00110000 ' Set up A/D Converter clock source to internal RC
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50
DEFINE LCD_DREG PORTC ' LCD on port c
DEFINE LCD_DBIT 0 ' Data bits C0..C3
DEFINE LCD_RSREG PORTA ' RS on PORTA
DEFINE LCD_RSBIT 1 ' RS on A1
DEFINE LCD_EREG PORTA ' E on PORTA
DEFINE LCD_EBIT 2 ' E on A2
DEFINE LCD_BITS 4 ' LCD 4 bit mode
DEFINE LCD_LINES 2 ' 2 line LCD display
Define LCD_COMMANDUS 2000 ' Command Delay (uS)
Define LCD_DATAUS 50 ' Data Delay (uS)
Temperature1 Var Word
Temperature2 Var Word
TempC1 Var Word
TempC2 Var Word
Float1 Var Word
Float2 Var Word
Sign1 Var Byte
Sign2 Var Byte
DQ1 Var PORTC.5 ' OUT SENSOR
DQ2 Var PORTC.4 ' IN SENSOR
Twist1 Var Bit
Dummy1 Var Byte
V1 Var Word
Twist2 Var Bit
Dummy2 Var Byte
V2 Var Word
symb Var Byte
Vfs con 20480 ' 20,480v
K16 con 61441 ' coefficiente filtro 15/16
Vbatt Var Word ' Vbatt filtrato
TmpW Var Word
Acc_Vbatt Var Word ' accumulatore Vbatt filtrato * 16
batt Var Word
DS18B20_1_12bit CON %01111111 ' 750ms, 0.0625°C (default)
DS18B20_2_12bit CON %01111111 ' 750ms, 0.0625°C (default)
LCDOUT 254,64,4,10,4,0,0,0,0,0 ' Cust Char #0 ; http://www.darreltaylor.com/files/CustChar.htm
LCDOUT 254,72,10,31,17,17,17,17,31,0 ' Cust Char #1
LCDOUT 254,80,10,31,17,17,17,31,31,0 ' Cust Char #2
LCDOUT 254,88,10,31,17,17,31,31,31,0 ' Cust Char #3
LCDOUT 254,96,10,31,17,31,31,31,31,0 ' Cust Char #4
LCDOUT 254,104,10,31,31,31,31,31,31,0 ' Cust Char #5
LCDOUT 254,112,15,3,5,9,16,16,16,0 ' Cust Char #6
LCDOUT 254,120,1,1,1,18,20,24,30,0 ' Cust Char #7
include "Elapsed.bas"
Twist1 = 0
Twist2 = 0
Pause 5000
LcdOut $FE, $80," TERMO "
LcdOut $FE, $C0," VOLT "
PAUSE 3000
LCDOUT $FE, 1, $FE, $0C ' Clear display, cursor off
Pause 200
;Init Sensor 1
OWOUT DQ1, 1, [$CC, $4E, 0, 0, DS18B20_1_12bit]
OWOut DQ1, 1, [$CC, $48] ' Start temperature conversion
OWOut DQ1, 1, [$CC, $B8]
OWOut DQ1, 1, [$CC, $BE]
Pause 50
OWIn DQ1, 2, [temperature1.byte0, temperature1.byte1]
Pause 50
;Init Sensor 2
OWOUT DQ2, 1, [$CC, $4E, 0, 0, DS18B20_2_12bit]
OWOut DQ2, 1, [$CC, $48] ' Start temperature conversion
OWOut DQ2, 1, [$CC, $B8]
OWOut DQ2, 1, [$CC, $BE]
Pause 50
OWIn DQ2, 2, [temperature2.byte0, temperature2.byte1]
Pause 50
More about "Elapsed.bas" (credits to Mr.Darrel !) here :
Bookmarks