X-CUBE-SPN7 for X-NUCLEO-IHM07M1: MC_6-STEP_LIB

X-NUCLEO-IHM07M1 X-CUBE-SPN7

X-CUBE-SPN7 for X-NUCLEO-IHM07M1

Motor Control driver. More...

Collaboration diagram for MC_6-STEP_LIB:

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.
 

Functions

uint64_t MCM_Sqrt (uint64_t wInput)
 It calculates the square root of a non-negative s64. It returns 0 for negative s64. More...
 
void MC_SixStep_EnableInput_CH1_E_CH2_E_CH3_D (void)
 
void MC_SixStep_EnableInput_CH1_E_CH2_D_CH3_E (void)
 
void MC_SixStep_EnableInput_CH1_D_CH2_E_CH3_E (void)
 
void MC_SixStep_DisableInput_CH1_D_CH2_D_CH3_D (void)
 
void MC_SixStep_Start_PWM_driving (void)
 
void MC_SixStep_Stop_PWM_driving (void)
 
void MC_SixStep_HF_TIMx_SetDutyCycle_CH1 (uint16_t)
 
void MC_SixStep_HF_TIMx_SetDutyCycle_CH2 (uint16_t)
 
void MC_SixStep_HF_TIMx_SetDutyCycle_CH3 (uint16_t)
 
void MC_SixStep_Current_Reference_Start (void)
 
void MC_SixStep_Current_Reference_Stop (void)
 
void MC_SixStep_Current_Reference_Setvalue (uint16_t)
 
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...
 

Variables

SIXSTEP_Base_InitTypeDef SIXSTEP_parameters
 
SIXSTEP_PI_PARAM_InitTypeDef_t PI_parameters
 
uint16_t Rotor_poles_pairs
 
uint32_t mech_accel_hz = 0
 
uint32_t constant_k = 0
 
uint32_t Time_vector_tmp = 0
 
uint32_t Time_vector_prev_tmp = 0
 
uint32_t T_single_step = 0
 
uint32_t T_single_step_first_value = 0
 
int32_t delta = 0
 
uint16_t index_array = 1
 
int16_t speed_tmp_array [FILTER_DEEP]
 
uint16_t speed_tmp_buffer [FILTER_DEEP]
 
uint16_t HFBuffer [HFBUFFERSIZE]
 
uint16_t HFBufferIndex = 0
 
uint8_t array_completed = FALSE
 
uint8_t buffer_completed = FALSE
 
uint8_t UART_FLAG_RECEIVE = FALSE
 
uint32_t ARR_LF = 0
 
int32_t Mech_Speed_RPM = 0
 
int32_t El_Speed_Hz = 0
 
uint16_t index_adc_chn = 0
 
uint16_t index_motor_run = 0
 
uint16_t test_motor_run = 1
 
uint8_t Enable_start_button = TRUE
 
uint16_t index_ARR_step = 1
 
uint32_t n_zcr_startup = 0
 
uint16_t index_startup_motor = 1
 
uint16_t target_speed = TARGET_SPEED
 
uint16_t shift_n_sqrt = 14
 
uint16_t cnt_bemf_event = 0
 
uint8_t startup_bemf_failure = 0
 
uint8_t speed_fdbk_error = 0
 
__IO uint32_t uwTick = 0
 
uint8_t dac_status = DAC_ENABLE
 
uint16_t index_align = 1
 
int32_t speed_sum_sp_filt = 0
 
int32_t speed_sum_pot_filt = 0
 
uint16_t index_pot_filt = 1
 
int16_t potent_filtered = 0
 
uint32_t Tick_cnt = 0
 
uint32_t counter_ARR_Bemf = 0
 
uint64_t constant_multiplier_tmp = 0
 

Detailed Description

Motor Control driver.

Function Documentation

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
tickvalue
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
uint64_t MCM_Sqrt ( uint64_t  wInput)

It calculates the square root of a non-negative s64. It returns 0 for negative s64.

Parameters
Inputuint64_t number
Return values
int32_tSquare root of Input (0 if Input<0)

Variable Documentation

uint32_t ARR_LF = 0

Autoreload LF TIM variable

uint8_t array_completed = FALSE

Speed filter variable

uint8_t buffer_completed = FALSE

Potentiometer filter variable

uint32_t constant_k = 0

1/3*mech_accel_hz

int32_t delta = 0

Startup variable

int32_t El_Speed_Hz = 0

Electrical motor speed

uint8_t Enable_start_button = TRUE

Start/stop button filter to avoid double command

uint16_t HFBuffer[HFBUFFERSIZE]

Buffer for Potentiometer Value Filtering at the High-Frequency ADC conversion

uint16_t HFBufferIndex = 0

High-Frequency Buffer Index

uint16_t index_adc_chn = 0

Index of ADC channel selector for measuring

uint16_t index_array = 1

Speed filter variable

uint16_t index_motor_run = 0

Tmp variable for DEMO mode

uint32_t mech_accel_hz = 0

Hz – Mechanical acceleration rate

int32_t Mech_Speed_RPM = 0

Mechanical motor speed

SixStep PI regulator structure

uint16_t Rotor_poles_pairs

Number of pole pairs of the motor

SIXSTEP_Base_InitTypeDef SIXSTEP_parameters

Main SixStep structure

int16_t speed_tmp_array[FILTER_DEEP]

Speed filter variable

uint16_t speed_tmp_buffer[FILTER_DEEP]

Potentiometer filter variable

uint32_t T_single_step = 0

Startup variable

uint32_t T_single_step_first_value = 0

Startup variable

uint16_t target_speed = TARGET_SPEED

Target speed for closed loop control

uint16_t test_motor_run = 1

Tmp variable for DEMO mode

uint32_t Time_vector_prev_tmp = 0

Startup variable

uint32_t Time_vector_tmp = 0

Startup variable

uint8_t UART_FLAG_RECEIVE = FALSE

UART commmunication flag

__IO uint32_t uwTick = 0

Tick counter - 1msec updated

Generated on Fri Sep 11 2015 16:47:21 for X-CUBE-SPN7 for X-NUCLEO-IHM07M1 by   doxygen 1.8.9.1