Pages: [1]   Go Down
Author Topic: Can we extend Arduino I2C pins? More SDA and SLC Pins?  (Read 2422 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a topic discussing my issue with getting an Optical mouse Sensor and Compass to work on a single Arduino here: http://arduino.cc/forum/index.php/topic,55891.0.html

The topic above is under "Sensors". I am not trying to double post, but I believe I need project guidance. My expensive way to "extend" arduino I2C is to just using another arduino unfortunately, which is making my project too big. Here is my current solution to communicate with two I2C devices:



Any guidance or help is much appreciated.
« Last Edit: March 28, 2011, 12:54:07 pm by LucidGold » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8842
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Real I2C devices have addresses and can share the I2C bus.  Your problem is that one of your devices is "I2C-like" but is not I2C.  Replace the ADNS-2620 with a real I2C device or, as I recommended, the ADNS-3000 which uses SPI.

Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So using two arduinos is the only way to resolve this ASAP. It will take time to understand how ADNS-3000 would work, then I need to buy parts to have the complete mouse using ADNS-3000. Sparkfun has the breakout for ADNS2620, which is what I am using.

this sucks.
Logged

Portugal
Offline Offline
God Member
*****
Karma: 6
Posts: 962
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

WTF.
I2c uses addresses, in fact 7 bits of them so you can have up to 127 devices in a single i2c bus, you can also use bit banged i2c to talk to your mouse and use the real i2c to talk to the green board.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
WTF.

Senso:

Could you direct me to the right bit-bang method?

I tried to implement Software I2C for Hmc6352 Compass http://www.arduino.cc/playground/Learning/Hmc6352.

I have looked at:
-------------------------------------------
SoftI2CMaster:
-------------------------------------------
.CPP: http://blinkm-projects.googlecode.com/svn/trunk/blinkm_examples/arduino/BlinkMSoftI2CDemo/SoftI2CMaster.cpp
.H:  http://blinkm-projects.googlecode.com/svn/trunk/blinkm_examples/arduino/BlinkMSoftI2CDemo/SoftI2CMaster.h

I did not use this because there is no Software RECIEVE method.
-------------------------------------------
SoftTWI:
-------------------------------------------
.CPP: http://code.google.com/p/fivevolt/source/browse/Quadcopter/Arduino/Telemetry/SoftTWI.cpp
.H: http://code.google.com/p/fivevolt/source/browse/Quadcopter/Arduino/Telemetry/SoftTWI.h

Code compiles but I always get 0.00 degrees. I used A5 and A4 because using Wire.H through the same code (replace every "compass." with "Wire."), I am able to get compass data. However, when I switch to SoftTWI I get 0.00.

Code:
#include "SoftTWI.h"

SoftTWI compass;

void setup()
{
  Serial.begin(9600); // Initiate Serial
  compass.attach(A5, A4);
  compass.begin();
}
 
void loop(){
  compass.beginTransmission(0x21);
  compass.send(65);     // Send "Get Data" command, info from Datasheet
  delay(100);         // interface command delay, info from Datasheet
  compass.requestFrom(0x21, 2); //get the two data bytes, MSB and LSB
  byte MSB = compass.receive(); // Result will be in tenths of degrees (0 to 3599)
  byte LSB = compass.receive(); // Provided in binary format over two bytes."
  compass.endTransmission();
  // Compute result from the two bytes results
  float myres = ((MSB << 8) + LSB) / 10;
  // Display result
  Serial.print(myres);
  Serial.println(" degrees");
  delay(1000);
}

Any thoughts?
« Last Edit: March 28, 2011, 01:35:45 pm by LucidGold » Logged

Pages: [1]   Go Up
Jump to: