Shop OBEX P1 Docs P2 Docs Learn Events
One Wire, Thermocouple, DS2762, The Prop and some noob questions. — Parallax Forums

One Wire, Thermocouple, DS2762, The Prop and some noob questions.

TJHJTJHJ Posts: 243
edited 2008-07-25 14:49 in Propeller 1
So I am trying to use the DS2762 to read and compensate a K type thermocouple, but between the one wire interface and others I am having a hard time.

With 8 chips on a one wire interface is there an easy way to identify which chip is physically located where in the sequence? I can get the 64 bit addresses of each chip but which chip I am looking at eludes me.

If the above is not so simple, lets place each chip on its own pin. Should I use the Skip net address (hex command CCh)?

According to the DS2762 data sheet the two items of interesest are The chip temperature and the V sense for the thermocouple are stored in given registers
Chip Temp= (hex) 18, 19
V Sense = (hex) 0C, 0D

so using onewire.spin

The command options are
PUB readAddress(p) | ah, al
  ah := readBits(32)
  al := readBits(32)
  longmove(p, @ah, 2)

PUB readBits(n) : b | mask
  b := 0
  mask := 1
  
  repeat n
    ' Pull low briefly, then sample.
    ' Ideally we'd be sampling 15us after pulling low.
    ' Our timing won't be that accurate, but we can be close enough.

    dira[noparse][[/noparse]pin]~~
    dira[noparse][[/noparse]pin]~
    if ina[noparse][[/noparse]pin]
      b |= mask

    mask <<= 1




So I would think I would issue a command like this to read the Chip temperature register.

Pub GetChipTemp
  Temp.byte[noparse][[/noparse]0] := readaddress(18)
  Temp.byte := readaddress(19)




But this seems to return nothing and I cant see where the return value from the register gets returned to my temp var(word). Maybe I am missing it or I have been looking at this to long.

Then if we are looking at more than one device on a chain, how/where do I specify which device we are talking to or receiving from. Or do I issue a command and receive the result back from all of the chips in sequence?

I guess I am most lost in where I am issuing the commands and receiving the return from which register.

THanks for all the help as always.
TJ

Post Edited (TJHJ) : 7/24/2008 5:06:36 PM GMT

Comments

  • scanlimescanlime Posts: 106
    edited 2008-07-24 17:31
    TJHJ said...
    So I am trying to use the DS2762 to read and compensate a K type thermocouple, but between the one wire interface and others I am having a hard time.

    With 8 chips on a one wire interface is there an easy way to identify which chip is physically located where in the sequence? I can get the 64 bit addresses of each chip but which chip I am looking at eludes me.

    You can't identify the chips' physical location unless they're on separate pins. One thing that might help: If you only have one device of each type on the bus, the low 8 bits of the 64-bit address are a "family code". Those bits map to a particular chip's model number.

    If this is a one-off project and you don't need to be able to mass produce them easily, you can use a single 1-wire bus pin, use a bus scanner tool (like the example included in SpinOneWire) to determine the address of each device by plugging just that single device in, then hardcode those addresses in your program.
    TJHJ said...

    If the above is not so simple, lets place each chip on its own pin. Should I use the Skip net address (hex command CCh)?

    If you gave each device a dedicated pin, you could use SKIP_ROM. If you decide to use one pin and hardcode the address, you would send a MATCH_ROM followed by that address.
    TJHJ said...

    So I would think I would issue a command like this to read the Chip temperature register.

    Pub GetChipTemp
      Temp.byte[noparse][[/noparse]0] := readaddress(18)
      Temp.byte := readaddress(19)
    
    



    readAddress is just a convenience function that does a 64-bit read. It isn't returning anything visible, because it's actually writing a 64-bit value to memory location 18. Oops [noparse]:)[/noparse]

    You'll need to look at the data sheet to figure out what commands the device responds to. The general sequence for talking to a 1-wire device is:

    1. Reset, to get the bus's attention
    2. Tell the bus how you're going to select a device (SKIP_ROM, MATCH_ROM, etc)
    3. If you're using an address (MATCH_ROM), send it. Addresses are 64-bit.
    4. Send a command. This is a device-specific byte, like CONVERT_T or READ_SCRATCHPAD.
    5. Read/write whatever data the command needs or has.

    If you want a general example of how this should work, the OneWireSpin package includes an example that can read DS18B20 temperature sensors. I haven't worked with the 1-wire thermocouple devices, but they're probably similar. Just take a look at some other 1-wire source code, and take a look at the command set in the chip's data sheet.

    Good luck!
    --Micah
  • TJHJTJHJ Posts: 243
    edited 2008-07-25 14:49
    Thank you so much for your help Micah.

    Ok so now that Im not trying to do something completely random, it seems to be working to an extent.
    Using the One Wire routine and getting the chip temperature I perform it like this.

    ow.Reset
    ow.tx(Skip_Rom)
    ow.Tx($18)
    Temp.byte[noparse][[/noparse]0]:= ow.Recivebyte
    
    ow.Reset
    ow.tx(Skip_Rom)
    ow.Tx($19)
    Temp.byte:= ow.Recivebyte
    Temp:= Temp >> 4 ' Also tried << 8 works as well. 
    
    
    
    



    Ok so here is where it gets interesting, This works but only as an integer value, it seems to match what I am seeing using a laser temp reader, but according to the DS2762 Data sheet this should be a number that is FP to a .125 Deg resolution stored in two's compliment. (Which I think is just Floating point)

    Temperature Register Format
      MSB&#8212;Address 18                      LSB&#8212;Address 19   
    S 2^9 2^8 2^7 2^6 2^5 2^4 2^3      2^2 2^1 2^0 X X X X X 
    MSb                       LSb     MSb                   LSb 
            Units: 0.125°C 
    
    


    So I am not really sure what is going on and why 4 or 8 shift increments work when its a 10 bit signed number. any ideas

    Also which way does it fill/transmit when receiving from the ds2762.

    Such that it would tx right to left and then the prop fills bottom up.

    So it would receive
    byte0(18)
    2^3 2^4 2^5 2^6 2^7 2^8 2^9 s 
    
    and byte1(19)
    x x x x x 2^0 2^1 2^2 
    
    


    but in this sense I would place 'byte[noparse][[/noparse]0]' as the most right bit, such that really it would look like
    16bit         bit 1                               bit 0
    x x x x x 2^0 2^1 2^2     2^3 2^4 2^5 2^6 2^7 2^8 2^9 s  
    eg %00000***_*******s
     
    
    


    Meaning they would need to be inverted? I think this is the cause of why the shift 4/8 works but makes it no longer a FP number.
    or would it transmit in reverse order so that when received it is placed in the correct order.

    THanks for all the help
    TJ

    Post Edited (TJHJ) : 7/25/2008 2:58:58 PM GMT
Sign In or Register to comment.