首页 步进电机插补算法stm

步进电机插补算法stm

举报
开通vip

步进电机插补算法stm文件管理序列号:[K8UY-K9IO69-O6M243-OL889-F88688]步进电机插补算法stm#include"stm32f10x.h"#include"delay.h"#include"misc.h"#include#include"stm32f10x_tim.h"#include"stm32f10x_rcc.h"#include"stm32f10x_usart.h"#includevoidRCC_Configuration(void);voidGPIO_Configuration(void);void...

步进电机插补算法stm
文件管理序列号:[K8UY-K9IO69-O6M243-OL889-F88688]步进电机插补算法stm#include"stm32f10x.h"#include"delay.h"#include"misc.h"#include#include"stm32f10x_tim.h"#include"stm32f10x_rcc.h"#include"stm32f10x_usart.h"#includevoidRCC_Configuration(void);voidGPIO_Configuration(void);voidNVIC_Configuration(void);voidTIM_Configuration(void);voidUSART_Configuration(void);intfputc(intch,FILE*f);intfgetc(FILE*f);floatMx=1.44f,My=2.88f;//起点floatNx=10.0f,Ny=7.61f;//终点floatX1,Y1;floatX2,Y2;floatX3,Y3;//三种 方法 快递客服问题件处理详细方法山木方法pdf计算方法pdf华与华方法下载八字理论方法下载 走后的坐标floatk;//斜率floatb;//y=kx+bfloatX,Y;//实际运行的坐标floatDelta1,Delta2,Delta3,Delta4;//三种方法的误差,4为不走最后一步的误差floatDelta;//实际误差//floatDeltaMax;//最大误差charway;//选择的走法inta;//TIM6中断次数intnum=0;//总步数inttx=1,ty=1;//用来判断中断是否发生intnumx,numy;//计XY的步数intcounter=0;//计数值floattime;//时间floatnxd,nyd;//开始减速坐标floatnx,ny;//nx=Nx-0.0144f;floatfenmu;//公式中分母//intfrex[20]={2,10,30,60,100,150,220,300,390,500};//intfrey[20]={2,10,30,60,100,150,220,300,390,500};intfrex[20]={1098,2931,7585,18242,37754,62245,81757,92414,97068,98901};intfrey[20]={1098,2931,7585,18242,37754,62245,81757,92414,97068,98901};intprex[20]={0};intprey[20]={0};intmain(void){inti,j;intnpwm=10;//加减速每段脉冲数//算出预分频值for(i=0;i<10;i++){}//配置,初始化RCC_Configuration();GPIO_Configuration();USART_Configuration();TIM_Configuration();NVIC_Configuration();Delay_Init();TIM_Cmd(TIM2,ENABLE);//catchXYTIM_Cmd(TIM6,ENABLE);//计时//TIM_SetCounter(TIM6,0);//开始运行{//计算相关量X=Mx;Y=My;k=(Ny-My)/(Nx-Mx);b=My-k*Mx;//y=kx+bnxd=Nx-90*0.0144f;nyd=Ny-90*0.0144f;nx=Nx-0.0144f;ny=Ny-0.0144f;fenmu=sqrt(k*k+1);for(i=1;i<10;i++)//加速阶段,分10段{while(jDeltaMax)//DeltaMax=Delta;}for(i=8;i>=0;i--)//减速阶段,分10段{TIM_PrescalerConfig(TIM3,prex[i]-1,TIM_PSCReloadMode_Immediate);//改预分频,频率TIM_PrescalerConfig(TIM4,prey[i]-1,TIM_PSCReloadMode_Immediate);while(jDeltaMax)//DeltaMax=Delta;}//判断是否要走超出终点{X1=X+0.0144f;Y1=Y;X2=X;Y2=Y+0.0144f;X3=X+0.0144f;Y3=Y+0.0144f;Delta1=sqrt((Nx-X1)*(Nx-X1)+(Ny-Y1)*(Ny-Y1));Delta2=sqrt((Nx-X2)*(Nx-X2)+(Ny-Y2)*(Ny-Y2));Delta3=sqrt((Nx-X3)*(Nx-X3)+(Ny-Y3)*(Ny-Y3));if(Delta1
©COPYRIGHT2009STMicroelectronics
*//*Includes------------------------------------------------------------------*/#include"stm32f10x_it.h"#include"stm32f10x_exti.h"#include"stm32f10x_rcc.h"#include"misc.h"#include"stm32f10x_dma.h"#include"stm32f10x_usart.h"#include/**@addtogroupTemplate_Project*@{*//*Privatetypedef-----------------------------------------------------------*//*Privatedefine------------------------------------------------------------*//*Privatemacro-------------------------------------------------------------*//*Privatevariables---------------------------------------------------------*//*Privatefunctionprototypes-----------------------------------------------*//*Privatefunctions---------------------------------------------------------*//******************************************************************************//*Cortex-M3ProcessorExceptionsHandlers*//******************************************************************************//***@briefThisfunctionhandlesNMIexception.*@paramNone*@retval:None*/voidNMI_Handler(void){}/***@briefThisfunctionhandlesHardFaultexception.*@paramNone*@retval:None*/voidHardFault_Handler(void){/*GotoinfiniteloopwhenHardFaultexceptionoccurs*///while(1){}}/***@briefThisfunctionhandlesMemoryManageexception.*@paramNone*@retval:None*/voidMemManage_Handler(void){/*GotoinfiniteloopwhenMemoryManageexceptionoccurs*/while(1){}}/***@briefThisfunctionhandlesBusFaultexception.*@paramNone*@retval:None*/voidBusFault_Handler(void){/*GotoinfiniteloopwhenBusFaultexceptionoccurs*/while(1){}}/***@briefThisfunctionhandlesUsageFaultexception.*@paramNone*@retval:None*/voidUsageFault_Handler(void){/*GotoinfiniteloopwhenUsageFaultexceptionoccurs*/while(1){}}/***@briefThisfunctionhandlesSVCallexception.*@paramNone*@retval:None*/voidSVC_Handler(void){}/***@briefThisfunctionhandlesDebugMonitorexception.*@paramNone*@retval:None*/voidDebugMon_Handler(void){}/***@briefThisfunctionhandlesPendSVCexception.*@paramNone*@retval:None*/voidPendSV_Handler(void){}/***@briefThisfunctionhandlesSysTickHandler.*@paramNone*@retval:None*/externvoidTimingDelay_Decrement(void);voidSysTick_Handler(void){}/******************************************************************************//*STM32F10xPeripheralsInterruptHandlers*//*AddheretheInterruptHandlerfortheusedperipheral(s)(PPP),forthe*//*availableperipheralinterrupthandler'snamepleaserefertothestartup*//*file(startup_stm32f10x_xx.s).*//******************************************************************************//***@briefThisfunctionhandlesPPPinterruptrequest.*@paramNone*@retval:None*//*voidPPP_IRQHandler(void){}*//***@}*//*******************(C)COPYRIGHT2009STMicroelectronics*****ENDOFFILE****/voidDMA1_Channel4_IRQHandler(void){}externintcounter;externdoubletime;externinta;externintnumx,numy,a,tx,ty;voidTIM2_IRQHandler(void)//catchx{if(TIM_GetITStatus(TIM2,TIM_IT_CC3)==SET){TIM_Cmd(TIM3,DISABLE);//X//numx++;//走的步数tx=0;TIM_ClearITPendingBit(TIM2,TIM_IT_CC3);}if(TIM_GetITStatus(TIM2,TIM_IT_CC4)==SET){TIM_Cmd(TIM4,DISABLE);//y//numy++;//走的步数ty=0;TIM_ClearITPendingBit(TIM2,TIM_IT_CC4);}}voidTIM6_IRQHandler(void){if(TIM_GetITStatus(TIM6,TIM_IT_Update)==SET){a++;//counter=TIM_GetCounter(TIM6);//TIM_Cmd(TIM6,DISABLE);//time=a*65536/72.0+counter/72.0;//printf("%d\n",a);//printf("%d\n",counter);//printf("%fus\n",time);TIM_ClearITPendingBit(TIM6,TIM_FLAG_Update);}}
本文档为【步进电机插补算法stm】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: ¥18.0 已有0 人下载
最新资料
资料动态
专题动态
个人认证用户
统江
人民教师
格式:doc
大小:46KB
软件:Word
页数:0
分类:企业经营
上传时间:2021-08-25
浏览量:1