技术文章和新闻通讯

PID控制设计变得容易

由Murad Abu-Khalaf,Mathworks,Rong Chen,Mathworks和Arkadiy Turevskiy,Mathworks


调谐PID控制器似乎很容易,只需您只找到三个值:比例,积分和衍生品收益。实际上,安全和系统地找到确保控制系统最佳性能的一组收益是一项复杂的任务。传统上,PID控制器可以手动调整或使用基于规则的方法。手动方法是迭代且耗时的,如果在硬件上使用,可能会造成损坏。基于规则的方法也有严重的局限性:它们不支持某些类型的植物模型,例如不稳定的植物,高阶植物或几乎没有时间延迟的植物。万博1manbetx除了调整外,PID控制还涉及设计和实施挑战,例如离散时间实现和定点缩放。

Using a four-bar linkage system as an example, this article describes a method that simplifies and improves the design and implementation of PID controllers. This method is based on two R2009b product features: the PID Controller blocks in Simulink®以及Simulink Control Design™中的PID调万博1manbetx整算法。

四杆连杆系统:控制设计目标

四杆连杆(图1)用于广泛的应用,包括汽车悬架,机器人执行器和飞机起落架。

pid_fig1_w.jpg
Figure 1. Four-bar linkage mechanism with stationary lower link colored in blue.

The control system consists of two elements: feedforward control and feedback PID control. Feedforward control inverts plant dynamics—it handles the major motion of the mechanism by taking into account the nonlinear behavior. Feedback PID control keeps positioning errors small in the face of modeling uncertainties and external disturbances. This article focuses on the design of feedback PID control.

PID控制器(图2)在其中一个链接的所需旋转角度和实际旋转角之间采用了误差信号,并创建了扭矩请求。该请求将添加到FeedForward控制器的扭矩请求中,并使用总和信号来驱动DC电动机,该直流电动机会驱动连接链接的关节旋转。控制器必须稳定植物的操作。它还必须提供快速的响应时间和几乎没有冲动的时间。由于控制器将在具有16位的定点处理器上实现,因此需要以离散的时间形式实现,并且必须相应地缩放收益和计算的信号。

pid_fig2_w.jpg
Figure 2. Four-bar linkage system controller architecture.

配置闭环系统并调整控制器

该植物模型由以Simmechanics™建模的四杆连锁机制和以Simelectronics建模的直流电动机组成®(Figure 3). To create the controller architecture shown in Figure 2, we simply add a discrete-time PID Controller block from the Simulink Discrete library. With the closed-loop system configured, we are ready to tune the controller.

pid_fig3_w.jpg
图3.包含直流电动机的Simelectronics模型的四杆连锁机制的Simmechanics模型。

To do that, we open the PID Controller block dialog, specify controller sampling time, and press “Tune” (Figure 4) to open the PID Tuner GUI. Before displaying the GUI, Simulink Control Design linearizes the plant at the current operating point and derives the linear time invariant (LTI) plant model seen by the PID Controller block in this feedback control loop. Computational delay associated with sampling is automatically taken into account. Using an automatic tuning method, Simulink Control Design then generates the initial gains of the PID controller. This tuning method imposes no limits on plant order or time delay, and it works in both continuous and discrete time domains.

pid_fig4_w.jpg
图4. PID调谐器,从“块”对话框打开。

图5显示了使用此初始PID设计的闭环系统的设定值跟踪响应。如果控制器性能令人满意,我们按“应用”来更新P,i,d和n在PID控制器块对话框中的p,i,d和n的值。然后,我们可以通过模拟非线性模型并查看结果来测试设计的性能(图6)。我们还可以使用简单的滑块进行交互式调整设计,以使控制器更快或更慢(图5,底部)。

此示例显示了使用此初始PID设计的闭环系统的设定值跟踪响应。(没有音频)
pid_fig6_w.jpg
Figure 6. Simulation results for the four-bar linkage model.

准备实施

为了准备在16位微处理器上实现的控制器,我们将其扩展为芯片支持的固定点算术。万博1manbetx

Using “Data Types” tab in the block dialog box, we apply the settings required for fixed-point design (Figure 7). We can obtain these settings automatically using the Fixed-Point Tool in Simulink. We then run the simulation using fixed-point settings to verify that the fixed-point design results closely match the results we obtained when the controller gains and signals were implemented as double-precision values.

pid_fig7_w.jpg
Figure 7. Fixed-point settings for implementing the PID controller on a processor with 16-bit fixed-point architecture.

生成生产代码

With the PID controller prepared for implementation, the final step is to use Real-Time Workshop Embedded Coder™ to generate C code (Figure 8). To test this code, we replace the PID Controller block with the generated C code and run the code in closed-loop simulation. We can do that by using Real-Time Workshop Embedded Coder to automatically create a Simulink block that invokes the generated C code.

pid_fig8_w.jpg
图8. 16位定点PID控制器的C代码实现。该代码是从PID控制器块生成的。

We can now run the simulation using the C code that will run on the actual processor. Simulation shows that the generated code produces results that closely match the results obtained with our PID Controller block with double-precision values (Figure 9).

pid_fig9_w.jpg
Figure 9. Simulation results comparing the performance of the generated C code with the performance of the double-precision PID Controller block.

我们现在可以将这段代码部署到处理器和start controlling our four-bar linkage in real time.

发布2009-91842V00

查看相关行业的文章