hi, meanwhile HT replied to my driver request.
If anyone else is interested, here is a servo driver sample:
Code: Select all
#include "NXCDefs.h"
#define IO_PORT IN_1
int err=0;
int err0=0;
int err1=0;
int err2=0;
int err3=0;
int err4=0;
int err5=0;
int err6=0;
int err7=0;
int status;
int count;
byte inI2Ccmd[]; // buffer for outbound I2C data
byte outbuf[];
void setservos(int timer, int servo1,int servo2,int servo3, int servo4, int servo5, int servo6)
{
ArrayInit(inI2Ccmd, 0, 10);
inI2Ccmd[0] = 0x02;
inI2Ccmd[1] = 0x41;
inI2Ccmd[2] = timer;
inI2Ccmd[3] = servo1;
inI2Ccmd[4] = servo2;
inI2Ccmd[5] = servo3;
inI2Ccmd[6] = servo4;
inI2Ccmd[7] = servo5;
inI2Ccmd[8] = servo6;
inI2Ccmd[9] = 0;
count=0;
I2CBytes(IO_PORT, inI2Ccmd, count, outbuf);
Wait(20);
ArrayInit(inI2Ccmd, 0, 2);
inI2Ccmd[0] = 0x02;
inI2Ccmd[1] = 0x41;
count=8;
I2CBytes(IO_PORT, inI2Ccmd, count, outbuf);
Wait(20);
if (ArrayLen(outbuf)==8)
{
if (outbuf[0]!=timer) err0+=1;
if (outbuf[1]!=servo1) err1+=1;
if (outbuf[2]!=servo2) err2+=1;
if (outbuf[3]!=servo3) err3+=1;
if (outbuf[4]!=servo4) err4+=1;
if (outbuf[5]!=servo5) err5+=1;
if (outbuf[6]!=servo6) err6+=1;
if (outbuf[7]!=0) err7+=1;
}
if (ArrayLen(outbuf)!=8) err+=1;
ClearScreen();
NumOut(20,LCD_LINE1,err);
NumOut(20,LCD_LINE2,err0);
NumOut(60,LCD_LINE2,err1);
NumOut(20,LCD_LINE3,err2);
NumOut(60,LCD_LINE3,err3);
NumOut(20,LCD_LINE4,err4);
NumOut(60,LCD_LINE4,err5);
NumOut(20,LCD_LINE5,err6);
NumOut(60,LCD_LINE5,err7);
}
void waitservos()
{
status=1;
while(status!=0)
{
ArrayInit(inI2Ccmd, 0, 2);
inI2Ccmd[0] = 0x02;
inI2Ccmd[1] = 0x40;
count=1;
I2CBytes(IO_PORT, inI2Ccmd, count, outbuf);
Wait(20);
if (ArrayLen(outbuf)==1) status=outbuf[0];
NumOut(20,LCD_LINE6,status);
}
}
task main()
{
SetSensorLowspeed(IO_PORT); // port 1 servo controller
SetSensorType(IO_PORT,SENSOR_TYPE_LOWSPEED);
while(TRUE)
{
setservos(1,0,22,44,66,88,110);
waitservos();
setservos(1,255,233,211,189,167,145);
waitservos();
}
}
Unfortunately a encoder motor sample is still missing, maybe to someone the pdfs are helpful.
Functions like these would be needed:
Code: Select all
// NXTport=(0,1,2); TXchannel= TetrixMuxChanell(0,1)...(0,1,2,3,4,5,6,7)
single up to 4*daisy chained
void TXMotorOn(NXTport, TXchannel, percentage)
void TXMotorCoast(NXTport, TXchannel)
void TXMotorBreak(NXTport, TXchannel)
long TXEncoderValue(NXTport, TXchannel)
Synchronizing would be fine of course even not necessarily already now from
the start
Code: Select all
void TXMotorSync(NXTport, TXchannelA, TXchannelB)