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

Go to the source code of this file.

Data Structures

struct  mcl_offline_param_detection_result_t
 Results of offline parameter testing. More...
 
struct  mcl_clc_coeff_cfg_t
 3p-3z Coefficients for 3p-3z controllers More...
 
struct  mcl_control_pid_cfg_t
 Configuration data for pid. More...
 
struct  mcl_control_pid_t
 pid running data More...
 
struct  mcl_control_dead_area_pwm_offset_t
 Used to compensate for pwm dead zones, Duty cycle ratio, between 0 and 1. More...
 
struct  mcl_control_dead_area_compensation_cfg_t
 DeadAera Compensation Configuration. More...
 
struct  mcl_control_dead_area_compensation_t
 DeadAera Compensation data. More...
 
struct  mcl_control_smc_cfg_t
 Sensorless smc configuration. More...
 
struct  mcl_control_smc_t
 Sensorless smc structure. More...
 
struct  mcl_control_offline_param_detection_cfg_t
 Offline Detection Configuration. More...
 
struct  mcl_control_offline_param_detection_t
 Offline Detection Data. More...
 
struct  mcl_control_svpwm_duty_t
 pwm duty cycle More...
 
struct  mcl_control_method_t
 Supported control algorithms. More...
 
struct  mcl_control_callback_t
 callback function More...
 
struct  mcl_control_cfg_t
 Control Function Configuration. More...
 
struct  mcl_control_t
 Control function running data. More...
 

Enumerations

enum  mcl_control_status_t { control_status_null = 0 , control_status_init = 1 , control_status_run = 2 , control_status_fail = 3 }
 Control Module Status. More...
 
enum  mcl_svpwm_sector_t {
  svpwm_sector1 = 1 , svpwm_sector2 = 2 , svpwm_sector3 = 3 , svpwm_sector4 = 4 ,
  svpwm_sector5 = 5 , svpwm_sector6 = 6
}
 Six sectors of svpwm. More...
 

Functions

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...
 
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...
 

Enumeration Type Documentation

◆ mcl_control_status_t

Control Module Status.

Enumerator
control_status_null 
control_status_init 
control_status_run 
control_status_fail 

◆ mcl_svpwm_sector_t

Six sectors of svpwm.

Enumerator
svpwm_sector1 
svpwm_sector2 
svpwm_sector3 
svpwm_sector4 
svpwm_sector5 
svpwm_sector6 

Function Documentation

◆ 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_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_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