miniFOC 1.0.3
This open-source project aims to accomplish a FOC(Field Oriented Control) scheme that is operatable with minimum costs in China.
Functions | Variables
encoder.h File Reference

this is the header file of encoder.c. More...

Go to the source code of this file.

Functions

void encoder_zeroing (void)
 correct the mechanical angle zero deviation between the magnetic encoder and FOC. More...
 
unsigned short encoder_get_mechanical_angle (void)
 read mechanical angle directly from encoder More...
 
float encoder_get_electronic_angle (void)
 according to the electrical angle calculated from the mechanical angle, this function will call encoder_get_mechanical_angle() function. More...
 
void encoder_update_speed (void)
 called every 2 milliseconds to calculate the speed. More...
 

Variables

volatile unsigned short machine_angle_offset
 mechanical angle offset, which is used to align the mechanical angle with the zero point of the electrical angle. More...
 

Detailed Description

this is the header file of encoder.c.

Author
Lao·Zhu
Version
V1.0.1
Date
10. October 2021

Definition in file encoder.h.

Function Documentation

◆ encoder_get_electronic_angle()

float encoder_get_electronic_angle ( void  )

according to the electrical angle calculated from the mechanical angle, this function will call encoder_get_mechanical_angle() function.

Return values
registerraw data reading back

Definition at line 93 of file encoder.c.

References ELECANGLE_COEFFICIENT, encoder_get_mechanical_angle(), ENCODER_RESO, FOC_Struct, MECHANGLE_COEFFICIENT, FOC_Structure_t::mechanical_angle, and POLAR_PAIRS.

Referenced by TIMER2_IRQHandler().

◆ encoder_get_mechanical_angle()

unsigned short encoder_get_mechanical_angle ( void  )

read mechanical angle directly from encoder

Return values
registerraw data reading back

Definition at line 76 of file encoder.c.

References encoder_read_data(), ENCODER_RESO, last_mechanical_angle, machine_angle_offset, and total_machine_angle.

Referenced by encoder_get_electronic_angle(), and foc_calibrate_phase().

◆ encoder_update_speed()

void encoder_update_speed ( void  )

called every 2 milliseconds to calculate the speed.

Definition at line 106 of file encoder.c.

References filter_update_value(), FOC_Struct, FOC_Structure_t::rotate_speed, systick_mechanical_angle_last, total_machine_angle, and velocity_filter.

Referenced by SysTick_Handler().

◆ encoder_zeroing()

void encoder_zeroing ( void  )

correct the mechanical angle zero deviation between the magnetic encoder and FOC.

Definition at line 119 of file encoder.c.

References CALI_TORQUE, delayms(), encoder_read_data(), foc_calculate_dutycycle(), machine_angle_offset, total_machine_angle, and update_pwm_dutycycle().

Referenced by main().

Variable Documentation

◆ machine_angle_offset

volatile unsigned short machine_angle_offset
extern

mechanical angle offset, which is used to align the mechanical angle with the zero point of the electrical angle.

Definition at line 23 of file encoder.c.

Referenced by encoder_get_mechanical_angle(), encoder_zeroing(), flash_read_parameters(), flash_write_parameters(), and report_local_variable().