X-CUBE-SPN11 for X-NUCLEO-IHM11M1
|
Motor Control driver. More...
Modules | |
Exported_types | |
Exported_function_6StepLib | |
MC_SixStep_TABLE | |
Set the peripherals (TIMx, GPIO etc.) for each step. | |
MC_SixStep_NEXT_step | |
Generate the next step number according with the direction (CW or CCW) | |
MC_SixStep_RESET | |
Reset all variables used for 6Step control algorithm. | |
MC_SixStep_Ramp_Motor_calc | |
Calculate the acceleration profile step by step for motor during start-up. | |
MC_SixStep_ARR_step | |
Generate the ARR value for Low Frequency TIM during start-up. | |
MC_SixStep_Alignment | |
Generate the motor alignment. | |
MC_SixStep_Speed_Val_target_potentiometer | |
Calculate the Motor Speed validation threshold according with the potentiometer value. | |
MC_SixStep_Speed_Potentiometer | |
Calculate the potentiometer value to set the Motor Speed. | |
MC_Set_PI_param | |
Set all parameters for PI regulator. | |
MC_PI_Controller | |
Compute the PI output for the Current Reference. | |
MC_Task_Speed | |
Main task: Speed Loop with PI regulator. | |
MC_Set_Speed | |
Set the new motor speed value. | |
MC_Bemf_Delay | |
Take the delay time after each new 6-step commutation. | |
MC_StartMotor | |
Start the Motor. | |
MC_StopMotor | |
Stop the Motor. | |
MC_GetElSpeedHz | |
Get the Eletrical Motor Speed from ARR value of LF TIM. | |
MC_GetMechSpeedRPM | |
Get the Mechanical Motor Speed (RPM) | |
MC_SixStep_Init_main_data | |
Init the main variables for motor driving from MC_SixStep_param.h. | |
MC_SixStep_INIT | |
Initialitation function for SixStep library. | |
MC_TIMx_SixStep_timebase | |
Low Frequency Timer Callback - Call the next step and request the filtered speed value. | |
MC_Speed_Filter | |
Calculate the speed filtered. | |
MC_Potentiometer_filter | |
Calculate the filtered potentiometer value. | |
MC_SysTick_SixStep_MediumFrequencyTask | |
Systick Callback - Call the Speed loop. | |
MC_SixStep_ARR_Bemf | |
Calculate the new Autoreload value (ARR) for Low Frequency timer. | |
MC_ADCx_SixStep_Bemf | |
Compute the zero crossing detection. | |
MC_EXT_button_SixStep | |
GPIO EXT Callback - Start or Stop the motor through the Blue push button on STM32Nucleo. | |
Main_Motor_parameters | |
All motor parameters for 6Step driving. | |
stm32F401_nucleo_ihm11m1 | |
Interface file for STM32F401 and Motor Control Library configuration. | |
Functions | |
uint64_t | MCM_Sqrt (uint64_t wInput) |
It calculates the square root of a non-negative s64. More... | |
void | MC_SixStep_EnableInput_CH1_E_CH2_E_CH3_D (void) |
Enable Input channel CH1 and CH2 for STSPIN230. More... | |
void | MC_SixStep_EnableInput_CH1_E_CH2_D_CH3_E (void) |
Enable Input channel CH1 and CH3 for STSPIN230. More... | |
void | MC_SixStep_EnableInput_CH1_D_CH2_E_CH3_E (void) |
Enable Input channel CH2 and CH3 for STSPIN230. More... | |
void | MC_SixStep_DisableInput_CH1_D_CH2_D_CH3_D (void) |
Enable Input channel CH2 and CH3 for STSPIN230. More... | |
void | MC_SixStep_Start_PWM_driving (void) |
Enable PWM channels for STSPIN230. More... | |
void | MC_SixStep_Stop_PWM_driving (void) |
Disable PWM channels for STSPIN230. More... | |
void | MC_SixStep_HF_TIMx_SetDutyCycle_CH1 (uint16_t) |
Set the Duty Cycle value for CH1. More... | |
void | MC_SixStep_HF_TIMx_SetDutyCycle_CH2 (uint16_t) |
Set the Duty Cycle value for CH2. More... | |
void | MC_SixStep_HF_TIMx_SetDutyCycle_CH3 (uint16_t) |
Set the Duty Cycle value for CH3. More... | |
void | MC_SixStep_Current_Reference_Start (void) |
Enable the Current Reference generation. More... | |
void | MC_SixStep_Current_Reference_Stop (void) |
Disable the Current Reference generation. More... | |
void | MC_SixStep_Current_Reference_Setvalue (uint16_t) |
Set the value for Current Reference. More... | |
void | MC_UI_INIT (void) |
void | UART_Set_Value (void) |
void | UART_Communication_Task (void) |
void | CMD_Parser (char *pCommandString) |
void | HAL_IncTick (void) |
This function is called to increment a global variable "uwTick" used as application time base. More... | |
uint32_t | HAL_GetTick (void) |
Povides a tick value in millisecond. More... | |
Detailed Description
Motor Control driver.
Function Documentation
void CMD_Parser | ( | char * | pCommandString | ) |
uint32_t HAL_GetTick | ( | void | ) |
Povides a tick value in millisecond.
- Note
- The function is declared as __Weak to be overwritten in case of other implementations in user file.
- Return values
-
tick value
Definition at line 1618 of file 6Step_Lib.c.
References uwTick.
Referenced by MC_SysTick_SixStep_MediumFrequencyTask().
void HAL_IncTick | ( | void | ) |
This function is called to increment a global variable "uwTick" used as application time base.
- Note
- In the default implementation, this variable is incremented each 1ms in Systick ISR.
- This function is declared as __weak to be overwritten in case of other implementations in user file.
- Return values
-
None
Definition at line 1607 of file 6Step_Lib.c.
References uwTick.
Referenced by SysTick_Handler().
void MC_SixStep_Current_Reference_Setvalue | ( | uint16_t | Iref | ) |
Set the value for Current Reference.
- Return values
-
None
Definition at line 480 of file stm32F401_nucleo_ihm11m1.c.
Referenced by MC_SixStep_INIT(), MC_SixStep_Ramp_Motor_calc(), MC_SixStep_RESET(), and MC_Task_Speed().
void MC_SixStep_Current_Reference_Start | ( | ) |
Enable the Current Reference generation.
- Return values
-
None
Definition at line 441 of file stm32F401_nucleo_ihm11m1.c.
Referenced by MC_SixStep_RESET().
void MC_SixStep_Current_Reference_Stop | ( | ) |
Disable the Current Reference generation.
- Return values
-
None
Definition at line 460 of file stm32F401_nucleo_ihm11m1.c.
Referenced by MC_StopMotor().
void MC_SixStep_DisableInput_CH1_D_CH2_D_CH3_D | ( | ) |
Enable Input channel CH2 and CH3 for STSPIN230.
- Return values
-
None
Definition at line 327 of file stm32F401_nucleo_ihm11m1.c.
Referenced by MC_StopMotor().
void MC_SixStep_EnableInput_CH1_D_CH2_E_CH3_E | ( | ) |
Enable Input channel CH2 and CH3 for STSPIN230.
- Return values
-
None
Definition at line 309 of file stm32F401_nucleo_ihm11m1.c.
Referenced by MC_SixStep_TABLE().
void MC_SixStep_EnableInput_CH1_E_CH2_D_CH3_E | ( | ) |
Enable Input channel CH1 and CH3 for STSPIN230.
- Return values
-
None
Definition at line 291 of file stm32F401_nucleo_ihm11m1.c.
Referenced by MC_SixStep_TABLE().
void MC_SixStep_EnableInput_CH1_E_CH2_E_CH3_D | ( | ) |
Enable Input channel CH1 and CH2 for STSPIN230.
- Return values
-
None
Definition at line 273 of file stm32F401_nucleo_ihm11m1.c.
Referenced by MC_SixStep_TABLE().
void MC_SixStep_HF_TIMx_SetDutyCycle_CH1 | ( | uint16_t | CCR_value | ) |
Set the Duty Cycle value for CH1.
- Return values
-
None
Definition at line 381 of file stm32F401_nucleo_ihm11m1.c.
Referenced by MC_SixStep_RESET(), and MC_SixStep_TABLE().
void MC_SixStep_HF_TIMx_SetDutyCycle_CH2 | ( | uint16_t | CCR_value | ) |
Set the Duty Cycle value for CH2.
- Return values
-
None
Definition at line 400 of file stm32F401_nucleo_ihm11m1.c.
Referenced by MC_SixStep_RESET(), and MC_SixStep_TABLE().
void MC_SixStep_HF_TIMx_SetDutyCycle_CH3 | ( | uint16_t | CCR_value | ) |
Set the Duty Cycle value for CH3.
- Return values
-
None
Definition at line 423 of file stm32F401_nucleo_ihm11m1.c.
Referenced by MC_SixStep_RESET(), and MC_SixStep_TABLE().
void MC_SixStep_Start_PWM_driving | ( | ) |
Enable PWM channels for STSPIN230.
- Return values
-
None
Definition at line 345 of file stm32F401_nucleo_ihm11m1.c.
Referenced by MC_SixStep_NEXT_step().
void MC_SixStep_Stop_PWM_driving | ( | ) |
Disable PWM channels for STSPIN230.
- Return values
-
None
Definition at line 363 of file stm32F401_nucleo_ihm11m1.c.
Referenced by MC_StopMotor().
void MC_UI_INIT | ( | void | ) |
Referenced by MC_SixStep_INIT().
uint64_t MCM_Sqrt | ( | uint64_t | wInput | ) |
It calculates the square root of a non-negative s64.
It returns 0 for negative s64.
- Parameters
-
Input uint64_t number
- Return values
-
int32_t Square root of Input (0 if Input<0)
Definition at line 533 of file 6Step_Lib.c.
References shift_n_sqrt.
Referenced by MC_SixStep_Ramp_Motor_calc().
void UART_Communication_Task | ( | void | ) |
Referenced by MC_SysTick_SixStep_MediumFrequencyTask().
void UART_Set_Value | ( | void | ) |
Variable Documentation
uint32_t ARR_LF = 0 |
Autoreload LF TIM variable
Definition at line 93 of file 6Step_Lib.c.
Referenced by MC_SixStep_ARR_Bemf(), MC_SixStep_NEXT_step(), and MC_SixStep_RESET().
uint8_t array_completed = FALSE |
Speed filter variable
Definition at line 90 of file 6Step_Lib.c.
Referenced by MC_SixStep_RESET(), and MC_Speed_Filter().
uint8_t buffer_completed = FALSE |
Potentiometer filter variable
Definition at line 91 of file 6Step_Lib.c.
Referenced by MC_Potentiometer_filter(), and MC_SixStep_RESET().
uint16_t cnt_bemf_event = 0 |
Definition at line 105 of file 6Step_Lib.c.
Referenced by MC_SixStep_ARR_Bemf(), MC_SixStep_RESET(), and MC_SysTick_SixStep_MediumFrequencyTask().
uint32_t constant_k = 0 |
1/3*mech_accel_hz
Definition at line 79 of file 6Step_Lib.c.
Referenced by MC_SixStep_Ramp_Motor_calc(), and MC_SixStep_RESET().
uint64_t constant_multiplier_tmp = 0 |
Definition at line 117 of file 6Step_Lib.c.
Referenced by MC_SixStep_Ramp_Motor_calc(), and MC_SixStep_RESET().
uint32_t counter_ARR_Bemf = 0 |
Definition at line 116 of file 6Step_Lib.c.
Referenced by MC_SixStep_ARR_Bemf(), and MC_SixStep_RESET().
uint8_t dac_status = DAC_ENABLE |
Definition at line 109 of file 6Step_Lib.c.
Referenced by MC_StartMotor(), and MC_Task_Speed().
int32_t delta = 0 |
Startup variable
Definition at line 84 of file 6Step_Lib.c.
Referenced by MC_SixStep_Ramp_Motor_calc(), and MC_SixStep_RESET().
int32_t El_Speed_Hz = 0 |
Electrical motor speed
Definition at line 95 of file 6Step_Lib.c.
Referenced by MC_GetElSpeedHz(), and MC_SixStep_RESET().
uint8_t Enable_start_button = TRUE |
Start/stop button filter to avoid double command
Definition at line 99 of file 6Step_Lib.c.
Referenced by MC_EXT_button_SixStep(), MC_SixStep_RESET(), and MC_SysTick_SixStep_MediumFrequencyTask().
uint16_t HFBuffer[HFBUFFERSIZE] |
Buffer for Potentiometer Value Filtering at the High-Frequency ADC conversion
Definition at line 88 of file 6Step_Lib.c.
Referenced by MC_ADCx_SixStep_Bemf(), MC_SixStep_RESET(), and MC_SixStep_Speed_Potentiometer().
uint16_t HFBufferIndex = 0 |
High-Frequency Buffer Index
Definition at line 89 of file 6Step_Lib.c.
Referenced by MC_ADCx_SixStep_Bemf(), and MC_SixStep_RESET().
uint16_t index_adc_chn = 0 |
Index of ADC channel selector for measuring
Definition at line 96 of file 6Step_Lib.c.
Referenced by MC_ADCx_SixStep_Bemf(), and MC_SixStep_RESET().
uint16_t index_align = 1 |
Definition at line 110 of file 6Step_Lib.c.
Referenced by MC_SixStep_Alignment(), and MC_SixStep_RESET().
uint16_t index_ARR_step = 1 |
Definition at line 100 of file 6Step_Lib.c.
Referenced by MC_SixStep_ARR_step(), and MC_SixStep_RESET().
uint16_t index_array = 1 |
Speed filter variable
Definition at line 85 of file 6Step_Lib.c.
Referenced by MC_SixStep_RESET(), and MC_Speed_Filter().
uint16_t index_motor_run = 0 |
Tmp variable for DEMO mode
Definition at line 97 of file 6Step_Lib.c.
Referenced by MC_SixStep_RESET(), and MC_SysTick_SixStep_MediumFrequencyTask().
uint16_t index_pot_filt = 1 |
Definition at line 113 of file 6Step_Lib.c.
Referenced by MC_Potentiometer_filter(), and MC_SixStep_RESET().
uint16_t index_startup_motor = 1 |
Definition at line 102 of file 6Step_Lib.c.
Referenced by MC_SixStep_Alignment(), MC_SixStep_ARR_step(), MC_SixStep_Ramp_Motor_calc(), and MC_SixStep_RESET().
uint32_t mech_accel_hz = 0 |
Hz – Mechanical acceleration rate
Definition at line 78 of file 6Step_Lib.c.
Referenced by MC_SixStep_Ramp_Motor_calc(), and MC_SixStep_RESET().
int32_t Mech_Speed_RPM = 0 |
Mechanical motor speed
Definition at line 94 of file 6Step_Lib.c.
Referenced by MC_GetMechSpeedRPM(), and MC_SixStep_RESET().
uint32_t n_zcr_startup = 0 |
Definition at line 101 of file 6Step_Lib.c.
Referenced by MC_SixStep_ARR_Bemf(), MC_SixStep_NEXT_step(), and MC_SixStep_RESET().
SIXSTEP_PI_PARAM_InitTypeDef_t PI_parameters |
SixStep PI regulator structure
Definition at line 74 of file 6Step_Lib.c.
int16_t potent_filtered = 0 |
Definition at line 114 of file 6Step_Lib.c.
Referenced by MC_Potentiometer_filter(), and MC_SixStep_RESET().
uint16_t Rotor_poles_pairs |
Number of pole pairs of the motor
Definition at line 77 of file 6Step_Lib.c.
Referenced by MC_GetMechSpeedRPM(), MC_SixStep_Ramp_Motor_calc(), and MC_SixStep_RESET().
uint16_t shift_n_sqrt = 14 |
Definition at line 104 of file 6Step_Lib.c.
Referenced by MCM_Sqrt().
SIXSTEP_Base_InitTypeDef SIXSTEP_parameters |
Main SixStep structure
Definition at line 73 of file 6Step_Lib.c.
uint8_t speed_fdbk_error = 0 |
Definition at line 107 of file 6Step_Lib.c.
Referenced by MC_SixStep_NEXT_step(), MC_SixStep_RESET(), and MC_SysTick_SixStep_MediumFrequencyTask().
int32_t speed_sum_pot_filt = 0 |
Definition at line 112 of file 6Step_Lib.c.
Referenced by MC_Potentiometer_filter(), and MC_SixStep_RESET().
int32_t speed_sum_sp_filt = 0 |
Definition at line 111 of file 6Step_Lib.c.
Referenced by MC_SixStep_RESET(), and MC_Speed_Filter().
int16_t speed_tmp_array[FILTER_DEEP] |
Speed filter variable
Definition at line 86 of file 6Step_Lib.c.
Referenced by MC_SixStep_RESET(), and MC_Speed_Filter().
uint16_t speed_tmp_buffer[FILTER_DEEP] |
Potentiometer filter variable
Definition at line 87 of file 6Step_Lib.c.
Referenced by MC_Potentiometer_filter(), and MC_SixStep_RESET().
uint8_t startup_bemf_failure = 0 |
Definition at line 106 of file 6Step_Lib.c.
Referenced by MC_SixStep_ARR_Bemf(), MC_SixStep_RESET(), and MC_SysTick_SixStep_MediumFrequencyTask().
uint32_t T_single_step = 0 |
Startup variable
Definition at line 82 of file 6Step_Lib.c.
Referenced by MC_SixStep_Ramp_Motor_calc(), and MC_SixStep_RESET().
uint32_t T_single_step_first_value = 0 |
Startup variable
Definition at line 83 of file 6Step_Lib.c.
Referenced by MC_SixStep_Ramp_Motor_calc(), and MC_SixStep_RESET().
uint16_t target_speed = TARGET_SPEED |
Target speed for closed loop control
Definition at line 103 of file 6Step_Lib.c.
Referenced by MC_Set_PI_param(), MC_SixStep_RESET(), MC_SixStep_Speed_Val_target_potentiometer(), and MC_Task_Speed().
uint16_t test_motor_run = 1 |
Tmp variable for DEMO mode
Definition at line 98 of file 6Step_Lib.c.
Referenced by MC_SixStep_RESET(), and MC_SysTick_SixStep_MediumFrequencyTask().
uint32_t Tick_cnt = 0 |
Definition at line 115 of file 6Step_Lib.c.
Referenced by MC_SixStep_RESET(), and MC_SysTick_SixStep_MediumFrequencyTask().
uint32_t Time_vector_prev_tmp = 0 |
Startup variable
Definition at line 81 of file 6Step_Lib.c.
Referenced by MC_SixStep_Ramp_Motor_calc(), and MC_SixStep_RESET().
uint32_t Time_vector_tmp = 0 |
Startup variable
Definition at line 80 of file 6Step_Lib.c.
Referenced by MC_SixStep_Ramp_Motor_calc(), and MC_SixStep_RESET().
uint8_t UART_FLAG_RECEIVE = FALSE |
UART commmunication flag
Definition at line 92 of file 6Step_Lib.c.
Referenced by MC_SysTick_SixStep_MediumFrequencyTask().
__IO uint32_t uwTick = 0 |
Tick counter - 1msec updated
Definition at line 108 of file 6Step_Lib.c.
Referenced by HAL_GetTick(), HAL_IncTick(), MC_SixStep_RESET(), MC_StartMotor(), and MC_StopMotor().
Generated by 1.8.11