COE:
因为canopen设计之初是针对can通讯的应用层,但是can一次只能发送8个字节的数据,ethercat的coe其实就是在can上作的一层封装,实现更多的数据传输,配置SDO都是通过coe来实现。
对象字典的Entry一般包含索引和子索引,这里的1C12包含4个子索引。第一个子索引是包含PDO映射的数目,后面3个是映射的具体PDO。也就是说后面要使用到0x1600,0x1601和0x1602这3个PDO。
int wkc = 0;
printf("Drive setup\n");
wkc += drive_write16(slave, 0x1C12, 0, 0);
wkc += drive_write16(slave, 0x1C13, 0, 0);
wkc += drive_write16(slave, 0x1A00, 0, 0);
wkc += drive_write32(slave, 0x1A00, 1, 0x60410010); // Statusword
wkc += drive_write32(slave, 0x1A00, 2, 0x60640020); // Position actual value
wkc += drive_write32(slave, 0x1A00, 3, 0x606C0020); // Velocity actual value
wkc += drive_write32(slave, 0x1A00, 4, 0x60770010); // Torque actual value
wkc += drive_write32(slave, 0x1A00, 5, 0x60610008); // Modes of operation display
wkc += drive_write32(slave, 0x1A00, 6, 0x230A0020); // 2nd Pos
wkc += drive_write8(slave, 0x1A00, 0, 6);
wkc += drive_write8(slave, 0x1600, 0, 0);
wkc += drive_write32(slave, 0x1600, 1, 0x60400010); // Controlword
wkc += drive_write32(slave, 0x1600, 2, 0x60710010); // Target torque
wkc += drive_w