#ifndef __ENCALIGNCTRLCLASS_H
#define __ENCALIGNCTRLCLASS_H
EncAlignCtrlClass.h 是一个头文件,定义了用于执行电机启动时的编码器自动对准过程的 EncAlignCtrl 类。 EncAlignCtrl 类具有初始化、开始对准、执行对准、检查是否对准、设置重启状态和获取重启状态等方法。
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Includes ------------------------------------------------------------------*/
#include "mc_type.h"
#include "speed_torq_ctrl.h"
#include "virtual_speed_sensor.h"
#include "encoder_speed_pos_fdbk.h"
结构体
typedef struct
{
SpeednTorqCtrl_Handle_t *pSTC; /*!< Speed and torque controller object used by EAC.*/
VirtualSpeedSensor_Handle_t *pVSS; /*!< Virtual speed sensor object used by EAC.*/
ENCODER_Handle_t *pENC; /*!< Encoder object used by EAC.*/
uint16_t hRemainingTicks; /*!< Number of clock events remaining to complete
the alignment.*/
bool EncAligned; /*!< This flag is true if the encoder has been
aligned at least one time, false if hasn't been
never aligned.*/
bool EncRestart; /*!< This flag is used to force a restart of the
motorafter the encoder alignment. It is true
if a restart is programmed else false*/
uint16_t hEACFrequencyHz; /*!< Frequency expressed in Hz at which the user
clocks the EAC calling EAC_Exec method */
int16_t hFinalTorque; /*!< Motor torque reference imposed by STC at the
end of programmed alignment. This value
represents actually the Iq current expressed in
digit.*/
int16_t hElAngle; /*!< Electrical angle of programmed alignment
expressed in s16degrees.*/
uint16_t hDurationms; /*!< Duration of the programmed alignment expressed
in milliseconds.*/
uint8_t bElToMecRatio; /*!< Coefficient used to transform electrical to
mechanical quantities and viceversa. It usually
coincides with motor pole pairs number*/
} EncAlign_Handle_t;
EAC_Init
void EAC_Init(EncAlign_Handle_t *pHandle, SpeednTorqCtrl_Handle_t *pSTC, VirtualSpeedSensor_Handle_t *pVSS, ENCODER_Handle_t *pENC );
初始化 EncAlignCtrl 实例。
pHandle
:EncAlign_Handle_t 结构体指针。pSTC
:SpeednTorqCtrl_Handle_t 结构体指针。pVSS
:VirtualSpeedSensor_Handle_t 结构体指针。pENC
:ENCODER_Handle_t 结构体指针。
EAC_StartAlignment
void EAC_StartAlignment(EncAlign_Handle_t *pHandle);
开始编码器对准过程。
pHandle
:EncAlign_Handle_t 结构体指针。
EAC_Exec
bool EAC_Exec(EncAlign_Handle_t *pHandle);
时钟编码器对准控制器。
pHandle
:EncAlign_Handle_t 结构体指针。
EAC_IsAligned
bool EAC_IsAligned(EncAlign_Handle_t *pHandle);
检查编码器是否已对准至少一次。
pHandle
:EncAlign_Handle_t 结构体指针。
EAC_SetRestartState
void EAC_SetRestartState(EncAlign_Handle_t *pHandle, bool restart);
设置编码器对准后重新启动的状态。
pHandle
:EncAlign_Handle_t 结构体指针。restart
:bool 类型,编码器对准后重新启动的状态。
EAC_GetRestartState
bool EAC_GetRestartState(EncAlign_Handle_t *pHandle);
获取编码器对准后重新启动的状态。
pHandle
:EncAlign_Handle_t 结构体指针。