历史上的今天
今天是:2025年04月22日(星期二)
2019年04月22日 | STM32 FOC SDK 上电电机自动旋转
2019-04-22 来源:eefocus
默认的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
史海拾趣
|
刚接触ST,以前没有做过任何的嵌入式工作,这是我的第一个接触到的软件平台。 目前遇到了关于串口的问题,我用的是UART1,在系统初始化的时候,cpu时钟已经打开了外设TIM1,UART1的门控寄存器。然后,我 ...… 查看全部问答> |
|
真的很急,有明白的帮帮我,我自己写了一个SPI通信的串行连接12864,程序在下面,不知道为什么就是屏幕不出字void Delay(int num); unsigned char tab1[]={ \" 电子万年历 \" \" QQ478706146 \" ...… 查看全部问答> |
|
MSP430G2553产生在一定范围内任意占空比,任意频率的方波 #include <msp430g2553.h>#define pwm_sf 200 //在这里可以任意调节频率,S是舵机的意思,#define pwm_vf 1000 //v是指电机的意思 (可以在这里随意设定舵机跟电机的频率)void pwm_sinit(unsigned char pwmva ...… 查看全部问答> |
|
请教一下各位,在14x系列中: 1.如果手动停止XT1(HF)或XT2,是否会使OFIFG置1? 2.如果我设置MCLK来源于XT2,我首先会开启XT2,然后会用到下面一段程序确保XT2开启正常,之后再对相关寄存器配置,使MCL ...… 查看全部问答> |
|
目的:一、步步入门学习f28027 三、制作输出电压可调的电源材料:一、LAUNCHXL-F28027二、12v.8.3A开关电源三、塑壳及其他电子元件目标:输出2路可调电压 输出电压暂时考虑:BUCK拓扑结构,输出电压1~9V,其余参数未定… 查看全部问答> |




