Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumWiring HardwareTroubleshooting › I2C .... bits?

Page Index Toggle Pages: 1
I2C .... bits? (Read 7910 times)
10/19/08 at 15:06:48

Kars   Offline
YaBB Newbies
Team Vossius
Amsterdam

Posts: 19
*
 
Hi all,

After playing with some I2C deviceas, and not knowing why it didn't work, I started searching.
The beginTransmission() explaination page(http://www.wiring.org.co/learning/libraries/Wire/Wire_beginTransmission_.html)  says:

address =An int value between 0 and 127 specifying the address of the device to trasmit to (BTW, there's a typo there, it should be transmit  Wink )

BUT! My device uses the adress: 0xC0 which is 192. So therefor it is not working!
Could the I2C be 8 bits instead of 7 bits?

Or is there an other option?(we can only change the adress to C2/C4/C6, not lower)

Thanks,

Kars
 

Buildig the same as Titus ^^
IP Logged
 
Reply #1 - 10/19/08 at 17:36:23

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
hey Kars, thanks, yes the Wire library uses a 0-127 address, please check this example: http://wiring.org.co/learning/examples/HMC6352sparkfun.html
In there you´ll find the device address is shifted :

int compassAddress = 0x42 >> 1;  // From datasheet compass address is 0x42
                                // shift the address 1 bit right, the Wire library only needs the 7
                                // most significant bits for the address
 
IP Logged
 
Reply #2 - 10/21/08 at 07:14:23

Titus   Offline
Full Member
Wiring Soccer Robot!
Amsterdam

Posts: 176
***
 
So just setting it to 0x60 would work too?

0xC0=12*16
>>
12/2*16=6*16=0x60?
 

Check www.TeamVossius.nl for our Autonomous soccer robots!
IP Logged
 
Reply #3 - 10/22/08 at 02:52:10

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
just do it this way:
int address = 0xC0 >> 1;

that´s all, now address contains the right address to use.

Wire.beginTransmission(address);


H.
 
IP Logged
 
Reply #4 - 10/22/08 at 13:40:31

Titus   Offline
Full Member
Wiring Soccer Robot!
Amsterdam

Posts: 176
***
 
Hi all,

We got a strange thing going on:
We ask a sensor over I2C to return something.
BUT even when nothing is connected to the I2C pins, we get the same value as sent.

here's our code:

Code:
# define SENSORADDRESS 0x27
# define RESULTREGISTER 0x24

#include <TwoWire.h>

void setup()
{
  Wire.begin();
  Serial.begin(9600);
}

void loop()
{
  Serial.print(Cball());
  Serial.print(" ");
  delay(350);
}


int Cball()
{
  Wire.beginTransmission(SENSORADDRESS);
  Wire.send(RESULTREGISTER);
  Wire.endTransmission();    

  Wire.requestFrom(SENSORADDRESS, 1);
   while (Wire.available() < 1 )   {
    // wait for result
  }
  return Wire.receive();
}
 



So the RESULTREGISTER is the value returned, no matter what SENSORADRESS we take, or what RESULTREGISTER, or connect I2C devices.

Please help!!

Titus(and Kars)
 

Check www.TeamVossius.nl for our Autonomous soccer robots!
IP Logged
 
Reply #5 - 10/23/08 at 05:04:02

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
hey guys, could you post a datasheet or part number for the device you´re using?
 
IP Logged
 
Reply #6 - 10/23/08 at 09:09:58

Titus   Offline
Full Member
Wiring Soccer Robot!
Amsterdam

Posts: 176
***
 
Here it is:
http://www.quantumtorque.com/component/page,shop.product_details/category_id,9/flypage,flypage_tony/product_id,31/option,com_virtuemart/Itemid,26/

But even when that thing is not connected, wiring returns the same value as was sent. I will try to hook up the compass later this day, to see if that still works, otherwise it's wiring 17

I'll try wiring 16 btw.

Titus
 

Check www.TeamVossius.nl for our Autonomous soccer robots!
IP Logged
 
Reply #7 - 10/30/08 at 07:22:47

Titus   Offline
Full Member
Wiring Soccer Robot!
Amsterdam

Posts: 176
***
 
Well, I did try my CMPS03 Compass sensor today, didn't work as suspected. Strange.
I'll ask kars to test his compass with wiring 0017.
any idea?
 

Check www.TeamVossius.nl for our Autonomous soccer robots!
IP Logged
 
Reply #8 - 12/30/08 at 17:38:01

Titus   Offline
Full Member
Wiring Soccer Robot!
Amsterdam

Posts: 176
***
 
Got it working today!!!!!!
Actually a very stupid mistake:
we had << in stead of >>

....
 

Check www.TeamVossius.nl for our Autonomous soccer robots!
IP Logged
 
Page Index Toggle Pages: 1