I'm In Need of a Bit of Help With The DS18B20
Hi Gang,
I'm in need of some help with DS1820's
I'm specifically using the DS18B20 so I can take advantage of the programmable resolution capability.
Using 9 bit resolution, the conversion time is under 100ms, which allows for monitoring a number of sensors with frequent display updating.
My problem is that I don't seem to be able to get the "Write Scratchpad" instruction to work.
I've searched and can't find any sample code that uses it, so I'm clueless on syntax.
From the data sheet, I have to write 3 bytes to the scratchpad, the high alarm, low alarm, and config.......· which is the register where the resoultion bits go.
I'd be most gratefull if someone can get me pointed inthe right direction here.
Thanks in advance,
Darlene
I'm in need of some help with DS1820's
I'm specifically using the DS18B20 so I can take advantage of the programmable resolution capability.
Using 9 bit resolution, the conversion time is under 100ms, which allows for monitoring a number of sensors with frequent display updating.
My problem is that I don't seem to be able to get the "Write Scratchpad" instruction to work.
I've searched and can't find any sample code that uses it, so I'm clueless on syntax.
From the data sheet, I have to write 3 bytes to the scratchpad, the high alarm, low alarm, and config.......· which is the register where the resoultion bits go.
I'd be most gratefull if someone can get me pointed inthe right direction here.
Thanks in advance,
Darlene
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
The BASIC Stamp 2 modules that support the 1-wire protocol is the BS2p family of controllers: BS2pe, BS2p24/40 and the BS2px. Do you have one of these controllers? The version should say right on the BASIC Stamp as to which controller it is; or what color is it? We can commonly determine which controller you have by the color.
Regarding the Scratchpad RAM;·it is·accessed by the PUT and GET commands. For example PUT 1, variablename. That is putting the BYTE size value of variablename in location 1 of the scratchpad ram location. But again, not all BASIC Stamp modules support this function; it would·be a BS2e or later controller.
So really the first question is what hardware specifically do you have?·Can you provide either part numbers or·something descriptive?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
I'm using·ten DS18B20's to monitor temps with an eleventh DS18B20 being monitored as a reference.
I'm using a BS2p stamp.
The ten temps are being displayed on a 4X20 lcd in 2 digits with no spaces between. Temps will always be within the·0 to 99 degree range.
I'll be monitoring the heat front in a reaction chamber as it moves from starting end to finished end. The ref sensor is just ahead of the reaction chamber.
When temps are within a minimal tolerance of reference for each sensor, they display on row 4.
As temps increase thru greater tolerance offsets, they display on row 3, and then on row 2, and finally row 1.
It gives a·reasonable approximation of·vetical bar graphs on a·graphic lcd.
The program and display is all working fine.
It's·that the conversion time for each conversion is lots longer at the default 12 bit resolution than it would be for 9 bit res.
That's where the Write Scratchpad [noparse][[/noparse]4E] function command comes in.
It seems it must be part of a OWOUT command, but so far in my short test program to get that command working, I'm so far unsuccessful.
All help is greatly appeciated,
Darlene
UPDATE:·
Wooooo· Hoooooo .....·· I've solved the problem.
This is the line of code that I needed to get exactly right:··· (Thi, Tlow, Config, ·are defined as constants)
OWOUT DS1820pin,3,[noparse][[/noparse]MatchROM,STR romData\8,WriteScratch,Thi,Tlow,Config]
And I added these lines to see what was happening while experimenting untill it worked properly:···· (tInLow, tInHigh, ThiIn, TlowIn, ConfigIn, are byte variables)
OWOUT DS1820pin,1,[noparse][[/noparse]MatchROM,STR romData\8,ReadScratch]
OWIN DS1820pin,2,[noparse][[/noparse]tInLow,tInHigh,ThiIn,TlowIn,ConfigIn]
DEBUG BIN8 TlowIn, "· ", BIN8 ThiIn, "· ", BIN8 ConfigIn, CR,CR
Like an idiot, it didn't dawn on me to BIN8 (as opposed to BIN)·the values on the debug screen untill I'd spent hours in frustration, so leading 0's didn't show,·so I kept thinking it wasn't right, even·when it might have been.
Everything seems to be running fine now at 100ms per conversion.
Post Edited (Geekgirl) : 11/12/2009 6:20:59 AM GMT
It's where the temp conversion·in read from, but also where the hi/lo temp alarms and the config register (which programs the conversion resolution) are written to.
Sorry if I wasn't clear,
Darlene