我的战队
关于云台电机的问题

本帖最后由 IRONMAN 于 2015-3-9 21:55 编辑



这几天一直在调云台电机,我用的是大疆给的例程,CAN通讯的配置是按照他给的,为什么给云台电机发数据没有应答呢?是不是给的例程有问题啊?有哪位大神调好了求交流。:handshake
这是CAN通讯的配置程序,我觉得是配置出了问题,不然为什么给它发了没有应答
void CAN1_Configuration(void)
{
CAN_InitTypeDef can;
CAN_FilterInitTypeDef can_filter;
GPIO_InitTypeDef gpio;
NVIC_InitTypeDef nvic;

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);

GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_CAN1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_CAN1);

gpio.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12;
gpio.GPIO_Mode = GPIO_Mode_AF;
GPIO_Init(GPIOA, &gpio);

nvic.NVIC_IRQChannel = CAN1_RX0_IRQn;
nvic.NVIC_IRQChannelPreemptionPriority = 0;
nvic.NVIC_IRQChannelSubPriority = 1;
nvic.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&nvic);

nvic.NVIC_IRQChannel = CAN1_TX_IRQn;
nvic.NVIC_IRQChannelPreemptionPriority = 1;
nvic.NVIC_IRQChannelSubPriority = 1;
nvic.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&nvic);

CAN_DeInit(CAN1);
CAN_StructInit(&can);

can.CAN_TTCM = DISABLE;
can.CAN_ABOM = DISABLE;
can.CAN_AWUM = DISABLE;
can.CAN_NART = DISABLE;
can.CAN_RFLM = DISABLE;
can.CAN_TXFP = ENABLE;
can.CAN_Mode = CAN_Mode_Normal;
can.CAN_SJW = CAN_SJW_1tq;
can.CAN_BS1 = CAN_BS1_9tq;
can.CAN_BS2 = CAN_BS2_4tq;
can.CAN_Prescaler = 3; //CAN BaudRate 42/(1+9+4)/3=1Mbps
CAN_Init(CAN1, &can);

can_filter.CAN_FilterNumber=0;
can_filter.CAN_FilterMode=CAN_FilterMode_IdMask;
can_filter.CAN_FilterScale=CAN_FilterScale_32bit;
can_filter.CAN_FilterIdHigh=0x0000;
can_filter.CAN_FilterIdLow=0x0000;
can_filter.CAN_FilterMaskIdHigh=0x0000;
can_filter.CAN_FilterMaskIdLow=0x0000;
can_filter.CAN_FilterFIFOAssignment=0;//the message which pass the filter save in fifo0
can_filter.CAN_FilterActivation=ENABLE;
CAN_FilterInit(&can_filter);

CAN_ITConfig(CAN1,CAN_IT_FMP0,ENABLE);
CAN_ITConfig(CAN1,CAN_IT_TME,ENABLE);
}

QQ图片20150309213710.png


不知道大家对这个图是怎么理解的?如果我现在想要向ID是0x201的云台电机发送数据1000我应该怎么打包数据?
请问这篇文章对你有用吗?
关于云台电机的问题
所有评论
暂无更多
关于作者
IRONMAN
IRONMAN
0 关注Ta
0 文章
0 经验值
0 获赞