thx, but that indeed is far too elaborated to me - I have no idea how to program this.
Maybe you can try...?
Give me your code, and I will try it out!
NXC: I²C drivers for Hitechnic Tetrix motor muxer ?
Re: NXC: I²C drivers for Hitechnic Tetrix motor muxer ?
Wish I could provide some code but it is way beyond my computing skills!
I was just passing on some stuff I found in the hope that it might help shed some light on the problem.
I was just passing on some stuff I found in the hope that it might help shed some light on the problem.
A sophistical rhetorician, inebriated with the exuberance of his own verbosity, and gifted with an egotistical imagination that can at all times command an interminable and inconsistent series of arguments to malign an opponent and to glorify himself.
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: NXC: I²C drivers for Hitechnic Tetrix motor muxer ?
That is all just referring to the commands and such that the controller is capable of doing.
What specifically so you want to be able to do? Do you just want simple speed and direction control?
It is hard to program a fool proof program, without the hardware to test it.
What specifically so you want to be able to do? Do you just want simple speed and direction control?
It is hard to program a fool proof program, without the hardware to test it.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: NXC: I²C drivers for Hitechnic Tetrix motor muxer ?
Here is an example you could try, using both the flag system and the waiting. I obviously don't have the hardware to test it, but you can try it for yourself.Basically, this should set the motors to random speeds and directions every 1000ms (1 second).
Code: Select all
#define TetrixPort S1 //Tetrix controller Port
#define TetrixAddr 0x02 //Tetrix controller Address
#define TetrixWaitTime 50 //How many ms to wait (at a minimum) before allowing another command to be sent
bool FlagUpdateTetrix=false; //Set to true to send the commands
byte TetrixControlData[]; //contains the control data
//This function does the lower level I2C communication, and should not ever need adjustments.
void TetrixController(byte port, byte addr, byte reg, byte data[])
{
byte result = -1; // default: error value
byte cmdbuf[]; // register number holder
int loop, n, nByteReady;
ArrayBuild(cmdbuf, addr, reg, data);
loop = STAT_COMM_PENDING; //Wait until bus is free
while (loop == STAT_COMM_PENDING ){ // ''
loop = I2CStatus(port, nByteReady); // ''
} // ''
n = I2CWrite(port, 0, cmdbuf); //When the I2C bus is ready, send the message you built
while (I2CStatus(port, nByteReady) == STAT_COMM_PENDING); //Wait until bus is free
}
//This is the task that updates the controller
task UpdateTetrixController(){
while(true){
until (FlagUpdateTetrix==true); //Wait until the flag is set true
TetrixController(TetrixPort, TetrixAddr, 0x44, TetrixControlData); //Send the commands
FlagUpdateTetrix=false; //Reset the flag back to false
Wait(TetrixWaitTime); //Wait the necessary amount of time for the controller's sake
}
}
task main(){
SetSensorLowspeed(TetrixPort); //Set up the port for I2C
TetrixControlData[0]=0x00; //Put motor 1 into speed control mode
TetrixControlData[3]=0x00; //Put motor 2 into speed control mode
start UpdateTetrixController; //start the update task
while(true){
int Motor_1_Speed = Random(200)-100; //Choose a random speed from -100 to 100
int Motor_2_Speed = Random(200)-100; //Choose a random speed from -100 to 100
TetrixControlData[1]=Motor_1_Speed; //-100 to 100. 0 is brake. -128 is float.
TetrixControlData[2]=Motor_2_Speed; //-100 to 100. 0 is brake. -128 is float.
FlagUpdateTetrix=true; //Allow NXT to update controller
Wait(1000); //Wait until the next random speed
}
}
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: NXC: I²C drivers for Hitechnic Tetrix motor muxer ?
thx matt for your efforts!
I tried your program right now, it says "Running" but it does quite nothing: no single motor action at all :(
I tried your program right now, it says "Running" but it does quite nothing: no single motor action at all :(
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: NXC: I²C drivers for Hitechnic Tetrix motor muxer ?
You're welcome for trying.
Oh well, I guess you'll just have to wait until John releases them, unless you figure it out beforehand.
Oh well, I guess you'll just have to wait until John releases them, unless you figure it out beforehand.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: NXC: I²C drivers for Hitechnic Tetrix motor muxer ?
Update:
I meanwhile managed reading through probably all available manuals for NXT-G and RobotC, and this is the disappointing result:
Neither in NXT-G nor in RobotC are provided blocks or routines or code examples for a quick frequently reading of the Tetrix encoder values. So I guess the reason is that it's simply not possible to do it in any programming language because of HT controller internals.
Therefore, a use for odometry is absolutely not possible with the HT Tetrix motor controller and the HT Tetrix encoders.
I meanwhile managed reading through probably all available manuals for NXT-G and RobotC, and this is the disappointing result:
Neither in NXT-G nor in RobotC are provided blocks or routines or code examples for a quick frequently reading of the Tetrix encoder values. So I guess the reason is that it's simply not possible to do it in any programming language because of HT controller internals.
Therefore, a use for odometry is absolutely not possible with the HT Tetrix motor controller and the HT Tetrix encoders.
Who is online
Users browsing this forum: No registered users and 1 guest