DS2760 and SX/B
Dunnsept
Posts: 115
OK, finally getting around to posting this. I got my DS2760 kits from parallax, spent quite a bit of time trying to reproduce the example BS2 code in SX/B and I'm not having any luck at all.
The chip returns a 12bit value for the t/c at 15.625 uV per.. that much I've got. I'm embarrassed to post my code because it's so fubar at this point, but the important bits would be as follows (tempin = RB.0) :
the reset command returns a 2 so I've got a good connection to the ds2760. But I'm getting odd values returned. tcuvb1 is coming back as 0 while tcuvb is coming in as 152. I know that I need to shift right 3 to align correctly, but in just using a K type table it is putting the recorded temp in the 9 degree C range (shift 3 = 19, * 15.625 = 296 = just under 8 degrees).. In reading up on the pbasic versions of the one wire stuff, it says that the functions automatically generate a reset command. Do I need to make a call to reset more often? If I put a reset in there before the readbyte command I get tcuvb1 = 255.
now to confuse things worse, if I do a readreg on $18 for the chip temperature, I'm getting something around 22C which should be about right for my office. I dont know if it's because I'm screwing things up trying to read the word back or if it's because of resets or something else. The rest of the code is just plain straight template and I'm using watch in the debugger to see what values are returned.
any pointers?· tips?· I'm not looking for anybody to just write code for me but I sure would like it if someone could point me in the right direction
also if it makes any difference, what I'm doing is just watching the variables and then doing the shifts and stuff by hand to make sure that I'm getting the right values out before I proceed.
Post Edited (Dunnsept) : 5/24/2006 5:58:13 PM GMT
The chip returns a 12bit value for the t/c at 15.625 uV per.. that much I've got. I'm embarrassed to post my code because it's so fubar at this point, but the important bits would be as follows (tempin = RB.0) :
owreset tempin,temp1 owwrbyte tempin,skipnet owwrbyte tempin,rdreg owwrbyte tempin,$0E owrdbyte tempin, tCuVB1 owrdbyte tempin, tcuvb
the reset command returns a 2 so I've got a good connection to the ds2760. But I'm getting odd values returned. tcuvb1 is coming back as 0 while tcuvb is coming in as 152. I know that I need to shift right 3 to align correctly, but in just using a K type table it is putting the recorded temp in the 9 degree C range (shift 3 = 19, * 15.625 = 296 = just under 8 degrees).. In reading up on the pbasic versions of the one wire stuff, it says that the functions automatically generate a reset command. Do I need to make a call to reset more often? If I put a reset in there before the readbyte command I get tcuvb1 = 255.
now to confuse things worse, if I do a readreg on $18 for the chip temperature, I'm getting something around 22C which should be about right for my office. I dont know if it's because I'm screwing things up trying to read the word back or if it's because of resets or something else. The rest of the code is just plain straight template and I'm using watch in the debugger to see what values are returned.
any pointers?· tips?· I'm not looking for anybody to just write code for me but I sure would like it if someone could point me in the right direction
also if it makes any difference, what I'm doing is just watching the variables and then doing the shifts and stuff by hand to make sure that I'm getting the right values out before I proceed.
Post Edited (Dunnsept) : 5/24/2006 5:58:13 PM GMT
Comments
In theory that looks like it should work...
I don't think more resets will help, your not using parasitic power.
What value pull-up resistor do you have on the 1-wire pin ?
Try a slight delay before attempting to read the 1st byte (PAUSE 1) ?
Does the value in tcuvb change if you change the temperature of the thermocouple ?
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
COMING SOON "SD DATA LOGGER" www.sddatalogger.com
"I reject your reality, and substitute my own." Mythbusters
·
I pinched the end of the TC wire between thumb and fingers and then ran debug. the values I was getting in the two bytes did not change. and yet the reset returned a 2 indicating a good connection. I do remember seeing someplace where they had mapped out the 16bits returned and what each bit meant. There was one for open TC junction and so on, but neither can I find it nor remember if those are implemented in the parallax kit
one other thing I forgot to mention, these values were all whilst the stuff was sitting on my desk, so TC and chip temp should have been mighty close to the same, unless the chip was actually hotter because it was heating itself up. (this obviously doesn't hold true when I was holding the TC junction in my hand)
so, CJ temp = 22, cjv = 0.879
TCv = 0.297
so adjusted seebeck voltage would be 1.176 and from my K type NIST table, the TC temp would then be somewhere around 29.5 degrees. my office is warm, but not that warm
Post Edited (Dunnsept) : 5/24/2006 7:03:33 PM GMT
·· As for our implementation, it's basically right out of the datasheet for the DS2760, so any bits the chip should be sending should be there, as per the datasheet.· The circuit is almost verbatim from it.· I hope this helps you troubleshoot.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I am getting tcuvb1 = 0 and tcuvb = 19 (after the shift right).
The values do not change whether I am holding the TC junction or not. I always get the same result back.
Chris, I guess the question then is, is my code a reasonable SX/B version of the pbasic code from the included examples? I must have something wrong in there because I'm not getting good data back from it. I also tried a different board tonight. same results.
I looked at the docs for the chip and tried manually doing the reads from the addresses $0E and $0F since those are MSB and LSB for the value I want. but I get the same results.
I guess I'll get out my BS2 stuff and try there to verify what sorts of values are getting returned.
Where my original question also came from is that the pbasic descriptions of the functions say that they generate 1-wire resets as needed. so I wasnt sure where I needed to put them in to make sure that things work properly
thanks
paul...
edit... OK.. by Jove, I think I've got it. Bean had the direction right. I put pause 1 after each statement, and am now getting reasonable results. my hands showed around 32/33 and a hot towel came out around 39.
Post Edited (Dunnsept) : 5/24/2006 10:44:00 PM GMT
Hooray!!!
Just for my info, can you see what the smallest PAUSEUS delay is that seems to work ?
I guess the SX is just too fast for the poor chip to keep up.
BTW You really should put all the one-wire commands in subroutines to save code space. Then you can just add the delay to the subroutine and call the subroutines without any delay in the main code.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
COMING SOON "SD DATA LOGGER" www.sddatalogger.com
"I reject your reality, and substitute my own." Mythbusters
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
waaaaay beyond anything I can do right now, numbah wun son didn't want to go to bed tonight, (partly my fault as he's fascinated by my "lectronics")
I'll see if I can tackle this tomorrow.. (or later tonight when swmbo gets home)
bean: I've got the stuff in a sub called "check_temp" so I can just keep calling it from main in my loops.. but like I said, I've got to get past the byte var limitation first
here's my idea.. I need to have 10bits to get the temperature range I need. so I'm thinking that I'll use·3 tables, if bit 0 of the MSB is 0 then use table one for values from 0 up to 110 (or wherever that gets me) and then if bit 0 is 1 use table 2 which is the values from 110 degrees up to 200 or however high it goes then if bit 1 is set, use table 3... sound reasonable?· so something like this:
make sense?· better ways to do this?· I'm going to re-create the K type table and cut it way down. If my coffee roaster gets to 700C then something is seriously wrong and I just dont need that sort of accuracy with this project.. actually 5 degrees or so is plenty
I guess what I'm getting at is that I don't need the full range of the thermocouple.. I am only interested in a very narrow band.. from about 350F up to about 475F. I need to know if it is below 350 so I can turn the heater on, or if it's above 475 to shut heater off and sound alarm or something because not too much higher than that and the coffee will ignite.· once this gets moved to the beer brewing system the range becomes even more narrow.. even for a stepped mash, start around 140, ramp to 145, then to 155, hold, ramp to 170 and we're done.
Post Edited (Dunnsept) : 5/25/2006 3:25:16 PM GMT
Here is what I came up with. This is NOT a complete program, but just shows how I would do it. I don't have a DS2760 so this is untested.
It basically uses two lookup tables. One contains the uvolts per °C for the cold junction reading.
The other contains the °F for each TC voltage (15.625uV). This is backwards from how the BS2 code works.
Well, I hope it helps you anyway...
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
COMING SOON "SD DATA LOGGER" www.sddatalogger.com
"I reject your reality, and substitute my own." Mythbusters
I'm working on another version of the program.. just haven't posted it yet.. from what I figure, (close enough for gubmint work) each degree C = .04mV
each bit of the TC data is 15.625uV so 2.56bits of TC data = 1degree C.
I then take the CJ temp, and can just add up the bits from the TC. There would be some error induced because of this, but might be within reasonable limits.
working it all up right now too see how accurate it would be. if I use 3 instead of 2.56 looks like somewhere around 4% or 5% error. I'll have to play with some numbers to see if that's close enough.
Post Edited (Dunnsept) : 5/26/2006 6:49:34 PM GMT
note: YMMV, this works for me and is accurate enough. this is also obviously not complete code
·
TC_LSB is the lsb returned from the DS2760 after adjusting the 12 bit data. cj_temp is the MSB from checking the cold junction temp.
I put together a speadsheet of the calculations to compare to the real K type table and the values are really close. looks like maybe +- 0.5 or so
sometimes it's right on.
I know that thermocouples are not linear but for the ranges I want this is really close and sure beats having to deal with all those table lookups ;-)
BTW: the heat sink on my regulator on the SX tech board is 113F whilst my office is 71F· isn't it wonderful the things you can discover with thermocouples?