为了便于在OpenModelica进行仿真,形成一个完整的仿真模型,没有使用第三方的库,参照了DrModelica的例程,按照Modelica库的开源模型定义了所用的基本元件模型。

首先给出一些基本类型的定义:

type ElectricPotential     = Real;
type ElectricCurrent = Real(quantity = "ElectricCurrent", unit = "A");
type Resistance = Real(quantity = "Resistance", unit = "Ohm", min = 0);
type Inductance = Real(quantity = "Inductance", unit = "H", min = 0);
type Voltage = ElectricPotential;
type Current = ElectricCurrent; type Force = Real(quantity = "Force", unit = "N");
type Angle = Real(quantity = "Angle", unit = "rad", displayUnit = "deg");
type Torque = Real(quantity = "Torque", unit = "N.m");
type AngularVelocity = Real(quantity = "AngularVelocity", unit = "rad/s", displayUnit = "rev/min");
type AngularAcceleration = Real(quantity = "AngularAcceleration", unit = "rad/s2");
type MomentOfInertia = Real(quantity = "MomentOfInertia", unit = "kg.m2"); type Time = Real (final quantity="Time", final unit="s"); connector RotFlange_a "1D rotational flange (filled square)"
Angle phi "Absolute rotational angle of flange";
flow Torque tau "Torque in the flange";
end RotFlange_a; //From Modelica.Mechanical.Rotational.Interfaces connector RotFlange_b "1D rotational flange (filled square)"
Angle phi "Absolute rotational angle of flange";
flow Torque tau "Torque in the flange";
end RotFlange_b; //From Modelica.Mechanical.Rotational.Interfaces connector Pin "Pin of an electrical component"
Voltage v "Potential at the pin";
flow Current i "Current flowing into the pin";
end Pin; //From Modelica.Electrical.Analog.Interfaces connector PositivePin "Positive pin of an electrical component"
Voltage v "Potential at the pin";
flow Current i "Current flowing into the pin";
end PositivePin; //From Modelica.Electrical.Analog.Interfaces connector NegativePin "Negative pin of an electrical component"
Voltage v "Potential at the pin";
flow Current i "Current flowing into the pin";
end NegativePin; //From Modelica.Electrical.Analog.Interfaces connector InPort "Connector with input signals of type Real"
parameter Integer n = 1 "Dimension of signal vector";
input Real signal[n] "Real input signals";
end InPort; // From Modelica.Blocks.Interfaces connector OutPort "Connector with output signals of type Real"
parameter Integer n = 1 "Dimension of signal vector";
output Real signal[n] "Real output signals";
end OutPort; // From Modelica.Blocks.Interfaces

基于上述自定义类型,定义一些基本元件的模型:

partial model Rigid           // Rotational class Rigid
"Base class for the rigid connection of two rotational 1D flanges"
Angle phi "Absolute rotation angle of component";
RotFlange_a rotFlange_a "(left) driving flange (axis directed into plane)";
RotFlange_b rotFlange_b "(right) driven flange (axis directed out of plane)";
equation
rotFlange_a.phi = phi;
rotFlange_b.phi = phi;
end Rigid; // From Modelica.Mechanics.Rotational.Interfaces model Inertia "1D rotational component with inertia"
extends Rigid;
parameter MomentOfInertia J = 1 "Moment of inertia";
AngularVelocity w "Absolute angular velocity of component";
AngularAcceleration a "Absolute angular acceleration of component";
equation
w = der(phi);
a = der(w);
J*a = rotFlange_a.tau + rotFlange_b.tau;
end Inertia; //From Modelica.Mechanics.Rotational partial model TwoPin // Same as OnePort in Modelica.Electrical.Analog.Interfaces
"Component with two electrical pins p and n and current i from p to n"
Voltage v "Voltage drop between the two pins (= p.v - n.v)";
Current i "Current flowing from pin p to pin n";
PositivePin p;
NegativePin n;
equation
v = p.v - n.v;
0 = p.i + n.i;
i = p.i;
end TwoPin; model DCMotor "DC Motor"
extends TwoPin;
extends Rigid;
OutPort SensorVelocity(n=1);
OutPort SensorCurrent(n=1);
parameter MomentOfInertia J"Total Inertia";
parameter Resistance R"Armature Resistance";
parameter Inductance L"Armature Inductance"; parameter Real Kt"Torque Constant";
parameter Real Ke"EMF Constant"; AngularVelocity w "Angular velocity of motor";
AngularAcceleration a "Absolute angular acceleration of motor";
Torque tau_motor;
RotFlange_b rotFlange_b; // Rotational Flange_b equation w = der(rotFlange_b.phi);
a = der(w);
v = R*i+Ke*w+L*der(i);
tau_motor = Kt*i;
J*a = tau_motor + rotFlange_b.tau;
SensorVelocity.signal[1] = w;
SensorCurrent.signal[1] = i;
end DCMotor; class Resistor "Ideal linear electrical Resistor"
extends TwoPin; // Same as OnePort
parameter Real R(unit = "Ohm") "Resistance";
equation
R*i = v;
end Resistor; // From Modelica.Electrical.Analog.Basic class Inductor "Ideal linear electrical Inductor"
extends TwoPin; // Same as OnePort
parameter Real L(unit = "H") "Inductance";
equation
v = L*der(i);
end Inductor; // From Modelica.Electrical.Analog.Basic class Ground "Ground node"
Pin p;
equation
p.v = 0;
end Ground; // From Modelica.Electrical.Analog.Basic model PWMVoltageSource
extends TwoPin;
InPort Command(n=1); parameter Time T = 0.003;
parameter Voltage Vin = 200; equation T*der(v)+ v = Vin*Command.signal[1]/10; end PWMVoltageSource; block Controller InPort command(n=1);
InPort feedback(n=1);
OutPort outPort(n=1); Real error;
Real pout;
parameter Real Kp=10;
parameter Real Max_Output_Pos = 10;
parameter Real Max_Output_Neg = -10; // parameter Real Ki=1; algorithm error := command.signal[1] - feedback.signal[1];
pout := Kp * error; if pout > Max_Output_Pos then
outPort.signal[1] := Max_Output_Pos;
elseif pout < Max_Output_Neg then
outPort.signal[1] := Max_Output_Neg;
else
outPort.signal[1] := pout;
end if; end Controller; block CommandSignalGenerator OutPort outPort(n=1);
Real acc; equation if time <= 1 then
acc =60;
elseif time <3 then
acc = 0;
elseif time <4 then
acc = -60;
else
acc = 0;
end if; der(outPort.signal[1]) = acc; end CommandSignalGenerator;

基于上述元件模型,给出一个直流调速系统实例:

model DCMotorControlSystem

  Ground       ground1;
Inertia inertia1(J = 3, w(fixed = true));
DCMotor motor1(J = 1,R = 0.6,L = 0.01,Kt=1.8, Ke= 1.8,rotFlange_b(phi(fixed = true)));
CommandSignalGenerator sg1;
Controller con1;
PWMVoltageSource PowerSource1;
equation
connect(sg1.outPort, con1.command);
connect(con1.feedback, motor1.SensorVelocity);
connect(con1.outPort, PowerSource1.Command);
connect(PowerSource1.p, motor1.p);
connect(motor1.rotFlange_b, inertia1.rotFlange_a);
connect(PowerSource1.n, ground1.p);
connect(ground1.p, motor1.n);
end DCMotorControlSystem;

模型检查通过后,就可以运行仿真命令并观察各个标量的波形。

simulate( DCMotorControlSystem, stopTime=5 )

直流调速系统Modelica基本模型的更多相关文章

  1. PLECS_晶闸管调速系统_9w

    3. 直流电机开环调压调速系统模型搭建 (1)电路图 (2)仿真 当 α = pi / 2.7 的时候,直流电机的稳定转速大约保持很低的速度. 随着α的减少,直流电机的速度逐渐增大.当α = pi / ...

  2. [问题解决]不使用PWM调速系统,彻底解决一个L298N带动两个电机却转速不同的问题

    问题描述:由单片机的VCC引脚供电,使用L298N控制两个电机,发现左右两个轮子的转速老是不一样,更多的情况是左轮转速高(左轮电机接OUT1和OUT2),右轮转速低(右轮电机接OUT3和OUT4)甚至 ...

  3. 直流电机PWM调速系统中控制电压非线性研究_控制元件_工业自动化控制_文章

    直流电机PWM调速系统中控制电压非线性研究_控制元件_工业自动化控制_文章_e-works数字化企业网 http://articles.e-works.net.cn/Component/Article ...

  4. 玩转X-CTR100 l STM32F4 l TB6612直流电机调速控制

    我造轮子,你造车,创客一起造起来!塔克创新资讯[塔克社区 www.xtark.cn ][塔克博客 www.cnblogs.com/xtark/ ] 本文介绍X-CTR100控制器的直流调速电机控制,X ...

  5. 通过PROFINET网络实现SINAMICS 120的PN IO OPC通讯,起动及调速控制 | OPC通讯

    1 概述 TCP/IP 通讯的传输时间可能太长,并且该时间具有不确定性,无法满足生产自动化领域的要求.因此,在进行时间要求苛刻的IO 有效载荷数据通讯时,PROFINET IO 不使用TCP/IP,而 ...

  6. 面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读

    SIGMOD 数据管理国际会议是数据库领域具有最高学术地位的国际性会议,位列数据库方向顶级会议之首.近日,腾讯云数据库团队的最新研究成果入选 SIGMOD 2022 Research Full Pap ...

  7. 权限系统与RBAC模型概述

    为了防止无良网站的爬虫抓取文章,特此标识,转载请注明文章出处.LaplaceDemon/SJQ. http://www.cnblogs.com/shijiaqi1066/p/3793894.html ...

  8. 过渡与动画 - steps调速函数&CSS值与单位之ch

    写在前面 上一篇中我们熟悉五种内置的缓动曲线和(三次)贝塞尔曲线,并且基于此完成了缓动效果. 但是如果我们想要实现逐帧动画,基于贝塞尔曲线的调速函数就显得有些无能为力了,因为我们并不需要帧与帧之间的过 ...

  9. 权限系统与RBAC模型概述[绝对经典]

    0. 前言 一年前,我负责的一个项目中需要权限管理.当时凭着自己的逻辑设计出了一套权限管理模型,基本原理与RBAC非常相似,只是过于简陋.当时google了一些权限管理的资料,从中了解到早就有了RBA ...

随机推荐

  1. [css]我要用css画幅画(二)

    接着之前的[css]我要用css画幅画(一) , 今天,我又画一个房子,很简单,屋顶.墙壁.门. 现在开始,做得效果都只兼容chrome,所以下面的css3的属性可能只有-webkit-前缀. 我只是 ...

  2. 测试必备技能系列4:如何用SSH向linux服务器上传下载文件

    通过ssh方式,向远程服务器上传文件 非常方便 直接看老徐之前的文章http://www.51testing.com/?uid-497177-action-viewspace-itemid-37054 ...

  3. 学C#你应该熟练使用ILDasm和Reflector【带视频教程】

    我们在学习C#的时候通常都会多多少少接触ILDasm和Reflector,这两样工具让我们对C#的理解不会只停留在编译器这个层面 上,而是让我们更深入的穿透编译器.这篇也是希望对IL和Reflecto ...

  4. .NET领域驱动设计—实践(穿过迷雾走向光明)

    阅读目录 开篇介绍 1.1示例介绍 (OnlineExamination在线考试系统介绍) 1.2分析.建模 (对真实业务进行分析.模型化) 1.2.1 用例分析 (提取系统的所有功能需求) 1.3系 ...

  5. 开窗函数 --over()

    一个学习性任务:每个人有不同次数的成绩,统计出每个人的最高成绩. 这个问题应该还是相对简单,其实就用聚合函数就好了. select id,name,max(score) from Student gr ...

  6. Xcode同时兼容Xcode7和Xcode8,两个版本并存,也适用于先升8再安装7

    先吐槽一下之前看到的一个教程,如下: 先在应用程序内,拷贝一份之前的xcode,然后再安装新版本,发现这种安装完成就是在之前上面迭代了  有木有?等于没任何作用 我这边就是不小心先升级了8,然后再安装 ...

  7. LeetCode #303. Range Sum Query

    问题: Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclu ...

  8. 描述Linux下文件删除的原理(计时3分钟)

    Linux是通过link的数量来控制文件删除的,只有当一个文件不存在任何link的时候,这个文件才会被删除.一般来说,每个文件都有2个link计数器:i_count 和 i_nlink. i_coun ...

  9. web性能优化系列之网站瓶颈识别

    最近,公司网站的的访问量日益增大,PV马上过百万了.前期网站一到访问高峰,马上会变得很卡甚至打不开,后来做了很多优化后现在访问比较顺畅了.经过此事明白了一个道理,在遇到这类问题要做到两点,第一要相信自 ...

  10. DPM检测模型 训练自己的数据集 读取接口修改

    (转载请注明作者和出处 楼燚(yì)航的blog :http://www.cnblogs.com/louyihang-loves-baiyan/ 未经允许请勿用于商业用途) 本文主要是针对上一篇基于D ...