STM32 PMSM FOC SDK_Part4


MCI_ExecTorqueRamp
MCI_SetCurrentReferences
Execute a ramp
STM32 PMSM FOC SDK v3.2
29/03/2013
MC Interface get methods 1/2
Method
MCI_IsCommandAcknowledged MCI_GetSTMState MCI_GetAvrgMecSpeed01Hz
• Sensorless algorithm improvement
• How to create User Project Interacting with MC Application • Dual motor control
• Resources sharing • Supported configurations • Code size efficiency
Agenda
• 1st day – Afternoon
• MC Application
• • • • Interface Tuning Tasks Classes interaction
• Current regulation • Ramp-up • Encoder alignment
1
• Speed sensors updates:
MCI_StopMotor
MCI_FaultAcknowledged
MCI_EncoderAlign
START
STOP
STM32 PMSM FOC SDK v3.2
29/03/2013
MC Interface buffered commands
• Buffered commands don't become active as soon as it is called but it will be executed when machine is in a predefined state (Ex. RUN).
It returns information about current motor measured torque. This value represents actually the Iq current 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]. It returns the motor phase current amplitude (0-to-peak) in s16A To convert s16A into Ampere following formula must be used: Current(Amp) = [Current(s16A) * Vdd micro] / [65536 * Rshunt * Aop]. It returns the applied motor phase voltage amplitude (0-topeak) in s16V. To convert s16V into Volts following formula must be used: PhaseVoltage(V) = [PhaseVoltage(s16V) * Vbus(V)] /[sqrt(3) *32767]. It returns the motor direction imposed by the last command (MCI_ExecSpeedRamp, MCI_ExecTorqueRamp or MCI_SetCurrentReferences).
6
Description
It returns information about the state of the last buffered command. It returns information about the state of the related oSTM object. It returns information about the current mechanical rotor speed reference expressed in tenths of HZ. It returns information about last computed average mechanical speed, expressed in 01Hz (tenth of Hertz). It returns information about the current motor torque reference. This value represents actually the Iq current reference 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]. It returns information about stator current reference in Curr_Components format. It returns the modality of the speed and torque controller.
MCI_GetTorqueRef
MCI_GetCurrentsReference MCI_GetControlMode
STM32 PMSM FOC SDK v3.2
29/03/2013
MC Interface get methods 2/2
Method
MCI_GetTorque
7
Description
4
• If more that one buffered command is send before the execution only the last is considered.
STM32 PMSM FOC SDK v3.2
29/03/2013
MC Interface buffered commands
• Current reading sensor update
STM32 PMSM FOC SDK v3.2
29/03/2013
MC Application
• The Motor Control Interface is the application built on top of the Motor Control Library this application is able to grant to the user layer the execution of a set of commands, named the MC Application Programming Interface (MC API). • The API is divided in two sections:
5
Method
MCI_ExecSpeedRamp
Description
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. 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. 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 when the oSTM state is START_RUN or RUN. User can check the status of the command calling the MCI_IsCommandAcknowledged method.
• MC Interface • MC Tuning
2
PWMnCurrFdbkClass
FOCDriveClass CFOC SpeednPosFdbkClass CSPD RevupCtrlClassReal sensor, observer
合集下载

基于STM32的+PMSM+FOC

基于STM32的+PMSM+FOC

基于STM32的+PMSM+FOC基于STM32+PMSM+FOC电机驱动项目PMSM:Permanent-Magnetic-Synchronous-Motor 永磁同步电机NVIC:Nested-Vectored-Interrupt-Controller 嵌套向量中断控制器MPU: Microprocessor-Unit 微处理器单元ISR: Interrupt-Service-Routine 中断服务程序IRQ: Interrupt-Request 中断申请Cortex—M3中断优先级:1)STM-32(Cortex-M3)中定义了两中优先级:抢占式优先级(Preemptive Priority)和副优先级(Sub-Priority);2)每一个中断源都需要指定这两种优先级;3)若IRQ1和IRQ2的抢占式优先级相同,系统在处理IRQ1的时候,IRQ2申请进入(无中断嵌套),IRQ2:必须等待系统将IRQ1处理完才处理IRQ2的申请;4)若IRQ1,IRQ2同时申请进入,系统首先会根据谁的抢占式优先级高,就先处理谁;5)如果IR1,IRQ2的抢占式优先级一样,副优先级高的首先被处理;6)如果IRQ1,IRQ2的抢占式优先级、副优先级一样高,系统根据二者在中断向量表中的排位顺序来决定处理;Cortex-M3中断优先级分组:STM 32中利用一些寄存器的位(4 bit)来指定两种中断优先级,4 bit的分组方式如下:1)第0组(NVIC_PriorityGroup_0):所有的4 bit全部用来表示副优先级(sub-priority2)第1组(NVIC_PriorityGroup_1):最高一位用于表示抢占式优先(preemptive-priority),最低3位用于表示副优先级(sub-priority);3)第2组(NVIC_PriorityGroup_2): 最高两位用于表示抢占式优先级(preemptive-priority),最低两位用于表示副优先级(sub-priority);4)第3组(NVIC_PriorityGroup_3):最高三位用于表示抢占式优先级,最低一位表示副优先级;5)第4组(NVIC_PriorityGroup_4): 四位全部用来表示抢占式优先级。

STM32F103_永磁同步电机_PMSM_FOC软件库_用户手册_中文版

STM32F103_永磁同步电机_PMSM_FOC软件库_用户手册_中文版

UM0492 用户手册 STM32F103xx 永磁同步电机磁场定向控制(PMSM FOC)软件库 V2.0 简 介
本用户手册介绍了永磁同步电机(PMSM)FOC 软件库,STM32F103xx 微控制 器就是针对磁场定向控制(FOC)3 相永磁电机固件库开发的。 这些 32 位,ARM 的 Cortex™- M3 的芯 ST 微控制器(STM32F103xx)附带一 套外围设备, 使之适用于永磁交流同步电机和交流异步电机磁场定向控制。特别 是, 本手册介绍了 STM32F103xx 软件库发展到可以控制外置型或嵌入型或在扭矩 和速度两个控制模式下控制正弦波驱动永磁电机。这些电机可能配备一编码器, 具有三个霍尔传感器或者他们可能无传感器。在 UM0483 用户手册中介绍了具有 编码器或测速发电机的交流感应电机的控制。 永磁同步电机磁场定向控制库是由几个 C 语言的模块构成,并列装 IAR EWARM 5.20,Keil 公司的 RealView MDK 3.22a 和 Green Hills 5.03 工作区。 它是用来同时快速评估 MCU 和可用的工具。此外,当和 STM32F103xx 电机控制入 门套件(STM3210B- MCKIT)及永磁电机一起使用时,可以让电机在很短的时间 运转起来。 它通过提供立即可用功能,也省去了 FOC 发展的耗时和速度调节的需 要,让用户专注于应用层。而且,因为有了转子位置重构无传感器算法,它可能 不需要任何速度传感器。 使用这个库的一个先决条件是要懂得 C 语言程序设计的基础知识, 永磁电机 驱动器和功率逆变器的硬件的基本知识。 需要定制现有模块和添加一个新型的完 整应用开发时才需要深入了解 STM32F103xx 功能。 图 1 显示了固件结构图。它广泛使用 STM32F103xx 标准库,但当需要优化执 行速度和代码大小时它也直接作用于硬件设备的外围设备。

基于STM32的+PMSM+FOC软件库培训_3

基于STM32的+PMSM+FOC软件库培训_3

eβ = −Φ m pωr sin( pωr t )
两者相除,可得到转子的位置角为:
ˆ ⎛ eβ θ r = pωr t = arctg ⎜ − ⎜ e ⎝ ˆα ⎞ ⎟ ⎟ ⎠
这个方法是开环的,它对耦合在反电动势里的干扰非 常敏感(它会使反电动势成为非正弦信号!)
基于STM32的 PMSM FOC软件库培训
⎧ dλ vα = rsiα + α ⎪ ⎪ dt ⎨ ⎪v = r i + dλβ s β ⎪β dt ⎩
⎧λα = Lsiα + sinθr ⋅ Φm ⎪ ; ⎨ ⎪λβ = Lsiβ + cosθr ⋅ Φm ⎩
其中 : Ls = Lls + 3Lms / 2;
θ r = pω r t
把磁链方程代入电压方程,得到:
=−
rs iα eα vα − + Ls Ls Ls rs i β e β v β =− − + Ls Ls Ls = pω r eβ = − p ω r eα
PMSM马达状态方程可线性表达为:
& ⎧ x(t ) = Ax(t ) + Bu (t ) ⎨ ⎩ y (t ) = Cx (t )
其中: 状态矢量 x=[iα iβ eα eβ ]t, 输入矢量 u=[vα vβ]t, 输出变量 y=[iα iβ]t
Mar ‘08 13
PLL 闭环系数计算
经过验证,Kp及Ki定义为:
P gain = 532 ⋅ Maximum electrical frequency Observer sampling freq
I gain =
1506742 ⋅ Maximum electrical frequency

STM32 FOC_讲座4

STM32 FOC_讲座4

• Current reading sensor update
STM32 PMSM FOC SDK v3.2
12/06/2014
MC Application
• The Motor Control Interface is the application built on top of the Motor Control Library this application is able to grant to the user layer the execution of a set of commands, named the MC Application Programming Interface (MC API). • The API is divided in two sections:
• MC Interface • MC Tuning
61
PWMnCurrFdbkClass
FOCDriveClass CFOC SpeednPosFdbkClass CSPD RevupCtrlClassReal sensor, observeClass
CSTC
STM32 PMSM FOC SDK v3.2
12/06/2014
MC Interface commands
Method
MCI_StartMotor
62
Description
This is a user command used to start the motor. 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. This is a user command used to stop the motor. 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. 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. This is a user command used to start the encoder alignment procedure. 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.

基于STM32的 PMSM FOC软件库培训_4

基于STM32的 PMSM FOC软件库培训_4

t
n
n
基于STM32的 PMSM FOC软件库培训
Mar ‘08
10
状态观测器方程回顾
如前所述,状态观测器的离散化方程为:
rT T T iα (k + 1) = iα (k ) s iα (k ) + K1T (iα (k ) iα (k )) eα (k ) + vα (k ) Ls Ls Ls i (k + 1) = i (k ) rsT i (k ) + K T (i (k ) i (k )) T e (k ) + T v (k ) β β β β β 1 β β Ls Ls Ls eα (k + 1) = eα (k ) + K2T (iα (k ) iα (k )) + pωr eβ (k )T eβ (k + 1) = eβ (k ) + K2T (iβ (k ) iβ (k )) pωr eα (k )T
Target current
+ -
e
KP
+
Voltage command +
Байду номын сангаас
Measured Current
KI
1 s
PI Controller
基于STM32的 PMSM FOC软件库培训
MCU Application Great China
Mar ‘08
7
转矩/磁链 闭环框图
Target current + Measured current
MCU Application Great China
Mar ‘08
12
基于STM32的 PMSM FOC软件库培训

基于STM32单片机的PMSM伺服系统设计

基于STM32单片机的PMSM伺服系统设计

图9
电流采样电路
电流流过采样电阻得到的电压信号是交流信号,有
正负性,信号电压值也非常小,因此需要对此信号进行
放大和整形。如图 10 所示,方案采用运放构建同相放大
器,用 3.3 V 单电源供电。交流相电流流经采样电阻 R0 而
产生交流微电压信号,此信号的变化会引起运放同相输
入端的电压产生相应的变化,再经过放大便可得到 0~
器,又作为 ADC 的触发源 [8]。ADC 用到的双规则同步模
式和注入同步模式由定时器 1 的两路比较器分别触发。
ADC 的 双 规 则 同 步 模 式 触 发 之 后 启 动 ADC 的 DMA 模
式,进行电压等非三相电流的模拟量采样。完成采样后
启动中断,中断程序执行读取编码器数据操作。ADC 的
规划 U、V、W 三相电流时,U 相电流信号接入 STM32 单
片机 ADC1 的其中一个通道管脚,V 相接 ADC1 和 ADC2
共有的一个管脚,W 相接 ADC2 其中一个管脚。这样每
个电流采样周期就可以根据 FOC 算出来的扇区选择其中
两相电流进行同时采样,如何计算出扇区此文不做详细
图 11
介绍,第三相的电流由基尔霍夫定律计算得出。
2.2 功率电路
如图 5 所示,PARK 变换模型的输入是 Iα、Iβ、电角
sin θùú
·
cos θû
CLARKE 变换模型
(1)
1.4 PARK 变换模型
éIdù écos θ
êI ú = ê
ë qû ë-sin θ
图6
(2)
PARK 变换模型
1.5 CLARKE 变换模型
如图 6 所示,CLARKE 变换的输入是三相电流 Ia、

STM32在变频波轮洗衣机上的应用

STM32在变频波轮洗衣机上的应用随着国家节能减排政策的引导和人们对节能环保意识提高,变频技术已广泛应用于空调、冰箱、洗衣机等白色家电领域,使用变频技术的家电产品逐渐受到消费者认可。

变频波轮洗衣机使用永磁同步电机(PMSM)直接驱动洗衣机波轮,采用变频技术对电机进行调速控制后,在噪音、转矩和调速性能等方面相对于传统波轮洗衣机改善效果明显。

方案介绍波轮洗衣机的洗涤原理是依靠电机带动装在洗衣桶底部的波轮正、反旋转,衣物在波轮的带动下上、下、左、右不停地翻转,同时在洗涤剂的作用下实现去污清洗。

因波轮洗衣机的工作原理,洗衣机电机需要不停的正、反转切换,且电机启动时要具备足够大的力矩。

针对上述应用,方案选用ST 公司Cortex-M3 内核的STM32F103C6T6A 微处理器和ST 公司的智能功率模块(IPM)STGIPL14K60 为平台,采用3 电阻电流检测和带霍尔传感器方法实现对洗衣机永磁同步电机(PMSM)的矢量控制(FOC)。

STM32F 系列为ST 发布的基于ARM 公司Cortex-M3 内核的微处理器,其拥有最高72MHz 的运行频率,并内部集成了一个专门用于马达控制的Advanced Timer,足以满足电机控制FOC 运算的需求。

同时ST 提供了完整的电机驱动解决方案,通过免费提供的电机固件库及PC 端的用户配置界面MotorControl WorkBench,用户可以快速实现马达应用评估。

STGIPL14K60 为ST 公司推出的智能功率模块(IPM),功率模块内集成600V 15A IGBT、半桥驱动、运算放大器、比较器、NTC 等器件,能够简化电机控制逆变电路,仅需用一个功率模块即可替代几十个分立器件,有效提高控制系。

基于STM32的+PMSM+FOC软件库培训_2

参照右图,SM-PMSM马达的电压和磁链方程为:
b
S
θr
q
a
vabcs = rs iabcs +
Lls + Lms
dλabcs dt
1 − Lms 2 Lls + Lms 1 − Lms 2
N
c
Φm
d
λabc = − Lms
s
1 2 1 − Lms 2
1 − Lms sin θ r 2 1 2 ⎞ ⎛ − Lms iabcs + sin ⎜θ r − π ⎟ Φ m 2 3 ⎠ ⎝ 2 ⎞ ⎛ Lls + Lms sin ⎜θ r + π ⎟ 3 ⎠ ⎝
基于STM32的 PMSM FOC软件库培训
MCU Application Great China
Mar ‘08 3
转子磁场定向控制 (FOC): 概述
数学理论应用于三相马达磁链及转矩的解耦控制 定子电流被分解成:
直轴电流Ids:用于产生磁场,与转子的磁场叠加 Ids 交轴电流Iqs:用于控制转矩(其作用等同于直流电机的电枢电 流)。
Mar ‘08
17
FOC 实现
函数: FOC_Model (MC_FOC_DRIVE.c)
Feature is executed after Current Conversions (SAMPLING FREQ) vq* = PI regulator (iq, iq ref)
(ia, ib) = Get Phase Currents
MCU Application Great China
Mar ‘08
6
坐标变换理论(3/3)
Clarke变换应用于定子电流:ias,ibs,ics:

基于STM32的永磁同步电机的控制共3篇

基于STM32的永磁同步电机的控制共3篇基于STM32的永磁同步电机的控制1永磁同步电机(Permanent Magnet Synchronous Motor,简称PMSM)是一种极具应用前景的高性能电机,被广泛应用于交通工具、家电、机械设备等领域。

随着电动汽车、新能源等产业的发展,PMSM的控制技术也越来越受到关注。

本文将基于STM32单片机,介绍PMSM的控制过程和相关技术。

一、PMSM的基本原理PMSM的基本原理是将定子上的三相绕组和转子上的永磁体之间的电磁作用力转化为机械转矩。

其中,定子上的三相绕组通过交流电源得到三相交流电,产生旋转磁场。

转子上的永磁体则产生磁动势,与旋转磁场作用产生转矩。

为了使PMSM能够实现精确的控制,需要知道其电磁状态,即定子电流、转子位置等信息。

接下来,我们将介绍PMSM的控制过程和所需技术。

二、PMSM的控制过程1. 传感器获取PMSM的控制需要准确的电磁状态信息,因此需要安装传感器获取定子电流、转子位置等信息。

一般来说,采用霍尔传感器或编码器获取转子位置信息,采用霍尔电流传感器或电阻分压电路获取定子电流信息。

2. 位置估算针对没有安装位置传感器的情况,可以采用磁场观测器或滑模观测器等算法来实现位置估算。

3. 控制算法选择对于PMSM的控制算法,可以选择基于直流型或交流型控制的空间矢量调制(Space Vector Modulation,简称SVPWM)或PI控制等算法。

其中,基于直流型控制的SVPWM由于计算量小、实现简单,更适合嵌入式单片机平台。

4. 控制器的设计与实现选择STM32单片机作为PMSM控制器,需要进行硬件和软件的设计与实现。

在硬件设计方面,需要选择合适的器件如功率MOS管、光耦、保险丝等;在软件实现方面,需要编写电机控制程序,实现数据采集、控制算法等功能。

5. 闭环控制系统搭建为了保证PMSM控制精度,需要建立闭环控制系统。

一般由电流环、速度环、位置环组成。

STM32 V4.0 电机软件库培训1


15
工具:GUI, IDE ,demo 板
工具:ST MC Workbench 1/2
• STMCWB PC软件通过图形界面产生软件库的参数头文件,方便用户 对软件库的配置及马达的调试
1 2 3 4
17
工具:ST MC Workbench 2/2
• 实时串口通讯
• 与PC实时通讯,实现马达的启动/停止,或速度的加减速 • 调试和监控软件参数 • 实时画出马达的参考及实际速度曲线
• 电流采样
• • 1-SHUNT 3-SHUNT
• 更换EVB可支持不同的MCU
EVB
• 更换EVB可支持不同的MCU
22
功率板
• 更换功率板可支持不同的功率
23
单板demo板
• 控制及功率部分集成在一块demo板上
24
STM32F0xx风扇demo板 1/2
• 拓扑结构 ωr*
STM32F0xx
Speed Control
vabc
Space Vector PWM
Current Control
i q*
MTPA & FLUX WEAKENING CONTROLLER
+
PID
-
vqs vds
vαβ
REVERSE PARK + circle limitation
i d*
+
θr el
PID
-
Te*
PID
• 必须读取定子的电流(1-shunt/3-shunt/ICS) • 必须读取转子的位置及速度(Encoder/Hall/Sensorless算法) • 电流的实时控制(PI/D):
• 不容易控制:高频正弦参考值、幅值的调制及与转子磁链的耦合 • 通过参考坐标系的转换来简化耦合问题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
相关文档
最新文档