HPM SDK
HPMicro Software Development Kit
hpm_mcl_encoder.h File Reference
#include "hpm_mcl_common.h"
#include "hpm_mcl_filter.h"

Go to the source code of this file.

Data Structures

struct  mcl_encoder_uvw_level_t
 uvw level 0 or 1 More...
 
struct  mcl_encoder_callback
 callback function More...
 
struct  mcl_encoder_cal_speed_t_function_t
 
struct  mcl_encoder_cal_speed_m_function_t
 
struct  mcl_encoder_cal_speed_m_t_function_t
 
struct  mcl_encoder_cal_speed_pll_cfg_t
 pll filter configuration More...
 
struct  mcl_encoder_cal_speed_pll_function_t
 Running data for the pll method of calculating speed. More...
 
struct  mcl_encoer_cfg_t
 Encoder Configuration. More...
 
struct  mcl_encoder_t
 Encoder operation data. More...
 

Macros

#define MCL_ENCODER_CAL_STRUCT_MAX_MEMMORY   (16)
 Maximum memory required for computational speed, word. More...
 

Typedefs

typedef struct mcl_encoder_callback mcl_encoder_callback_t
 callback function More...
 

Enumerations

enum  {
  mcl_encoder_start_sample_error = MAKE_STATUS(mcl_group_encoder, 0) , mcl_encoder_get_tick_error = MAKE_STATUS(mcl_group_encoder, 1) , mcl_encoder_update_tick_error = MAKE_STATUS(mcl_group_encoder, 2) , mcl_encoder_get_theta_error = MAKE_STATUS(mcl_group_encoder, 3) ,
  mcl_encoder_not_ready = MAKE_STATUS(mcl_group_encoder, 4) , mcl_encoder_get_uvw_error = MAKE_STATUS(mcl_group_encoder, 5)
}
 
enum  mcl_encoder_status_t { encoder_status_null = 0 , encoder_status_init = 1 , encoder_status_run = 2 , encoder_status_fail = 3 }
 
enum  mcl_encoder_cal_speed_function_t {
  encoder_method_t , encoder_method_m , encoder_method_m_t , encoder_method_pll ,
  encoder_method_user
}
 Method of calculating speed. More...
 

Functions

hpm_mcl_stat_t hpm_mcl_encoder_init (mcl_encoder_t *encoder, mcl_cfg_t *mcl_cfg, mcl_encoer_cfg_t *encoder_cfg, mcl_filter_iir_df1_t *iir)
 Initialize encoder data. More...
 
hpm_mcl_stat_t hpm_mcl_encoder_start_sample (mcl_encoder_t *encoder)
 Encoder starts sampling. More...
 
hpm_mcl_stat_t hpm_mcl_encoder_set_initial_theta (mcl_encoder_t *encoder, float theta)
 Sets the initial value of the angle. Normally, the programme does the initial value setting automatically, but if you are not satisfied with the result, you can set the initial value. The initial value determines the zero point of the electrical angle. This means that the angle read by the sensor is calibrated to zero by the initial value. More...
 
hpm_mcl_stat_t hpm_mcl_encoder_process (mcl_encoder_t *encoder, uint32_t tick_deta)
 Encoder processing, cycle call. More...
 
hpm_mcl_stat_t hpm_mcl_encoder_set_status (mcl_encoder_t *encoder, mcl_encoder_status_t status)
 Force update of encoder status. More...
 
float hpm_mcl_encoder_get_theta (mcl_encoder_t *encoder)
 Get the encoder angle value. More...
 
float hpm_mcl_encoder_get_speed (mcl_encoder_t *encoder)
 Get speed. More...
 
float hpm_mcl_encoder_get_forecast_theta (mcl_encoder_t *encoder)
 Get the angle predicted from the speed. More...
 
float hpm_mcl_encoder_get_raw_theta (mcl_encoder_t *encoder)
 Getting the raw angle data of the encoder. More...
 
void hpm_mcl_encoder_force_theta (mcl_encoder_t *encoder, float theta, bool enable)
 Force setting of the output angle of the encoder function. More...
 
hpm_mcl_stat_t hpm_mcl_encoder_get_absolute_theta (mcl_encoder_t *encoder, float *theta)
 Get the absolute position of the angle. More...
 
hpm_mcl_stat_t hpm_mcl_encoder_get_uvw_status (mcl_encoder_t *encoder, mcl_encoder_uvw_level_t *level)
 Get level status of uvw. More...
 
float hpm_mcl_encoder_get_sensorless_theta (mcl_encoder_t *encoder)
 Get sensorless theta. More...
 

Macro Definition Documentation

◆ MCL_ENCODER_CAL_STRUCT_MAX_MEMMORY

#define MCL_ENCODER_CAL_STRUCT_MAX_MEMMORY   (16)

Maximum memory required for computational speed, word.

Typedef Documentation

◆ mcl_encoder_callback_t

callback function

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
mcl_encoder_start_sample_error 
mcl_encoder_get_tick_error 
mcl_encoder_update_tick_error 
mcl_encoder_get_theta_error 
mcl_encoder_not_ready 
mcl_encoder_get_uvw_error 

◆ mcl_encoder_cal_speed_function_t

Method of calculating speed.

Enumerator
encoder_method_t 
encoder_method_m 
encoder_method_m_t 
encoder_method_pll 
encoder_method_user 

◆ mcl_encoder_status_t

Enumerator
encoder_status_null 
encoder_status_init 
encoder_status_run 
encoder_status_fail 

Function Documentation

◆ hpm_mcl_encoder_force_theta()

void hpm_mcl_encoder_force_theta ( mcl_encoder_t encoder,
float  theta,
bool  enable 
)

Force setting of the output angle of the encoder function.

Parameters
encodermcl_encoder_t
thetarad
enableEnable or disable the forced output function

◆ hpm_mcl_encoder_get_absolute_theta()

hpm_mcl_stat_t hpm_mcl_encoder_get_absolute_theta ( mcl_encoder_t encoder,
float *  theta 
)

Get the absolute position of the angle.

Parameters
encodermcl_encoder_t
thetarad
Returns
hpm_mcl_stat_t

◆ hpm_mcl_encoder_get_forecast_theta()

float hpm_mcl_encoder_get_forecast_theta ( mcl_encoder_t encoder)

Get the angle predicted from the speed.

Parameters
encodermcl_encoder_t
Returns
theta, rad

◆ hpm_mcl_encoder_get_raw_theta()

float hpm_mcl_encoder_get_raw_theta ( mcl_encoder_t encoder)

Getting the raw angle data of the encoder.

Parameters
encodermcl_encoder_t
Returns
theta, rad

◆ hpm_mcl_encoder_get_sensorless_theta()

float hpm_mcl_encoder_get_sensorless_theta ( mcl_encoder_t encoder)

Get sensorless theta.

Parameters
encodermcl_encoder_t
Returns
theta

◆ hpm_mcl_encoder_get_speed()

float hpm_mcl_encoder_get_speed ( mcl_encoder_t encoder)

Get speed.

Parameters
encodermcl_encoder_t
Returns
rad/s

◆ hpm_mcl_encoder_get_theta()

float hpm_mcl_encoder_get_theta ( mcl_encoder_t encoder)

Get the encoder angle value.

Parameters
encodermcl_encoder_t
Returns
angle value, rad

◆ hpm_mcl_encoder_get_uvw_status()

hpm_mcl_stat_t hpm_mcl_encoder_get_uvw_status ( mcl_encoder_t encoder,
mcl_encoder_uvw_level_t level 
)

Get level status of uvw.

Parameters
encodermcl_encoder_t
level0: low , 1: high
Returns
hpm_mcl_stat_t

◆ hpm_mcl_encoder_init()

hpm_mcl_stat_t hpm_mcl_encoder_init ( mcl_encoder_t encoder,
mcl_cfg_t mcl_cfg,
mcl_encoer_cfg_t encoder_cfg,
mcl_filter_iir_df1_t iir 
)

Initialize encoder data.

Parameters
encodermcl_encoder_t
mcl_cfgmcl_cfg_t
encoder_cfgmcl_encoer_cfg_t
iirmcl_filter_iir_df1_t
Returns
hpm_mcl_stat_t

parameter check

null function initialisation

parameter initial

◆ hpm_mcl_encoder_process()

hpm_mcl_stat_t hpm_mcl_encoder_process ( mcl_encoder_t encoder,
uint32_t  tick_deta 
)

Encoder processing, cycle call.

Parameters
encodermcl_encoder_t
tick_detaDifference in the number of cycles between two calls
Returns
hpm_mcl_stat_t

iir filter

◆ hpm_mcl_encoder_set_initial_theta()

hpm_mcl_stat_t hpm_mcl_encoder_set_initial_theta ( mcl_encoder_t encoder,
float  theta 
)

Sets the initial value of the angle. Normally, the programme does the initial value setting automatically, but if you are not satisfied with the result, you can set the initial value. The initial value determines the zero point of the electrical angle. This means that the angle read by the sensor is calibrated to zero by the initial value.

Parameters
encodermcl_encoder_t
thetaUsed to calibrate electrical angle to zero
Returns
hpm_mcl_stat_t hpm_mcl_stat_t

◆ hpm_mcl_encoder_set_status()

hpm_mcl_stat_t hpm_mcl_encoder_set_status ( mcl_encoder_t encoder,
mcl_encoder_status_t  status 
)

Force update of encoder status.

Parameters
encodermcl_encoder_t
statusmcl_encoder_status_t
Returns
hpm_mcl_stat_t

◆ hpm_mcl_encoder_start_sample()

hpm_mcl_stat_t hpm_mcl_encoder_start_sample ( mcl_encoder_t encoder)

Encoder starts sampling.

Parameters
encodermcl_encoder_t
Returns
hpm_mcl_stat_t