I2C Slave support in SX/B
Tony Leyland
Posts: 71
Hi,
I like I2C support in SX/B. Does anyone know if commands will be developed for a I2C Slave environment ? I ask this
as several of my projects involve connecting SXs together on a common I2C bus and having one as the Master with
others as Slaves.
Many thanks in advance,
Tony
I like I2C support in SX/B. Does anyone know if commands will be developed for a I2C Slave environment ? I ask this
as several of my projects involve connecting SXs together on a common I2C bus and having one as the Master with
others as Slaves.
Many thanks in advance,
Tony
Comments
Take a look at http://www.parallax.com/dl/src/prod/sx/i2cs.zip·for code·for a virtual peripheral·I2C slave (its written in assembly).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
· A I2C slave device must be "listening" at all times. So you can't really make a "command" to do I2C slave. It's something that has to be written into your program. And as Paul has stated, an interrupt would be the easiest way to to it.
· If it's just for SX to SX communication, I would think serial would be much easier to implement.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
Available now... SX-Video OSD module $59.95 www.sxvm.com
"Save your money. Pay with cash."
·
Serial would be a protocol for one SX to one SX. If however, you need some serious DISTANCE, and want to communicate with multiple SX mcu's (as in one master, many slaves), consider RS-485. I'm experimenting with some SN75176 chips (about $0.60 ea) and they seem simple enough to get a signal down a very long wire (spec says you can go up to over 4000 feet in some conditions and over 400Mbit/sec on shorter runs).
I'd highly recommend Jan Axelson's "Serial Complete" book. She presents the topic very well and my copy is well worn from referencing it often.
Ditto on making it an interrupt. That's why I'm spending so much time learning how to use interrupts (see my dumb questions in other posts) as they are the secret to getting mcu's to communicate efficiently.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John J. Couture
San Diego Miramar College
Did you say RS-485 at 400 Mbits/Sec with a 75176?
That's unbelievably fast. Please point us to where THAT can be found.
My experience confirms a limit of about 10 Mbits/Sec., and at that rate for not many feet; a few hundred over twisted pair.
Cheers,
Peter (pjv)
PJV is quite correct in that 10Mbits/sec is the TIA/EIA-485 limit.
As atonement for my sins (grin), I offer the following datasheets:
·· http://www.maxim-ic.com/appnotes.cfm/appnote_number/643
····· which shows the the 10M rate good for short distances (chart)
···http://focus.ti.com/lit/ds/symlink/sn75176b.pdf
····· which is the chip I use.
·· http://www.arcelect.com/RS485_info_Tutorial.htm
····· a tutorial on RS-485
·· http://ckp.made-it.com/rs485.html
······a quick chart that shows
········· 100Kbps @ 4000' and
·········· 10Mbps @ 50'
And finally, the home page of RS-485
·· http://www.rs485.com
·· with its quick reference guide: http://www.rs485.com/rs485spec.html
I apologize for the·previously incorrect info before (grovel, grovel, grovel)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John J. Couture
San Diego Miramar College
I'm disappointed; here I thought we were going to have some really good new technology inexpensively available, although I would not know how to drive an SX to bit-bang at 400 Mbits/Sec. I believe we can bit-bang the Ubicom IP3000 at 100 Mbits/sec so will need to give that a try.
Oh, well....I guess, there "ain't no free lunch", and thanks for the links.
Regarding the distances at 10 Mbit/Sec, my experience is that rate is reliably attainable over 200 feet, and that with standard asynchronous coding. I expect Manchester will beahve a little better with it's "no-DC-component", but alas at half the bit rate. Someday when more time is available, I'll try to see what the actual non theoretical limits are.
Cheers,
Peter (pjv)
Post Edited (pjv) : 10/21/2005 3:25:55 PM GMT
Thanks for pointing me in the right direction, I now understand why 'Slave' commands do not exist in SX/B.
I'll have to make sure not to use any time-sensitive commands while I have the ISR running. Mind you, I
will be using RS232, so I'll need to add a VP for that as well.
With this project I have 1 master SX, 2 other slave SXs an EEPROM and an LCD module. They will all be
connected to either 1 or 2 I2C buses. The 2 slave SXs will behave like an EEPROM, so that the master
can write to or read from locations within each SX via I2C and thus control the slave SX in question.
Tony
Another chip I use is a PCF8583 Real Time Clock. This I2C device has 2K of RAM (yes I checked the datasheet this time, grin). The only external parts needed are a 32K crystal and a tiny 10pf capacitor.
They communicate over I2C and they seem to keep excellent time. I supply them with a battery backup power supply of 3volts (2 AAA's which means the batteries will die of old age) and run the clock off of the 5v most of the time.
The RAM part is interesting too. The RTC uses the first 16 bytes of ram but the rest is available to the programmer. Thus, I keep it supplied with 3 volts and, once set, it provides an excellent resource. I bought mine a while back for about $0.60 and I assume they are still available. These would be less expensive than an SX?? and have quite a bit more RAM. Or you could use your SX?? to gather the data and store the data in the RAM chip for all MCU's to use. Now you have a NETWORK! Fun stuff!
Datasheet:
http://www.semiconductors.philips.com/acrobat_download/datasheets/PCF8583_5.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John J. Couture
San Diego Miramar College
regards peter
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
real-time clock function and I can utilise the extra storage space.
Tony
It's not that I'm blind (grin), Its just that I'm not careful. Thank you for the catch. Next thing you know I'll be pluging my SX chip into 110Volts! Geez! I gotta slow down.
Paul, I ordered some samples, thank you for the lead.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John J. Couture
San Diego Miramar College