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

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

  1. type ElectricPotential = Real;
  2. type ElectricCurrent = Real(quantity = "ElectricCurrent", unit = "A");
  3. type Resistance = Real(quantity = "Resistance", unit = "Ohm", min = 0);
  4. type Inductance = Real(quantity = "Inductance", unit = "H", min = 0);
  5. type Voltage = ElectricPotential;
  6. type Current = ElectricCurrent;
  7. type Force = Real(quantity = "Force", unit = "N");
  8. type Angle = Real(quantity = "Angle", unit = "rad", displayUnit = "deg");
  9. type Torque = Real(quantity = "Torque", unit = "N.m");
  10. type AngularVelocity = Real(quantity = "AngularVelocity", unit = "rad/s", displayUnit = "rev/min");
  11. type AngularAcceleration = Real(quantity = "AngularAcceleration", unit = "rad/s2");
  12. type MomentOfInertia = Real(quantity = "MomentOfInertia", unit = "kg.m2");
  13. type Time = Real (final quantity="Time", final unit="s");
  14. connector RotFlange_a "1D rotational flange (filled square)"
  15. Angle phi "Absolute rotational angle of flange";
  16. flow Torque tau "Torque in the flange";
  17. end RotFlange_a; //From Modelica.Mechanical.Rotational.Interfaces
  18. connector RotFlange_b "1D rotational flange (filled square)"
  19. Angle phi "Absolute rotational angle of flange";
  20. flow Torque tau "Torque in the flange";
  21. end RotFlange_b; //From Modelica.Mechanical.Rotational.Interfaces
  22. connector Pin "Pin of an electrical component"
  23. Voltage v "Potential at the pin";
  24. flow Current i "Current flowing into the pin";
  25. end Pin; //From Modelica.Electrical.Analog.Interfaces
  26. connector PositivePin "Positive pin of an electrical component"
  27. Voltage v "Potential at the pin";
  28. flow Current i "Current flowing into the pin";
  29. end PositivePin; //From Modelica.Electrical.Analog.Interfaces
  30. connector NegativePin "Negative pin of an electrical component"
  31. Voltage v "Potential at the pin";
  32. flow Current i "Current flowing into the pin";
  33. end NegativePin; //From Modelica.Electrical.Analog.Interfaces
  34. connector InPort "Connector with input signals of type Real"
  35. parameter Integer n = 1 "Dimension of signal vector";
  36. input Real signal[n] "Real input signals";
  37. end InPort; // From Modelica.Blocks.Interfaces
  38. connector OutPort "Connector with output signals of type Real"
  39. parameter Integer n = 1 "Dimension of signal vector";
  40. output Real signal[n] "Real output signals";
  41. end OutPort; // From Modelica.Blocks.Interfaces

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

  1. partial model Rigid // Rotational class Rigid
  2. "Base class for the rigid connection of two rotational 1D flanges"
  3. Angle phi "Absolute rotation angle of component";
  4. RotFlange_a rotFlange_a "(left) driving flange (axis directed into plane)";
  5. RotFlange_b rotFlange_b "(right) driven flange (axis directed out of plane)";
  6. equation
  7. rotFlange_a.phi = phi;
  8. rotFlange_b.phi = phi;
  9. end Rigid; // From Modelica.Mechanics.Rotational.Interfaces
  10. model Inertia "1D rotational component with inertia"
  11. extends Rigid;
  12. parameter MomentOfInertia J = 1 "Moment of inertia";
  13. AngularVelocity w "Absolute angular velocity of component";
  14. AngularAcceleration a "Absolute angular acceleration of component";
  15. equation
  16. w = der(phi);
  17. a = der(w);
  18. J*a = rotFlange_a.tau + rotFlange_b.tau;
  19. end Inertia; //From Modelica.Mechanics.Rotational
  20. partial model TwoPin // Same as OnePort in Modelica.Electrical.Analog.Interfaces
  21. "Component with two electrical pins p and n and current i from p to n"
  22. Voltage v "Voltage drop between the two pins (= p.v - n.v)";
  23. Current i "Current flowing from pin p to pin n";
  24. PositivePin p;
  25. NegativePin n;
  26. equation
  27. v = p.v - n.v;
  28. 0 = p.i + n.i;
  29. i = p.i;
  30. end TwoPin;
  31. model DCMotor "DC Motor"
  32. extends TwoPin;
  33. extends Rigid;
  34. OutPort SensorVelocity(n=1);
  35. OutPort SensorCurrent(n=1);
  36. parameter MomentOfInertia J"Total Inertia";
  37. parameter Resistance R"Armature Resistance";
  38. parameter Inductance L"Armature Inductance";
  39. parameter Real Kt"Torque Constant";
  40. parameter Real Ke"EMF Constant";
  41. AngularVelocity w "Angular velocity of motor";
  42. AngularAcceleration a "Absolute angular acceleration of motor";
  43. Torque tau_motor;
  44. RotFlange_b rotFlange_b; // Rotational Flange_b
  45. equation
  46. w = der(rotFlange_b.phi);
  47. a = der(w);
  48. v = R*i+Ke*w+L*der(i);
  49. tau_motor = Kt*i;
  50. J*a = tau_motor + rotFlange_b.tau;
  51. SensorVelocity.signal[1] = w;
  52. SensorCurrent.signal[1] = i;
  53. end DCMotor;
  54. class Resistor "Ideal linear electrical Resistor"
  55. extends TwoPin; // Same as OnePort
  56. parameter Real R(unit = "Ohm") "Resistance";
  57. equation
  58. R*i = v;
  59. end Resistor; // From Modelica.Electrical.Analog.Basic
  60. class Inductor "Ideal linear electrical Inductor"
  61. extends TwoPin; // Same as OnePort
  62. parameter Real L(unit = "H") "Inductance";
  63. equation
  64. v = L*der(i);
  65. end Inductor; // From Modelica.Electrical.Analog.Basic
  66. class Ground "Ground node"
  67. Pin p;
  68. equation
  69. p.v = 0;
  70. end Ground; // From Modelica.Electrical.Analog.Basic
  71. model PWMVoltageSource
  72. extends TwoPin;
  73. InPort Command(n=1);
  74. parameter Time T = 0.003;
  75. parameter Voltage Vin = 200;
  76. equation
  77. T*der(v)+ v = Vin*Command.signal[1]/10;
  78. end PWMVoltageSource;
  79. block Controller
  80. InPort command(n=1);
  81. InPort feedback(n=1);
  82. OutPort outPort(n=1);
  83. Real error;
  84. Real pout;
  85. parameter Real Kp=10;
  86. parameter Real Max_Output_Pos = 10;
  87. parameter Real Max_Output_Neg = -10;
  88. // parameter Real Ki=1;
  89. algorithm
  90. error := command.signal[1] - feedback.signal[1];
  91. pout := Kp * error;
  92. if pout > Max_Output_Pos then
  93. outPort.signal[1] := Max_Output_Pos;
  94. elseif pout < Max_Output_Neg then
  95. outPort.signal[1] := Max_Output_Neg;
  96. else
  97. outPort.signal[1] := pout;
  98. end if;
  99. end Controller;
  100. block CommandSignalGenerator
  101. OutPort outPort(n=1);
  102. Real acc;
  103. equation
  104. if time <= 1 then
  105. acc =60;
  106. elseif time <3 then
  107. acc = 0;
  108. elseif time <4 then
  109. acc = -60;
  110. else
  111. acc = 0;
  112. end if;
  113. der(outPort.signal[1]) = acc;
  114. end CommandSignalGenerator;

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

  1. model DCMotorControlSystem
  2. Ground ground1;
  3. Inertia inertia1(J = 3, w(fixed = true));
  4. DCMotor motor1(J = 1,R = 0.6,L = 0.01,Kt=1.8, Ke= 1.8,rotFlange_b(phi(fixed = true)));
  5. CommandSignalGenerator sg1;
  6. Controller con1;
  7. PWMVoltageSource PowerSource1;
  8. equation
  9. connect(sg1.outPort, con1.command);
  10. connect(con1.feedback, motor1.SensorVelocity);
  11. connect(con1.outPort, PowerSource1.Command);
  12. connect(PowerSource1.p, motor1.p);
  13. connect(motor1.rotFlange_b, inertia1.rotFlange_a);
  14. connect(PowerSource1.n, ground1.p);
  15. connect(ground1.p, motor1.n);
  16. end DCMotorControlSystem;

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

  1. 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. EF框架学习手记

    转载: [ASP.NET MVC]: - EF框架学习手记 1.EF(Entity Framework)实体框架EF是ADO.NET中的一组支持开发面向数据的软件应用程序的技术,是微软的一个ORM框架 ...

  2. (1)编写一个接口ShapePara,要求: 接口中的方法: int getArea():获得图形的面积。int getCircumference():获得图形的周长 (2)编写一个圆类Circle,要求:圆类Circle实现接口ShapePara。 该类包含有成员变量: radius:public 修饰的double类型radius,表示圆的半径。 x:private修饰的double型变量x,

    package com.hanqi.test; //创建接口 public interface ShapePara { //获取面积的方法 double getArea(); //获取周长的方法 do ...

  3. coursera机器学习笔记-神经网络,初识篇

    #对coursera上Andrew Ng老师开的机器学习课程的笔记和心得: #注:此笔记是我自己认为本节课里比较重要.难理解或容易忘记的内容并做了些补充,并非是课堂详细笔记和要点: #标记为<补 ...

  4. 高效coder,筹备开源框架toutou.escort.js

    背景:JavaScript在工作中运用的非常广泛,作为一门弱类型语言,在使用JavaScript的时候,很多事情需要coder manual的去完成,这无疑增加了coder的工作量. 扩展:在这样的背 ...

  5. java 生成 csv文件

    一.csv文件 逗号分隔值(Comma-Separated Values,CSV,有时也称为字符分隔值,因为分隔字符也可以不是逗号),其文件以纯文本形式存储表格数据(数字和文本).纯文本意味着该文件是 ...

  6. [转]Shell中read的常用方式

    原文:Linux Shell Scripting Tutorial V2.0 read命令的语法: read -p "Prompt" variable1 variable2 var ...

  7. 烂泥:学习mysql数据库主从同步复制原理

    本文由秀依林枫提供友情赞助,首发于烂泥行天下. 说明本篇文章部分转载自互联网. MySQL的Replication(英文为复制)是一个多MySQL数据库做主从同步的方案,特点是异步复制,广泛用在各种对 ...

  8. 56相册视频(土豆相册视频 激动相册视频 QQ动感影集等)——下载教程

    由于目前流行的相册视频或影集大多是由Flash.音乐和图片组合而成的动画,不属于完整视频,所以不能用常规的解析方法下载. 鉴于很多朋友希望可以下载自己精心制作的相册,故在本教程中,我们将以图文并茂的方 ...

  9. AC日记——求10000以内n的阶乘 openjudge 1.6 14

    14:求10000以内n的阶乘 总时间限制:  5000ms 内存限制:  655360kB 描述 求10000以内n的阶乘. 输入 只有一行输入,整数n(0<=n<=10000). 输出 ...

  10. AC日记——统计数字字符个数 openjudge 1.7 01

    01:统计数字字符个数 总时间限制:  1000ms 内存限制:  65536kB 描述 输入一行字符,统计出其中数字字符的个数. 输入 一行字符串,总长度不超过255. 输出 输出为1行,输出字符串 ...