# Process Control Simulations (PCS) for MATLAB
**PCS** is an open-source object-oriented library developed by Departamento de Informática y Automática at UNED, aiming to provide an easy-to-develop framework for process control simulations.
## Table of Contents
- [Introduction](#introduction)
- [Getting Started](#getting-started)
- [Using the Library](#using-the-library)
- [API Reference](#api-reference)
## Introduction
This manual describes the use of Matlab-based simulation library PCS, which facilitates development of process control loops in networked and/or event-based environments.
Several tutorial examples are provided to show how to prepare reusable controllers and processes and perform continuous, periodic or event-triggered simulations.
This manual also includes a detailed API reference of the library with every package and its contents.
For questions and bug reports, please direct them to the [issues page of the library](https://github.com/crcuned/pcsmatlab/issues).
## Getting Started
Download the zip archive from [PCS for MATLAB homepage](https://github.com/crcuned/pcsmatlab). Then
1. Extract all files to some suitable directory.
2. Start MATLAB R2014a or higher and navigate to previous directory.
3. Run *install.m* to add the necessary directories to the MATLAB path.
## Using the Library
Tutorials are given in ascending difficulty order.
### Development of a Quadruple-Tank Process
The following class represents the quadruple-tank process described [here](http://ieeexplore.ieee.org/document/845876/).
~~~matlab
classdef QuadrupleTank < PCS.Process.Process
properties
a % Cross-sections of the outlets holes
A % Cross-sections of the tanks
g % Acceleration of gravity
gamma % Positions of the valves
k % Voltage to volumetric flow rate gains
end
methods
function self = QuadrupleTank(a, A, g, gamma, k)
if ndims(a) ~= 2 || length(a) ~= 4
error('Cross-sections of the outlets holes must be a vector of length 4.');
end
if ndims(A) ~= 2 || length(A) ~= 4
error('Cross-sections of the tanks must be a vector of length 4.');
end
if ~isscalar(g)
error('Acceleration of gravity must be a scalar.');
end
if ndims(gamma) ~= 2 || length(gamma) ~= 2
error('Positions of the valves must be a vector of length 2.');
end
if ndims(k) ~= 2 || length(k) ~= 2
error('Voltage to volumetric flow rate gains must be a vector of length 2.');
end
self.a = a;
self.A = A;
self.g = g;
self.gamma = gamma;
self.k = k;
self.n_inputs = 2;
self.n_outputs = 2;
self.n_states = 4;
end
function dxdt = derivatives(self, t, x, u, ~, ~)
dxdt = zeros(4, 1);
xt = x(t);
dxdt(1) = -self.a(1)/self.A(1)*sqrt(2*self.g*xt(1)) + self.a(3)/self.A(1)*sqrt(2*self.g*xt(3)) + self.gamma(1)*self.k(1)/self.A(1)*u(t,1);
dxdt(2) = -self.a(2)/self.A(2)*sqrt(2*self.g*xt(2)) + self.a(4)/self.A(2)*sqrt(2*self.g*xt(4)) + self.gamma(2)*self.k(2)/self.A(2)*u(t,2);
dxdt(3) = -self.a(3)/self.A(3)*sqrt(2*self.g*xt(3)) + (1-self.gamma(2))*self.k(2)/self.A(3)*u(t,2);
dxdt(4) = -self.a(4)/self.A(4)*sqrt(2*self.g*xt(4)) + (1-self.gamma(1))*self.k(1)/self.A(4)*u(t,1);
end
function y = outputs(self, t, x, u, ~, ~)
y = x(t, [1 2]);
end
end
end
~~~
### Development of a PI Controller
The following class represents a general PI controller.
~~~matlab
classdef PI < PCS.Control.Controller
properties
K % Proportional gains
Ti % Integral times
end
methods
function self = PI(K, Ti)
if ndims(K) > 2
error('Proportional gains must be a vector.');
end
if ndims(Ti) > 2
error('Integral times must be a vector.');
end
if length(K) ~= length(Ti)
error('The lengths of the proportional gains and integral times must match.');
end
self.K = K;
self.Ti = Ti;
self.n_inputs = length(K);
self.n_outputs = length(K);
self.n_states = length(K);
end
function dxcdt = derivatives(self, t, ~, ~, y, ~, r)
dxcdt = self.Ti.^(-1).*(r(t) - y(t));
end
function u = outputs(self, t, xc, ~, y, ~, r)
u = self.K.*xc(t) + self.K.*(r(t) - y(t));
end
end
end
~~~
### Executing a Simulation
The following script is used to perform the [PI control](#development-of-a-pi-controller) of the [quadruple-tank process](#development-of-a-quadruple-tank-process).
~~~matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PI control of a quadruple-tank process %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Quadruple-tank process
a = [0.071 0.057 0.071 0.057];
A = [28 32 28 32];
g = 981;
gamma = [0.7 0.6];
k = [3.33 3.35];
process = QuadrupleTank(a, A, g, gamma, k);
% PI controller
K = [0.3816; 0.5058];
Ti = [62.9557; 91.3960];
controller = PI(K, Ti);
% Create simulation
simulation = PCS.Simulation(controller, process);
% Define initial states and time interval
simulation.xc0 = [31.4347; 33.4446];
simulation.x0 = [12.4; 12.7; 1.5919; 1.4551];
simulation.t0 = 0;
simulation.tend = 500;
% Define set-point conditions
simulation.set_preloaded_reference(1, 15);
simulation.set_preloaded_reference(2, 12.7);
% Execute simulation
data = simulation.run();
% Plot results
plot(data.t, data.x);
~~~
## API Reference
The API reference is organized by packages.
| Package | Description |
|:----------------------------- |:------------------------------------------------------------------------------------------------------------ |
| [PCS](#pcs) | Provides the core classes necessary to perform a process control simulation and the base system definition. |
| [PCS.Control](#pcscontrol) | Provides the base controller definition and some of the well-known control laws. |
| [PCS.Hardware](#pcshardware) | Provides classes for emulating physical interaction with real processes. |
| [PCS.Network](#pcsnetwork) | Provides classes for establishing a networked communication between control loop components. |
| [PCS.Process](#pcsprocess) | Provides the base process definition and some of the well-known industrial processes. |
| [PCS.Utils](#pcsutils) | Provides static classes with useful reusable functions to simplify the simulation of the closed-loop system. |
### PCS
Provides the core classes necessary to perform a process control simulation and the base system definition.
#### Class Summary
| Class | Description |
|:---------- |:----------- |
| [Simulation](#class-simulation-pcs) | The *Simulation* class contains the core functionality of the library that allows to perform process control simulations. |
| [System](#class-system-pcs) | An abstract class which provides a common definition for processes and controllers. |
##### Class Simulation ([PCS](#pcs))
- [handle](https://es.mathworks.com/help/matlab/ref/handle-class.html)
The *Simulation* class contains the core functionality of the library that allows to perform process control simulations.
###### Properties Summary
| Modifier | Property | Description |
|:-------- |:--------- |:----------- |
| None | actuators | Vector containing an actuator for each input of the process. |
| None | actuator\_links | Vector containing the links of the network controller-process (C-P). |
| None | d\_sensors | Vector containing a sensor for each disturbance affecting the process. |
| None | event\_tol | Zero-crossing tolerance for event location. |
| None | on\_zeno\_enter | Function handle to be called before a Zeno phenomenom occurs. |
| None | on\_zeno\_exit | Function handle to be called after Zeno phenomenom is solved. |
| None | sensor\_links | Vector containing the links of the network process-controller (P-C). |
| None | solver | A function handle to the ODE solver. |
| None | t0 | The ini
没有合适的资源?快使用搜索试试~ 我知道了~
毕业设计&课设-基于MATLAB的过程控制仿真.zip
共20个文件
m:18个
md:2个
需积分: 1 2 下载量 185 浏览量
2024-01-08
22:59:05
上传
评论
收藏 34KB ZIP 举报
温馨提示
matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计&课设-基于MATLAB的过程控制仿真.zip (20个子文件)
matlab_code
+PCS
Simulation.m 54KB
+Utils
Utils.m 3KB
InterpolationMethod.m 166B
+Hardware
Actuator.m 2KB
Device.m 154B
Sensor.m 3KB
System.m 512B
+Network
LinkType.m 132B
Link.m 6KB
SensorLink.m 2KB
ActuatorLink.m 940B
+Control
Controller.m 289B
SPGA.m 2KB
+Process
InvertedPendulum.m 2KB
Process.m 372B
FurutaPendulum.m 3KB
LICENSE.md 34KB
uninstall.m 177B
install.m 108B
README.md 20KB
共 20 条
- 1
资源评论
白话机器学习
- 粉丝: 9334
- 资源: 7681
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功