Go Down

Topic: [SOLVED] Cannot change SRF08 address (Read 1 time) previous topic - next topic

corn

May 08, 2012, 05:22 pm Last Edit: May 08, 2012, 11:16 pm by corn Reason: 1
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: [Select]
 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.

RIDDICK

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

corn

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.


RIDDICK

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)...  :)
-Arne

corn

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.

RIDDICK

#5
May 08, 2012, 10:29 pm Last Edit: May 08, 2012, 10:31 pm by RIDDICK Reason: 1
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)
-Arne

corn


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.

RIDDICK

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.")...
-Arne

corn

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

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy