Shop OBEX P1 Docs P2 Docs Learn Events
i2c probs — Parallax Forums

i2c probs

ArchiverArchiver Posts: 46,084
edited 2002-12-27 05:45 in General Discussion
Hi BS2p fans.

I am hoping for some assistance in getting my bs2p to talk to a
series of 8574A I2C chips I have connected. I have checked all
connections and they look OK. I just can not seem to communicate with
the devices.

I have connected SDA to AUXIO p15 and SCA to AUXIO p14. (Im am using
a BS2P/40.

I have connected pins 1,2 and 3 of the first 8574A to ground. I
assume this is address 0. The remaining two chips have individual
addresses.

I would like to read and display the status of inputs on each of the
three 8574A ICs.

Can anyone help with some simple code?

Are there any reference sites you can direct me to for examples of
I2C code for the BSP2/40?

I have reviewed the publication on Nuts and Volts (vol 3) re
expanding I/O. This is exactly what I want to achieve, however I can
not get the code to work.

I suspect the prob is in the I/O definitions , Device Address or
I2CPIN area. Is my problem to do with using AUXIO p15 and 14?
The N&V example use only pin p0. Not sure how that works with SDA and
SCL?

I would appreciate any advise.

Thanks
Ken

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-12-26 02:21
    Thanks Peter,
    Much appreciated.

    So it sounds like ONLY P0 and P1 or AUXIO P0/P1 can be used for I2c.

    No other pins can be setup to work?

    Thanks.

    Ken

    --- In basicstamps@yahoogroups.com, "peter verkaik"
    <peterverkaik@b...> wrote:
    > Hi Ken,
    >
    > The bs2p has builtin commands I2CIN and I2COUT but these operate on
    either
    > P0=SDA and P1=SCL or P8=SDA and P9=SCL. Other pins are not supported
    > by the I2C commands. Also don't forget to use the AUXIO command if
    you use
    > the
    > auxiliary P0/P1 or P8/P9. The manual has several examples using
    I2CIN and
    > I2COUT.
    >
    > I hope this resolves your problem.
    > Regards peter
    >
    >
    >
    Oorspronkelijk bericht
    > Van: digdul2002 <jduldig@s...> [noparse][[/noparse]mailto:jduldig@s...]
    > Verzonden: woensdag 25 december 2002 16:38
    > Aan: basicstamps@yahoogroups.com
    > Onderwerp: [noparse][[/noparse]basicstamps] i2c probs
    >
    > Hi BS2p fans.
    >
    > I am hoping for some assistance in getting my bs2p to talk to a
    > series of 8574A I2C chips I have connected. I have checked all
    > connections and they look OK. I just can not seem to communicate
    with
    > the devices.
    >
    > I have connected SDA to AUXIO p15 and SCA to AUXIO p14. (Im am using
    > a BS2P/40.
    >
    > I have connected pins 1,2 and 3 of the first 8574A to ground. I
    > assume this is address 0. The remaining two chips have individual
    > addresses.
    >
    > I would like to read and display the status of inputs on each of the
    > three 8574A ICs.
    >
    > Can anyone help with some simple code?
    >
    > Are there any reference sites you can direct me to for examples of
    > I2C code for the BSP2/40?
    >
    > I have reviewed the publication on Nuts and Volts (vol 3) re
    > expanding I/O. This is exactly what I want to achieve, however I can
    > not get the code to work.
    >
    > I suspect the prob is in the I/O definitions , Device Address or
    > I2CPIN area. Is my problem to do with using AUXIO p15 and 14?
    > The N&V example use only pin p0. Not sure how that works with SDA
    and
    > SCL?
    >
    > I would appreciate any advise.
    >
    > Thanks
    > Ken
    >
    >
    > 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-12-26 05:37
    Thanks Peter,

    I have changed the SDA pin to AUXIO8 and SLC to AUXIO9.

    What is the based ID $70. Where do I insert that into my code?
    ' {$STAMP BS2p}
    '{$PORT COM1}

    auxio
    I2Cpin CON 8
    result var byte

    Loop

    I2CIN I2Cpin,???,???, [noparse][[/noparse]result]

    DEBUG "Bits=... ", (", bin result ")

    Pause 2000
    Goto loop


    What do I insert for ???

    Should this not display a 0 or 1 depending on the input state.

    Any suggestions?

    Ken

    --- In basicstamps@yahoogroups.com, "peter verkaik"
    <peterverkaik@b...> wrote:
    > Ken,
    >
    > You can use P0/P1, P8/P9, aux P0/P1 and aux P8/P9 with the builtin
    i2c
    > commands.
    > Other pins can be used but then you must program the I2C routines
    yourself,
    > as you must when using the stamp 2, 2se or 2sx. The stamp 2p has
    builtin
    > commands
    > for i2c and therefore preferable. Btw, did you use the correct base
    id for
    > the PCF8574A?
    > The PCF8574 has base id $40, the PCF8574A has base id $70.
    >
    > Regards peter
    >
    >
    >
    >
    Oorspronkelijk bericht
    > Van: digdul2002 <jduldig@s...> [noparse][[/noparse]mailto:jduldig@s...]
    > Verzonden: woensdag 25 december 2002 18:22
    > Aan: basicstamps@yahoogroups.com
    > Onderwerp: [noparse][[/noparse]basicstamps] Re: i2c probs
    >
    > Thanks Peter,
    > Much appreciated.
    >
    > So it sounds like ONLY P0 and P1 or AUXIO P0/P1 can be used for I2c.
    >
    > No other pins can be setup to work?
    >
    > Thanks.
    >
    > Ken
    >
    > --- In basicstamps@yahoogroups.com, "peter verkaik"
    > <peterverkaik@b...> wrote:
    > > Hi Ken,
    > >
    > > The bs2p has builtin commands I2CIN and I2COUT but these operate
    on
    > either
    > > P0=SDA and P1=SCL or P8=SDA and P9=SCL. Other pins are not
    supported
    > > by the I2C commands. Also don't forget to use the AUXIO command if
    > you use
    > > the
    > > auxiliary P0/P1 or P8/P9. The manual has several examples using
    > I2CIN and
    > > I2COUT.
    > >
    > > I hope this resolves your problem.
    > > Regards peter
    > >
    > >
    > >
    Oorspronkelijk bericht
    > > Van: digdul2002 <jduldig@s...> [noparse][[/noparse]mailto:jduldig@s...]
    > > Verzonden: woensdag 25 december 2002 16:38
    > > Aan: basicstamps@yahoogroups.com
    > > Onderwerp: [noparse][[/noparse]basicstamps] i2c probs
    > >
    > > Hi BS2p fans.
    > >
    > > I am hoping for some assistance in getting my bs2p to talk to a
    > > series of 8574A I2C chips I have connected. I have checked all
    > > connections and they look OK. I just can not seem to communicate
    > with
    > > the devices.
    > >
    > > I have connected SDA to AUXIO p15 and SCA to AUXIO p14. (Im am
    using
    > > a BS2P/40.
    > >
    > > I have connected pins 1,2 and 3 of the first 8574A to ground. I
    > > assume this is address 0. The remaining two chips have individual
    > > addresses.
    > >
    > > I would like to read and display the status of inputs on each of
    the
    > > three 8574A ICs.
    > >
    > > Can anyone help with some simple code?
    > >
    > > Are there any reference sites you can direct me to for examples of
    > > I2C code for the BSP2/40?
    > >
    > > I have reviewed the publication on Nuts and Volts (vol 3) re
    > > expanding I/O. This is exactly what I want to achieve, however I
    can
    > > not get the code to work.
    > >
    > > I suspect the prob is in the I/O definitions , Device Address or
    > > I2CPIN area. Is my problem to do with using AUXIO p15 and 14?
    > > The N&V example use only pin p0. Not sure how that works with SDA
    > and
    > > SCL?
    > >
    > > I would appreciate any advise.
    > >
    > > Thanks
    > > Ken
    > >
    > >
    > > 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/
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-26 10:01
    Hi Ken,

    The bs2p has builtin commands I2CIN and I2COUT but these operate on either
    P0=SDA and P1=SCL or P8=SDA and P9=SCL. Other pins are not supported
    by the I2C commands. Also don't forget to use the AUXIO command if you use
    the
    auxiliary P0/P1 or P8/P9. The manual has several examples using I2CIN and
    I2COUT.

    I hope this resolves your problem.
    Regards peter


    Oorspronkelijk bericht
    Van: digdul2002 <jduldig@s...> [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=XfmeZxlW4lo63VicvypiMDB8NO9g-en-9dNLSQjcC7fSrNxS4YQUmEvSWmMsCQX9sTK5B0x1tJJ9zw]jduldig@s...[/url
    Verzonden: woensdag 25 december 2002 16:38
    Aan: basicstamps@yahoogroups.com
    Onderwerp: [noparse][[/noparse]basicstamps] i2c probs

    Hi BS2p fans.

    I am hoping for some assistance in getting my bs2p to talk to a
    series of 8574A I2C chips I have connected. I have checked all
    connections and they look OK. I just can not seem to communicate with
    the devices.

    I have connected SDA to AUXIO p15 and SCA to AUXIO p14. (Im am using
    a BS2P/40.

    I have connected pins 1,2 and 3 of the first 8574A to ground. I
    assume this is address 0. The remaining two chips have individual
    addresses.

    I would like to read and display the status of inputs on each of the
    three 8574A ICs.

    Can anyone help with some simple code?

    Are there any reference sites you can direct me to for examples of
    I2C code for the BSP2/40?

    I have reviewed the publication on Nuts and Volts (vol 3) re
    expanding I/O. This is exactly what I want to achieve, however I can
    not get the code to work.

    I suspect the prob is in the I/O definitions , Device Address or
    I2CPIN area. Is my problem to do with using AUXIO p15 and 14?
    The N&V example use only pin p0. Not sure how that works with SDA and
    SCL?

    I would appreciate any advise.

    Thanks
    Ken


    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-12-26 11:40
    Ken,

    You can use P0/P1, P8/P9, aux P0/P1 and aux P8/P9 with the builtin i2c
    commands.
    Other pins can be used but then you must program the I2C routines yourself,
    as you must when using the stamp 2, 2se or 2sx. The stamp 2p has builtin
    commands
    for i2c and therefore preferable. Btw, did you use the correct base id for
    the PCF8574A?
    The PCF8574 has base id $40, the PCF8574A has base id $70.

    Regards peter



    Oorspronkelijk bericht
    Van: digdul2002 <jduldig@s...> [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=mt9RcnO2GyYXBJVnUOJTvtLWlcJnFgldk0BodHhKwLs6mxf5HojurdlPqUBgl0CcIMOpr-bNt3JSVk4Ztfc]jduldig@s...[/url
    Verzonden: woensdag 25 december 2002 18:22
    Aan: basicstamps@yahoogroups.com
    Onderwerp: [noparse][[/noparse]basicstamps] Re: i2c probs

    Thanks Peter,
    Much appreciated.

    So it sounds like ONLY P0 and P1 or AUXIO P0/P1 can be used for I2c.

    No other pins can be setup to work?

    Thanks.

    Ken

    --- In basicstamps@yahoogroups.com, "peter verkaik"
    <peterverkaik@b...> wrote:
    > Hi Ken,
    >
    > The bs2p has builtin commands I2CIN and I2COUT but these operate on
    either
    > P0=SDA and P1=SCL or P8=SDA and P9=SCL. Other pins are not supported
    > by the I2C commands. Also don't forget to use the AUXIO command if
    you use
    > the
    > auxiliary P0/P1 or P8/P9. The manual has several examples using
    I2CIN and
    > I2COUT.
    >
    > I hope this resolves your problem.
    > Regards peter
    >
    >
    >
    Oorspronkelijk bericht
    > Van: digdul2002 <jduldig@s...> [noparse][[/noparse]mailto:jduldig@s...]
    > Verzonden: woensdag 25 december 2002 16:38
    > Aan: basicstamps@yahoogroups.com
    > Onderwerp: [noparse][[/noparse]basicstamps] i2c probs
    >
    > Hi BS2p fans.
    >
    > I am hoping for some assistance in getting my bs2p to talk to a
    > series of 8574A I2C chips I have connected. I have checked all
    > connections and they look OK. I just can not seem to communicate
    with
    > the devices.
    >
    > I have connected SDA to AUXIO p15 and SCA to AUXIO p14. (Im am using
    > a BS2P/40.
    >
    > I have connected pins 1,2 and 3 of the first 8574A to ground. I
    > assume this is address 0. The remaining two chips have individual
    > addresses.
    >
    > I would like to read and display the status of inputs on each of the
    > three 8574A ICs.
    >
    > Can anyone help with some simple code?
    >
    > Are there any reference sites you can direct me to for examples of
    > I2C code for the BSP2/40?
    >
    > I have reviewed the publication on Nuts and Volts (vol 3) re
    > expanding I/O. This is exactly what I want to achieve, however I can
    > not get the code to work.
    >
    > I suspect the prob is in the I/O definitions , Device Address or
    > I2CPIN area. Is my problem to do with using AUXIO p15 and 14?
    > The N&V example use only pin p0. Not sure how that works with SDA
    and
    > SCL?
    >
    > I would appreciate any advise.
    >
    > Thanks
    > Ken
    >
    >
    > 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/
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-26 16:43
    Ken,

    The id for a i2c device is made of a fixed part (the base id), an address
    part that correspond to
    the address pins on the device (pins 1-3 for the PCF8574A) and a read/write
    bit. The R/W bit
    Is 0 for a writecommand and 1 for a readcommand.

    Id = baseid + (a2a1a0<<1) + RW
    For the PCF8574A with all address pins grounded:
    Id = $70 + (0<<1) + 0 = $70 'write command
    Id = $70 + (0<<1) + 1 = $71 'read command

    The I2C commands for the PCF8574A are
    I2CIN pin,id,[noparse][[/noparse]inputdata]
    I2COUT pin,id,[noparse][[/noparse]outputdata],
    where pin is 0 for i2c bus at P0/P1 or 8 for i2c bus at P8/P9
    To read a value from your PCF8574A at i2cbus P0/P1 into a bytevariable
    pcfread:
    I2CIN :0,$71,[noparse][[/noparse]pcfread]
    To write a value to your PCF8574A at i2cbus aux P8/P9::
    AUXIO
    I2COUT :8,$70,[noparse][[/noparse]$AA] 'outputs the value $AA (10101010 binary)

    The first ??? in your code is for the calculared id
    The second ??? is for an internal address. Eeproms do have internal
    addresses,
    the PCF8574A does not so you can leave it out.
    I hope this makes it clear to you.

    Regards peter



    Oorspronkelijk bericht
    Van: digdul2002 <jduldig@s...> [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=y5AT6RImmahkdIa-46h1QbpKHSO1aUjAI3zcZlEY3A_2WvtdUmVwumA8Gfkk7w2--TeGiAb_7Nrlr6A7]jduldig@s...[/url
    Verzonden: woensdag 25 december 2002 21:38
    Aan: basicstamps@yahoogroups.com
    Onderwerp: [noparse][[/noparse]basicstamps] Re: i2c probs

    Thanks Peter,

    I have changed the SDA pin to AUXIO8 and SLC to AUXIO9.

    What is the based ID $70. Where do I insert that into my code?
    ' {$STAMP BS2p}
    '{$PORT COM1}

    auxio
    I2Cpin CON 8
    result var byte

    Loop

    I2CIN I2Cpin,???,???, [noparse][[/noparse]result]

    DEBUG "Bits=... ", (", bin result ")

    Pause 2000
    Goto loop


    What do I insert for ???

    Should this not display a 0 or 1 depending on the input state.

    Any suggestions?

    Ken

    --- In basicstamps@yahoogroups.com, "peter verkaik"
    <peterverkaik@b...> wrote:
    > Ken,
    >
    > You can use P0/P1, P8/P9, aux P0/P1 and aux P8/P9 with the builtin
    i2c
    > commands.
    > Other pins can be used but then you must program the I2C routines
    yourself,
    > as you must when using the stamp 2, 2se or 2sx. The stamp 2p has
    builtin
    > commands
    > for i2c and therefore preferable. Btw, did you use the correct base
    id for
    > the PCF8574A?
    > The PCF8574 has base id $40, the PCF8574A has base id $70.
    >
    > Regards peter
    >
    >
    >
    >
    Oorspronkelijk bericht
    > Van: digdul2002 <jduldig@s...> [noparse][[/noparse]mailto:jduldig@s...]
    > Verzonden: woensdag 25 december 2002 18:22
    > Aan: basicstamps@yahoogroups.com
    > Onderwerp: [noparse][[/noparse]basicstamps] Re: i2c probs
    >
    > Thanks Peter,
    > Much appreciated.
    >
    > So it sounds like ONLY P0 and P1 or AUXIO P0/P1 can be used for I2c.
    >
    > No other pins can be setup to work?
    >
    > Thanks.
    >
    > Ken
    >
    > --- In basicstamps@yahoogroups.com, "peter verkaik"
    > <peterverkaik@b...> wrote:
    > > Hi Ken,
    > >
    > > The bs2p has builtin commands I2CIN and I2COUT but these operate
    on
    > either
    > > P0=SDA and P1=SCL or P8=SDA and P9=SCL. Other pins are not
    supported
    > > by the I2C commands. Also don't forget to use the AUXIO command if
    > you use
    > > the
    > > auxiliary P0/P1 or P8/P9. The manual has several examples using
    > I2CIN and
    > > I2COUT.
    > >
    > > I hope this resolves your problem.
    > > Regards peter
    > >
    > >
    > >
    Oorspronkelijk bericht
    > > Van: digdul2002 <jduldig@s...> [noparse][[/noparse]mailto:jduldig@s...]
    > > Verzonden: woensdag 25 december 2002 16:38
    > > Aan: basicstamps@yahoogroups.com
    > > Onderwerp: [noparse][[/noparse]basicstamps] i2c probs
    > >
    > > Hi BS2p fans.
    > >
    > > I am hoping for some assistance in getting my bs2p to talk to a
    > > series of 8574A I2C chips I have connected. I have checked all
    > > connections and they look OK. I just can not seem to communicate
    > with
    > > the devices.
    > >
    > > I have connected SDA to AUXIO p15 and SCA to AUXIO p14. (Im am
    using
    > > a BS2P/40.
    > >
    > > I have connected pins 1,2 and 3 of the first 8574A to ground. I
    > > assume this is address 0. The remaining two chips have individual
    > > addresses.
    > >
    > > I would like to read and display the status of inputs on each of
    the
    > > three 8574A ICs.
    > >
    > > Can anyone help with some simple code?
    > >
    > > Are there any reference sites you can direct me to for examples of
    > > I2C code for the BSP2/40?
    > >
    > > I have reviewed the publication on Nuts and Volts (vol 3) re
    > > expanding I/O. This is exactly what I want to achieve, however I
    can
    > > not get the code to work.
    > >
    > > I suspect the prob is in the I/O definitions , Device Address or
    > > I2CPIN area. Is my problem to do with using AUXIO p15 and 14?
    > > The N&V example use only pin p0. Not sure how that works with SDA
    > and
    > > SCL?
    > >
    > > I would appreciate any advise.
    > >
    > > Thanks
    > > Ken
    > >
    > >
    > > 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/


    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-12-26 17:13
    Ken,

    The : in the I2C commands is obviously a typo error.
    Just remove it.
    Your debug statement should be
    debug "bits...", bin result,cr 'cr gives a carriage return

    Regards peter


    Oorspronkelijk bericht
    Van: digdul2002 <jduldig@s...> [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=xSC7ZaCkSiv3o6I65XbikAObBBEECs07AthsstUou2F3w1-BNzzyca4LF9AVoIGKOHnMCuduLrI1AQ]jduldig@s...[/url
    Verzonden: woensdag 25 december 2002 21:38
    Aan: basicstamps@yahoogroups.com
    Onderwerp: [noparse][[/noparse]basicstamps] Re: i2c probs

    Thanks Peter,

    I have changed the SDA pin to AUXIO8 and SLC to AUXIO9.

    What is the based ID $70. Where do I insert that into my code?
    ' {$STAMP BS2p}
    '{$PORT COM1}

    auxio
    I2Cpin CON 8
    result var byte

    Loop

    I2CIN I2Cpin,???,???, [noparse][[/noparse]result]

    DEBUG "Bits=... ", (", bin result ")

    Pause 2000
    Goto loop


    What do I insert for ???

    Should this not display a 0 or 1 depending on the input state.

    Any suggestions?

    Ken

    --- In basicstamps@yahoogroups.com, "peter verkaik"
    <peterverkaik@b...> wrote:
    > Ken,
    >
    > You can use P0/P1, P8/P9, aux P0/P1 and aux P8/P9 with the builtin
    i2c
    > commands.
    > Other pins can be used but then you must program the I2C routines
    yourself,
    > as you must when using the stamp 2, 2se or 2sx. The stamp 2p has
    builtin
    > commands
    > for i2c and therefore preferable. Btw, did you use the correct base
    id for
    > the PCF8574A?
    > The PCF8574 has base id $40, the PCF8574A has base id $70.
    >
    > Regards peter
    >
    >
    >
    >
    Oorspronkelijk bericht
    > Van: digdul2002 <jduldig@s...> [noparse][[/noparse]mailto:jduldig@s...]
    > Verzonden: woensdag 25 december 2002 18:22
    > Aan: basicstamps@yahoogroups.com
    > Onderwerp: [noparse][[/noparse]basicstamps] Re: i2c probs
    >
    > Thanks Peter,
    > Much appreciated.
    >
    > So it sounds like ONLY P0 and P1 or AUXIO P0/P1 can be used for I2c.
    >
    > No other pins can be setup to work?
    >
    > Thanks.
    >
    > Ken
    >
    > --- In basicstamps@yahoogroups.com, "peter verkaik"
    > <peterverkaik@b...> wrote:
    > > Hi Ken,
    > >
    > > The bs2p has builtin commands I2CIN and I2COUT but these operate
    on
    > either
    > > P0=SDA and P1=SCL or P8=SDA and P9=SCL. Other pins are not
    supported
    > > by the I2C commands. Also don't forget to use the AUXIO command if
    > you use
    > > the
    > > auxiliary P0/P1 or P8/P9. The manual has several examples using
    > I2CIN and
    > > I2COUT.
    > >
    > > I hope this resolves your problem.
    > > Regards peter
    > >
    > >
    > >
    Oorspronkelijk bericht
    > > Van: digdul2002 <jduldig@s...> [noparse][[/noparse]mailto:jduldig@s...]
    > > Verzonden: woensdag 25 december 2002 16:38
    > > Aan: basicstamps@yahoogroups.com
    > > Onderwerp: [noparse][[/noparse]basicstamps] i2c probs
    > >
    > > Hi BS2p fans.
    > >
    > > I am hoping for some assistance in getting my bs2p to talk to a
    > > series of 8574A I2C chips I have connected. I have checked all
    > > connections and they look OK. I just can not seem to communicate
    > with
    > > the devices.
    > >
    > > I have connected SDA to AUXIO p15 and SCA to AUXIO p14. (Im am
    using
    > > a BS2P/40.
    > >
    > > I have connected pins 1,2 and 3 of the first 8574A to ground. I
    > > assume this is address 0. The remaining two chips have individual
    > > addresses.
    > >
    > > I would like to read and display the status of inputs on each of
    the
    > > three 8574A ICs.
    > >
    > > Can anyone help with some simple code?
    > >
    > > Are there any reference sites you can direct me to for examples of
    > > I2C code for the BSP2/40?
    > >
    > > I have reviewed the publication on Nuts and Volts (vol 3) re
    > > expanding I/O. This is exactly what I want to achieve, however I
    can
    > > not get the code to work.
    > >
    > > I suspect the prob is in the I/O definitions , Device Address or
    > > I2CPIN area. Is my problem to do with using AUXIO p15 and 14?
    > > The N&V example use only pin p0. Not sure how that works with SDA
    > and
    > > SCL?
    > >
    > > I would appreciate any advise.
    > >
    > > Thanks
    > > Ken
    > >
    > >
    > > 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/


    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-12-27 05:22
    Hi Peter,

    Thanks for your assistance re my I2C prob. All is fine now. The two issues
    were with the dedicated pins on the BS2P 40 and the base ID of the 8574A.
    Both of these items I was unaware of. (particularly the based ID)

    Sorry to bother you. This will be the last time. Have you any ideas how I
    can reference the incoming DEC iobyte from the I2C chip, to particular
    output. Such as:

    (this argument does not work by the way) "if dec iobyte = 254 then output
    1" (assuming output 1 is a subroutine that turns on relay 1 connected to the
    BS2). For some reason the "if then" statement doesn't like "dec" or "bin".

    Do I need to use a Lookup table of the various dec values which relate to
    each input from the I2C chip?

    I will understand if you choose not to reply. Thanks for your help so far.
    I appreciate it.

    Ken.


    Original Message
    From: peter verkaik [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=wO9yNq-BGd9v0i64xemiS5OU_vcOwUhPTWvv9Zx6WYBPmflUiVE-EUAjINvIOtD4zUP9pWR0cx52iJTa-88AYdOqhA]peterverkaik@b...[/url
    Sent: Friday, 27 December 2002 3:43 AM
    To: basicstamps@yahoogroups.com
    Subject: RE: [noparse][[/noparse]basicstamps] Re: i2c probs


    Ken,

    The : in the I2C commands is obviously a typo error.
    Just remove it.
    Your debug statement should be
    debug "bits...", bin result,cr 'cr gives a carriage return

    Regards peter


    Oorspronkelijk bericht
    Van: digdul2002 <jduldig@s...> [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=yf_ALeMtsCFE77WQ8VWPEHGGFYIqCft0-Ods12bQYsEFSs3PWyTMvpbgfpmwrwdwlRhY-ahJr27ni7crFg]jduldig@s...[/url
    Verzonden: woensdag 25 december 2002 21:38
    Aan: basicstamps@yahoogroups.com
    Onderwerp: [noparse][[/noparse]basicstamps] Re: i2c probs

    Thanks Peter,

    I have changed the SDA pin to AUXIO8 and SLC to AUXIO9.

    What is the based ID $70. Where do I insert that into my code?
    ' {$STAMP BS2p}
    '{$PORT COM1}

    auxio
    I2Cpin CON 8
    result var byte

    Loop

    I2CIN I2Cpin,???,???, [noparse][[/noparse]result]

    DEBUG "Bits=... ", (", bin result ")

    Pause 2000
    Goto loop


    What do I insert for ???

    Should this not display a 0 or 1 depending on the input state.

    Any suggestions?

    Ken

    --- In basicstamps@yahoogroups.com, "peter verkaik"
    <peterverkaik@b...> wrote:
    > Ken,
    >
    > You can use P0/P1, P8/P9, aux P0/P1 and aux P8/P9 with the builtin
    i2c
    > commands.
    > Other pins can be used but then you must program the I2C routines
    yourself,
    > as you must when using the stamp 2, 2se or 2sx. The stamp 2p has
    builtin
    > commands
    > for i2c and therefore preferable. Btw, did you use the correct base
    id for
    > the PCF8574A?
    > The PCF8574 has base id $40, the PCF8574A has base id $70.
    >
    > Regards peter
    >
    >
    >
    >
    Oorspronkelijk bericht
    > Van: digdul2002 <jduldig@s...> [noparse][[/noparse]mailto:jduldig@s...]
    > Verzonden: woensdag 25 december 2002 18:22
    > Aan: basicstamps@yahoogroups.com
    > Onderwerp: [noparse][[/noparse]basicstamps] Re: i2c probs
    >
    > Thanks Peter,
    > Much appreciated.
    >
    > So it sounds like ONLY P0 and P1 or AUXIO P0/P1 can be used for I2c.
    >
    > No other pins can be setup to work?
    >
    > Thanks.
    >
    > Ken
    >
    > --- In basicstamps@yahoogroups.com, "peter verkaik"
    > <peterverkaik@b...> wrote:
    > > Hi Ken,
    > >
    > > The bs2p has builtin commands I2CIN and I2COUT but these operate
    on
    > either
    > > P0=SDA and P1=SCL or P8=SDA and P9=SCL. Other pins are not
    supported
    > > by the I2C commands. Also don't forget to use the AUXIO command if
    > you use
    > > the
    > > auxiliary P0/P1 or P8/P9. The manual has several examples using
    > I2CIN and
    > > I2COUT.
    > >
    > > I hope this resolves your problem.
    > > Regards peter
    > >
    > >
    > >
    Oorspronkelijk bericht
    > > Van: digdul2002 <jduldig@s...> [noparse][[/noparse]mailto:jduldig@s...]
    > > Verzonden: woensdag 25 december 2002 16:38
    > > Aan: basicstamps@yahoogroups.com
    > > Onderwerp: [noparse][[/noparse]basicstamps] i2c probs
    > >
    > > Hi BS2p fans.
    > >
    > > I am hoping for some assistance in getting my bs2p to talk to a
    > > series of 8574A I2C chips I have connected. I have checked all
    > > connections and they look OK. I just can not seem to communicate
    > with
    > > the devices.
    > >
    > > I have connected SDA to AUXIO p15 and SCA to AUXIO p14. (Im am
    using
    > > a BS2P/40.
    > >
    > > I have connected pins 1,2 and 3 of the first 8574A to ground. I
    > > assume this is address 0. The remaining two chips have individual
    > > addresses.
    > >
    > > I would like to read and display the status of inputs on each of
    the
    > > three 8574A ICs.
    > >
    > > Can anyone help with some simple code?
    > >
    > > Are there any reference sites you can direct me to for examples of
    > > I2C code for the BSP2/40?
    > >
    > > I have reviewed the publication on Nuts and Volts (vol 3) re
    > > expanding I/O. This is exactly what I want to achieve, however I
    can
    > > not get the code to work.
    > >
    > > I suspect the prob is in the I/O definitions , Device Address or
    > > I2CPIN area. Is my problem to do with using AUXIO p15 and 14?
    > > The N&V example use only pin p0. Not sure how that works with SDA
    > and
    > > SCL?
    > >
    > > I would appreciate any advise.
    > >
    > > Thanks
    > > Ken
    > >
    > >
    > > 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/


    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/
  • ArchiverArchiver Posts: 46,084
    edited 2002-12-27 05:45
    Numbers in the BASIC Stamp are treated as decimal, so you don't have to
    specify the DEC formatter. This is only needed when you are converting
    numbers for serial output (SEROUT, DEBUG, etc.) where their ASCII
    representations are desired.

    Just do this:

    IF (ioByte = 254) THEN Relay_1_On

    Remember that in this version of PBASIC (2.0), IF-THEN jumps to the target
    address when the condition is true. In about a month we'll release version
    2.5 of the language that will let you use IF-THEN-ELSE and SELECT-CASE (which
    may be useful for your application).

    -- Jon Williams
    -- Parallax


    In a message dated 12/26/2002 11:23:19 PM Central Standard Time,
    jduldig@s... writes:

    > (this argument does not work by the way) "if dec iobyte = 254 then output
    > 1" (assuming output 1 is a subroutine that turns on relay 1 connected to
    > the
    > BS2). For some reason the "if then" statement doesn't like "dec" or "bin".



    [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.