source: src/main/java/agents/anac/y2015/agentBuyogV2/flanagan/control/ZeroOrderHold.java

Last change on this file was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 5.1 KB
Line 
1/* Class ZeroOrderHold
2*
3* This class contains the constructor to create an instance of
4* a zero order hold (ZOH) and the methods needed to use this ZOH
5* in control loops in the time domain, Laplace transform s domain
6* or the z-transform z domain.
7*
8* s-domain transfer function = (1 - exp(-Td.s))/s
9* Td is the delay time.
10* Pade approximation always used in s-domain
11* 1 to 4 order Pade approximations available
12*
13* This class is a subclass of the superclass BlackBox.
14*
15* Author: Michael Thomas Flanagan.
16*
17* Created: 26 June 2003.
18* Updated: 2 July 2006, 6 April 2008, 2 December 2008, 6-7 November 2009
19*
20* DOCUMENTATION:
21* See Michael T Flanagan's JAVA library on-line web page:
22* http://www.ee.ucl.ac.uk/~mflanaga/java/ZeroOrderHold.html
23* http://www.ee.ucl.ac.uk/~mflanaga/java/
24*
25* Copyright (c) 2003 - 2009 Michael Thomas Flanagan
26*
27* PERMISSION TO COPY:
28*
29* Permission to use, copy and modify this software and its documentation for NON-COMMERCIAL purposes is
30* provided that an acknowledgement to the author, Dr Michael Thomas Flanagan at www.ee.ucl.ac.uk/~mflanaga, appears in all copies
31* and associated documentation or publications.
32*
33* Redistributions of the source code of this source code, or parts of the source codes, must retain the above copyright notice,
34* this list of conditions and the following disclaimer and requires written permission from the Michael Thomas Flanagan:
35*
36* Redistribution in binary form of all or parts of this class must reproduce the above copyright notice, this list of conditions and
37* the following disclaimer in the documentation and/or other materials provided with the distribution and requires written permission
38* from the Michael Thomas Flanagan:
39*
40* Dr Michael Thomas Flanagan makes no representations about the suitability or fitness of the software for any or for a particular purpose.
41* Dr Michael Thomas Flanagan shall not be liable for any damages suffered as a result of using, modifying or distributing this software
42* or its derivatives.
43*
44***************************************************************************************/
45
46package agents.anac.y2015.agentBuyogV2.flanagan.control;
47
48import agents.anac.y2015.agentBuyogV2.flanagan.complex.Complex;
49import agents.anac.y2015.agentBuyogV2.flanagan.complex.ComplexPoly;
50
51public class ZeroOrderHold extends BlackBox{
52
53 // Constructor
54 public ZeroOrderHold(double deltaT, int orderPade){
55 super("ZeroOrderHold");
56 super.sPoles = Complex.oneDarray(1);
57 super.setDeltaT(deltaT);
58 super.setPadeOrder(orderPade);
59 this.setNumDen(deltaT);
60
61 }
62
63 // Constructor
64 // Default Pade approximation order = 2
65 public ZeroOrderHold(double deltaT){
66 super("ZeroOrderHold");
67 super.sPoles = Complex.oneDarray(1);
68 super.setDeltaT(deltaT);
69 this.setNumDen(deltaT);
70 }
71
72 // Constructor
73 // for copy purposes
74 private ZeroOrderHold(){
75 super("ZeroOrderHold");
76 }
77
78
79 // set the numerators and denominators
80 // same polynomials, using Pade approximation for Pade and non-Pade forms
81 public void setNumDen(double deltaT){
82 // set denominator, s
83 super.sDenom = new ComplexPoly(0.0D, 1.0D);
84 super.sPoles[0].reset(0.0D, 0.0D);
85
86 // set exp(-sT) part of pade numerator
87 super.sNumer = new ComplexPoly(1.0D);
88 super.deadTime = deltaT;
89 super.pade();
90 super.deadTime = 0.0D;
91
92 // add 1 to exp(-sT)[=padeNumer/padeDenom]/s
93 super.sNumerPade = super.sNumerPade.plus(super.sDenomPade);
94 super.sZerosPade = sNumerPade.rootsNoMessages();
95
96 super.sNumer = super.sNumerPade;
97 super.sDenom = super.sDenomPade;
98 super.sPoles = super.sPolesPade;
99 super.sZeros = super.sZerosPade;
100
101 super.sNumerDegPade = super.sNumerPade.getDeg();
102 super.sDenomDegPade = super.sDenomPade.getDeg();
103 super.sNumerDeg = super.sNumerDegPade;
104 super.sDenomDeg = super.sDenomDegPade;
105
106 if(super.sNumerDeg==0){
107 super.sNumerScaleFactor = super.sNumer.coeffCopy(0);
108 }
109 else{
110 super.sNumerScaleFactor = BlackBox.scaleFactor(super.sNumerPade, super.sZerosPade);
111 }
112 if(super.sDenomDeg==0){
113 super.sDenomScaleFactor = super.sDenom.coeffCopy(0);
114 }
115 else{
116 super.sDenomScaleFactor = BlackBox.scaleFactor(super.sDenomPade, super.sPolesPade);
117 }
118 }
119
120 // Deep copy
121 public ZeroOrderHold copy(){
122 if(this==null){
123 return null;
124 }
125 else{
126 ZeroOrderHold bb = new ZeroOrderHold();
127 this.copyBBvariables(bb);
128
129 return bb;
130 }
131 }
132
133 // Clone - overrides Java.Object method clone
134 public Object clone(){
135 return (Object)this.copy();
136 }
137}
Note: See TracBrowser for help on using the repository browser.