Shop OBEX P1 Docs P2 Docs Learn Events
ADC0831 vs. ADC0834 redux — Parallax Forums

ADC0831 vs. ADC0834 redux

ArchiverArchiver Posts: 46,084
edited 2003-08-01 23:31 in General Discussion
I didn't see any response to my inquiry.

Is this a tough question or is this just not very interesting to
others?

Still would like to know.

Thanks,
Lawrence





--- In basicstamps@yahoogroups.com, "altengnw2000"
<altengnw2000@y...> wrote:
>
> These are the same chip except the ADC0834 has the ability to read
> four separate inputs.
>
> In the StampWorks manual experiment #27, it shows how to connect an
> ADC0831 and gives a sample program. I have performed this
experiment
> successfully.
>
> My question is about the ADC0834. It has two new pins: Data In
(DI)
> and SARS Status (SARS) How are these two pins connected to the
Basic
> Stamp?
>
> How would the ADC0831 program example have to be modified to
> operate this two pins.
>
> Thanks in advance for any help,
> Lawrence

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-06-29 16:12
    The ADC0831 uses the SPI clock to run a
    successive approximation A to D conversion
    in real time. Since it only does one
    channel, it is very straightforward to
    interface -- ie you only need to run a
    'SHIFTIN' command to get the data.

    The ADC0834 needs to have you send some
    data to it, to select the channel to
    be converted. I havn't done this,
    since the 0831 is so simple to interface,
    I havn't had to go to the multi-channel
    beast.

    Perhaps, nobody has had to go to the
    multi-channel beast, which is why you
    aren't getting any more answers.

    --- In basicstamps@yahoogroups.com, "altengnw2000"
    <altengnw2000@y...> wrote:
    > I didn't see any response to my inquiry.
    >
    > Is this a tough question or is this just not very interesting to
    > others?
    >
    > Still would like to know.
    >
    > Thanks,
    > Lawrence
    >
    >
    >
    >
    >
    > --- In basicstamps@yahoogroups.com, "altengnw2000"
    > <altengnw2000@y...> wrote:
    > >
    > > These are the same chip except the ADC0834 has the ability to
    read
    > > four separate inputs.
    > >
    > > In the StampWorks manual experiment #27, it shows how to connect
    an
    > > ADC0831 and gives a sample program. I have performed this
    > experiment
    > > successfully.
    > >
    > > My question is about the ADC0834. It has two new pins: Data In
    > (DI)
    > > and SARS Status (SARS) How are these two pins connected to the
    > Basic
    > > Stamp?
    > >
    > > How would the ADC0831 program example have to be modified to
    > > operate this two pins.
    > >
    > > Thanks in advance for any help,
    > > Lawrence
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-29 18:13
    The 0834 just uses a normal SPI interface. You have to tell it which channel
    to convert which is why it has a data in pin.

    SARS is the Successive Approximation Ready Signal - you can hook this to
    another stamp pin and check its status - if its high the conversion is in
    progress, if its low, its ready to read.

    You can either watch this pin and read the value when it goes low or, just
    wait a few milliseconds and then read (save a pin). It only takes 8 clock
    cycles for a conversion which is pretty darned quick in stamp terms.

    Original Message
    From: "Allan Lane" <allan.lane@h...>
    To: <basicstamps@yahoogroups.com>
    Sent: Sunday, June 29, 2003 8:12 AM
    Subject: [noparse][[/noparse]basicstamps] Re: ADC0831 vs. ADC0834 redux


    > The ADC0831 uses the SPI clock to run a
    > successive approximation A to D conversion
    > in real time. Since it only does one
    > channel, it is very straightforward to
    > interface -- ie you only need to run a
    > 'SHIFTIN' command to get the data.
    >
    > The ADC0834 needs to have you send some
    > data to it, to select the channel to
    > be converted. I havn't done this,
    > since the 0831 is so simple to interface,
    > I havn't had to go to the multi-channel
    > beast.
    >
    > Perhaps, nobody has had to go to the
    > multi-channel beast, which is why you
    > aren't getting any more answers.
    >
    > --- In basicstamps@yahoogroups.com, "altengnw2000"
    > <altengnw2000@y...> wrote:
    > > I didn't see any response to my inquiry.
    > >
    > > Is this a tough question or is this just not very interesting to
    > > others?
    > >
    > > Still would like to know.
    > >
    > > Thanks,
    > > Lawrence
    > >
    > >
    > >
    > >
    > >
    > > --- In basicstamps@yahoogroups.com, "altengnw2000"
    > > <altengnw2000@y...> wrote:
    > > >
    > > > These are the same chip except the ADC0834 has the ability to
    > read
    > > > four separate inputs.
    > > >
    > > > In the StampWorks manual experiment #27, it shows how to connect
    > an
    > > > ADC0831 and gives a sample program. I have performed this
    > > experiment
    > > > successfully.
    > > >
    > > > My question is about the ADC0834. It has two new pins: Data In
    > > (DI)
    > > > and SARS Status (SARS) How are these two pins connected to the
    > > Basic
    > > > Stamp?
    > > >
    > > > How would the ADC0831 program example have to be modified to
    > > > operate this two pins.
    > > >
    > > > Thanks in advance for any help,
    > > > Lawrence
    >
    >
    > 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 2003-06-29 19:01
    Thank you for responding.

    What PBASIC command do I send to tell it to read channel 2, for
    example?

    What does SPI stand for?

    Thanks,
    Lawrence



    --- In basicstamps@yahoogroups.com, pm <pmeloy@s...> wrote:
    > The 0834 just uses a normal SPI interface. You have to tell it
    which channel
    > to convert which is why it has a data in pin.
    >
    > SARS is the Successive Approximation Ready Signal - you can hook
    this to
    > another stamp pin and check its status - if its high the
    conversion is in
    > progress, if its low, its ready to read.
    >
    > You can either watch this pin and read the value when it goes low
    or, just
    > wait a few milliseconds and then read (save a pin). It only takes
    8 clock
    > cycles for a conversion which is pretty darned quick in stamp
    terms.
    >
    >
    Original Message
    > From: "Allan Lane" <allan.lane@h...>
    > To: <basicstamps@yahoogroups.com>
    > Sent: Sunday, June 29, 2003 8:12 AM
    > Subject: [noparse][[/noparse]basicstamps] Re: ADC0831 vs. ADC0834 redux
    >
    >
    > > The ADC0831 uses the SPI clock to run a
    > > successive approximation A to D conversion
    > > in real time. Since it only does one
    > > channel, it is very straightforward to
    > > interface -- ie you only need to run a
    > > 'SHIFTIN' command to get the data.
    > >
    > > The ADC0834 needs to have you send some
    > > data to it, to select the channel to
    > > be converted. I havn't done this,
    > > since the 0831 is so simple to interface,
    > > I havn't had to go to the multi-channel
    > > beast.
    > >
    > > Perhaps, nobody has had to go to the
    > > multi-channel beast, which is why you
    > > aren't getting any more answers.
    > >
    > > --- In basicstamps@yahoogroups.com, "altengnw2000"
    > > <altengnw2000@y...> wrote:
    > > > I didn't see any response to my inquiry.
    > > >
    > > > Is this a tough question or is this just not very interesting
    to
    > > > others?
    > > >
    > > > Still would like to know.
    > > >
    > > > Thanks,
    > > > Lawrence
    > > >
    > > >
    > > >
    > > >
    > > >
    > > > --- In basicstamps@yahoogroups.com, "altengnw2000"
    > > > <altengnw2000@y...> wrote:
    > > > >
    > > > > These are the same chip except the ADC0834 has the ability to
    > > read
    > > > > four separate inputs.
    > > > >
    > > > > In the StampWorks manual experiment #27, it shows how to
    connect
    > > an
    > > > > ADC0831 and gives a sample program. I have performed this
    > > > experiment
    > > > > successfully.
    > > > >
    > > > > My question is about the ADC0834. It has two new pins: Data
    In
    > > > (DI)
    > > > > and SARS Status (SARS) How are these two pins connected to
    the
    > > > Basic
    > > > > Stamp?
    > > > >
    > > > > How would the ADC0831 program example have to be modified to
    > > > > operate this two pins.
    > > > >
    > > > > Thanks in advance for any help,
    > > > > Lawrence
    > >
    > >
    > > 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 2003-06-29 20:03
    Go to www.National-Semi.com, look for ADC0831.
    Download the data sheet .PDF. They have a single
    PDF for several A to D chips.

    'SPI' stands for 'Serial Peripheral Interface'.
    Basically, the BS2 SHIFTOUT/SHIFTIN uses this
    interface. So, you'd use 'SHIFTOUT' to select
    which channel you want, then 'SHIFTIN' to
    get the data. See the timing diagram for the
    0834 chip in the PDF.

    As I said, I havn't done this personally.

    --- In basicstamps@yahoogroups.com, "altengnw2000"
    <altengnw2000@y...> wrote:
    > Thank you for responding.
    >
    > What PBASIC command do I send to tell it to read channel 2, for
    > example?
    >
    > What does SPI stand for?
    >
    > Thanks,
    > Lawrence
    >
    >
    >
    > --- In basicstamps@yahoogroups.com, pm <pmeloy@s...> wrote:
    > > The 0834 just uses a normal SPI interface. You have to tell it
    > which channel
    > > to convert which is why it has a data in pin.
    > >
    > > SARS is the Successive Approximation Ready Signal - you can hook
    > this to
    > > another stamp pin and check its status - if its high the
    > conversion is in
    > > progress, if its low, its ready to read.
    > >
    > > You can either watch this pin and read the value when it goes low
    > or, just
    > > wait a few milliseconds and then read (save a pin). It only takes
    > 8 clock
    > > cycles for a conversion which is pretty darned quick in stamp
    > terms.
    > >
    > >
    Original Message
    > > From: "Allan Lane" <allan.lane@h...>
    > > To: <basicstamps@yahoogroups.com>
    > > Sent: Sunday, June 29, 2003 8:12 AM
    > > Subject: [noparse][[/noparse]basicstamps] Re: ADC0831 vs. ADC0834 redux
    > >
    > >
    > > > The ADC0831 uses the SPI clock to run a
    > > > successive approximation A to D conversion
    > > > in real time. Since it only does one
    > > > channel, it is very straightforward to
    > > > interface -- ie you only need to run a
    > > > 'SHIFTIN' command to get the data.
    > > >
    > > > The ADC0834 needs to have you send some
    > > > data to it, to select the channel to
    > > > be converted. I havn't done this,
    > > > since the 0831 is so simple to interface,
    > > > I havn't had to go to the multi-channel
    > > > beast.
    > > >
    > > > Perhaps, nobody has had to go to the
    > > > multi-channel beast, which is why you
    > > > aren't getting any more answers.
    > > >
    > > > --- In basicstamps@yahoogroups.com, "altengnw2000"
    > > > <altengnw2000@y...> wrote:
    > > > > I didn't see any response to my inquiry.
    > > > >
    > > > > Is this a tough question or is this just not very interesting
    > to
    > > > > others?
    > > > >
    > > > > Still would like to know.
    > > > >
    > > > > Thanks,
    > > > > Lawrence
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > > --- In basicstamps@yahoogroups.com, "altengnw2000"
    > > > > <altengnw2000@y...> wrote:
    > > > > >
    > > > > > These are the same chip except the ADC0834 has the ability
    to
    > > > read
    > > > > > four separate inputs.
    > > > > >
    > > > > > In the StampWorks manual experiment #27, it shows how to
    > connect
    > > > an
    > > > > > ADC0831 and gives a sample program. I have performed this
    > > > > experiment
    > > > > > successfully.
    > > > > >
    > > > > > My question is about the ADC0834. It has two new pins:
    Data
    > In
    > > > > (DI)
    > > > > > and SARS Status (SARS) How are these two pins connected to
    > the
    > > > > Basic
    > > > > > Stamp?
    > > > > >
    > > > > > How would the ADC0831 program example have to be modified to
    > > > > > operate this two pins.
    > > > > >
    > > > > > Thanks in advance for any help,
    > > > > > Lawrence
    > > >
    > > >
    > > > 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 2003-06-30 22:47
    'SPI' stands for 'Serial Peripheral Interface'

    Is this an National Semi Conductor Standard or a Parallax standard
    or somebody elses?

    Is there a spec somewhere?

    Thanks,

    Lawrence


    --- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
    wrote:
    > Go to www.National-Semi.com, look for ADC0831.
    > Download the data sheet .PDF. They have a single
    > PDF for several A to D chips.
    >
    > 'SPI' stands for 'Serial Peripheral Interface'.
    > Basically, the BS2 SHIFTOUT/SHIFTIN uses this
    > interface. So, you'd use 'SHIFTOUT' to select
    > which channel you want, then 'SHIFTIN' to
    > get the data. See the timing diagram for the
    > 0834 chip in the PDF.
    >
    > As I said, I havn't done this personally.
    >
    > --- In basicstamps@yahoogroups.com, "altengnw2000"
    > <altengnw2000@y...> wrote:
    > > Thank you for responding.
    > >
    > > What PBASIC command do I send to tell it to read channel 2, for
    > > example?
    > >
    > > What does SPI stand for?
    > >
    > > Thanks,
    > > Lawrence
    > >
    > >
    > >
    > > --- In basicstamps@yahoogroups.com, pm <pmeloy@s...> wrote:
    > > > The 0834 just uses a normal SPI interface. You have to tell it
    > > which channel
    > > > to convert which is why it has a data in pin.
    > > >
    > > > SARS is the Successive Approximation Ready Signal - you can
    hook
    > > this to
    > > > another stamp pin and check its status - if its high the
    > > conversion is in
    > > > progress, if its low, its ready to read.
    > > >
    > > > You can either watch this pin and read the value when it goes
    low
    > > or, just
    > > > wait a few milliseconds and then read (save a pin). It only
    takes
    > > 8 clock
    > > > cycles for a conversion which is pretty darned quick in stamp
    > > terms.
    > > >
    > > >
    Original Message
    > > > From: "Allan Lane" <allan.lane@h...>
    > > > To: <basicstamps@yahoogroups.com>
    > > > Sent: Sunday, June 29, 2003 8:12 AM
    > > > Subject: [noparse][[/noparse]basicstamps] Re: ADC0831 vs. ADC0834 redux
    > > >
    > > >
    > > > > The ADC0831 uses the SPI clock to run a
    > > > > successive approximation A to D conversion
    > > > > in real time. Since it only does one
    > > > > channel, it is very straightforward to
    > > > > interface -- ie you only need to run a
    > > > > 'SHIFTIN' command to get the data.
    > > > >
    > > > > The ADC0834 needs to have you send some
    > > > > data to it, to select the channel to
    > > > > be converted. I havn't done this,
    > > > > since the 0831 is so simple to interface,
    > > > > I havn't had to go to the multi-channel
    > > > > beast.
    > > > >
    > > > > Perhaps, nobody has had to go to the
    > > > > multi-channel beast, which is why you
    > > > > aren't getting any more answers.
    > > > >
    > > > > --- In basicstamps@yahoogroups.com, "altengnw2000"
    > > > > <altengnw2000@y...> wrote:
    > > > > > I didn't see any response to my inquiry.
    > > > > >
    > > > > > Is this a tough question or is this just not very
    interesting
    > > to
    > > > > > others?
    > > > > >
    > > > > > Still would like to know.
    > > > > >
    > > > > > Thanks,
    > > > > > Lawrence
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > > --- In basicstamps@yahoogroups.com, "altengnw2000"
    > > > > > <altengnw2000@y...> wrote:
    > > > > > >
    > > > > > > These are the same chip except the ADC0834 has the
    ability
    > to
    > > > > read
    > > > > > > four separate inputs.
    > > > > > >
    > > > > > > In the StampWorks manual experiment #27, it shows how to
    > > connect
    > > > > an
    > > > > > > ADC0831 and gives a sample program. I have performed
    this
    > > > > > experiment
    > > > > > > successfully.
    > > > > > >
    > > > > > > My question is about the ADC0834. It has two new pins:
    > Data
    > > In
    > > > > > (DI)
    > > > > > > and SARS Status (SARS) How are these two pins connected
    to
    > > the
    > > > > > Basic
    > > > > > > Stamp?
    > > > > > >
    > > > > > > How would the ADC0831 program example have to be
    modified to
    > > > > > > operate this two pins.
    > > > > > >
    > > > > > > Thanks in advance for any help,
    > > > > > > Lawrence
    > > > >
    > > > >
    > > > > 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 2003-07-01 00:25
    At 09:47 PM 6/30/03 +0000, altengnw2000 wrote:

    >'SPI' stands for 'Serial Peripheral Interface'
    >
    >Is this an National Semi Conductor Standard or a Parallax standard
    >or somebody elses?
    >
    >Is there a spec somewhere?
    >
    >Thanks,
    >
    >Lawrence
    Lawrence -

    I believe the protocol came from Motorola, and is documented fairly well
    in "M68HC11 Reference Manual" (among other places). You can order the manual
    from Motorola Literature Distribution at 1-800-441-2447 or fax 1-303-675-2150
    at no charge.

    Regards,

    Bruce Bates
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-01 01:35
    I've never used the 0834 before but have used the ADC0838 in a
    project I did two years ago. If I remember right the 0834 had some
    limitations other than 4 vs. 8 inputs, I don't remember what though.
    Peter Anderson has some info at
    http://www.phanderson.com/printer/0838/0838.html
    Not about the stamp interface but it got me started last time.

    Also a google search for "adc0838 basic stamp" will find a number of
    project people have done with it, along with code. If that's not
    enough let me know I can dig up some of my old references on the
    project.

    Mike




    >I didn't see any response to my inquiry.
    >
    >Is this a tough question or is this just not very interesting to
    >others?
    >
    >Still would like to know.
    >
    >Thanks,
    >Lawrence
    >
    >
    >
    >
    >
    >--- In basicstamps@yahoogroups.com, "altengnw2000"
    ><altengnw2000@y...> wrote:
    >>
    >> These are the same chip except the ADC0834 has the ability to read
    >> four separate inputs.
    >>
    >> In the StampWorks manual experiment #27, it shows how to connect an
    >> ADC0831 and gives a sample program. I have performed this
    >experiment
    >> successfully.
    >>
    >> My question is about the ADC0834. It has two new pins: Data In
    >(DI)
    >> and SARS Status (SARS) How are these two pins connected to the
    >Basic
    >> Stamp?
    >>
    >> How would the ADC0831 program example have to be modified to
    >> operate this two pins.
    >>
    >> Thanks in advance for any help,
    >> Lawrence
    >
    >
    >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 2003-08-01 17:04
    I see something different (in the ordering of channels) than what the
    manual for ADC0838 describes when interfacing the ADC0838 to BS2p for
    measuring 8 analog single ended channels. Can someone explain why I
    see what I see?
    Let me explain.

    The manual for ADC0838 says the controlling bits is a 5 bit sequence:

    C4 C3 C2 C1 C0 (where C4 is always 1, C3 is 1 for single ended
    measurement).
    Since there are eight channels, channel number can be described by a
    three bits. C2 is the LSB (rightmost bit)of the channel number, C1 is
    the MSB (leftbit) of the channel number, C0 is the middle bit of the
    channel. Say, I use a byte called MUXBYTE for this control, then

    Channel Number MUXBYTE
    0 (%000) 24 (%11000)
    1 (%001) 28 (%11100)
    2 (%010) 25 (%11001)
    3 (%011) 29 (%11101)
    4 (%100) 26 (%11010)
    5 (%101) 30 (%11110)
    6 (%110) 27 (%11011)
    7 (%111) 31 (%11111)


    THe PBASIC code I use is somewhat like below:
    CS cib 0 ' Chip select pin of ADC to BS2p I/O pin 0
    ADCIn con 1 ' DI pin of ADC to BS2p I/O pin 1
    ADCOUT con 3 ' DO pin of ADC to BS2p I/O pin 3
    CLK con 2 ' CLK pin of ADC to BS2p I/O pin 2

    MUXBYTE var BYTE
    Channel var BYTE
    ADCVAL var BYTE

    DIRA = %0111
    HIGH CS

    FOR Channel = 0 to 7
    LOW CS
    MUXBYTE = %11000 | ((Channel & %001) << 2) | ((Channel & %110) >> 1)
    SHIFTIN ADCIN,CLK, MSBFIRST,[noparse][[/noparse]MUXBYTE\5]
    SHIFTOUT ADCOUT,CLK,MSBPOST,[noparse][[/noparse]ADCVal\9]
    DEBUG Dec Channel," ",Dec ADCVal
    HIGH CS
    NEXT

    END

    However, I find that if I use the above values, the channels that
    are actually read are different, namely:

    Channel Number MUXBYTE Channel actually read
    0 (%000) 24 (%11000) 0 (%000)
    1 (%001) 28 (%11100) 2 (%010)
    2 (%010) 25 (%11001) 4 (%100)
    3 (%011) 29 (%11101) 6 (%110)
    4 (%100) 26 (%11010) 1 (%001)
    5 (%101) 30 (%11110) 3 (%011)
    6 (%110) 27 (%11011) 5 (%101)
    7 (%111) 31 (%11111) 7 (%111)

    This makes me think the control sequence is actually
    C4 C3 C2 C1 C0 actually represents
    C4 - always 1
    C3 - always 1 for single ended measurement
    C2 - Middle bit of channel
    C1 - LSB of channel (rightmost bit)
    C0 - MSB of channel (leftmost bit)

    So, if I compute the MUXBYTE as follows

    MUXBYTE = %11000 | ((Channel & %100) >> 2) | ((Channel & %011) << 1)

    I find that the correct channels are read.

    Any idea why I see this?


    Thanks a lot
    Mohammed


    --- In basicstamps@yahoogroups.com, Mike Davey <mdavey@n...> wrote:
    > I've never used the 0834 before but have used the ADC0838 in a
    > project I did two years ago. If I remember right the 0834 had some
    > limitations other than 4 vs. 8 inputs, I don't remember what
    though.
    > Peter Anderson has some info at
    > http://www.phanderson.com/printer/0838/0838.html
    > Not about the stamp interface but it got me started last time.
    >
    > Also a google search for "adc0838 basic stamp" will find a number
    of
    > project people have done with it, along with code. If that's not
    > enough let me know I can dig up some of my old references on the
    > project.
    >
    > Mike
    >
    >
    >
    >
    > >I didn't see any response to my inquiry.
    > >
    > >Is this a tough question or is this just not very interesting to
    > >others?
    > >
    > >Still would like to know.
    > >
    > >Thanks,
    > >Lawrence
    > >
    > >
    > >
    > >
    > >
    > >--- In basicstamps@yahoogroups.com, "altengnw2000"
    > ><altengnw2000@y...> wrote:
    > >>
    > >> These are the same chip except the ADC0834 has the ability to
    read
    > >> four separate inputs.
    > >>
    > >> In the StampWorks manual experiment #27, it shows how to
    connect an
    > >> ADC0831 and gives a sample program. I have performed this
    > >experiment
    > >> successfully.
    > >>
    > >> My question is about the ADC0834. It has two new pins: Data In
    > >(DI)
    > >> and SARS Status (SARS) How are these two pins connected to the
    > >Basic
    > >> Stamp?
    > >>
    > >> How would the ADC0831 program example have to be modified to
    > >> operate this two pins.
    > >>
    > >> Thanks in advance for any help,
    > >> Lawrence
    > >
    > >
    > >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 2003-08-01 20:19
    Hi Mohammed,

    The MUXBYTE logic as in the program seems to match the ADC0838 data
    sheet. However, (maybe this is a typo), a SHIFTOUT ... [noparse][[/noparse]MUXBYTE] to
    send the command needs to come before the SHIFTIN ...[noparse][[/noparse]ADCVal] to
    read the data. The result of the program as written would be weird.

    -- Tracy


    >THe PBASIC code I use is somewhat like below:
    >
    >CS cib 0 ' Chip select pin of ADC to BS2p I/O pin 0
    >ADCIn con 1 ' DI pin of ADC to BS2p I/O pin 1
    >ADCOUT con 3 ' DO pin of ADC to BS2p I/O pin 3
    >CLK con 2 ' CLK pin of ADC to BS2p I/O pin 2
    >
    >MUXBYTE var BYTE
    >Channel var BYTE
    >ADCVAL var BYTE
    >
    >DIRA = %0111
    >HIGH CS
    >
    >FOR Channel = 0 to 7
    > LOW CS
    > MUXBYTE = %11000 | ((Channel & %001) << 2) | ((Channel & %110) >> 1)
    > SHIFTIN ADCIN,CLK, MSBFIRST,[noparse][[/noparse]MUXBYTE\5]
    > SHIFTOUT ADCOUT,CLK,MSBPOST,[noparse][[/noparse]ADCVal\9]
    > DEBUG Dec Channel," ",Dec ADCVal
    > HIGH CS
    >NEXT
    >
    >END
  • ArchiverArchiver Posts: 46,084
    edited 2003-08-01 21:35
    Thanks Tracy. I am sorry there was a typo. I did not copy from the
    program (I retyped it and made a mistake).

    The statements should have read
    SHIFTOUT ADCIn,CLK,MSBFIRST,[noparse][[/noparse]MUXBYTE\5]
    SHIFTIN ADCOUT,CLK,MSBPOST,[noparse][[/noparse]ADCRes\9]


    I am giving more details here. (Sorry for the long post). I
    appreciate your explanation for the results that I observe. I think
    it may have something to do with how the SHIFTIn statement works or
    something to do with the ADC0838 behaviour.


    After submitting the previous post, I found that:
    using the correct control bits (as specifed in the ADC0838
    datasheet), that is,

    MUXBYTE = %11000 | ((Channel & %001) << 2) | ((Channel & %110) >>
    1)
    and not using the "\9" in the SHIFTIN statement gave the voltages of
    the channels correctly (case 2). If I use the "\9" modifier then the
    channel ordering is mixed up as I stated in the original post (case
    1).

    However, if I use the following control sequence bits as computed by
    MUXBYTE= %11000 | ((Channel & %100) >> 2) | ((Channel & %011) << 1)
    and use the SHIFTIN statment with the "\9" modifier (case 3), I get
    the right results. If I do not use the "\9" modifier in the SHIFTIN
    statement while using this MUXBYTE (case 4), then I get wrong
    ordering of channel results. And this wrongly ordered result is NOT
    the same as the wrongly ordered results which I get using the correct
    MUXBYTE (as specified in the manual for ADC0838) but using the "\9"
    modifier in the SHIFTIN statement.

    In all the cases (channels 0 and 7) are read correctly , only the
    channels in between are mixed up.

    I have seven 1.2K resistor connected between +5 and GND. Channel 0 is
    connected to +5 V, Channel 7 is connected to GND and the channels 1
    to 6 are connected at terminals in between the 1.2K so that I should
    get (5V,4.286,3.571,2.857,2.143,1.429,0.714,0 volts) on the channels
    0 to 7 respectively.
    Let me post below my actual BS2p code (which is modified from a BS2
    code I found at
    http://people.msoe.edu/~barnicks/courses/cs400/19967/aqua/dsgnrpt-
    web/mic.htm) and the results I get in each case.
    ***************************************************************
    Case 1
    ***************************************************************

    CS CON 0 ' Chip select is I/O pin 0.
    ADCIn CON 1 ' Data input to ADC is I/O pin 1.
    ADCOut CON 3 ' Data output from ADC is I/O pin 3.
    CLK CON 2 ' Clock is I/O pin 2.
    ADCRes VAR Byte ' A-to-D result: one byte.
    ADCVol VAR Word
    Channel VAR Byte ' Number of the channel we want to measure
    MUXBYTE VAR Byte ' Sequence of bits for initialization

    DIRA = %0111 ' Set direction bits properly
    HIGH CS

    DEBUG "
    ",CR
    DEBUG " Channel ; MUXBYTE ; ADCResult ;
    Voltage*100" ,CR
    DEBUG "
    ",CR
    FOR Channel = 0 TO 7 ' Go through all the channels
    LOW CS ' Chip select active low.
    MUXBYTE = %11000 | ((Channel & %001) << 2) | ((Channel & %110) >>
    1)
    ' MUXBYTE= %11000 | ((Channel & %100) >> 2) | ((Channel & %011) <<
    1)
    SHIFTOUT ADCIn,CLK,MSBFIRST,[noparse][[/noparse]MUXBYTE\5]
    ' SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes]
    SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes\9]
    HIGH CS ' Chip select inactive
    ADCVol = (ADCRes*100)*/5
    DEBUG DEC CHANNEL," (%",BIN3 Channel,") ; ",DEC MUXBYTE, "
    (%",BIN MUXBYTE,") ; "
    DEBUG DEC3 ADCRes," (%",BIN8 ADCRes,") ; ",DEC3 ADCVol,"
    (%",BIN8 ADCVol,") " , CR

    NEXT ' Go to next channel
    DEBUG "
    ",CR
    END
    Below are the results from the debug window for case 1
    Channel ; MUXBYTE ; ADCResult ; Voltage*100
    0 (%000) ; 24 (%11000) ; 255 (%11111111) ; 498 (%11110010)
    1 (%001) ; 28 (%11100) ; 183 (%10110111) ; 357 (%01100101)
    2 (%010) ; 25 (%11001) ; 111 (%01101111) ; 216 (%11011000)
    3 (%011) ; 29 (%11101) ; 036 (%00100100) ; 070 (%01000110)
    4 (%100) ; 26 (%11010) ; 220 (%11011100) ; 429 (%10101101)
    5 (%101) ; 30 (%11110) ; 147 (%10010011) ; 287 (%00011111)
    6 (%110) ; 27 (%11011) ; 072 (%01001000) ; 140 (%10001100)
    7 (%111) ; 31 (%11111) ; 000 (%00000000) ; 000 (%00000000)
    ****************************************************

    Case 2:
    Program statements (only the relevant statements):

    MUXBYTE = %11000 | ((Channel & %001) << 2) | ((Channel & %110) >>
    1)
    ' MUXBYTE= %11000 | ((Channel & %100) >> 2) | ((Channel & %011) <<
    1)
    SHIFTOUT ADCIn,CLK,MSBFIRST,[noparse][[/noparse]MUXBYTE\5]
    SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes]
    ' SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes\9]
    Resulst for case 2:

    Channel ; MUXBYTE ; ADCResult ; Voltage*100
    0 (%000) ; 24 (%11000) ; 255 (%11111111) ; 498 (%11110010)
    1 (%001) ; 28 (%11100) ; 219 (%11011011) ; 427 (%10101011)
    2 (%010) ; 25 (%11001) ; 183 (%10110111) ; 357 (%01100101)
    3 (%011) ; 29 (%11101) ; 146 (%10010010) ; 285 (%00011101)
    4 (%100) ; 26 (%11010) ; 110 (%01101110) ; 214 (%11010110)
    5 (%101) ; 30 (%11110) ; 073 (%01001001) ; 142 (%10001110)
    6 (%110) ; 27 (%11011) ; 036 (%00100100) ; 070 (%01000110)
    7 (%111) ; 31 (%11111) ; 000 (%00000000) ; 000 (%00000000)


    Case 3:
    Program statements (only the relevant statements):
    ' MUXBYTE = %11000 | ((Channel & %001) << 2) | ((Channel & %110)
    >> 1)
    MUXBYTE= %11000 | ((Channel & %100) >> 2) | ((Channel & %011) << 1)
    SHIFTOUT ADCIn,CLK,MSBFIRST,[noparse][[/noparse]MUXBYTE\5]
    ' SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes]
    SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes\9]

    Results for case 3:

    Channel ; MUXBYTE ; ADCResult ; Voltage*100
    0 (%000) ; 24 (%11000) ; 255 (%11111111) ; 498 (%11110010)
    1 (%001) ; 26 (%11010) ; 220 (%11011100) ; 429 (%10101101)
    2 (%010) ; 28 (%11100) ; 183 (%10110111) ; 357 (%01100101)
    3 (%011) ; 30 (%11110) ; 147 (%10010011) ; 287 (%00011111)
    4 (%100) ; 25 (%11001) ; 111 (%01101111) ; 216 (%11011000)
    5 (%101) ; 27 (%11011) ; 072 (%01001000) ; 140 (%10001100)
    6 (%110) ; 29 (%11101) ; 036 (%00100100) ; 070 (%01000110)
    7 (%111) ; 31 (%11111) ; 000 (%00000000) ; 000 (%00000000)

    Case 4:
    Program statements (only the relevant statements):

    Results for case 4:

    Channel ; MUXBYTE ; ADCResult ; Voltage*100
    0 (%000) ; 24 (%11000) ; 255 (%11111111) ; 498 (%11110010)
    1 (%001) ; 26 (%11010) ; 110 (%01101110) ; 214 (%11010110)
    2 (%010) ; 28 (%11100) ; 219 (%11011011) ; 427 (%10101011)
    3 (%011) ; 30 (%11110) ; 073 (%01001001) ; 142 (%10001110)
    4 (%100) ; 25 (%11001) ; 183 (%10110111) ; 357 (%01100101)
    5 (%101) ; 27 (%11011) ; 036 (%00100100) ; 070 (%01000110)
    6 (%110) ; 29 (%11101) ; 146 (%10010010) ; 285 (%00011101)
    7 (%111) ; 31 (%11111) ; 000 (%00000000) ; 000 (%00000000)

    --- In basicstamps@yahoogroups.com, Tracy Allen <tracy@e...> wrote:
    > Hi Mohammed,
    >
    > The MUXBYTE logic as in the program seems to match the ADC0838 data
    > sheet. However, (maybe this is a typo), a SHIFTOUT ... [noparse][[/noparse]MUXBYTE]
    to
    > send the command needs to come before the SHIFTIN ...[noparse][[/noparse]ADCVal] to
    > read the data. The result of the program as written would be weird.
    >
    > -- Tracy
    >
    >
    > >THe PBASIC code I use is somewhat like below:
    > >
    > >CS cib 0 ' Chip select pin of ADC to BS2p I/O pin 0
    > >ADCIn con 1 ' DI pin of ADC to BS2p I/O pin 1
    > >ADCOUT con 3 ' DO pin of ADC to BS2p I/O pin 3
    > >CLK con 2 ' CLK pin of ADC to BS2p I/O pin 2
    > >
    > >MUXBYTE var BYTE
    > >Channel var BYTE
    > >ADCVAL var BYTE
    > >
    > >DIRA = %0111
    > >HIGH CS
    > >
    > >FOR Channel = 0 to 7
    > > LOW CS
    > > MUXBYTE = %11000 | ((Channel & %001) << 2) | ((Channel & %110) >>
    1)
    > > SHIFTIN ADCIN,CLK, MSBFIRST,[noparse][[/noparse]MUXBYTE\5]
    > > SHIFTOUT ADCOUT,CLK,MSBPOST,[noparse][[/noparse]ADCVal\9]
    > > DEBUG Dec Channel," ",Dec ADCVal
    > > HIGH CS
    > >NEXT
    > >
    > >END
  • ArchiverArchiver Posts: 46,084
    edited 2003-08-01 23:31
    As a follup to my previous post, I found that

    using the correct MUXBYTE and using

    SHIFTIN ADCOUT,CLK,MSBPRE,[noparse][[/noparse]ADCRes\9]

    results in correct acquisition of channel voltages. but

    SHIFTIN ADCOUT,CLK,MSBPRE,[noparse][[/noparse]ADCRes]
    gives incorrect result.

    Now I understand all the results I have obtained.
    ADC0838 gives out a leading 0 followed by the MSB and the next 7 bits
    of the data and the LSB continues to be available (as I have SE* held
    high always) until CS* is made high. Also,The leading zero is
    available before the clock pulse. (So, the bit stream available out
    of ADCs DO pin is [noparse][[/noparse]0 A7 A6 A5 A4 A3 A2 A1 A0 A0]

    Case 1:
    So, using
    SHIFTIN ADCOUT,CLK,MSBPOST,[noparse][[/noparse]ADCRes\9]
    results in stamp reading the 9 bits beginning with A7
    i.e. [noparse][[/noparse]A7 A6 A5 A4 A3 A2 A1 A0 A0]
    Since ADCRes is a byte sized, the MSB A7 is lost resulting in
    ADCRes = [noparse][[/noparse]A6 A5 A4 A3 A2 A1 A0 A0] which is wrong

    (I confirmed this by defining ADCRes as a WORD and using the above
    SHIFTIN statement. THen rightshifted the ADCRes by 1 bit to get the
    right answer).

    Case 2:
    When using
    SHIFTIN ADCOUT,CLK,MSBPOST,[noparse][[/noparse]ADCRes]
    results in stamp reading the 8 bits beginning with A7
    i.e. [noparse][[/noparse]A7 A6 A5 A4 A3 A2 A1 A0] which is also stored as is in
    ADCRes, giving the correct result.

    Using the wrong MUX word and using the ADCRes\9 in the SHIFTIN as in
    case 1 gave the correct result by sheer coincidence for my circuitry,
    I think.

    Tracy, Is my reasoning right?

    Thanks
    Mohammed

    --- In basicstamps@yahoogroups.com, "mohammedrasiq"
    <mohammedrasiq@y...> wrote:
    > Thanks Tracy. I am sorry there was a typo. I did not copy from the
    > program (I retyped it and made a mistake).
    >
    > The statements should have read
    >
    > SHIFTOUT ADCIn,CLK,MSBFIRST,[noparse][[/noparse]MUXBYTE\5]
    > SHIFTIN ADCOUT,CLK,MSBPOST,[noparse][[/noparse]ADCRes\9]
    >
    >
    >
    > I am giving more details here. (Sorry for the long post). I
    > appreciate your explanation for the results that I observe. I think
    > it may have something to do with how the SHIFTIn statement works or
    > something to do with the ADC0838 behaviour.
    >
    >
    > After submitting the previous post, I found that:
    > using the correct control bits (as specifed in the ADC0838
    > datasheet), that is,
    >
    > MUXBYTE = %11000 | ((Channel & %001) << 2) | ((Channel & %110) >>
    > 1)
    > and not using the "\9" in the SHIFTIN statement gave the voltages
    of
    > the channels correctly (case 2). If I use the "\9" modifier then
    the
    > channel ordering is mixed up as I stated in the original post (case
    > 1).
    >
    > However, if I use the following control sequence bits as computed by
    > MUXBYTE= %11000 | ((Channel & %100) >> 2) | ((Channel & %011) << 1)
    > and use the SHIFTIN statment with the "\9" modifier (case 3), I get
    > the right results. If I do not use the "\9" modifier in the SHIFTIN
    > statement while using this MUXBYTE (case 4), then I get wrong
    > ordering of channel results. And this wrongly ordered result is NOT
    > the same as the wrongly ordered results which I get using the
    correct
    > MUXBYTE (as specified in the manual for ADC0838) but using the "\9"
    > modifier in the SHIFTIN statement.
    >
    > In all the cases (channels 0 and 7) are read correctly , only the
    > channels in between are mixed up.
    >
    > I have seven 1.2K resistor connected between +5 and GND. Channel 0
    is
    > connected to +5 V, Channel 7 is connected to GND and the channels 1
    > to 6 are connected at terminals in between the 1.2K so that I
    should
    > get (5V,4.286,3.571,2.857,2.143,1.429,0.714,0 volts) on the
    channels
    > 0 to 7 respectively.
    > Let me post below my actual BS2p code (which is modified from a BS2
    > code I found at
    > http://people.msoe.edu/~barnicks/courses/cs400/19967/aqua/dsgnrpt-
    > web/mic.htm) and the results I get in each case.
    > ***************************************************************
    > Case 1
    > ***************************************************************
    >
    > CS CON 0 ' Chip select is I/O pin 0.
    > ADCIn CON 1 ' Data input to ADC is I/O pin 1.
    > ADCOut CON 3 ' Data output from ADC is I/O pin 3.
    > CLK CON 2 ' Clock is I/O pin 2.
    > ADCRes VAR Byte ' A-to-D result: one byte.
    > ADCVol VAR Word
    > Channel VAR Byte ' Number of the channel we want to measure
    > MUXBYTE VAR Byte ' Sequence of bits for initialization
    >
    > DIRA = %0111 ' Set direction bits properly
    > HIGH CS
    >
    > DEBUG "
    -
    > ",CR
    > DEBUG " Channel ; MUXBYTE ; ADCResult ;
    > Voltage*100" ,CR
    > DEBUG "
    -
    > ",CR
    > FOR Channel = 0 TO 7 ' Go through all the channels
    > LOW CS ' Chip select active low.
    > MUXBYTE = %11000 | ((Channel & %001) << 2) | ((Channel & %110)
    >>
    > 1)
    > ' MUXBYTE= %11000 | ((Channel & %100) >> 2) | ((Channel & %011)
    <<
    > 1)
    > SHIFTOUT ADCIn,CLK,MSBFIRST,[noparse][[/noparse]MUXBYTE\5]
    > ' SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes]
    > SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes\9]
    > HIGH CS ' Chip select inactive
    > ADCVol = (ADCRes*100)*/5
    > DEBUG DEC CHANNEL," (%",BIN3 Channel,") ; ",DEC MUXBYTE, "
    > (%",BIN MUXBYTE,") ; "
    > DEBUG DEC3 ADCRes," (%",BIN8 ADCRes,") ; ",DEC3 ADCVol,"
    > (%",BIN8 ADCVol,") " , CR
    >
    > NEXT ' Go to next channel
    > DEBUG "
    -
    > ",CR
    > END
    >
    > Below are the results from the debug window for case 1
    >
    > Channel ; MUXBYTE ; ADCResult ; Voltage*100
    >
    > 0 (%000) ; 24 (%11000) ; 255 (%11111111) ; 498 (%11110010)
    > 1 (%001) ; 28 (%11100) ; 183 (%10110111) ; 357 (%01100101)
    > 2 (%010) ; 25 (%11001) ; 111 (%01101111) ; 216 (%11011000)
    > 3 (%011) ; 29 (%11101) ; 036 (%00100100) ; 070 (%01000110)
    > 4 (%100) ; 26 (%11010) ; 220 (%11011100) ; 429 (%10101101)
    > 5 (%101) ; 30 (%11110) ; 147 (%10010011) ; 287 (%00011111)
    > 6 (%110) ; 27 (%11011) ; 072 (%01001000) ; 140 (%10001100)
    > 7 (%111) ; 31 (%11111) ; 000 (%00000000) ; 000 (%00000000)
    >
    > ****************************************************
    >
    > Case 2:
    > Program statements (only the relevant statements):
    >
    > MUXBYTE = %11000 | ((Channel & %001) << 2) | ((Channel & %110)
    >>
    > 1)
    > ' MUXBYTE= %11000 | ((Channel & %100) >> 2) | ((Channel & %011)
    <<
    > 1)
    > SHIFTOUT ADCIn,CLK,MSBFIRST,[noparse][[/noparse]MUXBYTE\5]
    > SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes]
    > ' SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes\9]
    >
    > Resulst for case 2:
    >
    >
    >
    > Channel ; MUXBYTE ; ADCResult ; Voltage*100
    >
    > 0 (%000) ; 24 (%11000) ; 255 (%11111111) ; 498 (%11110010)
    > 1 (%001) ; 28 (%11100) ; 219 (%11011011) ; 427 (%10101011)
    > 2 (%010) ; 25 (%11001) ; 183 (%10110111) ; 357 (%01100101)
    > 3 (%011) ; 29 (%11101) ; 146 (%10010010) ; 285 (%00011101)
    > 4 (%100) ; 26 (%11010) ; 110 (%01101110) ; 214 (%11010110)
    > 5 (%101) ; 30 (%11110) ; 073 (%01001001) ; 142 (%10001110)
    > 6 (%110) ; 27 (%11011) ; 036 (%00100100) ; 070 (%01000110)
    > 7 (%111) ; 31 (%11111) ; 000 (%00000000) ; 000 (%00000000)
    >
    >
    >
    > Case 3:
    > Program statements (only the relevant statements):
    > ' MUXBYTE = %11000 | ((Channel & %001) << 2) | ((Channel & %110)
    > >> 1)
    > MUXBYTE= %11000 | ((Channel & %100) >> 2) | ((Channel & %011) <<
    1)
    > SHIFTOUT ADCIn,CLK,MSBFIRST,[noparse][[/noparse]MUXBYTE\5]
    > ' SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes]
    > SHIFTIN ADCOut,CLK,MSBPOST,[noparse][[/noparse]ADCRes\9]
    >
    >
    > Results for case 3:
    >
    >
    > Channel ; MUXBYTE ; ADCResult ; Voltage*100
    >
    > 0 (%000) ; 24 (%11000) ; 255 (%11111111) ; 498 (%11110010)
    > 1 (%001) ; 26 (%11010) ; 220 (%11011100) ; 429 (%10101101)
    > 2 (%010) ; 28 (%11100) ; 183 (%10110111) ; 357 (%01100101)
    > 3 (%011) ; 30 (%11110) ; 147 (%10010011) ; 287 (%00011111)
    > 4 (%100) ; 25 (%11001) ; 111 (%01101111) ; 216 (%11011000)
    > 5 (%101) ; 27 (%11011) ; 072 (%01001000) ; 140 (%10001100)
    > 6 (%110) ; 29 (%11101) ; 036 (%00100100) ; 070 (%01000110)
    > 7 (%111) ; 31 (%11111) ; 000 (%00000000) ; 000 (%00000000)
    >
    >
    > Case 4:
    > Program statements (only the relevant statements):
    >
    >
    > Results for case 4:
    >
    >
    >
    > Channel ; MUXBYTE ; ADCResult ; Voltage*100
    >
    > 0 (%000) ; 24 (%11000) ; 255 (%11111111) ; 498 (%11110010)
    > 1 (%001) ; 26 (%11010) ; 110 (%01101110) ; 214 (%11010110)
    > 2 (%010) ; 28 (%11100) ; 219 (%11011011) ; 427 (%10101011)
    > 3 (%011) ; 30 (%11110) ; 073 (%01001001) ; 142 (%10001110)
    > 4 (%100) ; 25 (%11001) ; 183 (%10110111) ; 357 (%01100101)
    > 5 (%101) ; 27 (%11011) ; 036 (%00100100) ; 070 (%01000110)
    > 6 (%110) ; 29 (%11101) ; 146 (%10010010) ; 285 (%00011101)
    > 7 (%111) ; 31 (%11111) ; 000 (%00000000) ; 000 (%00000000)
    >
    >
    > --- In basicstamps@yahoogroups.com, Tracy Allen <tracy@e...> wrote:
    > > Hi Mohammed,
    > >
    > > The MUXBYTE logic as in the program seems to match the ADC0838
    data
    > > sheet. However, (maybe this is a typo), a SHIFTOUT ... [noparse][[/noparse]MUXBYTE]
    > to
    > > send the command needs to come before the SHIFTIN ...[noparse][[/noparse]ADCVal] to
    > > read the data. The result of the program as written would be
    weird.
    > >
    > > -- Tracy
    > >
    > >
    > > >THe PBASIC code I use is somewhat like below:
    > > >
    > > >CS cib 0 ' Chip select pin of ADC to BS2p I/O pin 0
    > > >ADCIn con 1 ' DI pin of ADC to BS2p I/O pin 1
    > > >ADCOUT con 3 ' DO pin of ADC to BS2p I/O pin 3
    > > >CLK con 2 ' CLK pin of ADC to BS2p I/O pin 2
    > > >
    > > >MUXBYTE var BYTE
    > > >Channel var BYTE
    > > >ADCVAL var BYTE
    > > >
    > > >DIRA = %0111
    > > >HIGH CS
    > > >
    > > >FOR Channel = 0 to 7
    > > > LOW CS
    > > > MUXBYTE = %11000 | ((Channel & %001) << 2) | ((Channel & %110)
    >>
    > 1)
    > > > SHIFTIN ADCIN,CLK, MSBFIRST,[noparse][[/noparse]MUXBYTE\5]
    > > > SHIFTOUT ADCOUT,CLK,MSBPOST,[noparse][[/noparse]ADCVal\9]
    > > > DEBUG Dec Channel," ",Dec ADCVal
    > > > HIGH CS
    > > >NEXT
    > > >
    > > >END
Sign In or Register to comment.