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.

[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);
		
	}
 

Possible, start converion command missed? Also, delay 750ms needed for conversion.
 

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: 50

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: 58

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.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top