DRV10987不使用EVM和GUI,直接在自己电路环境中进行软件开发,整体步骤如何?
第一步,还是需要确定电机相关参数:部分参数从点击手册获取,一部分实际测量吗?
第二步,根据参数写0x90~0x96 eeprom寄存器的值
第三步,映射影子寄存器
第四步,设置0x30设置速度
第四步,读取0x01速度反馈
第五步,电机转动
按照以上步骤,可以顺利驱动电机吗?谢谢,盼复
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
uint16_t reg_data[16] = {0x8000,0x8000,0x0000,0xC0DE,\ 0xC04B,0x0049,0x00C0,0x3788,0x3BAF,0x7840,0x007A,0x1006,\ 0x1002,0x0000,0xFF}; uint16_t close_reg_data[16] = {0x8000,0x8000,0x0000,0xC0DE,\ 0xD04B,0x00BB,0x00C0,0x3788,0x3B0F,0x7840,0x007A,0x1006,\ 0x1002,0x0000,0xFF}; int reg30_data = 0x8000,default_speed = 0x812C,speed = 0,stop_speed = 0,speed_read = 0; /*开环控制参数*/ BSP.bldc.method->write(&BSP.bldc.attribute,0x60,®_data[0],2);//禁用电机驱动 BSP.bldc.method->write(&BSP.bldc.attribute,0x31,®_data[2],2); BSP.bldc.method->write(&BSP.bldc.attribute,0x31,®_data[3],2); BSP.bldc.method->read(&BSP.bldc.attribute,0x32,&read_data[2],2); BSP.bldc.method->write(&BSP.bldc.attribute,0x90,®_data[4],2); //0x004B BSP.bldc.method->write(&BSP.bldc.attribute,0x91,®_data[5],2); //0x49 BSP.bldc.method->write(&BSP.bldc.attribute,0x92,®_data[6],2); BSP.bldc.method->write(&BSP.bldc.attribute,0x93,®_data[7],2); BSP.bldc.method->write(&BSP.bldc.attribute,0x94,®_data[8],2); BSP.bldc.method->write(&BSP.bldc.attribute,0x95,®_data[9],2); BSP.bldc.method->write(&BSP.bldc.attribute,0x96,®_data[10],2); BSP.bldc.method->write(&BSP.bldc.attribute,0x35,®_data[11],2); BSP.bldc.method->read(&BSP.bldc.attribute,0x32,&read_data[2],2); BSP.bldc.method->write(&BSP.bldc.attribute,0x60,®_data[13],2); //启用电机 BSP.bldc.method->write(&BSP.bldc.attribute,0x30,®30_data,2); //override位置1,开启i2c控制模式 BSP.bldc.method->write(&BSP.bldc.attribute,0x30,&default_speed,2); //写默认速度 BSP.bldc.method->read(&BSP.bldc.attribute,0x30,&speed_read,2); //读速度 BSP.bldc.method->write(&BSP.bldc.attribute,0x60,®_data[13],2); //启用电机 /*闭环控制*/ BSP.bldc.method->write(&BSP.bldc.attribute,0x60,&close_reg_data[0],2);//禁用电机驱动 BSP.bldc.method->write(&BSP.bldc.attribute,0x31,&close_reg_data[2],2); BSP.bldc.method->write(&BSP.bldc.attribute,0x31,&close_reg_data[3],2); BSP.bldc.method->read(&BSP.bldc.attribute,0x32,&close_reg_data[2],2); BSP.bldc.method->write(&BSP.bldc.attribute,0x90,&close_reg_data[4],2); //0x004B BSP.bldc.method->write(&BSP.bldc.attribute,0x91,&close_reg_data[5],2); //0x49 BSP.bldc.method->write(&BSP.bldc.attribute,0x92,&close_reg_data[6],2); BSP.bldc.method->write(&BSP.bldc.attribute,0x93,&close_reg_data[7],2); BSP.bldc.method->write(&BSP.bldc.attribute,0x94,&close_reg_data[8],2); BSP.bldc.method->write(&BSP.bldc.attribute,0x95,&close_reg_data[9],2); BSP.bldc.method->write(&BSP.bldc.attribute,0x96,&close_reg_data[10],2); BSP.bldc.method->write(&BSP.bldc.attribute,0x35,&close_reg_data[11],2); BSP.bldc.method->read(&BSP.bldc.attribute,0x32,&close_reg_data[2],2); BSP.bldc.method->write(&BSP.bldc.attribute,0x60,&close_reg_data[13],2); //启用电机 /*锁检测*/ BSP.bldc.method->read(&BSP.bldc.attribute,0x00,&read_data[7],2); if(read_data[7] != 0x4){ BSP.bldc.method->write(&BSP.bldc.attribute,0x00,®_data[14],2);//clear错误寄存器 BSP.bldc.method->read(&BSP.bldc.attribute,0x00,&read_data[7],2); } sscanf(optarg,"%x",&speed); BSP.bldc.method->write(&BSP.bldc.attribute,0x30,®30_data,2); //override位置1,开启i2c控制模式 BSP.bldc.method->write(&BSP.bldc.attribute,0x30,&default_speed,2); //写默认速度 BSP.bldc.method->read(&BSP.bldc.attribute,0x30,&speed_read,2); //读速度 BSP.bldc.method->write(&BSP.bldc.attribute,0x60,®_data[13],2); //启用电机
BSP.bldc.method->init(&BSP.bldc.attribute); //初始化
os_msleep(10);
/*开环控制参数*/
BSP.bldc.method->write(&BSP.bldc.attribute,0x60,®_data[0],2);//禁用电机驱动
BSP.bldc.method->write(&BSP.bldc.attribute,0x31,®_data[2],2);//往0x31写0x0000
BSP.bldc.method->write(&BSP.bldc.attribute,0x31,®_data[3],2);//往0x31写0xC0DE
BSP.bldc.method->read(&BSP.bldc.attribute,0x32,&read_data[2],2);//读0x32为eereadstatus为1
BSP.bldc.method->write(&BSP.bldc.attribute,0x90,®_data[4],2); //0x90写入0xC04B
BSP.bldc.method->write(&BSP.bldc.attribute,0x91,®_data[5],2); //0x91写入0x0049
BSP.bldc.method->write(&BSP.bldc.attribute,0x92,®_data[6],2); //0x92写0x00C0
BSP.bldc.method->write(&BSP.bldc.attribute,0x93,®_data[7],2); //0x93写0x3788
BSP.bldc.method->write(&BSP.bldc.attribute,0x94,®_data[8],2); //0x94写0x3BAF
BSP.bldc.method->write(&BSP.bldc.attribute,0x95,®_data[9],2); //0x95写0x7840
BSP.bldc.method->write(&BSP.bldc.attribute,0x96,®_data[10],2); //0x96写0x007A
BSP.bldc.method->write(&BSP.bldc.attribute,0x35,®_data[11],2); //0x35写0x1006
BSP.bldc.method->read(&BSP.bldc.attribute,0x32,&read_data[2],2); //读0x32
BSP.bldc.method->write(&BSP.bldc.attribute,0x60,®_data[13],2); //启用电机,0x60写0x0000
BSP.bldc.method->write(&BSP.bldc.attribute,0x30,®30_data,2); //override位置1,开启i2c控制模式
BSP.bldc.method->write(&BSP.bldc.attribute,0x30,&default_speed,2); //写默认速度
BSP.bldc.method->read(&BSP.bldc.attribute,0x30,&speed_read,2); //读速度
BSP.bldc.method->write(&BSP.bldc.attribute,0x60,®_data[13],2); //启用电机
/*锁检测*/
// BSP.bldc.method->read(&BSP.bldc.attribute,0x00,&read_data[7],2);
// while(read_data[7] != 0x4 || read_data[7] != 0x0){
// BSP.bldc.method->write(&BSP.bldc.attribute,0x00,®_data[14],2);//clear错误寄存器
// BSP.bldc.method->read(&BSP.bldc.attribute,0x00,&read_data[7],2);
// }
BSP.bldc.method->read(&BSP.bldc.attribute,0x00,&read_data[7],2);
while(read_data[7] == 0x1 || read_data[7] == 0x2 || read_data[7] == 0x4 || read_data[7] == 0x5){
BSP.bldc.method->write(&BSP.bldc.attribute,0x00,®_data[14],2);//clear错误寄存器
BSP.bldc.method->read(&BSP.bldc.attribute,0x00,&read_data[7],2);
}
/*闭环控制*/
BSP.bldc.method->write(&BSP.bldc.attribute,0x60,&close_reg_data[0],2);//禁用电机驱动
BSP.bldc.method->write(&BSP.bldc.attribute,0x31,&close_reg_data[2],2);//往0x31写0x0000
BSP.bldc.method->write(&BSP.bldc.attribute,0x31,&close_reg_data[3],2);//往0x31写0xC0DE
BSP.bldc.method->read(&BSP.bldc.attribute,0x32,&close_reg_data[2],2);//读0x32为eereadstatus为1
BSP.bldc.method->write(&BSP.bldc.attribute,0x90,&close_reg_data[4],2);//0x90写入0xD04B
BSP.bldc.method->write(&BSP.bldc.attribute,0x91,&close_reg_data[5],2);//0x91写入0x00BB
BSP.bldc.method->write(&BSP.bldc.attribute,0x92,&close_reg_data[6],2);//0x92写0x00C0
BSP.bldc.method->write(&BSP.bldc.attribute,0x93,&close_reg_data[7],2);//0x93写0x3788
BSP.bldc.method->write(&BSP.bldc.attribute,0x94,&close_reg_data[8],2);//0x94写0x3B0F
BSP.bldc.method->write(&BSP.bldc.attribute,0x95,&close_reg_data[9],2);//0x95写0x7840
BSP.bldc.method->write(&BSP.bldc.attribute,0x96,&close_reg_data[10],2);//0x96写0x007A
BSP.bldc.method->write(&BSP.bldc.attribute,0x35,&close_reg_data[11],2);//0x35写0x1006
BSP.bldc.method->read(&BSP.bldc.attribute,0x32,&close_reg_data[2],2);//读0x32
BSP.bldc.method->write(&BSP.bldc.attribute,0x60,&close_reg_data[13],2); //启用电机
sscanf(optarg,"%x",&speed);
BSP.bldc.method->write(&BSP.bldc.attribute,0x30,®30_data,2); //override位置1,开启i2c控制模式
BSP.bldc.method->write(&BSP.bldc.attribute,0x30,&default_speed,2); //写默认速度
BSP.bldc.method->read(&BSP.bldc.attribute,0x30,&speed_read,2); //读速度
BSP.bldc.method->write(&BSP.bldc.attribute,0x60,®_data[13],2); //启用电机
写入 EEPROM 并旋转电机的整个过程是没有问题的。 在运行此代码之前,请确保电源电压介于6.2V 和28V 之间就好。