本帖最后由 freeelectron 于 2018-9-2 16:56 编辑
通过任务1:主要熟悉调用MC API实现电机基础操作,了解速度参数设定 。
添加代码,通过最简单的方法,将代码添加到while (1)即可: - while (1)
- {
- /* USER CODE END WHILE */
- /* USER CODE BEGIN 3 */
- MC_ProgramSpeedRampMotor1(3000/6,1000);
- MC_StartMotor1();
- HAL_Delay(10000);
- MC_StopMotor1();
- HAL_Delay(5000);
- }
- /* USER CODE END 3 */
复制代码
速度波形查看:
API说明: void MC_ProgramSpeedRampMotor1( int16_t hFinalSpeed, uint16_t hDurationms );
//设置速度指令。.在调用此函数后速度指令在 hDurationms 设置的时间内由当前速度变化到 hFinalSpeed设置的目标速度。
MC_StartMotor1();
//启动
MC_StopMotor1();
//停止
|