Introduction: Connecting Two OOBoards Together Using I2C

This instructable covers how to connect two OOBoards using I2C.

Step 1: Connecting to the I2C Network Bus

There are two I2C busses on the OOBoards, a local bus, and a network bus.

The OOPIC code is essentially an interpreted
language, ie the "code" is stored in EEPROM, and read/interpreted by
the microprocessor in real time. The EEPROM uses the LOCAL I2C bus to
communicate with the microcontroller. If you were to look at this
local bus on the oscilloscope, you would see constant chatter. On the OOBoards
boards, the local bus is what is connected to the I2C connector, this
isn't necessarily what we want.

The NETWORK bus is usually the bus that is used to communicate with
other devices/oopics, on the OOBoards this bus does not have a
connector. In order to access this bus, you must solder wires to pins
42 and 37 of the microcontroller (marked N_SDA, N_SCL on the schematic
respectively).

Step 2: Add the Pullup Resistors

Once SDA and SCL connections are made on each processor, the two boards can
be linked together by connecting SDA to SDA, SCL to SCL, and
connecting a common ground wire between the boards. You will also need
a pull-up resistor on each line (i used 12k, but thats just what I had
lying around).

Note that you only need one pullup resistor per line for a total of two resistors (not 4).

Step 3: Program the Slave

Now that the physical connections are there, you will need to program the slave microcontroller. I added some code below that should get you started.

Dim SLAVE As New oDDELinkDim LED As New oDIO1Sub Main()	'set our I2C address to 2 (note, this must match the remote	'address we set in the master code)	ooPIC.Node = 2		'setup an LED	LED.IOLine = 5 	LED.Direction = cvOutput    	'now, link the output of our DDELink object to   	'the LED, and turn it on...now automagically, the LED will blink	SLAVE.Output.Link(LED)	SLAVE.Operate = cvTrueEnd Sub

Step 4: Program the Master

Finally, program the master microcontroller. Pay close attention to the lines that set the DDELink's .Location property: Unless this is set properly, this will NOT work!

Dim Master As New oDDELinkDim wire As New oWireDim hz1 As New oBitSub Main()		&apos;link the 1 second timer to the a bit we can access	&apos;this bit will now toggle once per second	wire.Input.Link(ooPIC.Hz1)	wire.Output.Link(hz1)	wire.Operate = cvTrue		&apos;this sets the I2C address of our local microcontroller	&apos;the I2C interface is not active until an address is set	ooPIC.Node = 1   	&apos;now we setup our DDELink object, our input is the bit hz1 	&apos;note that the object also has a .Output property that is used 	&apos;when we are in recieve mode	Master.Input.Link(hz1)		&apos;this is the I2C address of the remote microcontroller, note that	&apos;in the slave code, we tell it to have an address of 2	Master.Node = 2	&apos;ugh...this is the crappy part, this is the "address" of the DDELink	&apos;object in the slave&apos;s memory space. In order to figure out this number,	&apos;we need to open and compile the slave code, then goto View->Compiled Code.	&apos;look for something like:	&apos;L*.Construct.Begin ;Dim <name> as new oDDELink	&apos;where * is any number, and <name> is the name of your DDELink object	&apos;in your slave code. The line immediately below it should read something like:	&apos;C0020:041 ;This.<name>.Address	&apos;the number to the right of the &apos;:&apos; is the address of the slave DDELink object	Master.Location = 41	&apos;this tells the object that we will be sending data (ie, copy data from our .Input property	&apos;to the slaves .output property (note, if you set this to recieve, it is the opposite)	Master.Direction = cvSend	&apos;turn it on, but nothing is happening yet...	Master.Operate = cvTrue	Do		&apos;check to see if we are currently transmitting data		If Master.Transmitting = cvFalse Then			&apos;setting this value to 1 will cause the master to send the value to the slave			&apos;note, this is automatically reset to 0 upon completion of transmission			Master.Sync = 1		End If	LoopEnd Sub

Comments

author
chipper35 (author)2012-11-03

This is a HIGHLY specialized topic area. Thanks for contributing it, but I can't imagine that many people here would connect with this. We've got some smart people here, but this is very narrowly focused.

About This Instructable

2,267views

3favorites

License:

More by arsinio:Connecting two OOBoards together using I2CInterfacing a CMUCam2 to an OOPIC
Add instructable to: