| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- /*
- * Copyright (c) 2021-2022 HPMicro
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
- #ifndef HPM_FOC_H
- #define HPM_FOC_H
- #if defined(__cplusplus)
- extern "C" {
- #endif /* __cplusplus */
- #include "hpm_motor_math.h"
- /**
- * @addtogroup mcl_foc_interface HPMicro MCL FOC APIs
- * @ingroup middleware_mcl_interfaces
- * @{
- *
- */
- /**
- * @brief Calculation of speed by angular difference of sampling.
- *
- * @param[inout] par Speed parameters @ref BLDC_CONTRL_SPD_PARA
- */
- void hpm_mcl_bldc_foc_al_speed(BLDC_CONTRL_SPD_PARA *par);
- /**
- * @brief Update output pwm according to duty cycle, provided by the user
- *
- * @param[inout] par @ref BLDC_CONTROL_PWMOUT_PARA
- */
- void hpm_mcl_bldc_foc_pwmset(BLDC_CONTROL_PWMOUT_PARA *par);
- /**
- * @brief Reconfiguring three-phase currents
- *
- * @param[inout] par @ref BLDC_CONTROL_CURRENT_PARA
- */
- void hpm_mcl_bldc_foc_current_cal(BLDC_CONTROL_CURRENT_PARA *par);
- /**
- * @brief pi control function
- *
- * @param[inout] par @ref BLDC_CONTRL_PID_PARA
- */
- void hpm_mcl_bldc_foc_pi_contrl(BLDC_CONTRL_PID_PARA *par);
- /**
- * @brief Clark Transformation
- *
- * @param[in] currentu U-phase current
- * @param[in] currentv V-phase current
- * @param[in] currentw W-phase current
- * @param[out] currentalpha alpha-axis current
- * @param[out] currentbeta beta-axis current
- */
- void hpm_mcl_bldc_foc_clarke(HPM_MOTOR_MATH_TYPE currentu, HPM_MOTOR_MATH_TYPE currentv, HPM_MOTOR_MATH_TYPE currentw,
- HPM_MOTOR_MATH_TYPE *currentalpha, HPM_MOTOR_MATH_TYPE *currentbeta);
- /**
- * @brief transform
- *
- * @brief Park transform
- *
- * @param[in] currentalpha alpha-axis current
- * @param[in] currentbeta beta-axis current
- * @param[out] currentd d-axis current
- * @param[out] currentq q-axis current
- * @param[in] sin_angle sin(theta)
- * @param[in] cos_angle cos(theta)
- */
- void hpm_mcl_bldc_foc_park(HPM_MOTOR_MATH_TYPE currentalpha, HPM_MOTOR_MATH_TYPE currentbeta,
- HPM_MOTOR_MATH_TYPE *currentd, HPM_MOTOR_MATH_TYPE *currentq,
- HPM_MOTOR_MATH_TYPE sin_angle, HPM_MOTOR_MATH_TYPE cos_angle);
- /**
- * @brief Motor rotor angle, electrical angle
- *
- * @param[in] ud d-axis voltage
- * @param[in] uq q-axis voltage
- * @param[out] ualpha u-alpha-axis voltage
- * @param[out] ubeta u-beta-axis voltage
- * @param[in] sin_angle sin(theta)
- * @param[in] cos_angle cos(theta)
- */
- void hpm_mcl_bldc_foc_inv_park(HPM_MOTOR_MATH_TYPE ud, HPM_MOTOR_MATH_TYPE uq,
- HPM_MOTOR_MATH_TYPE *ualpha, HPM_MOTOR_MATH_TYPE *ubeta,
- HPM_MOTOR_MATH_TYPE sin_angle, HPM_MOTOR_MATH_TYPE cos_angle);
- /**
- * @brief svpwm function
- *
- * @param par @ref BLDC_CONTROL_PWM_PARA
- */
- void hpm_mcl_bldc_foc_svpwm(BLDC_CONTROL_PWM_PARA *par);
- /**
- * @brief Speed Control PI Loop
- *
- * @param[in] memory Internal Data
- * @param[in] targetspeed target speed
- * @param[in] curspeed Current speed
- * @param[in] kp Scale factor
- * @param[in] ki Integral factor
- * @param[in] max Output maximum and integration maximum
- * @param[out] output Output after pi control
- */
- void hpm_mcl_bldc_foc_speed_ctrl(float *memory, float targetspeed, float curspeed,
- float kp, float ki, int16_t max, int16_t *output);
- /**
- * @brief Position Control P Loop
- *
- * @param targetpos Target position
- * @param curpos current position
- * @param kp Scale factor
- * @param max Output maximum
- * @param output Output after p control
- */
- void hpm_mcl_bldc_foc_position_ctrl(float targetpos, float curpos,
- float kp, float max, float *output);
- /**
- * @brief dq-axis voltage conversion to pwm output
- *
- * @param par @ref BLDC_CONTROL_FOC_PARA
- */
- void hpm_mcl_bldc_foc_ctrl_dq_to_pwm(BLDC_CONTROL_FOC_PARA *par);
- /**
- * @}
- *
- */
- #if defined(__cplusplus)
- }
- #endif /* __cplusplus */
- #endif
|