Shop OBEX P1 Docs P2 Docs Learn Events
Ds2436 — Parallax Forums

Ds2436

adaleadale Posts: 6
edited 2013-10-13 08:50 in BASIC Stamp
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

Comments

  • bobhillierbobhillier Posts: 27
    edited 2004-08-17 19:57
    I am a beginner with 1-wire technology myself. I have programmed a number of 1-wire circuits on my BS2p PRO board and been successful with temperature, memory and RTC. I have not been successful with a wired connection via the RJ-11 connector due to signal integrity on my wires. I am investigating solutions and will post my results.
    ·
    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
  • adaleadale Posts: 6
    edited 2004-08-18 15:23
    I have read all the above lit also.· My problem is I can't understand the register info.· I come from an old assembler language programming background and I am thinking I have a mental block about it.· I will try again!
  • bobhillierbobhillier Posts: 27
    edited 2004-08-18 19:29
    The DS2436 registers are in mulitple pages of 32 bytes per page.
    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
  • adaleadale Posts: 6
    edited 2004-08-18 20:04
    You're a saint!· I will try your code and see what happens!

    Albie Dale
  • adaleadale Posts: 6
    edited 2004-08-19 12:18
    I tried your code last night without much success.· Here is the code I am using :

    ·· 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
  • bobhillierbobhillier Posts: 27
    edited 2004-08-19 13:22
    I'll look at this tonight at home.
    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 WilliamsJon Williams Posts: 6,491
    edited 2004-08-19 13:32
    I had a quick look at the DS2436 data sheet a few days ago and it appears to me that you have to pull an entire scratchpad out of the device in order to get to a single register. Have any of you that have the DS2436 tried this? (I don't have one) Suggestion: Use SPSTR with I2CIN to move the DS2436's scratchpad into the BASIC Stamp's scratchpad -- then pull your register(s) from there with GET.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • bobhillierbobhillier Posts: 27
    edited 2004-08-20 00:41
    I have written some code I believe will work for the DS2436. I don't have one of these devices so let me·what happens.·(I've attached the full file that you should be able to run. It runs with dummy data.) This code is based on the demo program in the BASIC Stamp 2p24 Professional Starter Kit (.pdf)

    '······ 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
  • adaleadale Posts: 6
    edited 2004-09-07 12:38
    Well, I finally got the time to play with the DS2436 and Bob's code he posted worked flawlessly.· You just need to add

    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
  • bhaddajibhaddaji Posts: 1
    edited 2004-10-04 02:47
    I have a 1-wire hardware using DS275 ic, can it be used to program a DS2434 device? What you sent software to me and try out? Can anybody help as I encountered a Low Battery display on my equipment after replacing the new Battery pack. my email address bhaddaji@tm.net.my. Truly appreciate it and Best regards.
  • Mr.EdMr.Ed Posts: 35
    edited 2006-01-30 10:33
    Hi there,

    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·burger.gif·, i will try to make my own. But i sure could use a nudge (or two) in the right direction! smilewinkgrin.gif

    How did the DS2436 project end up? rolleyes.gif· 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
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-01-30 11:29
    Ed -

    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
  • Mr.EdMr.Ed Posts: 35
    edited 2006-01-30 11:42
    Thanks Bruce!

    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!· smilewinkgrin.gif

    Thanks,

    Ed.·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    A horse is a horse, of course of course...
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-01-30 12:38
    Ed -

    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
  • stereysterey Posts: 3
    edited 2013-10-13 07:36
    Hello everyone I am new member,I'm looking for a schematic to read and write a battery chips DS2434. Has anyone found it? If anyone can please let me have a scheme by @ mail. Thanks and best regards stefano sterey@libero.it
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-10-13 07:41
    7 years, 8 months, and 13 days
  • ercoerco Posts: 20,257
    edited 2013-10-13 07:51
    Minutes, please, Peej?

    :)
  • stereysterey Posts: 3
    edited 2013-10-13 07:54
    six hours and 58 minutes...
  • Mike GreenMike Green Posts: 23,101
    edited 2013-10-13 08:09
    The DS2436 is very similar to the DS2424 and much of the discussion earlier in this thread applies to both chips. The DS2424 datasheet has the details including a schematic showing how to connect the DS2424 to a microcontroller like the Stamps.
  • stereysterey Posts: 3
    edited 2013-10-13 08:50
    Many thanks Mike!
    Mike Green wrote: »
    The DS2436 is very similar to the DS2424 and much of the discussion earlier in this thread applies to both chips. The DS2424 datasheet has the details including a schematic showing how to connect the DS2424 to a microcontroller like the Stamps.
Sign In or Register to comment.