基于STM32F0+L6474步进驱动开源分享:源码+原理图+BOM表等全部开源 基本功能:细分设置、电流设置、软件启动、停止、正反转、加减速、回原点、回参考点等你想到的功能都有 主芯片:STM32F030R8T6(NUCLEO板都支持) 软件:KEIL MDK打开(5.0以上版本) 资料下载:见附件 原创:锝臻科技——游名 //----- Increase deceleration while running
/* Increase deceleration of device 0 to 480 step/s^2 */ //减速度测试
BSP_MotorControl_SetDeceleration(0,480); //设置减速度为480
HAL_Delay(5000); //延时5S
/* Decrease speed of device 0 to 1200 step/s */
BSP_MotorControl_SetMaxSpeed(0,1200); //设置最高速度为1200
HAL_Delay(5000); //延时5S
/* Get current speed */
mySpeed = BSP_MotorControl_GetCurrentSpeed(0); //获取当前速度
//----- Soft stopped required while running //电机运转时:软件停止电机运转测试
/* Request soft stop of device 0 */
BSP_MotorControl_SoftStop(0); //发送软件停止指令
/* Wait for the motor of device 0 ends moving */
BSP_MotorControl_WaitWhileActive(0); //等待电机停止运转
/* Wait for 2 seconds */
HAL_Delay(2000); //延时2S
//----- Run stopped by hardstop
/* Request device 0 to run in FORWARD direction */
BSP_MotorControl_Run(0,FORWARD); //电机正转
HAL_Delay(5000); //延时5S
/* Request device 0 to immediatly stop */
BSP_MotorControl_HardStop(0); //电机硬件停止
BSP_MotorControl_WaitWhileActive(0); //等待电机停转
/* Request device 0 to disable bridge */
BSP_MotorControl_CmdDisable(0); //关闭电机驱动H桥, 关闭后,手旋转电机就可以转的动,要不然转不动;
/* Wait for 2 seconds */
HAL_Delay(2000); //延时2S
//----- GOTO stopped by softstop //移动到目标点过程中:软件停止测试
/* Request device 0 to go to position 20000 */
BSP_MotorControl_GoTo(0,20000); //发送移动20000步命令
HAL_Delay(5000); //延时5S
/* Request device 0 to perform a soft stop */
BSP_MotorControl_SoftStop(0); //软件停止
BSP_MotorControl_WaitWhileActive(0); //等待电机停止
/* Wait for 2 seconds */
HAL_Delay(2000); //延时2S
|