Shop OBEX P1 Docs P2 Docs Learn Events
Question about DS18B20 and also KingBright 2 digit 7-segment LED — Parallax Forums

Question about DS18B20 and also KingBright 2 digit 7-segment LED

ludlowludlow Posts: 4
edited 2006-09-14 23:10 in BASIC Stamp
I'm pretty new to this so if I'm posting in the wrong forum, I apologize. I have two questions I was hoping someone could help me with.

Firstly, I'm working on a little project for monitoring temperatures (various locations within a room). I've seen a few of these out there - but I'm wanting to make my own as an entry project into micro-electronics. tongue.gif

Question 1:

I've got a BS2px24 attached to my Board of Education and right now am simply trying to read a DS18B20 (temp chip).

I've simply copied and pasted the Parallax example program used for OWIN and OWOUT into my dev. environment. (obviously making sure the pins match how I have the Board of Education setup).

When I run the program all I seem to get is 255 for everything - or $FF is you prefer.

The example program says it's meant to work with the DS1820, but can anyone see a reason it wouldn't work with the DS18B20. From reading through both datasheets - it seems they have the same ROM functions.

Question 2:

I'll be using a 2-digit 7-segment LED display from KingBright (it's blue smurf.gif)

I've been able to successfully configure a single digit 7-segment (control it from a PBASIC program, etc) but can someone point me to a document that explains how to wire a 2, or 3 digit display on the BOE?

My problem comes from trying to figure out where to get the additional pins on the BOE.

In a more general sense, what do you do when you need to control more than 16 pins? Surely peoples projects have to exceed the board's limit now and again? Again - I'm sure it's trivial - just a fundamental point I don't understand yet.

Thanks Much!

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-09-13 19:49
    Hello,

    ·· On the 1-Wire device, please attach (not paste) the code you are running for verification.· As for expanding digits or even I/O, there are many ways to do this.· For the digits you could use a 7-Segment driver chip such as the MAX7219 or the MC14489.· Each of these is controlled by 3 I/O pins and can control 8 displays or 5 displays, respectively.· When expanding I/O, this can be done using shift registers.· There are examples of all these things in our Stamp Works manual, which can be downloaded free as a PDF file from the bottom of the following page.· I hope this helps.· Take care.

    http://www.parallax.com/detail.asp?product_id=27220

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • ludlowludlow Posts: 4
    edited 2006-09-13 21:43
    Thanks for the info about the 7-digit LED display. I'll read about the driver chip and how to use shift registers.

    I've attached the code I'm currently using to try and communicate with the DS18B20 as Project_002.bpx
  • ludlowludlow Posts: 4
    edited 2006-09-13 21:48
    I attached that file on the previous post - but to anyone who doesn't want to open the external file:

    ' {$STAMP BS2px}
    ' {$PBASIC 2.5}
    
    
    DQ              PIN     2               ' 1-Wire buss pin
    
    RdROM           CON     $33             ' read serial number
    MatchROM        CON     $55             ' match SN -- for multiple devices
    SkipROM         CON     $CC             ' ignore SN -- use for one device
    CvrtTmp         CON     $44             ' start temperature conversion
    RdSP            CON     $BE             ' read DS1822 scratchpad
    
    tempIn          VAR     Word            ' raw temperature
    sign            VAR     tempIn.BIT11    ' 1 = negative temperature
    tLo             VAR     tempIn.BYTE0
    tHi             VAR     tempIn.BYTE1
    tSign           VAR     Bit             ' saved sign bit
    tempC           VAR     Word            ' final Celsius temp
    tempF           VAR     Word            ' final Fahrenheit temp
    ID              VAR     Byte(8)
    
    
    PAUSE 500
    
    'Try to send reset and presence pulse
    OWOUT DQ, 1, [noparse][[/noparse]$33]
    OWIN DQ, 0, [noparse][[/noparse]STR ID\8]
    DEBUG "Family Code: ", HEX2 ID(0), "h", CR
    DEBUG "Ser# ", HEX2 ID(1), HEX2 ID(2), HEX2 ID(3), HEX2 ID(4), HEX2 ID(5), HEX2 ID(6), "h", CR
    DEBUG "CRC Value: ", HEX2 ID(7), "h", CR
    PAUSE 5000
    
    Main:
      DO
        GOSUB Get_Temperature               ' read temperature from DS1822
        DEBUG HOME,                         ' display
              "DS1822", CR,
              "------", CR,
              SDEC tempC, " C ", CR,
              SDEC tempF, " F ", CR, CR,
              "tLo: ", IBIN tLo, CR,
              "tHi: ", DEC tHi, CR,
              "tSign: ", SDEC tSign, CR,
              "tempIn: ", SDEC tempIn, CR
    
        PAUSE 1000
      LOOP
    
      END
    
    Get_Temperature:
      OWOUT DQ, 1, [noparse][[/noparse]SkipROM, CvrtTmp]       ' send convert temperatrue command
      DO                                    ' wait on conversion
        PAUSE 25                            ' small loop pad
        OWIN DQ, 4, [noparse][[/noparse]tempIn]                ' check status (bit transfer)
        DEBUG SDEC tempIn, CR
      LOOP UNTIL (tempIn)                   ' 1 when complete
      OWOUT DQ, 1, [noparse][[/noparse]SkipROM, RdSP]          ' read DS1822 scratchpad
      OWIN  DQ, 2, [noparse][[/noparse]tLo, tHi]               ' get raw temp data
      tSign = sign                          ' save sign bit
      tempC = tempIn >> 4                   ' round to whole degrees
      tempC.BYTE1 = $FF * tSign             ' correct 2's compliment bits
      tempF = (ABS tempC) * 9 / 5           ' start F conversion
      IF (tSign) THEN                       ' finish F conversion
        tempF = 32 - tempF                  ' C was negative
      ELSE
        tempF = tempF + 32                  ' C was positive
      ENDIF
      RETURN
    
    




    Additionally, here is the output I am getting

    Family Code: FFh
    Ser# FFFFFFFFFFFFh
    CRC Value: FFh
    
    (debugger resets to Home position here)
    
    DS1822
    ------
    -1 C 
    31 F
    
    tLo: %11111111
    tHi: 255
    tSign: 1
    tempIn: -1
    
    
  • ludlowludlow Posts: 4
    edited 2006-09-14 23:10
    ...could anything be determined from that code sample?
Sign In or Register to comment.