默认的STM32F FOC SDK提供的工程文件下载到STM32以后不会电机不会自动转,想要让电机转,必须通过串口上位机ST Motor Control Workbench这个软件
若想脱离上位机让电机上电自动旋转,需要在main函数里面调用电机启动函数
UI_ExecCmd (oUI, MC_PROTOCOL_CMD_START_MOTOR);
根据UM1052 User manual STM32F PMSM single/dual FOC SDK v4.2手册中描述的可以利用FOC提供的UI函数来屏蔽底层驱动,直接在用户层编写程序
提供的函数定义在 UserInterfaceClass.c 中,其中主要的函数有
/**
* @brief Creates an object of the class UserInterface
* @param pUserInterfaceParams pointer to an UserInterface parameters structure
* @retval CUI new instance of UserInterface object
*/
CUI UI_NewObject(pUserInterfaceParams_t pUserInterfaceParams);
/**
* @brief Initialization of UI object. It perform the link between the UI
* object and the MC interface and MC tuning objects. It must be called
* before the derived class initialization.
* @param this related object of class CUI.
* @param bMCNum Is the total number of MC object presnet in the list.
* @param pMCI is the pointer of the list of MC interface objects to be linked
* with the UI.
* @param pMCT is the pointer of the list of MC tuning objects to be linked
* with the UI.
* @param pUICfg is the pointer of the user interface configuration list. Each
* element of the list must be a bit field containing one (or more) of
* the exported configuration option UI_CFGOPT_xxx (eventually OR-ed).
* @retval none.
*/
void UI_Init(CUI this, uint8_t bMCNum, CMCI* pMCI, CMCT* pMCT, uint32_t* pUICfg);
/**
* @brief It is used to select the MC on which UI operates.
* @param this related object of class CUI.
* @param bSelectMC The new selected MC, zero based, on which UI operates.
* @retval bool It return true if the bSelectMC is valid oterwise return false.
*/
bool UI_SelectMC(CUI this,uint8_t bSelectMC);
/**
* @brief It is used to retrive the MC on which UI currently operates.
* @param this related object of class CUI.
* @retval uint8_t It returns the currently selected MC, zero based, on which
* UI operates.
*/
uint8_t UI_GetSelectedMC(CUI this);
/**
* @brief It is used to retrive the configuration of the MC on which UI
* currently operates.
* @param this related object of class CUI.
* @retval uint32_t It returns the currently configuration of selected MC on
* which UI operates.
* It represents a bit field containing one (or more) of
* the exported configuration option UI_CFGOPT_xxx (eventually OR-ed).
*/
uint32_t UI_GetSelectedMCConfig(CUI this);
/**
* @brief It is used to execute a SetReg command coming from the user.
* @param this related object of class CUI.
* @param bRegID Code of register to be updated. Valid code is one of the
* MC_PROTOCOL_REG_xxx values exported by UserInterfaceClass.
* @param wValue is the new value to be set.
* @retval bool It returns true if the SetReg command has been performed
* succesfully otherwise returns false.
*/
bool UI_SetReg(CUI this, MC_Protocol_REG_t bRegID, int32_t wValue);
/**
* @brief It is used to execute a GetReg command coming from the user.
* @param this related object of class CUI.
* @param bRegID Code of register to be updated. Valid code is one of the
* MC_PROTOCOL_REG_xxx values exported by UserInterfaceClass.
* @retval int32_t is the current value of register bRegID.
*/
int32_t UI_GetReg(CUI this, MC_Protocol_REG_t bRegID);
/**
* @brief It is used to retrieve the current selected MC tuning object.
* @param this related object of class CUI.
* @retval CMCT It returns the currently selected MC tuning object on which
* UI operates.
*/
CMCT UI_GetCurrentMCT(CUI this);
/**
* @brief It is used to execute a command coming from the user.
* @param this related object of class CUI.
* @param bCmdID Code of register to be updated. Valid code is one of the
* MC_PROTOCOL_CMD_xxx define exported by UserInterfaceClass.
* @retval bool It returns true if the command has been performed
* succesfully otherwise returns false.
*/
bool UI_ExecCmd(CUI this, uint8_t bCmdID);
/**
* @brief It is used to execute a speed ramp command coming from the user.
* @param this related object of class CUI.
* @param wFinalMecSpeedRPM final speed value expressed in RPM.
* @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 bool It returns true if the command has been performed
* succesfully otherwise returns false.
*/
bool UI_ExecSpeedRamp(CUI this, int32_t wFinalMecSpeedRPM, uint16_t hDurationms);
/**
* @brief It is used to execute a torque ramp command coming from the user.
* @param this related object of class CUI.
* @param hTargetFinal final torque value. See MCI interface for more
details.
* @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 bool It returns true if the command has been performed
* succesfully otherwise returns false.
*/
bool UI_ExecTorqueRamp(CUI this, int16_t hTargetFinal, uint16_t hDurationms);
/**
* @brief It is used to execute a get Revup data command coming from the user.
* @param this related object of class CUI.
* @param bStage is the rev up phase, zero based, to be read.
* @param pDurationms is the pointer to an uint16_t variable used to retrieve
* the duration of the Revup stage.
* @param pFinalMecSpeed01Hz is the pointer to an int16_t variable used to
* retrieve the mechanical speed at the end of that stage expressed in
* 0.1Hz.
* @param pFinalTorque is the pointer to an int16_t variable used to
* retrieve the value of motor torque at the end of that
* stage. This value represents actually the Iq current expressed in
* digit.
* @retval bool It returns true if the command has been performed
* succesfully otherwise returns false.
*/
bool UI_GetRevupData(CUI this, uint8_t bStage, uint16_t* pDurationms,
int16_t* pFinalMecSpeed01Hz, int16_t* pFinalTorque );
/**
* @brief It is used to execute a set Revup data command coming from the user.
* @param this related object of class CUI.
* @param bStage is the rev up phase, zero based, to be modified.
* @param hDurationms is the new duration of the Revup stage.
* @param hFinalMecSpeed01Hz is the new mechanical speed at the end of that
* stage expressed in 0.1Hz.
* @param hFinalTorque is the new value of motor torque at the end of that
* stage. This value represents actually the Iq current expressed in
* digit.
* @retval bool It returns true if the command has been performed
* succesfully otherwise returns false.
*/
bool UI_SetRevupData(CUI this, uint8_t bStage, uint16_t hDurationms,
int16_t hFinalMecSpeed01Hz, int16_t hFinalTorque );
/**
* @brief It is used to execute a set current reference command coming from
* the user.
* @param this related object of class CUI.
* @param hIqRef is the current Iq reference on qd reference frame. This value
* is expressed in digit. To convert current expressed in digit to
* current expressed in Amps is possible to use the formula:
* Current(Amp) = [Current(digit) * Vdd micro] / [65536 * Rshunt * Aop]
* @param hIdRef is the current Id reference on qd reference frame. This value
* is expressed in digit. See hIqRef param description.
* @retval none.
*/
void UI_SetCurrentReferences(CUI this, int16_t hIqRef, int16_t hIdRef);
/**
* @brief Hardware and software initialization of the DAC object. This is a
* virtual function and is implemented by related object.
* @param this related object of class UI. It must be a DACx_UI object casted
上一篇:STM32系统学习——EXTI(外部中断)
下一篇:关于STM32 NVIC配置的解释
推荐阅读最新更新时间:2024-10-31 17:40
设计资源 培训 开发板 精华推荐
- NCP1086 3.3V 固定输出线性稳压器的典型应用
- NCP300LSN34T1 3.4V 电压检测器的典型应用,用于具有附加迟滞的微处理器复位电路
- haojiahuo
- 基于合宙Air530Z的定位器&授时器
- ADSL调制解调器的FSK调制解调器应用电路
- LTC3615HFE 双路 3A 同步降压型 DC/DC 转换器的典型应用,具有外部补偿功能
- LT3063 的典型应用 - 具有输出放电功能的 45V Vin、微功率、低噪声、200mA LDO
- 基于bq4050的锂电池电量计与保护板模块
- LTM4636IY 三相 0.9V/120A 降压稳压器的典型应用电路
- 具有关断低压差线性稳压器的 LT3007ITS8 3.3V、20mA 电源的典型应用电路