Ds2436
adale
Posts: 6
I have a DS2436 1-wire chip that I am trying to read the counter register ($80) with a BS2p.· The chip is hooked up to a battery and I need to see if the battery back is not charging because of the counter being maxed out or if it is something else. I can look at the SN ($33) and read some of the registers but I really have no idea what I am looking at since Dallas Semi/Maxium makes it so hard to do this.· Any ideas or suggestions would be greatly appreciated.
adale
adale
Comments
·
To work with your DS2436...
·
Read the spec at http://pdfserv.maxim-ic.com/en/ds/DS2436.pdf
They have some excellent byte sequences to accomplish your task. They also have other docs that could prove useful. See http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2917.
Try the example 1-wire experiments in the BS2p board docs and other Parallax docs. Those examples are excellent to get you going.
·
If you're working with wires more than 12-18 inches long then you may see some transmission line effects impacting your communications (or so my current level of research suggests). There are solutions that apparently work but I have not completed my investigations.
·
Bob, Ottawa
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
······ Bob, Ottawa
W75 54 17·· N45 18 30
·········· G16 #27
Page 4 registers contain the conversion and status control for temp and voltage. From the pdf spec guide the following memory locations are of interest.
Memory pg 4
Byte·addr·purpose
· 0····$60 ·Temp LSB (decimal degrees C)
··1····$61 ·Temp MSB (integer degrees C)
··2··· $62 ·status (bit0 shows·T conversion status, Bit 3 shows V status)
··3··· $63 ·status
··23·· $77 ·Voltage LSB
··24·· $78 ·Voltage MSB
Variables you will need in your pbasic code are:
Temp·VAR·WORD·' Hi byte is interger temp
Volt·VAR·WORD·' 10mV/bit
Status·VAR·WORD·' bit0 Tconvert, bit3 Vconvert
I believe the correct command sequenece in your pbasic code should be:
Action············ Tx············· Rx·········· Comment
******········· *******···· *******··******·********************
SkipROM········· $CC························· ·if you have more than one 1-wire device then
··················································· · you need to use MatchROM with 8 byte ID
ConvertVolt·····$B4
Wait for done·· $B2 $62········ <word>····loop until Bit3=0 (about 10 msec)
GetV·············· $B2 $77 $78·· <word>··· store in Volt
ConvertTemp·· $D2
Wait for done·· $B2 $62········· ·<word>·· loop until Bit0=0 (about 10 msec)
GetV·············· $B2 $60 $61····· <word>· store in Temp
You need to use the OWOUT and OWIN command sequence to send and receive these bytes.
You could look at the example 1-wire code Parallax provides for the DS1822. All of that code (except the actual DS1822 GetTemp sequence) could be used for this example. See http://www.parallax.com/dl/docs/prod/stamps/bs2p24starterkit.pdf
Does this help? (please identify any errors I may have made)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
······ Bob, Ottawa
W75 54 17·· N45 18 30
·········· G16 #27
Albie Dale
·· romData· VAR Byte(8)·· 'data from chip
···· idx····· VAR Byte····· 'counter for sn:
···· regData· VAR Byte(2)·· 'data from register
···· ridx···· VAR Byte····· 'counter for register data
· Main
····· DEBUG· "sn :"
····· OWOUT 0,2,[noparse][[/noparse]$33]··················· 'send read·SN
····· OWIN 0,2,[noparse][[/noparse]STR romData\8]······· 'read SN
······· FOR idx = 0 TO 7
····· DEBUG HEX2 romData(idx)," "····· ' show ID, serial num, CRC
····· NEXT
······DEBUG CR································'move down·a line on debug
····· DEBUG "register data : "············
····· OWOUT 0,2,[noparse][[/noparse]$B2,$80]·············· 'send read register and starting point
····· OWIN 0,2,[noparse][[/noparse]STR regData\2]
······· FOR ridx = 0 TO 2
····· DEBUG HEX2 regData(ridx)," "····· 'show register data,·two bytes
····· NEXT
·STOP
I get the SN fine and I see register data but the read seems to start at the same point $00, first register, and never will start at $80.· I have also tried to look at the other points such as the temp, volts, etc. with the same results.· Any ideas
Any ideas
Jon Willimas mentioned a couple weeks ago that programming these 1-wire devices is very complicated. These things work but take time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
······ Bob, Ottawa
W75 54 17·· N45 18 30
·········· G16 #27
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
'······ Sample DS2436 DATA
'······ Voltage: 4.8v (01 E3)
'······ Temperature: 25°C (19 10)
'······ counter = 942
SkipROM········· CON $CC··· '·skip rom (one device)
OW_FERst······ CON %0001 ' Front-End Reset
OW_BERst······ CON %0010 ' Back-End Reset
ConvertV······· CON $B4····· ' convert the voltage
ConvertT······· CON $D2···· ·' convert the temperature
ReadRegister·· CON $B2····· ' read page 4 and page 5 of DS2436
voltage· VAR·· Word
vLo······ VAR·· voltage.BYTE0
vHi······· VAR·· voltage.BYTE1
temp···· VAR·· Word
tLo······· VAR·· temp.BYTE0
tHi········ VAR·· temp.BYTE1
Get_Volt:
· OWOUT OWpin,OW_FERst,[noparse][[/noparse]SkipROM,ConvertV]· ' send voltage conversion command
· PAUSE 15 ' give it some time (could wait until bit3 at $62 equals 0)
· OWOUT OWpin,OW_FERst,[noparse][[/noparse]SkipROM,ReadRegister, $77] ' lo byte voltage
· OWIN· OWpin,OW_BERst,[noparse][[/noparse]vLo]
· OWOUT OWpin,OW_FERst,[noparse][[/noparse]SkipROM,ReadRegister, $78] ' hi byte voltage
· OWIN· OWpin,OW_BERst,[noparse][[/noparse]vHi]
· RETURN
Get_Temp:
· OWOUT OWpin,OW_FERst,[noparse][[/noparse]SkipROM,ConvertT]· ' send voltage conversion command
· PAUSE 15 ' give it some time (could wait until bit1 at $62 equals 0)
· OWOUT OWpin,OW_FERst,[noparse][[/noparse]SkipROM,ReadRegister, $60] ' lo byte temp
· OWIN· OWpin,OW_BERst,[noparse][[/noparse]tLo]
· OWOUT OWpin,OW_FERst,[noparse][[/noparse]SkipROM,ReadRegister, $61] ' hi byte temp
· OWIN· OWpin,OW_BERst,[noparse][[/noparse]tHi]
· RETURN
Let me know what values you receive in vLo, VHi, tLo and tHi.
This DS2436 has 5 pages of memory. Pages 4 and 5 are the status and control registers and are accessed using the ReadRegister command. Pages 1, 2 and 3 are scratchpad and are accessed using ReadScratchpad command.
The spec says the ReadRegister command is followed by a byte address and then data. The spec does not say a register range can be provided (i.e. $60 $61) so I have written separate ReadRegister requests, one per register byte.
If you have more then one 1-wire device on the bus then you will need to use the matchRom command instead of the skipRom command.
The spec says that a RESET is sent to initiate a sequnece so I have used the 1-wire front-end reset command on the read commands. I used the back-end reset command on the actual OWIN command to prepare the bus for the next instruction (after reading the values). This works with other 1-wire devices so should work with this device.
The actual BS2p demo program has more code that plays with the formatting of the temp value. I skipped all that to keep this as simple as possible.
If there are coding errors then please let me know.·
This 1-wire technology is pretty cool and it has it's niche in the application world but it is sure tricky to get working.
Share your results.... Bob
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
······ Bob, Ottawa
W75 54 17·· N45 18 30
·········· G16 #27
the OWpin con.· I am now going to add the necessary code to allow a module to be built to read this info as necessary.
Also found the voltage and temperature info very helpful.· This is my first experience with the Stamp and now I know
why it has such a following.· I will post the finally code after I have built and tested it.· Thanks again!
ADale
I am VERY interested in this subject. I am a big fan of 1-wire devices, although it seems, not everybody likes them as much as i do. My interest started with using a DS1820 connected to a Linux machine running Digitemp (by Brian Lane). After that i·built my own 1-wire weatherstation, but Digitemp does not support all the devices that i want to use. Compiling my own (XP/Linux)software was out of the question, so i went on looking for a substitute. This way i got to the Basic Stamps and saw a few weather related articles made by Jon Williams. I saw that the Basic Stamp was capable of·much more then just 1-wire stuff, so i was hooked immediately. But sometimes programming remains quite a challange for me and i'm in need of every example of sourcecode i can get. I would like to use the following 1-wire devices (a few are covered by Jon Williams in N&V):
DS1820, DS2423, DS2450, DS2406, DS2438 (closely related to DS2436?).
I should be able to put something together with what Jon provided. Only the last two mentioned devices are a bit tough to handle. The DS2438 has a HIH3610 humidity sensor and a light sensitive diode connected to it (shown at www.maxim-ic.com). I have seen allmost all articles on the Parallax website, but maybe there are more sources for example codes. I'm not asking for complete ready to swollow code··, i will try to make my own. But i sure could use a nudge (or two) in the right direction!
How did the DS2436 project end up? · It seems closely related to my DS2438, so above code might work on the 38 too...
Best regards,
Ed.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
A horse is a horse, of course of course...
Post Edited (Mr.Ed) : 1/30/2006 12:48:30 PM GMT
Here is one place that you might want to look at, Dallas Weather Instruments:
http://www.txwx.com/
Here is another Linux + One Wire weather station reference:
http://oww.sourceforge.net/
Regards,
Bruce Bates
The first link is new to me, the second one is not.
The 32 bit One-Six server looks promising, although i prefer to stick·with the BS2P24 aproach.
I welcome·EVERY single·suggestion (allready familiar to me or not), so yours·are much appreciated!·
Thanks,
Ed.·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
A horse is a horse, of course of course...
I'm going to start a companion thread to this one, mostly to give it a more descriptive topic heading in case others in the future would like the various Maxim/Dallas, 1-wire or iButton Weather Station, of Parallax links. I suspect you may have visited most of them, but it might be handy to have the links in one place for reference. Please DO add a note to this forthcoming thread which includes the (always) EXCELLENT Nuts and Volts article by Jon Williams, as it is a very important reference to this topic.
This is a placeholder for a link to the other thread, if some Forum Modirator would be kind enough to supply it. Links to threads like soldering, are NOT an art I've mastered, and I'm not afraid to admit it <sigh>. The other Forum thread can be found here:
[noparse][[/noparse] please insert thread link here ]
I will mention now, as well as in the new thread, the original One Wire Weather Station was a develpment project by Maxim/Dallas, early on in the life of the 1-Wire series of devices. As I remember, the whole package was originally available from Maxim/Dallas when it first appeared, but the responsibility for it soon was assumed by an outside vendor due to its IMMENSE popularity.
Regards,
Bruce Bates