Guy on Simulink

Simulink & Model-Based Design

在Arduino板上实现PID控制器

本周我的同事pravallika.又回到了运动控制故事!

Pravallikota Vinnakota,Guest Blogger

在我的以前的帖子,我们看到如何估计连续转移功能System Identification Toolbox。We estimated the following transfer function for a simple DC Motor usingt

从直流电动机识别的传递功能

For this transfer function, we designed the following controller usingpidtune

PidTune生成的控制器

我们现在将在Arduino UNO上实施控制器,并了解DC电机如何使用此控制器。要在硬件上部署控制器,我们将使用Simulink的功能生成可执行文件并在所选硬件上运行它。金宝app

将控制器部署到Arduino Board

You probably noticed that the controller shown above is in a continuous form. To use it on our target, the first thing to do is to discretize it using theC2D.功能:

Discretizing the controller generated by pidtune

然后我们抓住了PID块来自Simulin金宝appk库并配置它。

PID块configuration

为了使PID控制器在硬件限制内的输出,我们转到PID高级选项卡并启用输出饱和度以及防风保护。

先进的PID块配置

To test the controller on the hardware, we created a Simulink model using blocks from theArduino支金宝app持包

As you can see, we receive the desired motor position from the serial port and compare it to the measured position from the Analog Input. The position error goes through the PID block which generates a voltage to be sent to the motor. We also send the measured position through the serial port.

控制器模型用于在Arduino板上使用

Hardware response

We ran the model on the target, sent it some commands and logged the data transmitted through the serial port. Here is what it looks like:

从我们的控制器记录的数据

因此,跟踪参考信号确实非常好。当我们将响应与模拟的硬件与模拟的响应进行比较时,我们观察到它们非常接近!系统识别工具箱模型非常好。

现在轮到你了

系统难以模型时如何设计控制器?您是否尝试过在Simulink中运行目标硬件功能以在支持的电路板上运行模型?金宝app金宝app离开一个让我们知道在这里评论

|

Comments

要发表评论,请点击here要登录您的MathWorks帐户或创建新的。