Shop OBEX P1 Docs P2 Docs Learn Events
Ds18b20 — Parallax Forums

Ds18b20

gtslabsgtslabs Posts: 40
edited 2008-01-25 02:07 in General Discussion
I have not seen much here in the SX forum on the DS18B20 temperature sensor.· A few months ago I had made a simple project measuring 8 different sensors using a Picaxe. Now I need to measure 26 different sensors and though to use my SX48 protoboard.

I am looking at 2 different approaches.
1) use a different input pin for each sensor and thus knowing the physical location of each based on where it plugs into the board. Then read each sensor.· Can I loop thru different ports RB0..7, RC0..7, RD0..7,RE0..1 in one continous for loop?· Or do I need to make each port group a separate loop.·

2) use the 1-wire bus.
I read thru the DS18B20 datasheet and it does not look like I can get a temperature reading and Serial Numer from one memory scratchpad location.· I would have to first loop thru all the serial number saving them to memory then loop back thru these 64 bit serial numbers for·MATCH ROM to get the temperature of each device. I can see that I would be limited by my memory size with 26+ 64bit ID's to store.

So with the first approach I·am limited·to the number of ports on the board where the second approach I am limited by memory.· Any ideas on how to best go about this?

Thanks
Steve

Comments

  • VonSzarvasVonSzarvas Posts: 3,527
    edited 2008-01-24 08:45
    I spent a lot of time on these sensors, and your 2 points do indeed cover the problems.

    As I recall, I could squeeze in only 4 sensors with the sx28 using method 1. (depending on the clock freq.)

    "Looping" the ports would be a great solution. I think JonnyMac once alluded to the idea that with some creative sub-routines, you could create a virtual looping effect. If you can crack that nut, you have it solved. http://forums.parallax.com/showthread.php?p=691357

    I did intend to try it myself, and would still like to - sadly some very sudden events here have taken me away from my projects for a while - so if you get some good results please feed them back to the thread!

    Good luck, Max.
  • JonnyMacJonnyMac Posts: 9,217
    edited 2008-01-25 00:35
    If I were doing this I would embed the serial numbers in a data table and then loop through them. 1-Wire, like serial, is an asynchronous protocol that is very timing sensitive, hence the SX/B functions for it generate a fair bit of code -- for one pin. Trying to use multiple pins means you'd have to play games with masking, etc., and it would probably become a bit messy.

    If you really want to use 1-Wire, create a small app that read the serial number from device and then embed that in your target code. It's only eight bytes per device so you're not using a lot of data space to manage your sensors (208 bytes, about half a page) -- and they're all on the same pin so you can use standard code.
  • gtslabsgtslabs Posts: 40
    edited 2008-01-25 01:37
    Thanks JonnyMac
    Where did you get 8 bits per device. I thought they were 64 bit serial numbers.
  • JonnyMacJonnyMac Posts: 9,217
    edited 2008-01-25 02:07
    Eight bytes per device (1 byte = eight bits); eight-bytes x 26 devices = 208 bytes.
Sign In or Register to comment.