Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

4 ds18s20 display on an LCD using pic16f84a in Picbasic pro

Status
Not open for further replies.

jojokatada

Full Member level 5
Full Member level 5
Joined
Jan 13, 2005
Messages
255
Helped
19
Reputation
38
Reaction score
4
Trophy points
1,298
Visit site
Activity points
2,122
ds1820 picbasic

hi

is it possible to use 4 ds1820 a pic16f84a which will be display four different temperature on the 4 lines of the lcd?

so far it work with 1 ds1820 because i am using a 4x20 lcd.

sample code

DEFINE LCD_DREG PORTA 'LCD data port
DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTA 'LCD register select port
DEFINE LCD_RSBIT 4 'LCD register select bit
DEFINE LCD_EREG PORTB 'LCD enable port
DEFINE LCD_EBIT 3 'LCD enable bit
DEFINE LCD_BITS 4 'LCD bus size 4 or 8
DEFINE LCD_LINES 4 'Number lines on LCD
DEFINE LCD_COMMANDUS 2000 'Command delay time in us
DEFINE LCD_DATAUS 50 'Data delay time in us

symbol DQ1 = PORTB.4 'DQ connect to RB4
symbol DQ2 = PORTB.0
SYMBOL DQ3 = PORTB.1
SYMBOL DQ4 = PORTB.2

temperature var word
count_remain var byte
count_per_c var byte

temperature1 var word
count_remain1 var byte
count_per_c1 var byte

temperature2 var word
count_remain2 var byte
count_per_c2 var byte

temperature3 var word
count_remain3 var byte
count_per_c3 var byte



pause 100


Main: ' TEMP 1
owout DQ1, 1,[$CC, $44]
OWin DQ1, 4,[count_remain]
if count_remain = 0 then
owout DQ1, 1, [$CC, $BE]
owin DQ1, 0, [temperature.LOwBYTE, temperature.Highbyte, Skip 4, count_remain, count_per_c]
endif

temperature = ((( temperature >> 1) *100)- 25) + (((count_per_c - count_remain) * 100) / count_per_c)
lcdout $FE,1
LCDOUT " Environment Temp1", dec (temperature / 100) , ".", dec2 temperature, " C"
pause 1000

'TEMP 2
owout DQ2, 1,[$CC, $44]
OWin DQ2, 4,[count_remain1]
if count_remain1 = 0 then
owout DQ2, 1, [$CC, $BE]
owin DQ2, 0, [temperature1.LOwBYTE, temperature1.Highbyte, Skip 4, count_remain1, count_per_c1]
endif

temperature1 = ((( temperature1 >> 1) *100)- 25) + (((count_per_c1 - count_remain1) * 100) / count_per_c)
lcdout $FE,$C0
LCDOUT " Environment Temp2", dec (temperature1 / 100) , ".", dec2 temperature1, " C"
pause 1000

'TEMP 3
owout DQ3, 1,[$CC, $44]
OWin DQ3, 4,[count_remain2]
if count_remain2 = 0 then
owout DQ3, 1, [$CC, $BE]
owin DQ3, 0, [temperature2.LOwBYTE, temperature2.Highbyte, Skip 4, count_remain2, count_per_c2]
endif

temperature2= ((( temperature2 >> 1) *100)- 25) + (((count_per_c2 - count_remain2) * 100) / count_per_c2)
lcdout $FE,$94
LCDOUT" Environment Temp2",dec (temperature2 / 100) , ".", dec2 temperature2, "C"
pause 1000

'TEMP 4
owout DQ4, 1,[$CC, $44]
OWin DQ4, 4,[count_remain2]
if count_remain2 = 0 then
owout DQ4, 1, [$CC, $BE]
owin DQ4, 0, [temperature2.LOwBYTE, temperature2.Highbyte, Skip 4, count_remain2, count_per_c2]
endif

temperature2 = ((( temperature2 >> 1) *100)- 25) + (((count_per_c2 - count_remain2) * 100) / count_per_c2)
lcdout $FE,$D4
LCDOUT " Environment Temp4",dec (temperature2 / 100) , ".", dec2 temperature2, "C"
pause 1000

goto Main
end

so far compile fail
the error message

[218] address limit 3ffth exceeded

If anyone has any ideas on what may be wrong or any tips, it would be greatly appreciated[/list]
 

ds1820 pic16f84

hi it seem to me there are many viewers on my post did anybody try to compile my source ? what are the result please post so we could share

appreciate
 

ds18b20 picbasic

Your program is too large for the PIC 16F84A (only 1024 words of program memory). The compiler said that this. Maybe you have to change the PIC to another model with more memory (16F628A or larger, good options are 16F819, 16F88 and 18F1320).
Other option is to try to optimize your code, or simplify it, to decrease the memory to be used.
 

ds1820 pic basic

yes i did i try the pic16f876a it compile correct but i can't displa yi the 4 differents temperature in 4 lines of the lcd i got some strange character, sort of dump memory i guess. or perhaps the 18s20 can't connect in all the same as master i need to check maxim datasheet again.

appreciate the advice.
 

picbasic ds1820

---------------
Main: ' TEMP 1
owout DQ1, 1,[$CC, $44]
pause 1000 ; -- need this --
OWin DQ1, 4,[count_remain]
etc
---------------
You must move "pause 1000" after the "convert T" command ($44); ds18s20 needs about 800 ms to do the conversion, after that you can read it.
...and you must check if there are 4.7 k resistors from DQ to Vdd.
...and if you have 20 sensors, you write 20 routines for this? You can do only one and call it with "DQx" parameter
 
pic16f84a lcd

I see that you are pausing for 100ms at the beginning
of the program. I'm assuming this is to let the LCD
settle after powering up. That _should_ be long enough
for most LCD's, but I've had some otherwise standard
44780-based displays need 500ms or more to settle -
or else I'd have trouble communicating with them.

This may or may not be your problem (I don't have
any experience with using multiple 1-wire devices),
but it should be fast enough to recompile your code
and give it a try. Can't hurt.

Nick
 
temperature pic16f84a

This code should work and it's 1/2 size (569 words on 16f84)
---------------
symbol DQ1 = PORTB.4 'DQ connect to RB4
symbol DQ2 = PORTB.0
symbol DQ3 = PORTB.1
symbol DQ4 = PORTB.2
dq var byte
adr var byte
index var byte
temperature var word
count_remain var byte
count_per_c var byte

pause 1000

Main:
dq=dq1 : adr=$1 : index=1
gosub temp
dq=dq2 : adr=$c0 : index=2
gosub temp
dq=dq3 : adr=$94 : index=3
gosub temp
dq=dq4 : adr=$d4 : index=4
gosub temp

goto Main

temp:
owout DQ, 1,[$CC, $44]
pause 1000
owin DQ, 4,[count_remain]
if count_remain = 0 then
owout DQ, 1, [$CC, $BE]
owin DQ, 0, [temperature.LOwBYTE, temperature.Highbyte, Skip 4, count_remain, count_per_c]
endif

temperature = (((temperature >> 1)*100)-25)+(((count_per_c-count_remain) * 100)/count_per_c)
lcdout $FE,adr
lcdout " Environment Temp", dec index, dec (temperature / 100) , ".", dec2 temperature, " C"
return

end
------------------------
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top