Shop OBEX P1 Docs P2 Docs Learn Events
I2C On A BASIC Stamp? — Parallax Forums

I2C On A BASIC Stamp?

qummyqummy Posts: 16
edited 2006-02-21 15:05 in BASIC Stamp
hello all, i'm a beginner. i need to know is it possible to program software I2C( inter integrated circuit) using basic stamp.

Post Edited By Moderator (Jon Williams (Parallax)) : 1/19/2006 4:17:25 PM GMT

Comments

  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-01-19 16:13
    Yes, but you need one of the more recent Stamps to do it well. The BS24p works. Take a look at the Programming manual on-line for a good answer

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

    ······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-19 16:20
    You can, in fact, use the I2C protocol on any BS2-family Stamp.· If you have a BS2p-family module, I2C is built into the language.· If you have a BS2, BS2e, or BS2sx you can synthesize the protocol in code as the attached example (from StampWorks)·illustrates.

    Note -- make sure you add a subject title when you start a new thread so you'll get more responses (I fixed this thread for you).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-01-19 16:29
    I thought so. The I2C has the ability to slow down and wait. Still it is a lot easier to get started with pre-written code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

    ······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

    Post Edited (Kramer) : 1/21/2006 5:10:56 PM GMT
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-01-19 17:54
    A side note, the Stamp can be the master (the one initiating I2C commands) but cannot be a slave (receiving I2C commands).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • qummyqummy Posts: 16
    edited 2006-01-24 02:15
    This is regarding the Stampworks Experiment 32-I2C communication. Can u clarify how does the diagram works?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-24 03:47
    This is actually the simplest way to connect to a 24LC32 -- the address of the device is set to 0 (%000) by connecting lines A0-A2 to ground.· By the I2C specification, the SDA and SCL lines must be pulled up to Vdd; 4.7k is the typical value used.· After that it's a matter of "talking" to the chip per the I2C and chip specifications.· The I2C spec is HUGE document; perhaps this article I wrote for Nuts & Volts will shed some additional light on the subject.

    http://www.parallax.com/dl/docs/cols/nv/vol5/col/nv115.pdf

    At the beginning of StampWorks I suggest that one should download and study the part spec sheet before attempting an experiment (that's what we have to do an engineers) -- I've attached the 24LC32 docs for you to look at; it should also help you get going.

    Good luck, and have fun.· Once you get the hang of I2C you'll be happy as it is easy to use and there are a lot of neat parts that use the protocol.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • qummyqummy Posts: 16
    edited 2006-01-24 04:47
    okay..understood.

    the main purpose of this project is to connect between 2 basic stamp 2 modules. one will act as a master and another as slave. it will replicate a SCADA system(Supervisory Control Data Acquisition System).
    any idea on that?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-24 04:52
    Whoops... you can't do that with I2C as the BASIC Stamp only works as an I2C master, not a slave.· What you can do, though, is use serial, and you can even multi-drop it to have more than one BASIC Stamp slave.· If you are going with just one slave, you can use two wires and get flow control so the master doesn't attempt to send a command when the slave is busy.· Give this article a read:

    http://www.parallax.com/dl/docs/cols/nv/vol3/col/nv81.pdf

    This should get you going and allow you to have bi-directional comms between your Master and Slave Stamps.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • qummyqummy Posts: 16
    edited 2006-01-24 05:09
    Thank You Very Much Jon!
  • kelvin jameskelvin james Posts: 531
    edited 2006-01-25 06:43
    Just an add-on for anyone interested in the slave addressing for I2c ( more related to the bsp product ), there is not a lot of documentation on this, and what may be simple for some, sometimes is not for others. An " A " address comes from the preset address of the chip, the first 4 bits of the 7 bit address are 10100000, which converted to hex will give an A. The 8 th bit is used for read / write. To convert, open up windows calculator, set to scientific, set to byte, select bin, input binary number ( all 8 bits ), then select hex to convert. The next 3 bits are the user select addressing, if they are all wired to ground (0), then the address will still be A = 10100000. The fifth bit is A2, the sixth A1, and seventh A0. To change the address, one or a combination of A0, A1 and A2 are set high ( a one ), by connection to Vdd through a 4.7k resistor.
    Say a high is put on A0, the slave binary address will become 10100010, when converted to hex will become A2, the new address. Some chips use a different preset code address, check the specs.

    kelvin
  • qummyqummy Posts: 16
    edited 2006-02-09 05:28
    Okay, i got all the components ready for the master and slave experiment. just tht the diagram (fig 81.2) of
    nuts&volts 81 is not that clear.can u please clarify on it?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-02-09 16:18
    What's not clear about that diagram? All of the connections are shown. Have you attempted to hook it up?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • qummyqummy Posts: 16
    edited 2006-02-10 04:28
    Yes, i'm trying to hook it up. nevermind its clear now.
    Could u explain the communication protocol that is used in this experiment of connecting the two stamps.That is the most important question.TQVM.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-02-10 05:39
    That's all explained in the article -- it's all standard serial, using flow-control so that the slave Stamp can let the master Stamp know when it's ready for another command.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • qummyqummy Posts: 16
    edited 2006-02-19 09:25
    Jon, i'm having trouble to hook up the LCD display. the one that i have is BPI-216 serial LCD by seetron.
    which the connection is only involves, ser, Vss and 5V input. Could u please clarify?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-02-20 15:55
    Well, that just requires one pin (instead of seven as required by a parallel LCD); I'd connect it to P0 on the slave Stamp and then change out the parallel code for the SEROUT instructions used by the SEETRON LCD. Keep in mind you're making big changes to the circuit, so the article is of less use to you. If you can find a parallel LCD and use the code as presented, I think you'll be able to learn from it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • qummyqummy Posts: 16
    edited 2006-02-21 07:09
    I·found the root of the problem. my bs2 is·mounted on the Parallax Board of Education,Serial.
    which the 7pin connector is nowhere to be found.
    Let say if i get the parallel LCD, can it be connected to the board.
    Please help.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-02-21 15:05
    Sure -- I have several LCDs that I've soldered 22-guage solid wire to that allows me to plug them into a breadboard. If you want easy connections, you could get a Professional Development Board which has a socket for parallel LCDs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.