jcleaver
- 6th February 2007, 21:56
trying to read temperature have either chip cant get good reading
or maybe none
have a 877a at 20 mhz using bootloader
and have a 4.7 k pull up resistor
listing here
any help would be appreicated
have tried a number of programs to no avail
'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : JACK CLEAVER *
'* Notice : Copyright (c) 2007 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 2/6/2007 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
@ DEVICE pic16f877a, HS_OSC, WDT_ON, PWRT_ON, LVP_OFF, PROTECT_OFF
' Define LCD registers and bits
Define LCD_DREG PORTB ' Port for LCD Data
Define LCD_DBIT 4 ' Use upper 4 bits of Port
Define LCD_RSREG PORTB ' Port for RegisterSelect (RS) bit
Define LCD_RSBIT 3 ' Port Pin for RS bit
Define LCD_EREG PORTB ' Port for Enable (E) bit
Define LCD_EBIT 2 ' Port Pin for E bit
Define LCB_BITS 4 ' Using 4-bit bus
Define LCD_LINES 2 ' Using 2 line Display
Define LCD_COMMANDUS 2000 ' Command Delay (uS)
Define LCD_DATAUS 50 ' Data Delay (uS)
define loader_used 1
DEFINE OSC 20
'Pin 1 - Vdd (+5V)
'Pin 2 - Vss (GND)
'Pin 3 - Vo
'Pin 4 - RS to RD2 (PIC)
'Pin 5 - R/W (GND)
'Pin 6 - E to RD3 (PIC)
'Pin 11 - RD4 (PIC)
'Pin 12 - RD5 (PIC)
'Pin 13 - RD6 (PIC)
'Pin 14 - RD7 (PIC)
'DS18S20 - DQ pin to RC2(PIC), DQ pin to Vdd pin via 4.7 k r, GND pin to GND
'Define LCD_DREG PORTD
'Define LCD_DBIT 4
'Define LCD_RSREG PORTD
'Define LCD_RSBIT 2
'Define LCD_EREG PORTD
'Define LCD_EBIT 3
'Define LCD_BITS 4
'Define LCD_LINES 2
DQ var PORTC.2
temperature Var Word
count_remain Var Byte
count_per_c Var Byte
ADCON1 = 7
pause 100
Main: OWOut DQ,1,[$CC,$44]
Waitloop: OWIn DQ,4,[count_remain]
If count_remain = 0 Then Waitloop
OWOut DQ,1,[$CC,$BE]
OWIn DQ,0,[temperature.LOWBYTE,temperature.HIGHBYTE,Skip 4,count_remain,count_per_c]
temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100)/count_per_c)
Lcdout $fe,1,DEC (temperature/100),".",DEC2 temperature," C"
Pause 1000
Goto Main
End
or maybe none
have a 877a at 20 mhz using bootloader
and have a 4.7 k pull up resistor
listing here
any help would be appreicated
have tried a number of programs to no avail
'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : JACK CLEAVER *
'* Notice : Copyright (c) 2007 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 2/6/2007 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
@ DEVICE pic16f877a, HS_OSC, WDT_ON, PWRT_ON, LVP_OFF, PROTECT_OFF
' Define LCD registers and bits
Define LCD_DREG PORTB ' Port for LCD Data
Define LCD_DBIT 4 ' Use upper 4 bits of Port
Define LCD_RSREG PORTB ' Port for RegisterSelect (RS) bit
Define LCD_RSBIT 3 ' Port Pin for RS bit
Define LCD_EREG PORTB ' Port for Enable (E) bit
Define LCD_EBIT 2 ' Port Pin for E bit
Define LCB_BITS 4 ' Using 4-bit bus
Define LCD_LINES 2 ' Using 2 line Display
Define LCD_COMMANDUS 2000 ' Command Delay (uS)
Define LCD_DATAUS 50 ' Data Delay (uS)
define loader_used 1
DEFINE OSC 20
'Pin 1 - Vdd (+5V)
'Pin 2 - Vss (GND)
'Pin 3 - Vo
'Pin 4 - RS to RD2 (PIC)
'Pin 5 - R/W (GND)
'Pin 6 - E to RD3 (PIC)
'Pin 11 - RD4 (PIC)
'Pin 12 - RD5 (PIC)
'Pin 13 - RD6 (PIC)
'Pin 14 - RD7 (PIC)
'DS18S20 - DQ pin to RC2(PIC), DQ pin to Vdd pin via 4.7 k r, GND pin to GND
'Define LCD_DREG PORTD
'Define LCD_DBIT 4
'Define LCD_RSREG PORTD
'Define LCD_RSBIT 2
'Define LCD_EREG PORTD
'Define LCD_EBIT 3
'Define LCD_BITS 4
'Define LCD_LINES 2
DQ var PORTC.2
temperature Var Word
count_remain Var Byte
count_per_c Var Byte
ADCON1 = 7
pause 100
Main: OWOut DQ,1,[$CC,$44]
Waitloop: OWIn DQ,4,[count_remain]
If count_remain = 0 Then Waitloop
OWOut DQ,1,[$CC,$BE]
OWIn DQ,0,[temperature.LOWBYTE,temperature.HIGHBYTE,Skip 4,count_remain,count_per_c]
temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100)/count_per_c)
Lcdout $fe,1,DEC (temperature/100),".",DEC2 temperature," C"
Pause 1000
Goto Main
End