Shop OBEX P1 Docs P2 Docs Learn Events
ADC08831 Help needed — Parallax Forums

ADC08831 Help needed

ArchiverArchiver Posts: 46,084
edited 2002-01-08 22:49 in General Discussion
If anyone can help with sample programs using the ADC08831 Analog-to-
Digital IC, I would greatly appreciate it. I'm trying to get a
reading from an LM35DT teperature sensor (10mV/degree C) and I'm
having a little difficulty. When I do shiftin AD,CLK,MSBPOST,
[noparse][[/noparse]theData] I seem to lose the last bit while adding an extra 0 bit at
the beginning so I am doing shiftin AD,CLK,MSBPOST,[noparse][[/noparse]theData\9]. I'm
not exactly sure what I am doing wrong (if anything) so any help
would be GREATLY appreciated!

-special [noparse][[/noparse]k]

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-01-08 03:50
    Can you post a sample of the code?

    Original Message
    From: special_4k4 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=2r0ZQ--MCTLWv6X-T6pwf41S85HgpCwPtAQ9ioHubSTaAnVoY5_Bsi012ipqFvm4wyaQhZm-6ye_npQ]special_4k4@y...[/url
    Sent: Monday, January 07, 2002 10:48 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] ADC08831 Help needed

    If anyone can help with sample programs using the ADC08831 Analog-to-
    Digital IC, I would greatly appreciate it. I'm trying to get a
    reading from an LM35DT teperature sensor (10mV/degree C) and I'm
    having a little difficulty. When I do shiftin AD,CLK,MSBPOST,
    [noparse][[/noparse]theData] I seem to lose the last bit while adding an extra 0 bit at
    the beginning so I am doing shiftin AD,CLK,MSBPOST,[noparse][[/noparse]theData\9]. I'm
    not exactly sure what I am doing wrong (if anything) so any help
    would be GREATLY appreciated!

    -special [noparse][[/noparse]k]


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2002-01-08 03:56
    This is what I am doing now to measure the temperature (in C):

    'LM35DT:
    'Pin 1->5V
    'Pin 2->GND
    'Pin 3->Pin 2 on ADC08831
    '
    'ADC08831:
    ' Pin 0 1--U--8 5V
    'Pin 3 of LM35DT 2 7 Pin 2
    ' GND 3 6 Pin 1
    ' GND 4
    5 Ref. Voltage (2.55V using
    potentiometer)

    CS con 0
    CLK con 2
    AD con 1
    theData var Byte
    halfDegree var Byte

    DIRA=%0101
    convert:
    pause 1000
    low CS ' Select ADC
    theData = 0 ' Clear data
    shiftin AD,CLK,MSBPOST,[noparse][[/noparse]theData\9] ' Get data
    high CS ' Deselect ADC
    halfDegree=theData.bit0
    debug bin8 theData, " | "
    theData=theData>>1
    debug dec theData
    if halfDegree=1 then pointFive
    debug ".0° C",cr
    goto convert

    pointFive:
    debug ".5° C",cr
    goto convert

    --- In basicstamps@y..., "Dennie Bishop" <dbishop@e...> wrote:
    > Can you post a sample of the code?
    >
    >
    Original Message
    > From: special_4k4 [noparse][[/noparse]mailto:special_4k4@y...]
    > Sent: Monday, January 07, 2002 10:48 PM
    > To: basicstamps@y...
    > Subject: [noparse][[/noparse]basicstamps] ADC08831 Help needed
    >
    > If anyone can help with sample programs using the ADC08831 Analog-
    to-
    > Digital IC, I would greatly appreciate it. I'm trying to get a
    > reading from an LM35DT teperature sensor (10mV/degree C) and I'm
    > having a little difficulty. When I do shiftin AD,CLK,MSBPOST,
    > [noparse][[/noparse]theData] I seem to lose the last bit while adding an extra 0 bit at
    > the beginning so I am doing shiftin AD,CLK,MSBPOST,[noparse][[/noparse]theData\9]. I'm
    > not exactly sure what I am doing wrong (if anything) so any help
    > would be GREATLY appreciated!
    >
    > -special [noparse][[/noparse]k]
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@y...
    > from the same email address that you subscribed. Text in the
    Subject and
    > Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2002-01-08 07:19
    The ADC0831 does require that you shift in 9 bits, because the first
    bit out is a "dummy" bit. With a 2.55 volt reference, the
    resolution should be 1 degree C. (2.56 volt/256 = 0.10 volt) I
    think that if you want 0.5 degree resolution, you need a 1.28 volt
    reference.

    If you do use a 1.28 volt reference, then the formula to display with
    0.5 degree resolution can be simplified, using the data just as it
    comes from the shiftin command:
    theData = theData*5 ' each bit represents 0.5 degree
    debug dec theData/10,".",dec1 theData,cr

    -- regards,
    Tracy Allen
    electronically monitored ecosystems
    mailto:tracy@e...
    http://www.emesystems.com


    >When I do shiftin AD,CLK,MSBPOST,
    > > [noparse][[/noparse]theData] I seem to lose the last bit while adding an extra 0 bit at
    > > the beginning so I am doing shiftin AD,CLK,MSBPOST,[noparse][[/noparse]theData\9]. I'm
    > > not exactly sure what I am doing wrong (if anything)
    >....
    >This is what I am doing now to measure the temperature (in C):
    >
    >
    >'LM35DT:
    >'Pin 1->5V
    >'Pin 2->GND
    >'Pin 3->Pin 2 on ADC08831
    >'
    >'ADC08831:
    >' Pin 0 1--U--8 5V
    >'Pin 3 of LM35DT 2 7 Pin 2
    >' GND 3 6 Pin 1
    >' GND 4
    5 Ref. Voltage (2.55V using
    >potentiometer)
    >
    >CS con 0
    >CLK con 2
    >AD con 1
    >theData var Byte
    >halfDegree var Byte
    >
    >DIRA=%0101
    >convert:
    > pause 1000
    > low CS ' Select ADC
    > theData = 0 ' Clear data
    > shiftin AD,CLK,MSBPOST,[noparse][[/noparse]theData\9] ' Get data
    > high CS ' Deselect ADC
    > halfDegree=theData.bit0
    > debug bin8 theData, " | "
    > theData=theData>>1
    > debug dec theData
    > if halfDegree=1 then pointFive
    > debug ".0° C",cr
    >goto convert
    >
    >pointFive:
    > debug ".5° C",cr
    >goto convert
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-01-08 14:05
    The problem that I'm facing, however, is that I get the correct
    temperature only by shifting the data >>1. It seems like the last
    bit is representing half a degree... I get the correct temperature
    when I capture only the first 8 bits, but it maxes out at 127 (When I
    connect the V+ on the ADC to the ref voltage, which SHOULD give me
    255). When I connect the V+ on the ADC to the ref voltage and
    capture 9 bits (dropping the first), I get all 255 bits of
    resolution. I'm confused.

    -special [noparse][[/noparse]k]

    --- In basicstamps@y..., Tracy Allen <tracy@e...> wrote:
    > The ADC0831 does require that you shift in 9 bits, because the
    first
    > bit out is a "dummy" bit. With a 2.55 volt reference, the
    > resolution should be 1 degree C. (2.56 volt/256 = 0.10 volt) I
    > think that if you want 0.5 degree resolution, you need a 1.28 volt
    > reference.
    >
    > If you do use a 1.28 volt reference, then the formula to display
    with
    > 0.5 degree resolution can be simplified, using the data just as it
    > comes from the shiftin command:
    > theData = theData*5 ' each bit represents 0.5 degree
    > debug dec theData/10,".",dec1 theData,cr
    >
    > -- regards,
    > Tracy Allen
    > electronically monitored ecosystems
    > mailto:tracy@e...
    > http://www.emesystems.com
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-01-08 22:49
    Turns out that I WAS using a 1.28V reference voltage (stupid me) and
    that's what my problem was. I checked with my voltmeter today and
    saw the voltage was so low with the potentiometer, so I fixed that
    and it fixed my readings! Thanks for all the help [noparse]:)[/noparse]

    -special [noparse][[/noparse]k]

    --- In basicstamps@y..., Tracy Allen <tracy@e...> wrote:
    > The ADC0831 does require that you shift in 9 bits, because the
    first
    > bit out is a "dummy" bit. With a 2.55 volt reference, the
    > resolution should be 1 degree C. (2.56 volt/256 = 0.10 volt) I
    > think that if you want 0.5 degree resolution, you need a 1.28 volt
    > reference.
    >
    > If you do use a 1.28 volt reference, then the formula to display
    with
    > 0.5 degree resolution can be simplified, using the data just as it
    > comes from the shiftin command:
    > theData = theData*5 ' each bit represents 0.5 degree
    > debug dec theData/10,".",dec1 theData,cr
    >
    > -- regards,
    > Tracy Allen
    > electronically monitored ecosystems
    > mailto:tracy@e...
    > http://www.emesystems.com
    >
    >
Sign In or Register to comment.