当前位置:首页 > 基于STM32FOC4 - 2MC Application 用户接口函数my
基于STM32FOC4.2MC Application 用户接口函数(调用)
MC_h
/**
****************************************************************************** * @file MC.h
* @author STMicroelectronics - System Lab - MC Team * @version 4.2.0
* @date 20-Aug-2015 18:06
* @brief Access point to the MC API.
* To use any of the MC API function in a user code follow the steps: * 1) #include \
* 2) Create the CMCI local reference: CMCI oMCI
* 3) Get reference of MCI via: oMCI = GetMCI(M1) or oMCI = GetMCI(M1) * 4) Call any MCI function:
* e.g. MCI_ExecSpeedRamp(oMCI,speed,duration); * To use any MCT function in a user code follow the steps: * 1) #include \
* 2) Create the CMCT local reference: CMCT oMCT
* 3) Get reference of MCT via: oMCT = GetMCT(M1) or oMCT = GetMCT(M1) * 4) Get reference of specific object to tune: * e.g. CPI oPI = MCT_GetSpeedLoopPID(oMCT); * 5) Call any MCT function related to that object: * e.g. PI_SetKP(oPI,newKPValue);
* It is also available the DAC related function like:
* e.g. MC_SetDAC(DAC_CH0, MC_PROTOCOL_REG_OBS_EL_ANGLE); * e.g. MC_SetUserDAC(DAC_USER1,value);
******************************************************************************/
/** @defgroup MC_exported_methods MC exported methods * @{ */
/**
* @brief This function returns the reference of the MCInterface relative to * the selected drive.
* @param bMotor Motor reference number defined * \\link Motors_reference_number here \\endlink
* @retval CMCI Reference to MCInterface relative to the selected drive. * Note: it can be MC_NULL if MCInterface of selected drive is not * allocated. */
CMCI GetMCI(uint8_t bMotor);
/**
* @brief This function returns the reference of the MCTuning relative to * the selected drive.
* @param bMotor Motor reference number defined * \\link Motors_reference_number here \\endlink
* @retval CMCI Reference to MCInterface relative to the selected drive. * Note: it can be MC_NULL if MCInterface of selected drive is not * allocated. */
CMCT GetMCT(uint8_t bMotor);
/**
* @brief This function requests a user-defined regular conversion. All user * defined conversion requests must be performed inside routines with the
* same priority level. If previous regular conversion request is pending * this function has no effect, for this reason is better to call the * MC_RegularConvState and check if the state is UDRC_STATE_IDLE before * to call MC_RequestRegularConv.
* @param bChannel ADC channel used for the regular conversion.
* @param bSamplTime Sampling time selection, ADC_SampleTime_nCycles defined in * stm32fxxx_adc.h see ADC_sampling_times. */
void MC_RequestRegularConv(uint8_t bChannel, uint8_t bSamplTime);
/**
* @brief Get the last user-defined regular conversion.
* @retval uint16_t It returns converted value or oxFFFF for conversion error. * This function returns a valid result if the state returned by * MC_RegularConvState is UDRC_STATE_EOC. */
uint16_t MC_GetRegularConv(void);
/**
* @brief Use this function to know the status of the last requested regular * conversion.
* @retval UDRC_State_t The state of the last user-defined regular conversion. * It can be one of the following values:
* UDRC_STATE_IDLE no regular conversion request pending.
* UDRC_STATE_REQUESTED regular conversion has been requested and not * completed.
* UDRC_STATE_EOC regular conversion has been completed but not readed * from the user. */
UDRC_State_t MC_RegularConvState(void);
/**
* @brief This method is used to set up the DAC outputs. The selected * variables will be provided in the related output channels. * @param bChannel the DAC channel to be programmed. It must be one of the * exported channels decribed \\link DAC_Channels here\\endlink. * E.g. DAC_CH0.
* @param bVariable the variables to be provided in out through the selected * channel. It must be one of the exported UI register described * \\link MC_Protocol_REG here\\endlink. E.g. MC_PROTOCOL_REG_I_A. * @retval none. */
void MC_SetDAC(DAC_Channel_t bChannel, MC_Protocol_REG_t bVariable);
/**
* @brief This method is used to set the value of the \ * @param bUserChNumber the \ * the channels described \\link DAC_UserChannel here\\endlink can be * used. E.g. DAC_USER1.
* @param hValue 16bit signed value to be put in output. * @retval none. */
void MC_SetUserDAC(DAC_UserChannel_t bUserChNumber, int16_t hValue);
MCInterfaceClass_h
/**
****************************************************************************** * @file MCInterfaceClass.h
* @author STMicroelectronics - System Lab - MC Team * @version 4.2.0
* @date 20-Aug-2015 18:06
* @brief This file contains interface of MCInterface class
******************************************************************************/
/**
* @brief This is a buffered command to set a motor speed ramp. This commands * don't become active as soon as it is called but it will be executed * when the oSTM state is START_RUN or RUN. User can check the status * of the command calling the MCI_IsCommandAcknowledged method. * @param this related object of class CMCI.
* @param hFinalSpeed is the value of mechanical rotor speed reference at the * end of the ramp expressed in tenths of HZ.
* @param hDurationms the duration of the ramp expressed in milliseconds. It * is possible to set 0 to perform an instantaneous change in the * value. * @retval none. */
void MCI_ExecSpeedRamp(CMCI this, int16_t hFinalSpeed, uint16_t hDurationms);
/**
* @brief This is a buffered command to set a motor torque ramp. This commands * don't become active as soon as it is called but it will be executed * when the oSTM state is START_RUN or RUN. User can check the status * of the command calling the MCI_IsCommandAcknowledged method. * @param this related object of class CMCI.
* @param hFinalTorque is the value of motor torque reference at the end of * the ramp. This value represents actually the Iq current expressed in * digit.
* To convert current expressed in Amps to current expressed in digit * is possible to use the formula:
* Current (digit) = [Current(Amp) * 65536 * Rshunt * Aop] / Vdd micro. * @param hDurationms the duration of the ramp expressed in milliseconds. It * is possible to set 0 to perform an instantaneous change in the * value. * @retval none. */
void MCI_ExecTorqueRamp(CMCI this, int16_t hFinalTorque, uint16_t hDurationms);
/**
* @brief This is a buffered command to set directly the motor current * references Iq and Id. This commands don't become active as soon as * it is called but it will be executed when the oSTM state is * START_RUN or RUN. User can check the status of the command calling * the MCI_IsCommandAcknowledged method. * @param this related object of class CMCI.
* @param Iqdref current references on qd reference frame in Curr_Components * format. * @retval none. */
void MCI_SetCurrentReferences(CMCI this, Curr_Components Iqdref);
/**
* @brief This is a user command used to begin the start-up procedure. * If the state machine is in IDLE state the command is executed * instantaneously otherwise the command is discarded. User must take * care of this possibility by checking the return value.
* Before calling MCI_StartMotor it is mandatory to execute one of * these commands:\\n * MCI_ExecSpeedRamp\\n * MCI_ExecTorqueRamp\\n * MCI_SetCurrentReferences\\n
* Otherwise the behaviour in run state will be unpredictable.\\n * Note: The MCI_StartMotor command is used just to begin the * start-up procedure moving the state machine from IDLE state to * IDLE_START. The command MCI_StartMotor is not blocking the execution * of project until the motor is really running; to do this, the user * have to check the state machine and verify that the RUN state (or * any other state) has been reached. * @param this related object of class CMCI.
* @retval bool It returns TRUE if the command is successfully executed * otherwise it return FALSE. */
bool MCI_StartMotor(CMCI this);
/**
* @brief This is a user command used to begin the stop motor procedure. * If the state machine is in RUN or START states the command is * executed instantaneously otherwise the command is discarded. User * must take care of this possibility by checking the return value.\\n * Note: The MCI_StopMotor command is used just to begin the * stop motor procedure moving the state machine to ANY_STOP. * The command MCI_StopMotor is not blocking the execution of project * until the motor is really stopped; to do this, the user have to * check the state machine and verify that the IDLE state has been * reached again.
* @param this related object of class CMCI.
* @retval bool It returns TRUE if the command is successfully executed * otherwise it return FALSE. */
bool MCI_StopMotor(CMCI this);
/**
* @brief This is a user command used to indicate that the user has seen the * error condition. If is possible, the command is executed
* instantaneously otherwise the command is discarded. User must take * care of this possibility by checking the return value. * @param this related object of class CMCI.
* @retval bool It returns TRUE if the command is successfully executed * otherwise it return FALSE. */
bool MCI_FaultAcknowledged(CMCI this);
/**
* @brief This is a user command used to begin the encoder alignment procedure. * If the state machine is in IDLE state the command is executed * instantaneously otherwise the command is discarded. User must take * care of this possibility by checking the return value.\\n
* Note: The MCI_EncoderAlign command is used just to begin the * encoder alignment procedure moving the state machine from IDLE state * to IDLE_ALIGNMENT. The command MCI_EncoderAlign is not blocking the * execution of project until the encoder is really calibrated; to do * this, the user have to check the state machine and verify that the * IDLE state has been reached again. * @param this related object of class CMCI.
* @retval bool It returns TRUE if the command is successfully executed * otherwise it return FALSE. */
共分享92篇相关文档