eecs-bsp-test-code-2/inc/StepMotor.h

50 lines
4.4 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**********************************StepMotor 说明 ************************************************************************
StepMotor用于STC-B板控制步进电机。共提供1个驱动函数、3个应用函数
(1) StepMotorInit():步进电机模块驱动函数
(2) SetStepMotor(char StepMotor,unsigned char speed ,int steps ) 指定步进电机、按指定转动速度、转动指定步
函数参数StepMotor 指定步进电机取值enum StepMotorName中定义
enumStepMotor1 SM 接口上的步进电机
enumStepMotor2 此时用L0L3四个LED模拟一个4相步进电机
enumStepMotor3 此时用L4L7四个LED模拟一个4相步进电机
speed 步进电机转动速度0255单位步/S。 (实际每步时间=int(1000mS/speed) mS与设置速度可能存在一定误差
steps 步进电机转动步数(-3276832767负值表示反转
函数返回enumSetStepMotorOK 调用成功enum StepMotorActName中定义
enumSetStepMotorFail调用失败电机名不在指定范围或speed=0,或调用时正在转动)
3EmStop(char StepMotor) 紧急停止指定步进电机转动
函数参数StepMotor 指定步进电机。函数参数不对将返回0值。
函数返回:剩余未转完的步数
4GetStepMotorStatus(char StepMotor) 获取指定步进电机状态
函数参数StepMotor 指定步进电机
函数返回enumStepMotorFree:自由enum StepMotorActName中定义
enumStepMotorBusy,忙(正在转动)
enumSetStepMotorFail调用失败步进电机名不在指定范围
编写徐成电话18008400450 2021年4月16日设计2021年4月18日更新
*/
#ifndef _StepMotor_H_
#define _StepMotor_H_
extern void StepMotorInit(); // 步进电机模块初始化
extern char SetStepMotor(char StepMotor,unsigned char speed ,int steps ); // 指定步进电机、按指定转动速度、转动指定步
// 函数参数StepMotor 指定步进电机取值enum StepMotorName中定义
// enumStepMotor1 SM 接口上的步进电机
// enumStepMotor2 此时用L0L3四个LED模拟一个4相步进电机
// enumStepMotor3 此时用L4L7四个LED模拟一个4相步进电机
// speed 步进电机转动速度0255单位步/S (实际每步时间=int(1000mS/speed) mS与设置速度可能存在一定误差
// steps 步进电机转动步数(-3276832767负值表示反转
// 函数返回:
// enumSetStepMotorOK调用成功
// enumSetStepMotorFail调用失败电机名不在指定范围或speed=0,或调用时正在转动)
extern int EmStop(char StepMotor); // 紧急停止指定步进电机转动
// 函数参数StepMotor 指定步进电机(函数参数不对将返回0值)
// 函数返回:剩余未转完的步数
extern unsigned char GetStepMotorStatus(char StepMotor); // 获取指定步进电机状态
// 函数参数StepMotor 指定步进电机
// 函数返回enumStepMotorFree:自由
// enumStepMotorBusy,忙(正在转动)
// enumSetStepMotorFail调用失败步进电机名不在指定范围
enum StepMotorName {enumStepMotor1=0,enumStepMotor2,enumStepMotor3};
enum StepMotorActName {enumStepMotorFree,enumStepMotorBusy,enumSetStepMotorOK,enumSetStepMotorFail};
#endif