Jump to content
43oh

Dallas/Maxim One Wire Library


Recommended Posts

  • Replies 31
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Here is a basic library for 1-wire communication. It works with CPU frequency of 1 MHz or higher. Carefully crafted assembly code is used to allow operation over a wide CPU clock frequency range.  

Thanks to pointers from Rickta59 here's code tuned to work in msp430-gcc. I've used it in my project to read temperature from DS sensor and it works correctly. dow.zip

Hi oPossum (Kevin?),   Combining read/write bit "slot" functions is incredibly insightful. Bravo! After looking at the separate read and write routines on an old DS18B20 + PIC 10F200 project, comb

Posted Images

Pardon my ignorance, but what is "Dallas/Maxim One Wire"? Is it an asynchronous single-line protocol?

 

Yes. It's a two wire bus that has a time based protocol. Maxim/Dallas is the only manufacturer in the world.

 

Here's an excellent summary of it.

 

Most people use their temperature sensors in their HVAC projects.

 

But, it's also used in a serious manner. I have a client who has based their entire business on these temperature sensors. They are one of the largest users of one wire technology in the world.

Link to post
Share on other sites
  • 4 months later...
  • 3 weeks later...

Hi!

 

So I'm having a bit of a problem trying to figure out this code, and I'm wondering if anyone could help me out a bit.

 

Basically, I'm trying to use G2231 to read a DS18B20. I'm using pin 1.6 and 1 MHz factory calibrated clock.

The thing is, when I send down the initial check owex(0,0), I get correct behaviour (tested on 2 different sensors). 0xFFFF if the sensor is plugged in and 0 if it's not.

 

Then, I try to send down the Skip Rom command (0xCC) in order to verify the communication. It fails, for it always returns a 0. Curious enough, though, if I send down the ReadRom command (0x33), I do get the echo back (0x33). I'm using the sensor in the pull-up resistor configuration.

 

I get the feeling I'm missing something basic here. It says in the OP that if I don't get an echo when using 0xCC command, there's a problem on my bus, but I dont actually get what that would mean. I don't have access to an oscilloscope and the voltages check out fine. I'd be grateful for any help.

 

Here's my main code:

void main(void)
{

volatile int p;
volatile int test;

WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer

DCOCTL = 0;
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;


	LCD_init();

	one_wire_setup(&P1DIR, &P1IN, BIT6, 1);

	LCD_gotoXY(0,0);

	p = owex(0,0);

	if(p == 0xFFFF){
		LCD_writeString("D found.");
		LCD_gotoXY(0,1);
		test = owex(0xCC, 8);
		LCD_writeString(convertADC(test,0));
	}else{
		LCD_writeString("D not found.");
	}

}

 

So basically, if there's a sensor plugged in, I get this on the lcd:

Device found.

0

 

If there isn't, I get:

Device not found

Link to post
Share on other sites

Hi!

 

Thanks for the help. Sorry I didn't answer sooner but something unexpected came up.

 

Yeah, the jumper on 1.6 was removed, I forgot to mention that. Anyway, I'll try running your sample code tomorrow and try to see what comes up.

 

Thank you very much for your help so far :)

 

[EDIT]

Hah! Found the problem.

 

I had a "lightbulb" moment and checked to see if I didn't accidentally mistake my DS18B20 for a transistor or something else in TO-92 casing. Funny enough, it seems that my DS18B20 isn't DS18B20 at all, but DS18B20P, which is a Parasite-mode only chip. :lol:

It'll be a while before I can get my hands on a normal one. Will report back then.

Link to post
Share on other sites
  • 4 weeks later...
  • 7 months later...

I'm working on implementing this for the IV-18 Clock booster and I'm not sure if I've got things running correctly or if I'm misinterpreting the output

 

Before the print_temp function executes, the values for TF and TC are around 3304 and 6459.

This is what I'm seeing in the console:

 

One Wire Test
FF 33 28 53 92 BF 03 00 00 B2 
206.5000 403.6875 

 

I'm seeing numbers increase when I touch the sensor and back down when I take my finger off and the serial is always consistent.

 

Any suggestions?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.


×
×
  • Create New...