Jump to content
Sign in to follow this  
touch

Reading tempature from a DS1821+ 1-Wire tempature sensor

Recommended Posts

Thanks to everyone that looked into it, I had a feeling that it was a timing issue but as I don't have a scope, it's kind of difficult for me to debug. I did try adjusting the wait times according to what zeke had found, but I had no luck.

 

If anyone wants to have a stab at it, you can get free samples @ maxim-ic.com for testing, if you have a university or "non free" email: http://www.maxim-ic.com/datasheet/index ... /2794/t/or

 

Sort of OT, but I've also been wondering something, I don't totally understand how timers work (I'm pretty new to micro controller programming.), would it be possible to run a timer for something like delayms/us, and also run a timer for the timer-uart at the same time?

Share this post


Link to post
Share on other sites
...would it be possible to run a timer for something like delayms/us, and also run a timer for the timer-uart at the same time?

Ideally, you would want to use 2 timers for that, but the value line has only one.

You have two options:

1. alternate between tasks, uart, other delay task, uart, etc. Each time the task is completed you change settings to take care of the other task.

2. interrupt periodically and keep track of what needs to be done at the given interrupt. The problem with this one is that you will not be able to use capture feature because it will screw up your timing.

 

Also, let's not forget about USI which will handle I2C ans SPI. On some chips, you can even do UART.

And you can always choose the right cheap for the job rather than use the one you have.

Share this post


Link to post
Share on other sites

I am pondering the idea of creating a state machine that is driven by the timer. The challenge is to come up with a design that allows you to do more than one thing at a time ie: update an LCD while you're waiting for the one wire search routine to complete.

 

My intuition is telling me that the msp430 is not the right tool for this though. I say this because the msp430 wants to be in a low power mode most of the time rather than blasting through the main loop at 16MHz. At least that's what I've picked up from all the TI marketing information.

 

Nevertheless, I think that a state machine running at MCK of 8 or 16MHz would give this application the best chance of succeeding. I'll see what I can come up with as a proof of concept.

Share this post


Link to post
Share on other sites
...the msp430 wants to be in a low power mode most of the time...

Just because the low power modes are there, doesn't mean you have to use them. ;) I rarely, if ever use them because my projects are not intended to run off batteries for very long (usually a wall adapter).

Share this post


Link to post
Share on other sites

Hey Touch,

 

I just wanted to mention that I've got the 1us timer issue all sorted out and I've been able to generate the 1-Wire Reset command on my Launchpad.

 

Take a look at this thread to see what I did.

 

I hope it helps.

Share this post


Link to post
Share on other sites

That's great zeke.

 

I went ahead and followed your instructions and flashed the new DCO values and have got the sensor working. Temperature readout is working perfectly via UART.

 

I'll post the updated code soon, as the new code does not use MSPhere, and I've tried to clean it up some.

 

Thanks a bunch!

Share this post


Link to post
Share on other sites

Touch,

 

Could you do us a solid and post your resultant code?

Post it in the code vault sub-forum.

 

I'd like to see how you put it all together.

 

Don't forget to tell us your hardware config because I want to compare your implementation against mine.

 

Thanks!

Share this post


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.

Sign in to follow this  

×
×
  • Create New...