PDA

View Full Version : I2C On A BASIC Stamp?



qummy
01-20-2006, 12:09 AM
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

Loopy Byteloose
01-20-2006, 12:13 AM
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 [·黃鶴 ]·in Taiwan

Jon Williams
01-20-2006, 12:20 AM
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

Loopy Byteloose
01-20-2006, 12:29 AM
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 [·黃鶴 ]·in Taiwan

Post Edited (Kramer) : 1/21/2006 5:10:56 PM GMT

Paul Baker
01-20-2006, 01:54 AM
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

qummy
01-24-2006, 10:15 AM
This is regarding the Stampworks Experiment 32-I2C communication. Can u clarify how does the diagram works?

Jon Williams
01-24-2006, 11:47 AM
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

qummy
01-24-2006, 12:47 PM
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 Williams
01-24-2006, 12:52 PM
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

qummy
01-24-2006, 01:09 PM
Thank You Very Much Jon!

kelvin james
01-25-2006, 02:43 PM
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

qummy
02-09-2006, 01:28 PM
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 Williams
02-10-2006, 12:18 AM
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

qummy
02-10-2006, 12:28 PM
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 Williams
02-10-2006, 01:39 PM
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

qummy
02-19-2006, 05:25 PM
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 Williams
02-20-2006, 11:55 PM
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

qummy
02-21-2006, 03:09 PM
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 Williams
02-21-2006, 11:05 PM
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