I²C commands for Tetrix motor muxers?

Discussion specific to the intelligent brick, sensors, motors, and more.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: I²C commands for Tetrix motor muxers?

Post by HaWe »

so you think you can send 2 registers for the speed of 2 different motors at once?
And what about the mode byte and the different address of both motors?
And what if you want to have motor1 in power mode and motor2 in constant speed mode?

as I understand, it's

Code: Select all

// start motor number counting at ZERO (as usual in C)
address of each motor 0-7 = 2+MotorNumber // addr_mot_0=2, addr_mot_1=3, addr_mot_2=4, addr_mot_3=5, ...

mode_reg = 0x44 for motors 0,2,4,6 // Sel Action: 00=power control only, 01=constant speed
mode_reg = 0x47 for motors 1,3,5,7 // Sel Action: 00=power control only, 01=constant speed

power_reg = 0x45  for motors 0,2,4,6 // -100...+100 both for power and speed
power_reg = 0x46  for motors 1,3,5,7 // -100...+100 both for power and speed
so as far as I understand it,
mode_reg= 44+0 if motorNumber modulo 2=0
and
mode_reg= 44+3 if motorNumber modulo 2=1
similar it's with the power-registers:

Code: Select all

mode_reg= 44 + 3*(motorNumber % 2);
power_reg=45 + (motorNumber % 2);
But what I don't understand:
don't you have to wait after each address and register call until the IIC line is not_pending?
Can you REALLY send several register values all at once?
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: I²C commands for Tetrix motor muxers?

Post by mattallen37 »

so you think you can send 2 registers for the speed of 2 different motors at once?
I know so.
And what about the mode byte and the different address of both motors?
You can write to all four speed/mode registers at once. The address is the same. The address is the address of the controller, just like a family can live at the same street address, but there can be multiple people. Picture the address as the street address, and the registers as the commands you give to individual people at the same address.
And what if you want to have motor1 in power mode and motor2 in constant speed mode?
You can update (write) all 12 control registers with a single write command, therefore you can do just about anything.

Each motor controller has an I2C address, there is not an address for each channel (motor). How many controllers are you using, and how are they daisy chained? If only one, then the address is 0x02. If you have one daisy chained, then that one would have an address of 0x04.
But what I don't understand:
don't you have to wait after each address and register call until the IIC line is not_pending?
That should all taken care of by using the simple WriteI2CRegister function. It is multiple functions built into one, for the sake of simplicity.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: I²C commands for Tetrix motor muxers?

Post by HaWe »

thank you matt, you really helped me a lot!
only one question remainding:
why do they talk about address 02/03 for the first controller and 04/05 for the 2nd and so on although it's only 02 and 04?
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: I²C commands for Tetrix motor muxers?

Post by mattallen37 »

Because there are 7 bits available for the I2C address (some systems allow 10 bits, but rarely). The 7 address bits are the most significant bits, and the eighth bit (least significant bit) is the bit that determines weather the master (NXT) is reading or writing (1 and 0 respectively). The address that you use will ALWAYS be an even number (0x02 for example, but NEVER 0x03). The NXT takes care of the R/W bit for you.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: I²C commands for Tetrix motor muxers?

Post by HaWe »

matt, I can not claim to have understood much of it, but thanks anyway - I'll take the 02, forget about the 02/03 and won't ask why anymore ;)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: I²C commands for Tetrix motor muxers?

Post by mattallen37 »

So have you got things working at all yet? How about a progress/success report?
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: I²C commands for Tetrix motor muxers?

Post by HaWe »

will last some more days I'm afraid... :(
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: I²C commands for Tetrix motor muxers?

Post by mattallen37 »

No problem, just when you get around to it.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests