mc_api.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /**
  2. ******************************************************************************
  3. * @file mc_api.h
  4. * @author Motor Control SDK Team, ST Microelectronics
  5. * @brief This file defines the high level interface of the Motor Control SDK.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under Ultimate Liberty license
  13. * SLA0044, the "License"; You may not use this file except in compliance with
  14. * the License. You may obtain a copy of the License at:
  15. * www.st.com/SLA0044
  16. *
  17. ******************************************************************************
  18. * @ingroup MCIAPI
  19. */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef __MC_API_H
  22. #define __MC_API_H
  23. #include "mc_type.h"
  24. #include "mc_interface.h"
  25. #include "state_machine.h"
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif /* __cplusplus */
  29. /** @addtogroup MCSDK
  30. * @{
  31. */
  32. /** @addtogroup MCIAPI
  33. * @{
  34. */
  35. /* Starts Motor 1 */
  36. bool MC_StartMotor1(void);
  37. /* Stops Motor 1 */
  38. bool MC_StopMotor1(void);
  39. /* Programs a Speed ramp for Motor 1 */
  40. void MC_ProgramSpeedRampMotor1( int16_t hFinalSpeed, uint16_t hDurationms );
  41. /* Programs a Torque ramp for Motor 1 */
  42. void MC_ProgramTorqueRampMotor1( int16_t hFinalTorque, uint16_t hDurationms );
  43. /* Programs a current reference for Motor 1 */
  44. void MC_SetCurrentReferenceMotor1( qd_t Iqdref );
  45. /* Returns the state of the last submited command for Motor 1 */
  46. MCI_CommandState_t MC_GetCommandStateMotor1( void);
  47. /* Stops the execution of the current speed ramp for Motor 1 if any */
  48. bool MC_StopSpeedRampMotor1(void);
  49. /* Stops the execution of the on going ramp for Motor 1 if any */
  50. void MC_StopRampMotor1(void);
  51. /* Returns true if the last submited ramp for Motor 1 has completed, false otherwise */
  52. bool MC_HasRampCompletedMotor1(void);
  53. /* Returns the current mechanical rotor speed reference set for Motor 1, expressed in the unit defined by #SPEED_UNIT */
  54. int16_t MC_GetMecSpeedReferenceMotor1(void);
  55. /* Returns the last computed average mechanical rotor speed for Motor 1, expressed in the unit defined by #SPEED_UNIT */
  56. int16_t MC_GetMecSpeedAverageMotor1(void);
  57. /* Returns the final speed of the last ramp programmed for Motor 1, if this ramp was a speed ramp */
  58. int16_t MC_GetLastRampFinalSpeedMotor1(void);
  59. /* Returns the current Control Mode for Motor 1 (either Speed or Torque) */
  60. STC_Modality_t MC_GetControlModeMotor1(void);
  61. /* Returns the direction imposed by the last command on Motor 1 */
  62. int16_t MC_GetImposedDirectionMotor1(void);
  63. /* Returns the current reliability of the speed sensor used for Motor 1 */
  64. bool MC_GetSpeedSensorReliabilityMotor1(void);
  65. /* returns the amplitude of the phase current injected in Motor 1 */
  66. int16_t MC_GetPhaseCurrentAmplitudeMotor1(void);
  67. /* returns the amplitude of the phase voltage applied to Motor 1 */
  68. int16_t MC_GetPhaseVoltageAmplitudeMotor1(void);
  69. /* returns current Ia and Ib values for Motor 1 */
  70. ab_t MC_GetIabMotor1(void);
  71. /* returns current Ialpha and Ibeta values for Motor 1 */
  72. alphabeta_t MC_GetIalphabetaMotor1(void);
  73. /* returns current Iq and Id values for Motor 1 */
  74. qd_t MC_GetIqdMotor1(void);
  75. /* returns Iq and Id reference values for Motor 1 */
  76. qd_t MC_GetIqdrefMotor1(void);
  77. /* returns current Vq and Vd values for Motor 1 */
  78. qd_t MC_GetVqdMotor1(void);
  79. /* returns current Valpha and Vbeta values for Motor 1 */
  80. alphabeta_t MC_GetValphabetaMotor1(void);
  81. /* returns the electrical angle of the rotor of Motor 1, in DDP format */
  82. int16_t MC_GetElAngledppMotor1(void);
  83. /* returns the current electrical torque reference for Motor 1 */
  84. int16_t MC_GetTerefMotor1(void);
  85. /* Sets the reference value for Id */
  86. void MC_SetIdrefMotor1( int16_t hNewIdref );
  87. /* re-initializes Iq and Id references to their default values */
  88. void MC_Clear_IqdrefMotor1(void);
  89. /* Acknowledge a Motor Control fault on Motor 1 */
  90. bool MC_AcknowledgeFaultMotor1( void );
  91. /* Returns a bitfiled showing faults that occured since the State Machine of Motor 1 was moved to FAULT_NOW state */
  92. uint16_t MC_GetOccurredFaultsMotor1(void);
  93. /* Returns a bitfield showing all current faults on Motor 1 */
  94. uint16_t MC_GetCurrentFaultsMotor1(void);
  95. /* returns the current state of Motor 1 state machine */
  96. State_t MC_GetSTMStateMotor1(void);
  97. /**
  98. * @}
  99. */
  100. /**
  101. * @}
  102. */
  103. #ifdef __cplusplus
  104. }
  105. #endif /* __cpluplus */
  106. #endif /* __MC_API_H */
  107. /******************* (C) COPYRIGHT 2019 STMicroelectronics *****END OF FILE****/