Skip to content

File syn_foc_encoder.h

FileList > motor > syn_foc_encoder.h

Go to the source code of this file

Sensored FOC Rotor Position & Speed Interface (Encoder / Hall / Absolute).

  • #include "../common/syn_defs.h"
  • #include "../util/syn_qmath.h"
  • #include <stdbool.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_FOCEncoder
Sensored Encoder State.
struct SYN_FOCEncoderConfig
Sensored Encoder Configuration.

Public Types

Type Name
enum SYN_FOCEncoderType
Sensored Feedback Type.

Public Functions

Type Name
q16_t syn_foc_encoder_get_elec_angle (const SYN_FOCEncoder * enc)
Get current electrical angle in Q16 radians [0, 2*PI).
q16_t syn_foc_encoder_get_elec_speed (const SYN_FOCEncoder * enc)
Get current electrical speed in Q16 rad/s.
SYN_Status syn_foc_encoder_init (SYN_FOCEncoder * enc, const SYN_FOCEncoderConfig * cfg)
Initialize sensored encoder module.
void syn_foc_encoder_update_absolute (SYN_FOCEncoder * enc, uint16_t raw_angle_14bit)
Update position for Absolute Encoder.
void syn_foc_encoder_update_hall (SYN_FOCEncoder * enc, bool hall_u, bool hall_v, bool hall_w)
Update position for 3-Phase Digital Hall Sensors.
void syn_foc_encoder_update_quadrature (SYN_FOCEncoder * enc, int32_t raw_count)
Update position for ABZ Incremental Quadrature Encoder.

Public Types Documentation

enum SYN_FOCEncoderType

Sensored Feedback Type.

enum SYN_FOCEncoderType {
    SYN_FOC_ENCODER_QUADRATURE = 0,
    SYN_FOC_ENCODER_HALL = 1,
    SYN_FOC_ENCODER_ABSOLUTE = 2
};


Public Functions Documentation

function syn_foc_encoder_get_elec_angle

Get current electrical angle in Q16 radians [0, 2*PI).

q16_t syn_foc_encoder_get_elec_angle (
    const SYN_FOCEncoder * enc
) 

Parameters:

  • enc Pointer to encoder instance.

Returns:

Current electrical angle in Q16 radians.


function syn_foc_encoder_get_elec_speed

Get current electrical speed in Q16 rad/s.

q16_t syn_foc_encoder_get_elec_speed (
    const SYN_FOCEncoder * enc
) 

Parameters:

  • enc Pointer to encoder instance.

Returns:

Current electrical speed in Q16 rad/s.


function syn_foc_encoder_init

Initialize sensored encoder module.

SYN_Status syn_foc_encoder_init (
    SYN_FOCEncoder * enc,
    const SYN_FOCEncoderConfig * cfg
) 

Parameters:

  • enc Pointer to encoder instance.
  • cfg Pointer to encoder configuration.

Returns:

SYN_OK on success.


function syn_foc_encoder_update_absolute

Update position for Absolute Encoder.

void syn_foc_encoder_update_absolute (
    SYN_FOCEncoder * enc,
    uint16_t raw_angle_14bit
) 

Parameters:

  • enc Pointer to encoder instance.
  • raw_angle_14bit Raw 14-bit absolute angle (0..16383).

function syn_foc_encoder_update_hall

Update position for 3-Phase Digital Hall Sensors.

void syn_foc_encoder_update_hall (
    SYN_FOCEncoder * enc,
    bool hall_u,
    bool hall_v,
    bool hall_w
) 

Parameters:

  • enc Pointer to encoder instance.
  • hall_u Digital pin U state (0 or 1).
  • hall_v Digital pin V state (0 or 1).
  • hall_w Digital pin W state (0 or 1).

function syn_foc_encoder_update_quadrature

Update position for ABZ Incremental Quadrature Encoder.

void syn_foc_encoder_update_quadrature (
    SYN_FOCEncoder * enc,
    int32_t raw_count
) 

Parameters:

  • enc Pointer to encoder instance.
  • raw_count Current timer counter register (QEI count).


The documentation for this class was generated from the following file src/syntropic/motor/syn_foc_encoder.h