Author Topic: I2C Addresses  (Read 3826 times)

0 Members and 1 Guest are viewing this topic.

Offline want2learnTopic starter

  • Robot Overlord
  • ****
  • Posts: 189
  • Helpful? 4
I2C Addresses
« on: January 10, 2009, 04:56:41 AM »
Hi,
I'm playing around with I2C, this isn't a problem with premade boards.
The thing is that designing and building the boards is where i find most of my enjoyment.

Say I build 2 motor controllers, a servo controller, a 'smart' power supply and a few sensors of differing types. How do I allocate an address to each board and where do i find what address should be allocated to each board.
The 2 motor boards pose a problem too as they should both have the same address right ???

I want to be able to use premade boards too should the need arise so would like as little conflicts as possible.

I've tried looking on this site for as much info as possible but can't find anything, sorry if i missed it.
I've tried google about a million different ways over the past week or so and cant find a device address list or anything.

Please bear in mind that I'm still trying to come to grips with programming so if this is going to be over my head just tell me (and make any programming comments as simple as you can for me please ;D).
The question that drives me hazy:

Am I, or the others crazy?

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: I2C Addresses
« Reply #1 on: January 10, 2009, 09:22:33 AM »
I'm no expert with I2C but I believe that each physical board needs to have a different address. A bit like having unique IP addresses for each computer on the network. This is necessary so that each board knows which messages are intended for it. Some 3rd party boards use jumpers or little blocks of switches to allow you to change the address for each board to a unique number. Then your main code just needs to know the address of each card.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline want2learnTopic starter

  • Robot Overlord
  • ****
  • Posts: 189
  • Helpful? 4
Re: I2C Addresses
« Reply #2 on: January 10, 2009, 09:37:59 AM »
Sorry I meant how do i find out which address should be assigned to which type of board.

I don't want my boards to conflict with boards that are already available. I Know there are 116 available addresses but you know how it goes - I bet I'll pick one that's already in use.

The example with the motor drivers: What should be done when two or more boards of the same type are connected to the same bus. A better example may be the OPEN SERVO, connecting say 8 of these to the bus means 8 different address right?
The question that drives me hazy:

Am I, or the others crazy?

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: I2C Addresses
« Reply #3 on: January 10, 2009, 12:01:07 PM »
I don't know of a place where you can get an idea of what addresses are meant for what device type.

Open Servo is programmable, so you can set any address you want. Get the other parts with proper addresses and then use something different for the servos.

If you are building your own boards, we are in the same boat, since I am working on a Open CR Servo module (CR means Continuous Rotation) with quadrature encoders, that can be installed inside a modyfied servo. I am using ATmega25 (45 or 85 may be used, same pinout, each has more flash) in the 8 pin package. I have an 8 pin package H-Bridge from Jameco, called FAN8082 that I intend to use in the prototype. This may be changed to a different H-Bridge if necesary. I am still not sure if I want the modules to be programmable or just have 2 fixed addresses since there are usually 2 drive motors on each robot (left and right). If there are more motors per side, I guess they can share the address, or there will be 2 more addresses to handle pairs of motors. But I am not concerned with this aspect at this time.

I know there are Sharp IR sensors, Devantech Ultrasonic sensors, Compass sensors, accelerometers, gyros, LCD and probably others with I2C interface. Most of them have 2 or 3 jumpers to set the address in a specific range, each sensor type having a different range. I think studying the range of each sensor type would make sure there are no same addresses for different devices on the bus.

Here is an example of how I would do it for my robot:
I2C address is 7 bit for address and the eight bit for reading/writing, so:
(still not sure which is the r/w bit, so I just give an example)

bit 0 - for left-right motor
bits 1-2 - for servos
bits 3-4 - for IR sensors
bits 5-6 - for US sensors
bit 7 - for compass or other

Or, you can have 3 bits for OUPUT devices and 3 bits for INPUT devices and 1 bit for other stuff.
Check out the uBotino robot controller!

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: I2C Addresses
« Reply #4 on: January 10, 2009, 12:40:02 PM »
I have found the addresses for a few popular devices used in robotics:

Devantech CMPS03 Compass - uses 0xC0

Solarbotics I2C-It Sharp IR sensor - uses 3 solder jumpers to set the address in the range 0x20 - 0x2E

Devantech SRF08 Ultrasonic sensor - uses by default 0xE0. This can be changed to 16 addresses in the range 0xE0 - 0xFE by I2C commands, also supports broadcast address of 0x00

Open Servo - uses by default 0x10, can be changed to anything by I2C commands (and other methods)

Robotics Connection I2C Line Following Sensor - uses by default 0x50, can be changed to anything


« Last Edit: January 10, 2009, 01:02:34 PM by Ro-Bot-X »
Check out the uBotino robot controller!

Offline want2learnTopic starter

  • Robot Overlord
  • ****
  • Posts: 189
  • Helpful? 4
Re: I2C Addresses
« Reply #5 on: January 10, 2009, 01:25:04 PM »
Thanks so much for the info Ro-Bot-X  ;D

By the look of your first post I think I may be a little over my head at this point. But  hey I'm willing to take the chance that I'll swim and not sink :D.
I was kinda hoping that there would be a list of addresses to make things a bit simpler.

I really like the sound of your  CR Servo. I bet fitting it inside a servo will be a bugger.
I'll keep searching for addresses, I have only just started building my first board for I2C. When I finish building it I may need a little more help with the interface software, I don't know yet.

Again a big thanks
The question that drives me hazy:

Am I, or the others crazy?

Offline jka

  • Full Member
  • ***
  • Posts: 78
  • Helpful? 4
Re: I2C Addresses
« Reply #6 on: January 12, 2009, 03:33:46 AM »
From the I2C chapter of the dsPIC33F reference manual I got this list of reserved addresses, that I think you should stay away from. Other than that, I think you are free to choose.

Slave addressR/W bitDescription
0000 0000General call address
0000 0001Start byte
0000 001xCBUS address
0000 010xReserved
0000 011xReserved
0000 1xxxHS Master Code
1111 1xxxReserved
1111 0xxx10-bit slave upper byte

All in all, don't use all 0's or all 1's as the first 4 bits and you should be safe.

Offline want2learnTopic starter

  • Robot Overlord
  • ****
  • Posts: 189
  • Helpful? 4
Re: I2C Addresses
« Reply #7 on: January 17, 2009, 01:59:29 AM »
How does everyone feel about posting the I2C addresses of things they design or own in this post or on Dunks google page (related to the SoR Project) http://docs.google.com/View?docid=ddp2r5j8_24hhf75vck so people can check back and make sure there wont be any compatability issues.

« Last Edit: January 17, 2009, 02:26:13 AM by want2learn »
The question that drives me hazy:

Am I, or the others crazy?

Offline HDL_CinC_Dragon

  • Supreme Robot
  • *****
  • Posts: 1,261
  • Helpful? 5
Re: I2C Addresses
« Reply #8 on: January 17, 2009, 03:08:48 PM »
Would it be possible to create your own address settings for I2C? Like could you use a 7 position DIP switch to create your own 7 bit binary device address and somehow let your MCU know how to read the addresses?
United States Marine Corps
Infantry
Returns to society: 2014JAN11

paulstreats

  • Guest
Re: I2C Addresses
« Reply #9 on: January 17, 2009, 03:26:02 PM »
to hdl_cnc_dragon

Yes. Many components use a similar setup. A few ic's can have their address physically set by either tying pins high or low

Offline want2learnTopic starter

  • Robot Overlord
  • ****
  • Posts: 189
  • Helpful? 4
Re: I2C Addresses
« Reply #10 on: January 18, 2009, 02:25:06 AM »
I like the idea of selecting the addresses with DIP switches but I'm  trying to make any boards I design fit the guidelines on Dunks pages and an 8 way DIP switch takes up 10mm x 22mm (if I measured right).

This is a lot of room on an already packed board.
The question that drives me hazy:

Am I, or the others crazy?

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: I2C Addresses
« Reply #11 on: January 18, 2009, 06:56:44 PM »
Then just use double row pins (8x2) and jumpers to set what ever digits you want to be high.
Check out the uBotino robot controller!

Offline want2learnTopic starter

  • Robot Overlord
  • ****
  • Posts: 189
  • Helpful? 4
Re: I2C Addresses
« Reply #12 on: January 19, 2009, 06:55:34 AM »
I think I'm going to forget this for a while. >:(

I've tried playing about with I2C, looking at any tutorial I can find or have been pointed to you'd think my 3 year old could do it.
I'm struggling like buggery, maybe I should just let him do it ::).
 Seriously though, for now I've had enough.

Maybe I need to get better at programming or I've missed something I dunno but I'll come back to this in a couple of months (maybe) :(
The question that drives me hazy:

Am I, or the others crazy?

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: I2C Addresses
« Reply #13 on: January 19, 2009, 07:16:24 AM »
What were you trying to do? What didn't work as espected? Share with us, maybe we can help out...
Check out the uBotino robot controller!

Offline want2learnTopic starter

  • Robot Overlord
  • ****
  • Posts: 189
  • Helpful? 4
Re: I2C Addresses
« Reply #14 on: January 22, 2009, 02:49:42 PM »
Sorry, just a bit of venting :( , I was having a very bad day (an email saying I have 40 boards headed my way and not 1), I suppose the problems I'm having with my I2C boards were the straw that broke the camels back.

For now I'm happy to pursue knowledge in other programming areas and return to this soon. I think it's mainly my lack of experience thats letting me down.

Most of the problems I'm having are with the gas gauge IC (I think?). There is data missing/corrupted? when trying to get a reading.
My master is a MEGA168 and the gas gauge is a MAXIM DS2745 http://www.maxim-ic.com/quick_view2.cfm/qv_pk/4994

Thanks for the offer, but for now I feel I need to further my knowledge of programming before continuing with this.
The question that drives me hazy:

Am I, or the others crazy?

 


Get Your Ad Here

data_list