Telling an Arduino ...
 
Notifications
Clear all

Telling an Arduino its I2C address  


hayttom
(@hayttom)
Trusted Member
Joined: 3 months ago
Posts: 59
Topic starter  

Bill, I think you had a hardware trick on DB2 for telling your motor drivers how to deduce their distinct I2C addresses so you could use the same code for each.

I am running two Arduinos with CNC rev 3 shields driving stepper motors.  I'd like to do something similar - maybe jumpers between pins - so my Arduinos can also deduce their addresses.  Please could you (or another forum member) nudge me toward the solution?

Tom


Quote
codecage
(@codecage)
Member Admin
Joined: 2 years ago
Posts: 815
 

@haytom

Bill used a specific digital pin tied high on one Nano and low on the other for the Nano to set its I2C slave address to one of two address. Thereby assigning which Nano was the left or the right motor controller. 

SteveG


ReplyQuote
Spyder
(@spyder)
Prominent Member
Joined: 2 years ago
Posts: 876
 

@hayttom

I think I remember something about a multiplexer

I bought one to try it, but never got round to actually doing it

It's on my list of things to do


ReplyQuote
frogandtoad
(@frogandtoad)
Honorable Member
Joined: 2 years ago
Posts: 671
 
Posted by: @hayttom

Bill, I think you had a hardware trick on DB2 for telling your motor drivers how to deduce their distinct I2C addresses so you could use the same code for each.

I am running two Arduinos with CNC rev 3 shields driving stepper motors.  I'd like to do something similar - maybe jumpers between pins - so my Arduinos can also deduce their addresses.  Please could you (or another forum member) nudge me toward the solution?

@codecage is correct, and I think the video he was referring to is: I2C Part 2 - Build a I2C Sensor

But, I'm not sure if that's what you really need, as one is the master, and the other the slave anyway?

Can you provide some details around what exactly you are trying to do?

Cheers


ReplyQuote
hayttom
(@hayttom)
Trusted Member
Joined: 3 months ago
Posts: 59
Topic starter  

Thanks everybody!  Actually SteveG (@codecage) remembered most accurately what I need - which I have now found in part 9 of the DB1 saga.  Bill was running two Nanos as motor controllers.  I am running two Unos with CNC shields and in both scenarios the twin Arduinos should run the same code (for development simplicity) but have different slave addresses so they can be commanded individually

Here's Bill's explanation:

You’ll also notice the following conditions:

  • “Left Motor” Arduino Nano pin D4 is grounded.
  • “Right Motor” Arduino Nano pin D4 is connected to +5-volts.

These connections will allow the software to distinguish which controller it is running on. It needs to do this to set the correct I2C address.

This comes at about 09:35 in the video.

 

 

 

 

 

Tom


ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 2 years ago
Posts: 815
 

@hayttom

The episode that @frogandtoad mentions is a very important episode in trying to uncover the workings of using I2C to communicate between a Master and a Slave.  But the episode I was actually referring to was Episode 9 of the DB1 series - Motor Control Part 2.  That video and the accompanying article explain how Bill let the two Arduino Nanos determine which Slave address each should use so they both could actually run the same exact code. 

SteveG


ReplyQuote
hayttom
(@hayttom)
Trusted Member
Joined: 3 months ago
Posts: 59
Topic starter  

@codecage - Yup!  Big thanks!

Tom


ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 2 years ago
Posts: 815
 

@hayttom

I see you stumbled on the right episode just about the time I was posting my response about episode 9! 😎 

SteveG


ReplyQuote
hayttom
(@hayttom)
Trusted Member
Joined: 3 months ago
Posts: 59
Topic starter  

Steve,

 

I think 'stumbled' is a very tiny bit unfair - I tracked it down logically.  But I certainly benefited from your initial explanation, so, thanks again!

 

Tom

Tom


ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 2 years ago
Posts: 815
 

@hayttom

Sorry that I used that term so 'loosely' as I sure didn't mean you were lost in the forest without a hope.  It wasn't meant to be an unfair comment.  Just that you were actually way ahead of my follow-up comments.

SteveG


ReplyQuote
hayttom
(@hayttom)
Trusted Member
Joined: 3 months ago
Posts: 59
Topic starter  

@codecage I was just teasing you.  And you're way ahead with your mechanism and coding!  Can we see a video?

 

Tom

Tom


ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 2 years ago
Posts: 815
 

@hayttom

So hard to tell the feeling of the sender via a post or email.  Much easier to do face to face when you can read facial expressions and tone of voice.  I actually thought I may have offended you and as you can probably tell I meant nothing of the kind.

The other thing that I find difficult to grasp on worldwide forums such as this, are the many different cultures we encounter and not everyone shares the same sense of humor and speaking mannerisms that you or I might have.

And I'll see if I can get a least a short video of Willy Nilly, my DB1, taking a few baby steps.

SteveG


ReplyQuote
Foxy
 Foxy
(@foxy)
Eminent Member
Joined: 3 months ago
Posts: 35
 

@hayttom

History repeats itself. 

Years ago I had a similar problem using PLC's. Two machines, nominally identical except for some calibration numbers and I did not want a disaster if the software got mixed up so the cure was make the software carry both calibrations and and select which to use depending on a jumper on the terminal blocks.  Worked fine. 


ReplyQuote
hayttom
(@hayttom)
Trusted Member
Joined: 3 months ago
Posts: 59
Topic starter  

(For completeness - Bill showed his custom function for establishing the I2C address in episode 11 starting at about 06:05.)

Tom


ReplyQuote