HPM SDK
HPMicro Software Development Kit
hpm_mcl_encoder.c File Reference
#include <math.h>
#include "hpm_mcl_encoder.h"
#include "hpm_mcl_physical.h"

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...
 
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...
 
float hpm_mcl_encoder_get_raw_theta (mcl_encoder_t *encoder)
 Getting the raw angle data of the encoder. More...
 
float hpm_mcl_encoder_get_theta (mcl_encoder_t *encoder)
 Get the encoder angle value. More...
 
float hpm_mcl_encoder_get_sensorless_theta (mcl_encoder_t *encoder)
 Get sensorless theta. 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...
 
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...
 

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