HPM SDK
HPMicro Software Development Kit
hpm_mcl_control.c File Reference
#include "hpm_mcl_control.h"
#include "hpm_mcl_math.h"

Functions

float hpm_mcl_control_sin (float x)
 
float hpm_mcl_control_cos (float x)
 
float hpm_mcl_control_arctan (float y, float x)
 
hpm_mcl_stat_t hpm_mcl_control_clarke (float ia, float ib, float ic, float *alpha, float *beta)
 
hpm_mcl_stat_t hpm_mcl_control_park (float alpha, float beta, float sin_x, float cos_x, float *d, float *q)
 
hpm_mcl_stat_t hpm_mcl_control_pi (float ref, float sens, mcl_control_pid_t *pid_x, float *output)
 
hpm_mcl_stat_t hpm_mcl_control_inv_park (float d, float q, float sin_x, float cos_x, float *alpha, float *beta)
 
hpm_mcl_stat_t hpm_mcl_control_svpwm (float alpha, float beta, float vbus, mcl_control_svpwm_duty_t *duty)
 
hpm_mcl_stat_t hpm_mcl_control_step_svpwm (float alpha, float beta, float vbus, mcl_control_svpwm_duty_t *duty)
 
hpm_mcl_stat_t hpm_mcl_control_get_block_sector (hall_phase_t hall, uint8_t u, uint8_t v, uint8_t w, uint8_t *sector)
 
float hpm_mcl_control_lowpass_filter (float input, float *mem, float k)
 
hpm_mcl_stat_t hpm_mcl_control_dead_area_polarity_detection (mcl_control_dead_area_compensation_t *dead_area, float id, float iq, float theta, float deadtime, float ts, mcl_control_dead_area_pwm_offset_t *pwm_out)
 
void hpm_mcl_control_smc_init (mcl_control_smc_t *smc_cfg)
 
void hpm_mcl_control_smc_process (mcl_control_smc_t *smc_cfg, float ualpha, float ubeta, float ialpha, float ibeta)
 
hpm_mcl_stat_t hpm_mcl_control_offline_param_detection_rs (mcl_control_offline_param_detection_t *detection, float ialpha, float ibeta, float *ud, float *uq)
 
hpm_mcl_stat_t hpm_mcl_control_offline_param_detection_ld (mcl_control_offline_param_detection_t *detection, float ialpha, float ibeta, float *ud, float *uq)
 
hpm_mcl_stat_t hpm_mcl_control_offline_param_detection_lq (mcl_control_offline_param_detection_t *detection, float ialpha, float ibeta, float *ud, float *uq)
 
hpm_mcl_stat_t hpm_mcl_control_offline_param_detection_ls (mcl_control_offline_param_detection_t *detection)
 
hpm_mcl_stat_t hpm_mcl_control_offline_param_detection_flux (mcl_control_offline_param_detection_t *detection, float ialpha, float ibeta, float ualpha, float ubeta, float *ref_d, float *ref_q)
 
hpm_mcl_stat_t hpm_mcl_control_detection_init (mcl_control_offline_param_detection_t *detection)
 
hpm_mcl_stat_t hpm_mcl_pid_to_3p3z (mcl_control_pid_cfg_t *cfg_pid, mcl_clc_coeff_cfg_t *cfg_3p3z)
 Convert a 3p3z controller to a pid controller. More...
 
hpm_mcl_stat_t hpm_mcl_delta_pid (float setpoint, float feedback, mcl_control_pid_t *pid_x, float *output)
 
hpm_mcl_stat_t hpm_mcl_position_pid (float setpoint, float feedback, mcl_control_pid_t *pid_x, float *output)
 Calculate the output of a Positional PID controller. More...
 
hpm_mcl_stat_t hpm_mcl_pid_init (mcl_control_pid_t *pid_x)
 
hpm_mcl_stat_t hpm_mcl_control_init (mcl_control_t *control, mcl_control_cfg_t *cfg)
 Initialise the operating data for the control function. More...
 

Function Documentation

◆ hpm_mcl_control_arctan()

float hpm_mcl_control_arctan ( float  y,
float  x 
)

◆ hpm_mcl_control_clarke()

hpm_mcl_stat_t hpm_mcl_control_clarke ( float  ia,
float  ib,
float  ic,
float *  alpha,
float *  beta 
)

◆ hpm_mcl_control_cos()

float hpm_mcl_control_cos ( float  x)

◆ hpm_mcl_control_dead_area_polarity_detection()

hpm_mcl_stat_t hpm_mcl_control_dead_area_polarity_detection ( mcl_control_dead_area_compensation_t dead_area,
float  id,
float  iq,
float  theta,
float  deadtime,
float  ts,
mcl_control_dead_area_pwm_offset_t pwm_out 
)

◆ hpm_mcl_control_detection_init()

hpm_mcl_stat_t hpm_mcl_control_detection_init ( mcl_control_offline_param_detection_t detection)

◆ hpm_mcl_control_get_block_sector()

hpm_mcl_stat_t hpm_mcl_control_get_block_sector ( hall_phase_t  hall,
uint8_t  u,
uint8_t  v,
uint8_t  w,
uint8_t *  sector 
)

◆ hpm_mcl_control_init()

hpm_mcl_stat_t hpm_mcl_control_init ( mcl_control_t control,
mcl_control_cfg_t cfg 
)

Initialise the operating data for the control function.

Parameters
controlmcl_control_t
cfgmcl_control_cfg_t
Returns
hpm_mcl_stat_t

Data initialisation

function initialisation

◆ hpm_mcl_control_inv_park()

hpm_mcl_stat_t hpm_mcl_control_inv_park ( float  d,
float  q,
float  sin_x,
float  cos_x,
float *  alpha,
float *  beta 
)

◆ hpm_mcl_control_lowpass_filter()

float hpm_mcl_control_lowpass_filter ( float  input,
float *  mem,
float  k 
)

◆ hpm_mcl_control_offline_param_detection_flux()

hpm_mcl_stat_t hpm_mcl_control_offline_param_detection_flux ( mcl_control_offline_param_detection_t detection,
float  ialpha,
float  ibeta,
float  ualpha,
float  ubeta,
float *  ref_d,
float *  ref_q 
)

◆ hpm_mcl_control_offline_param_detection_ld()

hpm_mcl_stat_t hpm_mcl_control_offline_param_detection_ld ( mcl_control_offline_param_detection_t detection,
float  ialpha,
float  ibeta,
float *  ud,
float *  uq 
)

◆ hpm_mcl_control_offline_param_detection_lq()

hpm_mcl_stat_t hpm_mcl_control_offline_param_detection_lq ( mcl_control_offline_param_detection_t detection,
float  ialpha,
float  ibeta,
float *  ud,
float *  uq 
)

◆ hpm_mcl_control_offline_param_detection_ls()

hpm_mcl_stat_t hpm_mcl_control_offline_param_detection_ls ( mcl_control_offline_param_detection_t detection)

◆ hpm_mcl_control_offline_param_detection_rs()

hpm_mcl_stat_t hpm_mcl_control_offline_param_detection_rs ( mcl_control_offline_param_detection_t detection,
float  ialpha,
float  ibeta,
float *  ud,
float *  uq 
)

◆ hpm_mcl_control_park()

hpm_mcl_stat_t hpm_mcl_control_park ( float  alpha,
float  beta,
float  sin_x,
float  cos_x,
float *  d,
float *  q 
)

◆ hpm_mcl_control_pi()

hpm_mcl_stat_t hpm_mcl_control_pi ( float  ref,
float  sens,
mcl_control_pid_t pid_x,
float *  output 
)

◆ hpm_mcl_control_sin()

float hpm_mcl_control_sin ( float  x)

◆ hpm_mcl_control_smc_init()

void hpm_mcl_control_smc_init ( mcl_control_smc_t smc_cfg)

◆ hpm_mcl_control_smc_process()

void hpm_mcl_control_smc_process ( mcl_control_smc_t smc_cfg,
float  ualpha,
float  ubeta,
float  ialpha,
float  ibeta 
)

◆ hpm_mcl_control_step_svpwm()

hpm_mcl_stat_t hpm_mcl_control_step_svpwm ( float  alpha,
float  beta,
float  vbus,
mcl_control_svpwm_duty_t duty 
)

◆ hpm_mcl_control_svpwm()

hpm_mcl_stat_t hpm_mcl_control_svpwm ( float  alpha,
float  beta,
float  vbus,
mcl_control_svpwm_duty_t duty 
)

◆ hpm_mcl_delta_pid()

hpm_mcl_stat_t hpm_mcl_delta_pid ( float  setpoint,
float  feedback,
mcl_control_pid_t pid_x,
float *  output 
)

Calculates the output of a Delta PID controller.

This function implements a Delta PID (Proportional-Integral-Derivative) controller calculation to determine the controller's output value based on the setpoint and feedback values. The PID controller adjusts the output value using proportional (P), integral (I), and derivative (D) terms to minimize the error between the setpoint and feedback values.

Parameters
setpointThe desired output value of the system.
feedbackThe actual output value of the system.
pid_xPointer to the PID controller structure containing the configuration and state.
outputPointer to store the calculated controller output value.
Returns
Returns a status code indicating whether the function executed successfully.

Note:

  • This function assumes that the PID controller structure mcl_control_pid_t is properly initialized.
  • The function internally limits the output value to ensure it does not exceed the configured minimum and maximum output values.

◆ hpm_mcl_pid_init()

hpm_mcl_stat_t hpm_mcl_pid_init ( mcl_control_pid_t pid_x)

◆ hpm_mcl_pid_to_3p3z()

hpm_mcl_stat_t hpm_mcl_pid_to_3p3z ( mcl_control_pid_cfg_t cfg_pid,
mcl_clc_coeff_cfg_t cfg_3p3z 
)

Convert a 3p3z controller to a pid controller.

Parameters
pidmcl_control_pid_cfg_t
p3z3mcl_clc_coeff_cfg_t
Returns
hpm_mcl_stat_t

The relationship between the 3p3z coefficients and the P, I, and D gains of the basic PID is obtained by the standard discrete transform method, and the final result given here. Principle View Knowledge Base.

◆ hpm_mcl_position_pid()

hpm_mcl_stat_t hpm_mcl_position_pid ( float  setpoint,
float  feedback,
mcl_control_pid_t pid_x,
float *  output 
)

Calculate the output of a Positional PID controller.

This function implements a typical PID (Proportional-Integral-Derivative) controller to compute the control signal based on the setpoint and feedback. The PID controller optimizes the control process by adjusting three parameters: proportional gain (KP), integral gain (KI), and derivative gain (KD). The proportional term responds quickly to the error, the integral term eliminates steady-state error, and the derivative term predicts and reduces overshoot.

Parameters
setpointThe setpoint, i.e., the desired output value
feedbackThe feedback signal, representing the actual output value
pid_xPointer to the PID controller structure, containing the configuration and state
outputPointer to the output control signal
Returns
hpm_mcl_stat_t The execution status, indicating whether the PID calculation was successful