Shop OBEX P1 Docs P2 Docs Learn Events
Can I use I2C to interface two BS2P ? — Parallax Forums

Can I use I2C to interface two BS2P ?

LiveBotLiveBot Posts: 4
edited 2005-02-01 15:10 in BASIC Stamp
Hi everyone

Can I use I2C to interface two BS2P ?
It seams that it cannot be slave!

I have been searching thru the BS Archive, but found no solution.

What is the best way to establish coms between two BS2P then?

Can anyone point to me where to find some of the best code examples for Serial BS2P to BS2P comunication?

thanx a lot in·advance

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Comments

  • BeanBean Posts: 8,129
    edited 2005-01-25 00:06
    That's right the stamps must be the master, actually being the slave is much harder to code.

    Serial is probably the best.

    Bean.
  • achilles03achilles03 Posts: 247
    edited 2005-01-25 00:13
    You could do something like SPI pretty easily... it might require some code modification. On the receiving stamp, use one pin to act as the chipset (CS), and instead of using the shiftin command, monitor the "CLK" pin until it changes state, then read the data pin. You might have to slow down the info you're shifting in... maybe use code similar to the BS1's shiftout.

    You might be able to do something like this for I2C too...?


    Dave
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-01-25 00:54
    If you want to communicate Stamp-to-Stamp, serial (SEROUT and SERIN) is the most effective way to go. As indicated, the BS2p's I2C commands are master only.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • LiveBotLiveBot Posts: 4
    edited 2005-01-31 23:20
    Thanx Bean, Dave and Jon.

    Ok. Serial's fine.

    Maybe some day I'll try Dave's suggestion.

    What is the max speed assuming 2 BS2p40?

    I want the 1st BS to read data from the 2nd (or the 2nd to
    send data to the 1st)
    How can I use polling to sense the data sent by the other BS?
    Or do I just stand still waiting for the serin data to arrive?

    Can someone point out code examples?

    Thanx in advance

    Rui

    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-01-31 23:53
    Depends on whether you need flow control or not. The help file has an example of Stamp-to-Stamp communication using SEROUT/SERIN with flow-control.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • trendtrend Posts: 112
    edited 2005-02-01 06:03
    Correct me if I am wrong.. but I believe the big benefit of i2c is this is a bus.. and you can have multiple devices on this bus at the same time... (i think up to 254.. but don't quote me.. just remember it is a lot [noparse];)[/noparse] )
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-02-01 15:10
    That's the idea. Of course, you can have a serial bus as well. Using open baudmode schemes, you can drop a number of devices onto a single-wire serial bus; the only thing you have to do is design an addressing protocol that works for you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
Sign In or Register to comment.