Shop OBEX P1 Docs P2 Docs Learn Events
I2C, see if I actually understand it. — Parallax Forums

I2C, see if I actually understand it.

ArchiverArchiver Posts: 46,084
edited 2002-10-08 02:21 in General Discussion
So the I2C spec allows me to interface with (compliant) chips using
three stamp pins. Once the first device is on the I2C bus, subsequent
devices only require a single pin (Chip Select) more. The other two
pins are shared between all I2C devices.

So if I had say.. 8 DS1620 chips. I would need 10 pins to control
them all. 3 for the first chip and one each for the next 7 (seperate
CS).

To increase the number of inputs, I could use a shift register. Each
shift register output pin would go to the CS pin of (up to) 8 other
I2C compatible devices, all of which would share the clock and data
lines (although some chips may have a seperate clock source, like a
crystal). So for my 8 DS1620s, I'd only need three pins of the stamp.

Is the above correct?

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-10-07 19:49
    I was thinking SPI was the 3-wire and I2C was 2-wire. Keep in mind you don't
    count the power and ground connections.

    Parallax says the I2C protocol requires only two I/O pins, serial data and
    serial clock, and they may be shared with other devices.

    Original Message

    > So the I2C spec allows me to interface with (compliant) chips using
    > three stamp pins. Once the first device is on the I2C bus, subsequent
    > devices only require a single pin (Chip Select) more. The other two
    > pins are shared between all I2C devices.
    >
    > So if I had say.. 8 DS1620 chips. I would need 10 pins to control
    > them all. 3 for the first chip and one each for the next 7 (seperate
    > CS).
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-10-07 20:10
    The I2C protocol only requires two pins: clock and data (both pulled up to
    Vdd through 1K - 4.7K). This differs from SP1/3-wire used by the DS1620
    because the chip selection is carried in the protocol as part of the command
    byte sent down the bus.

    So, if you have eight DS1721s, you can connect to all of them through just
    two Stamp pins since they use the I2C protocol. If you're using a BS2p, you
    can use I2CIN and I2COUT. If you're using any other Stamp, you'll have to do
    the I2C comm in code. It's not hard.

    You would, in fact, need 10 pins for eight DS1620s. You would need two for
    clock and data, then one for each chip select (called Reset on the DS1620).
    Another thing you need to do is connect each DS1620 to the common bus through
    a 1K resistor. This will prevent shorts in case two or more devices get
    activated at the same time.

    Yes, you could reduce the pins by using an output shift register like the
    74HC595. The x595 could share your clock and data lines, but would need its
    own Latch line. The x595 outputs would connect to the DS1620 Reset pins.
    This would bring your total pin count down to three: clock, data, 74x595
    Latch. Of course, you also need the x595, and the resistors.

    Just to be clear, the DS1620 does not use the I2C protocol. The DS1721 does.

    -- Jon Williams
    -- Parallax


    In a message dated 10/7/02 1:43:51 PM Central Daylight Time,
    ghidera2000@y... writes:


    > So the I2C spec allows me to interface with (compliant) chips using
    > three stamp pins. Once the first device is on the I2C bus, subsequent
    > devices only require a single pin (Chip Select) more. The other two
    > pins are shared between all I2C devices.
    >
    > So if I had say.. 8 DS1620 chips. I would need 10 pins to control
    > them all. 3 for the first chip and one each for the next 7 (seperate
    > CS).
    >
    > To increase the number of inputs, I could use a shift register. Each
    > shift register output pin would go to the CS pin of (up to) 8 other
    > I2C compatible devices, all of which would share the clock and data
    > lines (although some chips may have a seperate clock source, like a
    > crystal). So for my 8 DS1620s, I'd only need three pins of the stamp.
    >
    >




    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-10-07 23:36
    Ah ok, right operation, wrong spec [noparse]:D[/noparse] I'm getting it slowly!

    One thing I've definately learned, the choices are bewildering...
    I2C, SPI, that RS-435 (455? arg, the 1000+ ft 2 wire IC network). And
    thats just the ones I've seen in my short two weeks.

    I guess which one I choose will have more to do with what my local
    suppliers carry than capabilities of the spec.

    --- In basicstamps@y..., Rodent <daweasel@s...> wrote:
    > I was thinking SPI was the 3-wire and I2C was 2-wire. Keep in mind
    you don't
    > count the power and ground connections.
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-10-08 00:31
    Im curious which of these standards the Shiftin/Shiftout commands comply
    with?

    Nick

    on 7/10/02 6:36 PM, ghidera2000 at ghidera2000@y... wrote:

    > Ah ok, right operation, wrong spec [noparse]:D[/noparse] I'm getting it slowly!
    >
    > One thing I've definately learned, the choices are bewildering...
    > I2C, SPI, that RS-435 (455? arg, the 1000+ ft 2 wire IC network). And
    > thats just the ones I've seen in my short two weeks.
    >
    > I guess which one I choose will have more to do with what my local
    > suppliers carry than capabilities of the spec.
    >
    > --- In basicstamps@y..., Rodent <daweasel@s...> wrote:
    >> I was thinking SPI was the 3-wire and I2C was 2-wire. Keep in mind
    > you don't
    >> count the power and ground connections.
    >>
    >
    >
    >
    > 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-10-08 00:32
    Alot of this stuff including some of the devices mentioned is covered in the
    Nuts & Volts of Basic Stamps books. Its probably also in various Stampworks
    and Stamps in Class documents as well. Just download from the Parallax
    website and browse at your convenience.

    Original Message


    > Im curious which of these standards the Shiftin/Shiftout commands comply

    > > Ah ok, right operation, wrong spec [noparse]:D[/noparse] I'm getting it slowly!
    > >
    > > One thing I've definately learned, the choices are bewildering...
    > > I2C, SPI, that RS-435 (455? arg, the 1000+ ft 2 wire IC network). And
    > > thats just the ones I've seen in my short two weeks.
    > >
    > > I guess which one I choose will have more to do with what my local
    > > suppliers carry than capabilities of the spec.

    > >> I was thinking SPI was the 3-wire and I2C was 2-wire. Keep in mind
    > > you don't
    > >> count the power and ground connections.
  • ArchiverArchiver Posts: 46,084
    edited 2002-10-08 02:03
    Technically, SHIFTIN and SHIFTOUT "comply" with the SPI/3-wire standard, but
    they can be used (a bit of a cheat) with I2C as well. I say it's a "cheat"
    because SHIFTOUT drives the data line high and low; in the I2C spec, the
    master only pulls the clock and data lines low and lets the bus pull-ups take
    them high. If you're concerned about a bus short, you can insert a 220
    resistor in your clock and data lines. It's pretty cheap insurance for your
    BASIC Stamp.

    There is I2C code for non-BS2 Stamps posted on our web site (associated with
    my Nuts & Volts column).

    -- Jon Williams
    -- Parallax



    In a message dated 10/7/02 6:29:52 PM Central Daylight Time,
    nickstedman@s... writes:


    > Im curious which of these standards the Shiftin/Shiftout commands comply
    > with?
    >
    > Nick
    >
    > on 7/10/02 6:36 PM, ghidera2000 at ghidera2000@y... wrote:
    >
    > > Ah ok, right operation, wrong spec [noparse]:D[/noparse] I'm getting it slowly!
    > >
    > > One thing I've definately learned, the choices are bewildering...
    > > I2C, SPI, that RS-435 (455? arg, the 1000+ ft 2 wire IC network). And
    > > thats just the ones I've seen in my short two weeks.
    > >
    > > I guess which one I choose will have more to do with what my local
    > > suppliers carry than capabilities of the spec.
    > >
    > > --- In basicstamps@y..., Rodent <daweasel@s...> wrote:
    > >> I was thinking SPI was the 3-wire and I2C was 2-wire. Keep in mind
    > >




    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-10-08 02:21
    >Im curious which of these standards the Shiftin/Shiftout commands comply
    > with?

    Both. Although, with I2C, there are other overheads.

    Jon Williams did an article on I2C not long ago, and I also have some
    examples on my site:
    http://www.lennard.net.nz/ click on circuit ideas then I2C (under buses).

    The BS2p also has I2C commands built in (I2Cin, I2Cout), but if you don't
    have a BS2p, then Shiftin/out will work.


    --
    http://www.lennard.net.nz/
    Ben Lennard, NCEE, Dip EE

    Electronics R&D

    Hm: +64 4 972 7567
    Mb: +64 21 536 627
    87 Spencer Street
    Crofton Downs
    Wellington
    New Zealand

    "To the optimist, the glass is half full. To the pessimist, the glass is
    half empty. To the engineer, the glass is twice as big as it needs to be."

    No animals were harmed in the transmission of this email, although the
    Dog next door is living on borrowed time, let me tell you! Those of you
    with an overwhelming fear of the unknown will be gratified to learn that
    there is no hidden message revealed by reading this warning backwards.




    > From: Nick Stedman <nickstedman@s...>
    > Reply-To: basicstamps@yahoogroups.com
    > Date: Mon, 07 Oct 2002 19:31:57 -0400
    > To: <basicstamps@yahoogroups.com>
    > Subject: Re: [noparse][[/noparse]basicstamps] Re: I2C, see if I actually understand it.
    >
    > Im curious which of these standards the Shiftin/Shiftout commands comply
    > with?
    >
    > Nick
    >
    > on 7/10/02 6:36 PM, ghidera2000 at ghidera2000@y... wrote:
    >
    >> Ah ok, right operation, wrong spec [noparse]:D[/noparse] I'm getting it slowly!
    >>
    >> One thing I've definately learned, the choices are bewildering...
    >> I2C, SPI, that RS-435 (455? arg, the 1000+ ft 2 wire IC network). And
    >> thats just the ones I've seen in my short two weeks.
    >>
    >> I guess which one I choose will have more to do with what my local
    >> suppliers carry than capabilities of the spec.
    >>
    >> --- In basicstamps@y..., Rodent <daweasel@s...> wrote:
    >>> I was thinking SPI was the 3-wire and I2C was 2-wire. Keep in mind
    >> you don't
    >>> count the power and ground connections.
    >>>
    >>
    >>
    >>
    >> 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/
    >>
    >>
    >
    >
    > 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/
    >
    >
Sign In or Register to comment.