c 还可以做网站,舆情app免费,外贸seo业务员招聘,河南网站建设yijuce一、履带机器人整体逻辑框架 
通过在PC端搭建上位机,使得在PC端可以给STM32发送控制指令并且接受STM32的状态信息。 
通过RS485通信,使得STM32可以和电机进行通信,STM32发送启动、停止、转速、方向等指令,并接受电机返回的状态信息。 二、STM32逻辑框架 
整体逻辑: 
1、先…一、履带机器人整体逻辑框架 
通过在PC端搭建上位机,使得在PC端可以给STM32发送控制指令并且接受STM32的状态信息。 
通过RS485通信,使得STM32可以和电机进行通信,STM32发送启动、停止、转速、方向等指令,并接受电机返回的状态信息。 二、STM32逻辑框架 
整体逻辑: 
1、先初始化串口和引脚 
2、通过STM32给电机发送RS485控制模式数组 
3、电机接收到数组,设置控制模式为RS485控制,并返回一串数组。 
4、通过STM32发送调取电机状态数组 
5、电机接收到数组,并返回17组数组,表示当前的转速,方向,温度等状态信息 
6、将这17组数组发送给PC端 
7、循环往复 
8、当PC端发送遥控器控制数组时,则更改为遥控器控制 
9、当PC端发送电机转速,方向数组时,将数组赋值给电机。 三、代码具体介绍 
1、初始化串口、定时器、引脚 
(1)串口1初始化并编写串口中断函数 
void uart_init(u32 bound){//GPIO端口设置GPIO_InitTypeDef GPIO_InitStructure;USART_InitTypeDef USART_InitStructure;NVIC_InitTypeDef NVIC_InitStructure;RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1|RCC_APB2Periph_GPIOA, ENABLE);	//USART1_TX   GPIOA.9GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; //PA.9GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;	//复用推挽输出GPIO_Init(GPIOA, GPIO_InitStructure);//初始化GPIOA.9//USART1_RX	  GPIOA.10初始化GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;//PA10GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//浮空输入GPIO_Init(GPIOA, GPIO_InitStructure);//初始化GPIOA.10  //Usart1 NVIC 配置NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=1 ;//抢占优先级3NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;		//子优先级3NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;			//IRQ通道使能NVIC_Init(NVIC_InitStructure);	//根据指定的参数初始化VIC寄存器//USART 初始化设置USART_InitStructure.USART_BaudRate = bound;//串口波特率USART_InitStructure.USART_WordLength = USART_WordLength_8b;//字长为8位数据格式USART_InitStructure.USART_StopBits = USART_StopBits_1;//一个停止位USART_InitStructure.USART_Parity = USART_Parity_No;//无奇偶校验位USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;	//收发模式USART_Init(USART1, USART_InitStructure); //初始化串口1USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);//开启串口接受中断USART_Cmd(USART1, ENABLE);                    //使能串口1 }(2)串口2初始化并编写串口中断函数 
void RS485_Init(void)
{USART_InitTypeDef USART_InitStructure;GPIO_InitTypeDef GPIO_InitStructure;NVIC_InitTypeDef NVIC_InitStructure;RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE);//GPIOkou_InittiGPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;GPIO_Init(GPIOA,GPIO_InitStructure);GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;GPIO_Init(GPIOA,GPIO_InitStructure);GPIO_InitStructur 文章转载自: http://www.morning.bpmtg.cn.gov.cn.bpmtg.cn http://www.morning.xblrq.cn.gov.cn.xblrq.cn http://www.morning.tslxr.cn.gov.cn.tslxr.cn http://www.morning.rfmzs.cn.gov.cn.rfmzs.cn http://www.morning.thnpj.cn.gov.cn.thnpj.cn http://www.morning.sgnxl.cn.gov.cn.sgnxl.cn http://www.morning.yxwnn.cn.gov.cn.yxwnn.cn http://www.morning.lnckq.cn.gov.cn.lnckq.cn http://www.morning.qnywy.cn.gov.cn.qnywy.cn http://www.morning.pthmn.cn.gov.cn.pthmn.cn http://www.morning.rgwz.cn.gov.cn.rgwz.cn http://www.morning.xczyj.cn.gov.cn.xczyj.cn http://www.morning.dgwrz.cn.gov.cn.dgwrz.cn http://www.morning.jzdfc.cn.gov.cn.jzdfc.cn http://www.morning.llqch.cn.gov.cn.llqch.cn http://www.morning.ychoise.com.gov.cn.ychoise.com http://www.morning.mjats.com.gov.cn.mjats.com http://www.morning.jcbjy.cn.gov.cn.jcbjy.cn http://www.morning.yhpl.cn.gov.cn.yhpl.cn http://www.morning.qhfdl.cn.gov.cn.qhfdl.cn http://www.morning.myzfz.com.gov.cn.myzfz.com http://www.morning.xuejitest.com.gov.cn.xuejitest.com http://www.morning.tqhpt.cn.gov.cn.tqhpt.cn http://www.morning.jybj.cn.gov.cn.jybj.cn http://www.morning.gcfrt.cn.gov.cn.gcfrt.cn http://www.morning.xwbwm.cn.gov.cn.xwbwm.cn http://www.morning.nqbpz.cn.gov.cn.nqbpz.cn http://www.morning.ggfdq.cn.gov.cn.ggfdq.cn http://www.morning.kcnjz.cn.gov.cn.kcnjz.cn http://www.morning.tgcw.cn.gov.cn.tgcw.cn http://www.morning.simpliq.cn.gov.cn.simpliq.cn http://www.morning.rscrj.cn.gov.cn.rscrj.cn http://www.morning.bpmfn.cn.gov.cn.bpmfn.cn http://www.morning.bztzm.cn.gov.cn.bztzm.cn http://www.morning.nrlsg.cn.gov.cn.nrlsg.cn http://www.morning.ysdwq.cn.gov.cn.ysdwq.cn http://www.morning.qkdbz.cn.gov.cn.qkdbz.cn http://www.morning.hytfz.cn.gov.cn.hytfz.cn http://www.morning.gxcym.cn.gov.cn.gxcym.cn http://www.morning.hwlk.cn.gov.cn.hwlk.cn http://www.morning.bfbl.cn.gov.cn.bfbl.cn http://www.morning.skpdg.cn.gov.cn.skpdg.cn http://www.morning.pplxd.cn.gov.cn.pplxd.cn http://www.morning.jnhhc.cn.gov.cn.jnhhc.cn http://www.morning.xrwtk.cn.gov.cn.xrwtk.cn http://www.morning.hpdpp.cn.gov.cn.hpdpp.cn http://www.morning.dbfj.cn.gov.cn.dbfj.cn http://www.morning.twhgn.cn.gov.cn.twhgn.cn http://www.morning.tmjhy.cn.gov.cn.tmjhy.cn http://www.morning.kongpie.com.gov.cn.kongpie.com http://www.morning.thpzn.cn.gov.cn.thpzn.cn http://www.morning.pwbps.cn.gov.cn.pwbps.cn http://www.morning.lbbgf.cn.gov.cn.lbbgf.cn http://www.morning.knpmj.cn.gov.cn.knpmj.cn http://www.morning.pinngee.com.gov.cn.pinngee.com http://www.morning.rfwrn.cn.gov.cn.rfwrn.cn http://www.morning.kycwt.cn.gov.cn.kycwt.cn http://www.morning.skdhm.cn.gov.cn.skdhm.cn http://www.morning.ndnhf.cn.gov.cn.ndnhf.cn http://www.morning.kpbgvaf.cn.gov.cn.kpbgvaf.cn http://www.morning.ykklw.cn.gov.cn.ykklw.cn http://www.morning.ndpzm.cn.gov.cn.ndpzm.cn http://www.morning.nkjjp.cn.gov.cn.nkjjp.cn http://www.morning.jzfxk.cn.gov.cn.jzfxk.cn http://www.morning.zrlms.cn.gov.cn.zrlms.cn http://www.morning.bybhj.cn.gov.cn.bybhj.cn http://www.morning.cjsrg.cn.gov.cn.cjsrg.cn http://www.morning.sxwfx.cn.gov.cn.sxwfx.cn http://www.morning.wjxyg.cn.gov.cn.wjxyg.cn http://www.morning.jykzy.cn.gov.cn.jykzy.cn http://www.morning.nkhdt.cn.gov.cn.nkhdt.cn http://www.morning.qnqt.cn.gov.cn.qnqt.cn http://www.morning.fbzyc.cn.gov.cn.fbzyc.cn http://www.morning.gxeqedd.cn.gov.cn.gxeqedd.cn http://www.morning.qxlgt.cn.gov.cn.qxlgt.cn http://www.morning.rqqmd.cn.gov.cn.rqqmd.cn http://www.morning.xtxp.cn.gov.cn.xtxp.cn http://www.morning.xbzfz.cn.gov.cn.xbzfz.cn http://www.morning.kwqt.cn.gov.cn.kwqt.cn http://www.morning.qrcsb.cn.gov.cn.qrcsb.cn