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.

[AVR] Reading DS18B20 chip ?

Status
Not open for further replies.

bianchi77

Advanced Member level 4
Joined
Jun 11, 2009
Messages
1,313
Helped
21
Reputation
44
Reaction score
20
Trophy points
1,318
Location
California
Activity points
9,442
Guys,

I tried to read DS18B20...
but the output in USART is

Temperature : ?

What should I change in this code ? thanks
Code:
char printbuff[100];
	double d = 0;
	int d1 = d; 
		
	usart_init(BAUD_PRESCALE);
	usart_pstr("TEST DS18B20 \n" );
	//init interrupt
	sei();
	
	while(1)
	{
		d = ds18b20_gettemp();
		//printf(printbuff,"%d",d1);
		
		sprintf(printbuff, "%.2f", d);
		usart_pstr("Temperature:");
		usart_pstr(printbuff);
		usart_pstr("\r\n");
		_delay_ms(500);
		
	}
 

Easyrider83

Advanced Member level 5
Joined
Oct 11, 2011
Messages
1,608
Helped
373
Reputation
746
Reaction score
361
Trophy points
1,363
Location
Tallinn, Estonia
Activity points
8,577
Possible, start converion command missed? Also, delay 750ms needed for conversion.
 

mikewardlow

Newbie level 5
Joined
Apr 13, 2006
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,336
Attached is a Windows Liberty Basic program the uses the LinkUSB adapter
perhaps you can get some idea from it...
 

Attachments

  • LB-1wire.zip
    5.2 KB · Views: 2

mikewardlow

Newbie level 5
Joined
Apr 13, 2006
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,336
Attached is a Windows Liberty Basic program the uses the LinkUSB adapter
perhaps you can get some idea from it...

adding attachment

low level send rom address or skip rom - must select device
send convert cmd wait 750 ms if in parasite mode
send read scratch pad to get values
process the values

does you hi level get-temperature
does your hilevel support the adapter you are using, I use LinkUSB [DS9097U]
 

Attachments

  • LB-1wire.zip
    5.2 KB · Views: 3

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,920
Helped
4,874
Reputation
9,766
Reaction score
4,661
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
126,943
It depends on what the function "ds18b20_gettemp()" does and whether it includes all the delays and commands needed for the device to return a value.

You are assigning the result to a double so printing it as a float wont work!

Brian.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top