Jump to content
Sign in to follow this  
Daz

One Wire Revisited

Recommended Posts

Hi all,

This is getting extremely stressful now.

 

I don't understand what the functions in the 1 wire routine are doing.

 

I presumed (wrongly it seems) that if I put them into my project, then printed the 'data' from the 'short data = oo_get_data();' function then I would get some sort of value.

 

Is this right or wrong?

 

very confused,

Daz.

Share this post


Link to post
Share on other sites
I presumed (wrongly it seems) that if I put them into my project, then printed the 'data' from the 'short data = oo_get_data();' function then I would get some sort of value.

You must be getting some sort of value (even if its zero)?

 

Regards

Dave

Share this post


Link to post
Share on other sites

Hi Dave,

I added a 1 second delay after the print command and I get a value of '-1', regardless of the state of the sensor.

 

Does this seem correct, I thought the value would vary even if the value didn't make sense?

 

Regards,

Daz.

Share this post


Link to post
Share on other sites

If you have access to an oscilloscope it would be handy, but it sounds like

you have a timing issue. Some onewire devices are extremely sensitive

about the timing cycles and others are not.

 

Adding more time will not help the issue as the device will change the

state of the line to acknowledge the bit or data sequence but it only holds

it for a short amount of time. The Dallas DS1820 acks after ~60uS for an

init/reset pulse and is ready for cmd/data 470uS+ after that.

Share this post


Link to post
Share on other sites

Download and use this one-wire example code. There are nop(); instruction you have to change depend on crystal frequency. I don´t know if the built in lib take care of the timing or if it just work on one crystal frequency?

http://www.lika.be/content/view/21/30/

 

Here is also a function I wrote to get tempature data but it use the float libary(it´s not 100% tested).

 

oo_temperature ReadTemperature( char lsb, char msb, char remain, char nr_count)
{
int temp_int;
float frac_deg;
oo_temperature data;

temp_int = lsb/2;

if ( msb == 0xFF )
	temp_int -= 128;

if ( nr_count != 0 )
	frac_deg = float32_div( float32_from_int32( (nr_count-remain) ), float32_from_int32( nr_count ) );
else
	frac_deg = 0.25;

frac_deg = float32_add( frac_deg, float32_from_int32( temp_int ) );
data.temp = float32_sub( frac_deg, 0.25 );
data.int_temp = float32_to_int32( data.temp );
data.decimal = float32_to_int32(float32_mul( float32_sub( data.temp, float32_from_int32( float32_to_int32_round_to_zero( data.temp ) ) ), 100));
if ( data.decimal < 0 )
	data.decimal -= data.decimal*2;

return data;
}

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...