Command 46: doesn't complete full move.
Posted: Mon Mar 21, 2016 11:49 pm
Following the directions provided in this forum, I am trying to use command 46.
For example, to move 100K counts at V = 20k/sec and A = 20k/sec.sec, I issue first command to move 90k counts at V = 20k/sec and second follow on command to move 10k counts at V = 0k/sec.
What I get is the motors moving about 99700 counts (as reported by roboclaw (2x 15A).
I have plenty of integral in the tuning so this isn't a case where P fails to get motors to target alone.
Continued repeats of the move leave the motors about 300 counts further behind each time. The errors of the motors are different and the error magnitude varies each move but it roughly 0.3% error.
If I manually pull the motors away from finish position, they move back when I release, but move back to ~99700, not 100K.
Using roboclaw V4.1.16.
Here is the first command (as viewed by logic analyzer on the UART pins): Same message viwed as HEX if that is easier for you to read. Here is the second command: It is shown here sent with 20mS delay after first command, but delay of virtually 0 gives same results.
Here is the code used to setup and send the move(part should look familiar to you):
Can you please let me know what you think needs to be done to get the move to be correct? The error should be 0.0% every single time if the part is usable. I haven't yet counted the actual encoder edges manually to see if the edges match the numbers being provided by roboclaw.
For example, to move 100K counts at V = 20k/sec and A = 20k/sec.sec, I issue first command to move 90k counts at V = 20k/sec and second follow on command to move 10k counts at V = 0k/sec.
What I get is the motors moving about 99700 counts (as reported by roboclaw (2x 15A).
I have plenty of integral in the tuning so this isn't a case where P fails to get motors to target alone.
Continued repeats of the move leave the motors about 300 counts further behind each time. The errors of the motors are different and the error magnitude varies each move but it roughly 0.3% error.
If I manually pull the motors away from finish position, they move back when I release, but move back to ~99700, not 100K.
Using roboclaw V4.1.16.
Here is the first command (as viewed by logic analyzer on the UART pins): Same message viwed as HEX if that is easier for you to read. Here is the second command: It is shown here sent with 20mS delay after first command, but delay of virtually 0 gives same results.
Here is the code used to setup and send the move(part should look familiar to you):
Code: Select all
int driveForward (int iDistance, int iSpeed, int iAccel){
char data [23];
int i, j, k;
float fD0 = ((float)(iSpeed * iSpeed)) / (2 * iAccel);
float fD1 = fD0;
float fDt = fD0 + fD1;
if( fDt > iDistance ) {
fD0 = fD0/fDt * iDistance;
fD1 = fD1/fDt * iDistance;
}
else{
fD0 = iDistance - fD1;
}
for (k = 0; k < 2; k++){
// k == 0 : send accel, top speed, and distance for ramp up and steady state
// k == 1 : send accel, final speed (zero), distance for ramp down and stop
if (k == 1){
fD0 = fD1;
iSpeed = 0;
}
j = 0;
// Send: [Address, 46, Accel(4 Bytes), SpeedM1(4 Bytes),
// DistanceM1(4 Bytes),SpeedM2(4 bytes) , DistanceM2(4 Bytes), Buffer, CRC(2 bytes)]
// load address and command
data[j++] = (char) 128 ;
data[j++] = (char) 46 ;
// load accel for both motors
for (i = 0 ; i < 4 ; i++){
data[j++] = ((unsigned int) iAccel) >> (24 - (i*8));
}
// load speed for motor 0
for (i = 0 ; i < 4 ; i++){
data[j++] = ((signed int) iSpeed) >> (24 - (i*8));
}
// load distance for motor 0
for (i = 0 ; i < 4 ; i++){
data[j++] = ((unsigned int) fD0) >> (24 - (i*8));
}
// load speed for motor 1
for (i = 0 ; i < 4 ; i++){
data[j++] = ((signed int) iSpeed) >> (24 - (i*8));
}
// load distance for motor 1
for (i = 0 ; i < 4 ; i++){
data[j++] = ((unsigned int) fD0) >> (24 - (i*8));
}
data [j] = 0; // send 0 to put command at rear of buffer
sendCommand (23, &data);
vTaskDelay( (TickType_t) 20 );
}
}
int sendCommand (int bytes, char * data){
int i;
uint16_t crc = 0;
for (i = 0; i < bytes; i++){
uart1_putc((char) *(data + i) );
crc = crc16( data + i , crc);
}
uart1_putc((char) (crc >> 8) );
uart1_putc((char) (crc) );
}