Page 2 of 2

Re: I²C commands for Tetrix motor muxers?

Posted: 27 Nov 2010, 08:32
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?

Re: I²C commands for Tetrix motor muxers?

Posted: 27 Nov 2010, 10:23
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.

Re: I²C commands for Tetrix motor muxers?

Posted: 27 Nov 2010, 10:33
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?

Re: I²C commands for Tetrix motor muxers?

Posted: 27 Nov 2010, 19:46
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.

Re: I²C commands for Tetrix motor muxers?

Posted: 27 Nov 2010, 21:00
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 ;)

Re: I²C commands for Tetrix motor muxers?

Posted: 27 Nov 2010, 21:24
by mattallen37
So have you got things working at all yet? How about a progress/success report?

Re: I²C commands for Tetrix motor muxers?

Posted: 27 Nov 2010, 22:25
by HaWe
will last some more days I'm afraid... :(

Re: I²C commands for Tetrix motor muxers?

Posted: 27 Nov 2010, 22:36
by mattallen37
No problem, just when you get around to it.