by Starlight » Fri Feb 27, 2009 9:44 am
by Starlight
Fri Feb 27, 2009 9:44 am
Hi all. currently I'm writing moving position for sync write. I'm using PIC18F4550, and for single dynamixel, it perform well. By the way, I wanna control up to 14 number of dynamixel, so it will waste a lots of time to calculate the checksum. So I came up with the following code:
(control only 2 number of dynamixel)
*******MOVING POSITION (SYNC WRITE)***********
uart_send(0xFF);
uart_send(0xFF);
uart_send(0xFE);
uart_send(0x0E); //LENGTH = (L+1)*N+4
uart_send(0x83);
uart_send(0x1E); //goal position
uart_send(0x04); //length of data to be written (1 dynamixel)
sendSW(1,0x0010,0x0150);
checksum_1 = sendSW (1,0x0010,0x0150);
sendSW(2,0x0220,0x0360);
checksum_2 = sendSW (2,0x0220,0x0360);
t_checksum = checksum_1 + checksum_2;
uart_send(0x4E+t_checksum); //total checksum
char sendSW (char id, int pos, int speed)
{
uart_send(id); //ID
uart_send((char)pos);
uart_send((char)(pos>>8));
uart_send((char)speed); //Moving Speed
uart_send((char)(speed>>8));
return(~(char)(id+(char)pos+(char)(pos>>8)+(char)speed+(char)(speed>>8))); //checksum
}
But it seem not exactly corret, is there any error or mistake in calculating the return value of checksum ?
Or have anyone came out with better method for controlling up to 14 number of dynamixel without wasting lots of time in calculating the checksum and reduce the line of programming ?
Thanks !
Hi all. currently I'm writing moving position for sync write. I'm using PIC18F4550, and for single dynamixel, it perform well. By the way, I wanna control up to 14 number of dynamixel, so it will waste a lots of time to calculate the checksum. So I came up with the following code:
(control only 2 number of dynamixel)
*******MOVING POSITION (SYNC WRITE)***********
uart_send(0xFF);
uart_send(0xFF);
uart_send(0xFE);
uart_send(0x0E); //LENGTH = (L+1)*N+4
uart_send(0x83);
uart_send(0x1E); //goal position
uart_send(0x04); //length of data to be written (1 dynamixel)
sendSW(1,0x0010,0x0150);
checksum_1 = sendSW (1,0x0010,0x0150);
sendSW(2,0x0220,0x0360);
checksum_2 = sendSW (2,0x0220,0x0360);
t_checksum = checksum_1 + checksum_2;
uart_send(0x4E+t_checksum); //total checksum
char sendSW (char id, int pos, int speed)
{
uart_send(id); //ID
uart_send((char)pos);
uart_send((char)(pos>>8));
uart_send((char)speed); //Moving Speed
uart_send((char)(speed>>8));
return(~(char)(id+(char)pos+(char)(pos>>8)+(char)speed+(char)(speed>>8))); //checksum
}
But it seem not exactly corret, is there any error or mistake in calculating the return value of checksum ?
Or have anyone came out with better method for controlling up to 14 number of dynamixel without wasting lots of time in calculating the checksum and reduce the line of programming ?
Thanks !