MOTOR_STEP_O_ATY.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * @file MOTOR_STEP_O_ATY.h
  3. *
  4. * @param Project DEVICE_GENERAL_ATY_LIB
  5. *
  6. * @author ATY
  7. *
  8. * @copyright
  9. * - Copyright 2017 - 2026 MZ-ATY
  10. * - This code follows:
  11. * - MZ-ATY Various Contents Joint Statement -
  12. * <a href="https://mengze.top/MZ-ATY_VCJS">
  13. * https://mengze.top/MZ-ATY_VCJS</a>
  14. * - CC 4.0 BY-NC-SA -
  15. * <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  16. * https://creativecommons.org/licenses/by-nc-sa/4.0/</a>
  17. * - Your use will be deemed to have accepted the terms of this statement.
  18. *
  19. * @brief functions of open loop stepper motor control for C platform
  20. *
  21. * @version
  22. * - 1_00_260109 > ATY
  23. * -# Preliminary version
  24. ********************************************************************************
  25. */
  26. #ifndef __MOTOR_STEP_O_ATY_H
  27. #define __MOTOR_STEP_O_ATY_H
  28. #include "INCLUDE_ATY.h"
  29. /******************************* For user *************************************/
  30. /******************************************************************************/
  31. struct MOTOR_STEP_O_ATY_Dev{
  32. uint8_t (*enSet)(uint8_t en);
  33. uint8_t (*dirSet)(uint8_t dir);
  34. void (*pwmSet)(float frequency, float dutycycle);
  35. void (*pwmSetCount)(float frequency, float dutycycle, uint16_t step);
  36. uint8_t mode;
  37. uint8_t enable;
  38. uint8_t direction;
  39. uint16_t stepCount;
  40. float frequency; // Hz
  41. float dutyCycle; // 0-100f
  42. float speed; // rpm
  43. uint16_t fullSteps; // steps per revolution, 360 / 1.8 degree = 200 steps
  44. uint8_t microstepping; // 1/8 = 8, 1/16, 1/32, 1/64, 1/128, 1/256
  45. uint8_t lock;
  46. };
  47. #define MOTOR_OPEN_MODE_COUNT 0x00 // Count mode - run for specified steps, step set 1 to continuous
  48. #define MOTOR_OPEN_MODE_NOCOUNT 0x01 // Continuous mode - run continuously
  49. uint8_t MSO_Cycle(struct MOTOR_STEP_O_ATY_Dev* dev,
  50. uint8_t mode, uint8_t enable, uint8_t direction,
  51. uint16_t stepCount,
  52. float frequency, float dutyCycle, float speed);
  53. #endif /* __MOTOR_STEP_O_ATY_H */
  54. /******************************** End Of File *********************************/