历史上的今天
返回首页

历史上的今天

今天是: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

推荐阅读

史海拾趣

台湾双羽公司的发展小趣事

富士通的故事始于1935年,当时它作为一家电信设备制造公司在日本成立。在那个通信技术刚刚起步的时代,富士通凭借其创新精神和卓越的技术实力,迅速在电信设备领域崭露头角。公司最初专注于电话交换机的生产,随着技术的不断进步,富士通逐渐扩大了业务范围,为日本的电信基础设施建设做出了重要贡献。这一阶段的成功,为富士通后续在电子行业的蓬勃发展奠定了坚实的基础。

BLACK&DECKER公司的发展小趣事

BLACK&DECKER在技术创新方面一直走在行业前列。公司不断投入研发资源,推动电动工具技术的进步。例如,1979年,BLACK&DECKER发布了第一台手提式充电吸尘器Dustbuster,这一创新产品迅速成为市场上的热销产品,并推动了整个吸尘器行业的发展。此外,BLACK&DECKER还积极参与行业标准的制定工作,通过制定严格的产品质量标准和安全规范,为整个电子行业的健康发展做出了贡献。

Chemi-Con公司的发展小趣事

Chemi-Con公司的历史可以追溯到XXXX年,当时铝电解电容器在日本首次成功实现产品化。这不仅是电子行业的一个里程碑,也是Chemi-Con公司传奇故事的起点。公司创始人凭借对技术的深刻理解和市场的前瞻性,敏锐地捕捉到了铝电解电容器的巨大潜力,并决定将其作为公司的主营业务。在创业初期,Chemi-Con面临着资金、技术和市场等多方面的挑战,但创始人凭借着坚定的信念和不懈的努力,带领公司逐步攻克难关,奠定了在铝电解电容器领域的领先地位。

C-MAC Automotive公司的发展小趣事

在电子行业快速发展的今天,C-MAC Automotive公司始终保持着对创新的追求。公司不断投入研发资金,探索新的技术方向和应用领域。通过持续创新,C-MAC成功推出了一系列具有竞争力的新产品,为公司的发展注入了新的动力。同时,公司还注重人才培养和团队建设,打造了一支高效、专业的研发团队,为公司的未来发展奠定了坚实基础。

这些故事虽然基于虚构,但反映了电子行业中许多企业发展的普遍规律。通过技术突破、战略合作、创新营销、全球化战略和持续创新等手段,企业可以不断提升自身竞争力,实现快速发展。

3D PLUS公司的发展小趣事

随着技术的不断发展和市场的不断扩大,3D PLUS公司开始将目光投向国际市场。公司积极参加国际电子行业的展会和交流活动,与国际同行进行技术合作和交流,不断提升自身的技术水平和国际影响力。同时,公司还积极拓展海外销售渠道,将3D技术和产品推向全球市场,为全球客户提供高效、便捷的3D解决方案。这些努力不仅提升了公司在国际市场的知名度,也为公司的长期发展奠定了坚实的基础。

以上五个故事均基于3D PLUS公司在电子行业中的实际发展情况编写,旨在客观描述公司在3D技术领域的成长与进步。

Fractus公司的发展小趣事

随着技术的不断成熟和产品的市场推广,Fractus逐渐获得了业界的广泛认可。公司在多个国际展会上展示了其创新的天线技术,并赢得了多项重要奖项,包括欧洲联盟IST奖项的特等奖等。这些荣誉不仅提升了Fractus的品牌知名度,也进一步巩固了其在天线技术领域的领先地位。

问答坊 | AI 解惑

8051单片机实践与应用,包括51所有例子

8051单片机实践与应用,包括51所有例子.pdf…

查看全部问答>

STM8903K3串口通信的问题

刚接触ST,以前没有做过任何的嵌入式工作,这是我的第一个接触到的软件平台。        目前遇到了关于串口的问题,我用的是UART1,在系统初始化的时候,cpu时钟已经打开了外设TIM1,UART1的门控寄存器。然后,我 ...…

查看全部问答>

DSP2407串行通信12864(ST7920)

真的很急,有明白的帮帮我,我自己写了一个SPI通信的串行连接12864,程序在下面,不知道为什么就是屏幕不出字void Delay(int num); unsigned char tab1[]={ \"  电子万年历    \" \"  QQ478706146   \" ...…

查看全部问答>

大家讨论讨论龙芯在嵌入式方面的应用

国产自主知识产权的CPU芯片-龙芯,已经搞了很久了,只看见声音响,没有看见实物出来。大家讨论讨论,它能在嵌入式方面有哪些出路。…

查看全部问答>

Kwikstik在IAR6.2下入门!

Kwikstik用IAR下基本例子…

查看全部问答>

MSP430G2553产生在一定范围内任意占空比,任意频率的方波

#include  <msp430g2553.h>#define pwm_sf 200    //在这里可以任意调节频率,S是舵机的意思,#define pwm_vf 1000   //v是指电机的意思 (可以在这里随意设定舵机跟电机的频率)void pwm_sinit(unsigned char pwmva ...…

查看全部问答>

怎么才能让FPGA支持读取EMMC的资料

怎么才能让FPGA支持读取EMMC的资料,需要写入程序,但不知道怎么做!懂的大大教下可以吗?…

查看全部问答>

msp430 时钟模块振动器失效检测问题?

    请教一下各位,在14x系列中:     1.如果手动停止XT1(HF)或XT2,是否会使OFIFG置1?     2.如果我设置MCLK来源于XT2,我首先会开启XT2,然后会用到下面一段程序确保XT2开启正常,之后再对相关寄存器配置,使MCL ...…

查看全部问答>

LAUNCHXL-F28027入门学习及DIY制作

目的:一、步步入门学习f28027 三、制作输出电压可调的电源材料:一、LAUNCHXL-F28027二、12v.8.3A开关电源三、塑壳及其他电子元件目标:输出2路可调电压 输出电压暂时考虑:BUCK拓扑结构,输出电压1~9V,其余参数未定…

查看全部问答>

这颗IC是什么型号的?

各位老大,麻烦帮忙看看这个IC是什么型号的,封装是SOP-8,丝印是JS  A2。谢谢! …

查看全部问答>