Pages: [1]   Go Down
Author Topic: [SOLVED] Cannot change SRF08 address  (Read 1011 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
I currently am trying to work with several SRF08 sensors (on an Arduino Uno), but in order to do so, I obviously have to change their addresses... but, although I follow the data-sheet's instructions, I can't get to do that.
Here is the code :

Code:
 Wire.begin();
  Wire.beginTransmission(Old_Address);
  Wire.send(0);
  Wire.send(0xA0);
  Wire.endTransmission();
  
  Wire.beginTransmission(Old_Address);
  Wire.send(0);
  Wire.send(0xAA);
  Wire.endTransmission();
  
  Wire.beginTransmission(Old_Address);
  Wire.send(0);
  Wire.send(0xA5);
  Wire.endTransmission();
  
  Wire.beginTransmission(Old_Address);
  Wire.send(0);
  Wire.send(New_Address);
  Wire.endTransmission();

I don't know what to do, I hope someone will be able to help. Thanks in advance.
« Last Edit: May 08, 2012, 04:16:57 pm by corn » Logged

Brunsbüttel, SH, F.Rep.GERM
Offline Offline
God Member
*****
Karma: 4
Posts: 596
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

it doesnt accept all addresses according to this:
http://www.robot-electronics.co.uk/htm/srf08tech.shtml
Logged

-Arne

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

For some reason it kinda worked. I tried to set an address to EE, and it was set to F7 instead... any idea why it occurred ? Though strictly speaking it doesn't matter to me as long as the address has changed, I'd like to know how this works. Maybe a bit is shifted.

Logged

Brunsbüttel, SH, F.Rep.GERM
Offline Offline
God Member
*****
Karma: 4
Posts: 596
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

oh - 0xF7 isnt a correct SRF08 address...

i guess,
that is because of 7bit I2C addresses:
0xF7 = B11110111
0xEE = B11101110
0xEE (8bit address) --right-shift--> B01110111 = 0x77

so i guess ur new 7bit I2C address is 0x77 (which is equal 0xF7 modulo 128)...  smiley
Logged

-Arne

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

Hm, addresses are supposed to range from E0 to FE though. And I know odd addresses aren't suppose to work, but they do.
Thanks for the help.
Logged

Brunsbüttel, SH, F.Rep.GERM
Offline Offline
God Member
*****
Karma: 4
Posts: 596
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

nope
there r 8bit I2C addresses and 7bit I2C addresses...

the arduino Wire library uses 7bit I2C addresses...
http://arduino.cc/it/Reference/Wire

and the SRF08 address programming interface uses 8bit I2C addresses...

u can convert them like this:
1. 7bit to 8bit: shift left by 1bit
2. 8bit to 7bit: shift right by 1bit

8bit range: E0..FE (just even numbers) --> 7bit range: 70..7F (all numbers)
« Last Edit: May 08, 2012, 03:31:40 pm by RIDDICK » Logged

-Arne

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

nope
there r 8bit I2C addresses and 7bit I2C addresses...

the arduino Wire library uses 7bit I2C addresses...
http://arduino.cc/it/Reference/Wire
Thank you very much, I feel stupid for not noticing that.
Logged

Brunsbüttel, SH, F.Rep.GERM
Offline Offline
God Member
*****
Karma: 4
Posts: 596
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i think it is normal that one (esp. a learner) misses some tiny detail...
most important is, that u mentioned that something went wrong, and that u hunted for an explanation...
in ur 2nd post u already had the right idea ("Maybe a bit is shifted.")...
Logged

-Arne

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

Yep. Well now that I've understood that I'll have a good deal less problems working with them. Thanks again.
Logged

Pages: [1]   Go Up
Jump to: