我使用STM32F407基于CANopen_Cia402标准来控制电机,但是在电机RPDO1设置完后,想通过RPDO1来改变电机控制字的时候发现它的值并未改变,用SDO则能成功改变。 下面是我的代码,不知道是我初始化有问题还是我的PDO报文有问题,劳请大神们指点 这是报文部分的代码 /*------NMT初始化------*/ {0x02,0x00+NodeID},//关闭远程节点 {0x82,0x00+NodeID},//复位NodeID对应节点 /*---------------------*/ {0x2f,0x60,0x60,0x00,0x04,0x00,0x00,0x00},//设置伺服运行模式为转矩轮廓模式 {0x40,0x61,0x60,0x00,0x00,0x00,0x00,0x00},//核对运行模式 {0x23,0x15,0x20,0x00,0x01,0x00,0x00,0x00},//设置正向转矩速度限制为1%额定速度 {0x23,0x16,0x20,0x00,0x01,0x00,0x00,0x00},//设置反向转矩速度限制为1%额定速度 {0x2f,0x01,0x1A,0x00,0x00,0x00,0x00,0x00},//清除TPDO2的映射项 {0x23,0x00,0x14,0x01,0x00+NodeID,0x20,0x00,0x80},//禁能RPDO1 {0x2F,0x00,0x16,0x00,0x00,0x00,0x00,0x00},//清除RPDO1的映射项 {0x23,0x00,0x16,0x01,0x10,0x00,0x40,0x60},//将0x6040 子索引0x00 数据长度为16位的(控制字)作为第一个映射对象 {0x23,0x00,0x16,0x02,0x10,0x00,0x71,0x60},//将0x6071 子索引0x00 数据长度为16位的作为第二个映射对象 {0x2F,0x00,0x14,0x02,0xff,0x00,0x00,0x00},//将RPDO1的传输类型设置为异步,即将接收到的数据直接更新到应用 {0x2F,0x00,0x16,0x00,0x02,0x00,0x00,0x00},//设置RPDO1的映射项位2个 {0x23,0x00,0x14,0x01,0x00+NodeID,0x20,0x00,0x00},//使能RPDO1 {0x23,0x00,0x18,0x01,0x80+NodeID,0x01,0x00,0x80},//禁能TPDO1 {0x2F,0x00,0x1A,0x00,0x00,0x00,0x00,0x00},//清除TPDO1的映射项 {0x23,0x00,0x1A,0x01,0x10,0x00,0x41,0x60},//将0x6041 子索引0x00 数据长度为16位的(状态字)作为第一个映射对象 {0x23,0x00,0x1A,0x02,0x10,0x00,0x77,0x60},//将0x6077 子索引0x00 数据长度为16位的(实际转矩值)作为第二个映射对象 {0x2F,0x00,0x18,0x02,0x01,0x00,0x00,0x00},//设置TPDO1的传输类型为接收一个同步帧时发送 {0x2F,0x00,0x1A,0x00,0x02,0x00,0x00,0x00},//设置TPDO1的映射项为2个 {0x23,0x00,0x18,0x01,0x80+NodeID,0x01,0x00,0x00},//使能TPDO1 {0x01,0x00+NodeID},//启动节点 {0x00},//心跳 {0x00},//同步 {0x06,0x00,0x00,0x00}, {0x07,0x00,0x00,0x00}, {0x0f,0x00,0x00,0x00},//3步通过RPDO1改变控制字使得节点允许操作下面是COB-ID /*-----NMT初始化-----*/ 0x00, 0x00, /*-------------------*/ 0x600 + NodeID, 0x600 + NodeID, 0x600 + NodeID, 0x600 + NodeID, 0x600 + NodeID, 0x600 + NodeID,//RPDO1设置 0x600 + NodeID, 0x600 + NodeID, 0x600 + NodeID, 0x600 + NodeID, 0x600 + NodeID, 0x600 + NodeID, 0x600 + NodeID, 0x600 + NodeID,//tpdo1设置 0x600 + NodeID, 0x600 + NodeID, 0x600 + NodeID, 0x600 + NodeID, 0x600 + NodeID, 0x600 + NodeID, 0x00,//开启节点 0x700 + NodeID, 0x80, 0x200 + NodeID, 0x200 + NodeID, 0x200 + NodeID,
|