/** * @file MOTOR_STEP_C_ATY.h * * @param Project DEVICE_GENERAL_ATY_LIB * * @author ATY * * @copyright * - Copyright 2017 - 2026 MZ-ATY * - This code follows: * - MZ-ATY Various Contents Joint Statement - * * https://mengze.top/MZ-ATY_VCJS * - CC 4.0 BY-NC-SA - * * https://creativecommons.org/licenses/by-nc-sa/4.0/ * - Your use will be deemed to have accepted the terms of this statement. * * @brief functions of close loop stepper motor control for C platform * Based on position feedback from encoder (e.g. MT6816) * * @version * - 1_00_260109 > ATY * -# Preliminary version ******************************************************************************** */ #ifndef __MOTOR_STEP_C_ATY_H #define __MOTOR_STEP_C_ATY_H #include "INCLUDE_ATY.h" /******************************* For user *************************************/ /******************************************************************************/ struct MOTOR_STEP_C_ATY_Dev{ uint8_t (*enSet)(uint8_t en); uint8_t (*dirSet)(uint8_t dir); void (*pwmSet)(float frequency, float dutycycle); void (*pwmSetCount)(float frequency, float dutycycle, uint16_t step); uint8_t mode; uint8_t enable; uint8_t direction; uint16_t stepCount; float frequency; // Hz float dutyCycle; // 0-100f float speed; // rpm uint8_t autoPower; uint8_t forbidReverseCorrection; /* if used for flow control, fix over steps may lead no effect or bad effect, set this to 1 to forbid motor reverse */ uint8_t positionFixFlag; float startAngle; float targetAngle; uint8_t angleLock; uint16_t cycleSpace; // in ms uint16_t fullSteps; // steps per revolution, 360 / 1.8 degree = 200 steps uint8_t microstepping; // 1/8 = 8, 1/16, 1/32, 1/64, 1/128, 1/256 uint8_t lock; }; #define MOTOR_STEP_C_MODE_POST_MOTION 0x00 // post-Motion Correction #define MOTOR_STEP_C_MODE_NOCOUNT 0x01 // continuous mode - run continuously #define MOTOR_STEP_C_MODE_POSITION_CC 0x02 // position Closed-Loop Control #define MOTOR_STEP_C_MODE_ANGLE_LOCK 0x03 // angle lock uint8_t MSC_Cycle(struct MOTOR_STEP_C_ATY_Dev* dev, uint8_t mode, uint8_t enable, uint8_t direction, uint16_t stepCount, float frequency, float dutyCycle, float speed, float currentAngle, float targetAngle); #endif /* __MOTOR_STEP_C_ATY_H */ /******************************** End Of File *********************************/