One Wire, Thermocouple, DS2762, The Prop and some noob questions.
TJHJ
Posts: 243
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
So I would think I would issue a command like this to read the Chip temperature register.
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
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
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.
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.
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
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.
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
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
but in this sense I would place 'byte[noparse][[/noparse]0]' as the most right bit, such that really it would look like
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