Main Content

Field-Oriented Control of PMSM Using Hall Sensor

该示例实现了面向现场的控制(FOC)技术,以控制三相永久磁铁同步电动机(PMSM)的速度。焦点算法需要转子位置反馈,这是由霍尔传感器获得的。有关焦点的详细信息,请参阅面向现场的控制(FOC)

This example uses the Hall sensor to measure the rotor position. A Hall effect sensor varies its output voltage based on the strength of the applied magnetic field. A PMSM consists of three Hall sensors located electrically 120 degrees apart. A PMSM with this setup can provide six valid combinations of binary states (for example, 001,010,011,100,101, and 110). The sensor provides the angular position of the rotor in the multiples of 60 degrees, which the controller uses to compute the angular velocity. The controller can then use the angular velocity to compute an accurate angular position of the rotor.

Models

The example includes these models:

You can use these models for both simulation and code generation. You can also use the open_system command to open the Simulink® model. For example, use this command for a F28069M based controller:

open_system('mcb_pmsm_foc_hall_f28069m.slx');

有关您可以用于不同硬件配置的模型名称,请参见“生成代码”中所需的硬件主题,并部署模型以定位硬件部分。

必需的MathWorks®产品下载188bet金宝搏

To simulate model:

1。For the model:MCB_PMSM_FOC_HALL_F28069M

  • 电动机控制区块™

  • 定点Designer™

2。For the model:MCB_PMSM_FOC_HALL_F28379D

  • 电动机控制区块™

生成代码和部署模型:

1。For the model:MCB_PMSM_FOC_HALL_F28069M

  • 电动机控制区块™

  • 嵌入式编码器®

  • 嵌入式编码器®Support Package for Texas Instruments™ C2000™ Processors

  • 定点Designer™

2。For the model:MCB_PMSM_FOC_HALL_F28379D

  • 电动机控制区块™

  • 嵌入式编码器®

  • 嵌入式编码器®Support Package for Texas Instruments™ C2000™ Processors

  • 定点Designer™(仅需要优化代码生成)

先决条件

1。获取电动机参数。我们使用Simulink®模型提供默认电机参数,您可以用电动机数据表或其他源的值替换。金宝app

但是,如果使用电动机控制硬件,则可以使用电动机控制模块群参数估计工具来估计要使用的电动机的参数。有关说明,请参阅Estimate PMSM Parameters Using Recommended Hardware

参数估计工具更新摩托车变量(在MATLAB®工作区中)具有估计的电机参数。

2。If you obtain the motor parameters from the datasheet or other sources, update the motor parameters and inverter parameters in the model initialization script associated with the Simulink® models. For instructions, see估计控制收益和使用实用程序功能

如果使用参数估计工具,则可以更新逆变器参数,但不要更新模型初始化脚本中的电动机参数。脚本自动从更新的摩托车工作区变量。

模拟模型

This example supports simulation. Follow these steps to simulate the model.

1。打开此示例中包含的模型。

2。要模拟模型,请单击on theSimulation标签。

3。要查看和分析仿真结果,请单击Data Inspectoron theSimulation标签。

生成代码和部署模型以目标硬件

本节指示您生成代码并在目标硬件上运行焦点算法。

此示例使用主机和目标模型。主机模型是控制器硬件板的用户界面。您可以在主机计算机上运行主机模型。使用主机模型的先决条件是将目标模型部署到控制器硬件板上。主机模型使用串行通信来命令目标simulink®模型并在闭环控制中运行电动机。金宝app

需要硬件

This example supports these hardware configurations. You can also use the target model name to open the model for the corresponding hardware configuration, from the MATLAB® command prompt.

有关与前面硬件配置相关的连接,请参见F28069控制卡配置

有关与前面硬件配置相关的连接,请参见Launchxl-F28069M和launchxl-F28379D配置

在目标硬件上生成代码并运行模型

1。Simulate the target model and observe the simulation results.

2。Complete the hardware connections.

3。该模型会自动计算模数转换器(ADC)或当前偏移值。要禁用此功能(默认情况下启用),请在模型初始化脚本中将值0更新为变量倒置。

Alternatively, you can compute the ADC offset values and update it manually in the model initialization scripts. For instructions, see跑3-Phase AC Motors in Open-Loop Control and Calibrate ADC Offset

4。Compute the Hall sensor offset value and update it in the model initialization script associated with the target model. For instructions, seePMSM电动机的大厅偏移校准

5。Open the target model for the hardware configuration that you want to use. If you want to change the default hardware configuration settings for the model, seeModel Configuration Parameters

6。Load a sample program to CPU2 of LAUNCHXL-F28379D, for example, program that operates the CPU2 blue LED by using GPIO31 (c28379D_cpu2_blink.slx), to ensure that CPU2 is not mistakenly configured to use the board peripherals intended for CPU1.

7。点击构建,部署和开始on the硬件选项卡将模型部署到硬件。

8。In the target model, click the主机模型hyperlink to open the associated host model. You can also use the open_system command to open the host model. For example, use this command for a F28069M based controller:

open_system('mcb_host_model_f28069m.slx');

For details about the serial communication between the host and target models, seeHost-Target Communication

9。In the host model, open the blocks Host Serial Setup, Host Serial Receive, and Host Serial Transmit, and select a港口

10.更新主机模型中的参考速度值。

11。点击on theSimulation选项卡以运行主机模型。

12。Change the position of the Start / Stop Motor switch to On, to start running the motor.

笔记:当您以低参考速度在硬件上运行此示例时,由于已知问题,PMSM可能不会遵循低参考速度。

13。在主机模型的时间范围内观察来自RX子系统的调试信号。

笔记:If you are using a F28379D based controller, you can also select the debug signals that you want to monitor.