<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Control Systems on R Views</title>
    <link>https://rviews.rstudio.com/tags/control-systems/</link>
    <description>Recent content in Control Systems on R Views</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Thu, 24 Aug 2017 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://rviews.rstudio.com/tags/control-systems/" rel="self" type="application/rss+xml" />
    
    
    
    
    <item>
      <title>Control Systems Toolbox – System Interconnection</title>
      <link>https://rviews.rstudio.com/2017/08/24/control-systems-toolbox/</link>
      <pubDate>Thu, 24 Aug 2017 00:00:00 +0000</pubDate>
      
      <guid>https://rviews.rstudio.com/2017/08/24/control-systems-toolbox/</guid>
      <description>
        


&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;/post/2017-08-18-control-systems-toolbox_files/FigA.png&#34; /&gt;

&lt;/div&gt;
&lt;p&gt;Dynamic systems are usually represented by a model before they can be analyzed computationally. These dynamic systems are systems that change, evolve or have their states altered or varied with time based on a set of defined rules. Dynamic systems could be mechanical, electrical, electronic, biological, sociological, and so on. Many such systems are usually defined by a set rules that are represented as a set of nonlinear differential equations. A generic first-order differential form is as shown below: &lt;span class=&#34;math display&#34;&gt;\[
     \frac{dx}{dt} =  f ( x(t), u(t), t )   ........... (1)
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where &lt;em&gt;x(t)&lt;/em&gt; is the state vector representing the configuration (or state) of the system at the time, &lt;em&gt;t&lt;/em&gt;, &lt;em&gt;u(t)&lt;/em&gt; represents the external control input at time, &lt;em&gt;t&lt;/em&gt;, and &lt;em&gt;f&lt;/em&gt; is a function that gives the rate of change of the state vector for a specific input, state and time.&lt;/p&gt;
&lt;p&gt;The system of (1) could be said to be time invariant if we assume that &lt;em&gt;f&lt;/em&gt; does not explicitly depend on time. This implies that the relation of (1) becomes:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
     \frac{dx}{dt} =  f (x, u)  ........... (2)
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For such time-invariant systems, the control input may remain time-variant, but the coefficients of the function &lt;em&gt;f&lt;/em&gt; are constant since the underlying physical laws themselves are not usually time-dependent. Over a sufficiently small operating range, the dynamics of most systems are approximately linear, and the following relation entails a linear time-invariant (LTI) system:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
     \frac{dx}{dt} =  Ax + Bu   ........... (3)
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Several engineering challenges till today are being solved using LTI techniques, while most results obtained from control theory are based on the described assumptions associated with LTI systems.&lt;/p&gt;
&lt;div id=&#34;laplace-transform&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Laplace Transform&lt;/h3&gt;
&lt;p&gt;For those systems that are described by differential equations, it is possible to convert the system’s time-domain model into a frequency-domain (s-domain) representation. Two striking benefits for doing this are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the differential equations that define the system are transformed into algebraic equations, which are often easier to analyze&lt;/li&gt;
&lt;li&gt;The frequency response of the system can be obtained&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This frequency-domain output / input representation is called the transfer function. Many control system models are available in transfer function representation, and this model is mostly used in the block diagram representation of control systems.&lt;/p&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;/post/2017-08-18-control-systems-toolbox_files/Fig1_pitchcontrolblock.png&#34; /&gt;

&lt;/div&gt;
&lt;p&gt;Figure 1 shows the block diagram for the pitch-control system of an Unmanned Free Swimming Submersible (UFSS) vehicle. This system and its block diagram shall be detailed in the Case Study section of this article.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;transfer-function-expressions&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Transfer Function Expressions&lt;/h3&gt;
&lt;p&gt;A transfer function expression is an algebraic expression in the frequency-domain. It is usually the ratio of the output to the input of a control system. Evaluating such expressions while retaining their mathematical form (as in symbolic mathematics) should be possible using a scientific computing language. An example of such expression is shown below:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
     G(s) = \frac{Output}{Input} =  \frac{s^2 + 3s + 4}{2s^3 + 4s^2 + 5s + 1} 
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Models of physical systems often appear as transfer functions with the coefficients of state as electrical, mechanical, chemical, or other physical quantities. Users would find it convenient to simply input these transfer functions as-is into a computer, and quickly analyze the system.&lt;/p&gt;
&lt;p&gt;In the following mechanical example of a mass-spring-damper system of [1], the transfer function contains symbols &lt;code&gt;m&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt;, which represent mass, damping constant, and spring constant variables respectively, as shown below:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;/post/2017-08-18-control-systems-toolbox_files/Fig2_mass_spring_damper.png&#34; /&gt; Figure 2: Mass-Spring-Damper diagram &lt;span class=&#34;math display&#34;&gt;\[
     \frac{X(s)}{F(s)} = \frac{1}{ms^2+bs+k} 
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;where m = 1; k = 1; b = 0.2&lt;/p&gt;
&lt;p&gt;In this Google Summer of Code (GSoC) 2017 project, we have tried to include such capability within the &lt;code&gt;control&lt;/code&gt; library, making it possible to create a transfer function model from the evaluation of a rational expression (the transfer function). A function named &lt;code&gt;TF()&lt;/code&gt; was created to accept transfer function expressions, and return a transfer function model after evaluation. Therefore, to create this mass-spring-damper model within R, use the &lt;code&gt;control&lt;/code&gt; library as shown in the snippet below:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt; m &amp;lt;- 1;  k &amp;lt;- 1;  b &amp;lt;- 0.2
TF(&amp;quot;1/(m*s^2 + b *s + k)&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## y1:
##                 1 
##   - - - - - - - - - - -
##      s^2 + 0.2 s + 1 
## 
## 
## Transfer Function: Continuous time model&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;electric-motor-example&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Electric Motor Example&lt;/h3&gt;
&lt;p&gt;Consider the following example from a University of Michigan course page on Control Systems using MATLAB – an example of an electric motor [2]&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;/post/2017-08-18-control-systems-toolbox_files/Fig3_motor-diagram.png&#34; /&gt; Figure 3: showing electric motor physical model [2]&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://en.wikipedia.org/wiki/DC_motor&#34;&gt;Wikipedia&lt;/a&gt;: A DC motor is any class of rotary electric machines that converts direct current electrical energy into mechanical energy. It can provide translational motion when coupled with wheel, drums and cables. DC motors are used in propulsion of electric vehicles, elevator and hoists, or in drives for steel rolling mills. Several applications are: air compressors, vacuum cleaner, hair drier, sewing machine, and even toys or any system that requires variable speed.&lt;/p&gt;
&lt;p&gt;The physical parameters for this example are [3]:&lt;/p&gt;
&lt;p&gt;Moment of inertia of the rotor, J = 3.2284E-6 kg.m^2&lt;/p&gt;
&lt;p&gt;Motor viscous friction constant, b = 3.5077E-6 N.m.s&lt;/p&gt;
&lt;p&gt;Electromotive force constant, Ke = 0.0274 V/rad/sec&lt;/p&gt;
&lt;p&gt;Motor torque constant, Kt = 0.0274 N.m/Amp&lt;/p&gt;
&lt;p&gt;Electric resistance, R = 4 Ohm&lt;/p&gt;
&lt;p&gt;Electric inductance, L = 2.75E-6 H&lt;/p&gt;
&lt;p&gt;where, Kt = Ke = K&lt;/p&gt;
&lt;p&gt;The input of the system is the voltage source (V) applied to the motor’s armature, while the output is the rotational speed of the shaft.&lt;/p&gt;
&lt;div id=&#34;open-loop-response-of-the-electric-motor&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Open-Loop Response of the electric motor&lt;/h4&gt;
&lt;p&gt;The open-loop transfer function for the DC motor described above in the s-domain is:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
     P(s) = \frac{K}{(s(Js + b)(Ls + R) + K^2)} 
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;step&lt;/code&gt; function is usually used to analyze the system’s step response, so it is applied here to analyze the open-loop response of the system. Using the &lt;code&gt;control&lt;/code&gt; library, this model in the s-domain could be created and analyzed in R as follows:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt; J &amp;lt;- 3.2284E-6;
b &amp;lt;- 3.5077E-6;
K &amp;lt;- 0.0274;
R &amp;lt;- 4;
L &amp;lt;- 2.75E-6;
P_motor &amp;lt;- TF(&amp;quot;K/(s*((J*s + b)*(L*s + R) + K^2))&amp;quot;)
time &amp;lt;- seq(0,0.2,0.001)
stepplot(P_motor, t = time)&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;figure&#34;&gt;&lt;span id=&#34;fig:unnamed-chunk-2&#34;&gt;&lt;/span&gt;
&lt;img src=&#34;/post/2017-08-18-control-systems-toolbox_files/figure-html/unnamed-chunk-2-1.png&#34; alt=&#34;Figure 4: Electric Motor Open-loop Step Response&#34; width=&#34;672&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;
Figure 1: Figure 4: Electric Motor Open-loop Step Response
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;From the above plot showing the system’s step response, it is clear that when a step input (of 1 volt) is applied to the system, the electric motor’s position grows unbounded - system instability.&lt;/p&gt;
&lt;p&gt;The stability of the system can also be determined from the poles of the transfer function using the &lt;code&gt;pole&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;pole(P_motor)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##               [,1]
## [1,]  0.000000e+00
## [2,] -1.454487e+06
## [3,] -5.922604e+01&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As shown above, one of the poles of the open-loop transfer function is on the imaginary axis while the other two poles are in the left half of the complex s-plane. A pole on the imaginary axis indicates that the free response of the system will not only grow unbounded, but also will not decay to zero [3].&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;closed-loop-response-of-the-electric-motor&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Closed-Loop Response of the electric motor&lt;/h4&gt;
&lt;p&gt;We can add feedback the motor model with a controller set to 1, and then investigate the system’s closed-loop step response for stability. This can be obtained using the following R commands:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;P_motor2 &amp;lt;- feedback(P_motor, 1)
print(P_motor2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## y1:
##                                                     0.0274 
##   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
##     8.8781e-12 s^3 + 1.291361e-05 s^2 + 0.0007647908 s + 0.0274 
## 
## 
## Transfer Function: Continuous time model&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# OR

P_motor2 &amp;lt;- cloop(P_motor, -1)
print(P_motor2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## y1:
##                                                     0.0274 
##   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
##     8.8781e-12 s^3 + 1.291361e-05 s^2 + 0.0007647908 s + 0.0274 
## 
## 
## Transfer Function: Continuous time model&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;stepplot(P_motor2, t = time)&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;figure&#34;&gt;&lt;span id=&#34;fig:unnamed-chunk-4&#34;&gt;&lt;/span&gt;
&lt;img src=&#34;/post/2017-08-18-control-systems-toolbox_files/figure-html/unnamed-chunk-4-1.png&#34; alt=&#34;Figure 5: Electric Motor Closed-loop Step Response&#34; width=&#34;672&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;
Figure 2: Figure 5: Electric Motor Closed-loop Step Response
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The above closed-loop step response shows that the addition of feedback has stabilized the system.&lt;/p&gt;
&lt;p&gt;The damping and natural frequencies associated with the poles of this closed-loop system could be obtained using the following &lt;code&gt;damp&lt;/code&gt; function:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;damp(P_motor2)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##      Eigenvalue            Damping     Freq. (rad/s)    Freq. (Hz). 
##      ----------            -------     -------------    -----------
## -29.61     +     35.28j   0.64           46.06           0.46      
## -29.61     -     35.28j   0.64           46.06           0.46      
## -1454487.32 +      0.00j   1.00           1454487.32      0.00&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## $omega
##              [,1]
## [1,] 4.606386e+01
## [2,] 4.606386e+01
## [3,] 1.454487e+06
## 
## $zeta
## [1] 0.642853 0.642853 1.000000&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Furthermore, using the &lt;code&gt;TF()&lt;/code&gt; function, transfer function models could be summed, subtracted, multiplied, and divided. This is exemplified in the following section.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;system-interconnections&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;System Interconnections&lt;/h2&gt;
&lt;p&gt;In many cases, systems or subsystems have to be interconnected to obtain a particular controlled or regulated activity. Interconnecting models of components allows you to easily construct large control system models.&lt;/p&gt;
&lt;p&gt;Analyzing systems that are modeled in a block diagram should be easily done using a scientific computing tool like R. The time response or frequency response of a system (such as shown in Figure 1), can be obtained after the block diagram is simplified. Simplification means that the several components (blocks described by different transfer functions) that make up the complete system have to be algebraically reduced to one transfer function to represent the system. This mathematical reduction is done based on the rules of control theory.&lt;/p&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;/post/2017-08-18-control-systems-toolbox_files/Fig6_block_connection.png&#34; /&gt;

&lt;/div&gt;
&lt;p&gt;Figure 6: Block Diagram Interconnection&lt;/p&gt;
&lt;p&gt;For an example, Figure 6 shows the interconnection of dynamic system models of a plant P(s), a controller C(s), sensor dynamics S(s), and a filter F(s). To analyze the system requires constructing a single (equivalent) model that represents the entire closed-loop control system.&lt;/p&gt;
&lt;p&gt;In the second coding phase of the GSoC 2017, the following model interconnection functions have been produced as shown in Figure 7 below:&lt;/p&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;/post/2017-08-18-control-systems-toolbox_files/Fig7_modelconnections.png&#34; /&gt;

&lt;/div&gt;
&lt;p&gt;Figure 7: System Model Interconnections&lt;/p&gt;
&lt;div id=&#34;append-connection-using-the-append-function&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Append Connection using the &lt;code&gt;append&lt;/code&gt; function&lt;/h4&gt;
&lt;p&gt;A number of systems, whether in transfer-function, state-space or zero-pole model, could be appended into one state-space model using the &lt;code&gt;append&lt;/code&gt; function. The block diagram arrangement is found in Figure 7 (e).&lt;/p&gt;
&lt;p&gt;The syntax is: &lt;code&gt;append(sys1, sys2, …, sysN)&lt;/code&gt;. The resulting model is in state-space form.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt; sys1 &amp;lt;- ss(1,2,3,4)
 sys2 &amp;lt;- ss(2,3,4,5)
 sys3 &amp;lt;- ss(6,7,8,9)
 sys4 &amp;lt;- tf(1, c(1,2,5))
 append(sys1, sys2, sys3)
 append(sys1, sys2, sys4, sys3)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;series-connection-using-the-series-function&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Series Connection using the &lt;code&gt;series&lt;/code&gt; function&lt;/h4&gt;
&lt;p&gt;This function connects two systems in series, in transfer-function, state-space or zero-pole model, into one model. The block diagram arrangement is found in Figure 7 (a).&lt;/p&gt;
&lt;p&gt;Syntax: &lt;code&gt;series(sys1, sys2)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Arithmetically, this could be achieved using the &lt;code&gt;TF()&lt;/code&gt; function in the following manner:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;TF(“sys1*sys2”)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;For now, &lt;code&gt;TF(“sys1*sys2”)&lt;/code&gt; is only possible when &lt;code&gt;sys1&lt;/code&gt; and &lt;code&gt;sys2&lt;/code&gt; are transfer-function models&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;parallel-connection-using-the-parallel-function&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Parallel Connection using the &lt;code&gt;parallel&lt;/code&gt; function&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;parallel&lt;/code&gt; function connects two systems in parallel, in transfer-function, state-space or zero-pole model, into one model. The block diagram arrangement is found in Figure 7 (c).&lt;/p&gt;
&lt;p&gt;Syntax: &lt;code&gt;parallel(sys1, sys2)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Arithmetically, this could be achieved using the &lt;code&gt;TF()&lt;/code&gt; function in the following manner:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;TF(“sys1 + sys2”)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;For now, &lt;code&gt;TF(“sys1+ sys2”)&lt;/code&gt; is only possible when &lt;code&gt;sys1&lt;/code&gt; and &lt;code&gt;sys2&lt;/code&gt; are transfer-function models&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback-connection-using-the-feedback-function&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Feedback Connection using the &lt;code&gt;feedback&lt;/code&gt; function&lt;/h4&gt;
&lt;p&gt;This function sets up a closed-loop transfer function from output to input based on the standard configuration shown in Figure 7 (b).&lt;/p&gt;
&lt;p&gt;Syntax: &lt;code&gt;feedback(sys1, sys2)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Arithmetically, this could be achieved using the &lt;code&gt;TF()&lt;/code&gt; function in the following manner:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;TF(“sys1 / (1 + sys2*sys1)”)&lt;/code&gt;, but this is not recommended in terms of accuracy. &lt;code&gt;feedback(sys1, sys2)&lt;/code&gt; is preferred.&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;general-block-diagram-building-using-connect-function&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;General block diagram building using &lt;code&gt;connect&lt;/code&gt; function&lt;/h4&gt;
&lt;p&gt;Using the &lt;code&gt;connect&lt;/code&gt; function, more complicated (especially multiple-input multiple-output (MIMO) ) block diagrams could be set up. For this case, all systems that are to be connected are first appended, then connected using their inputs and outputs.&lt;/p&gt;
&lt;p&gt;Syntax: &lt;code&gt;connect(append(sys1, sys2, sys3), connections, inputs, outputs)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;case-study-unmanned-free-swimming-submersible-ufss-vehicle&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Case Study – Unmanned Free Swimming Submersible (UFSS) Vehicle&lt;/h3&gt;
&lt;p&gt;The Unmanned Free-Swimming Submersible (UFSS) vehicle was one of the first autonomous underwater vehicles (AUVs). It was developed in the late 1970s as a test vehicle to demonstrate the potential of autonomous vehicles over long distances, and to study laminar flow [5]. A picture showing an Unmanned Free-Swimming Submersible (UFSS) vehicle is shown in Figure 8 below.&lt;/p&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;/post/2017-08-18-control-systems-toolbox_files/Fig8_UFSS_PIC.png&#34; /&gt;

&lt;/div&gt;
&lt;p&gt;Figure 8: Unmanned Free Swimming Submersible Vehicle (UFSS). Source: [5]&lt;/p&gt;
&lt;p&gt;Nise [4] relates the following concerning the UFSS:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The depth of the vehicle is controlled as follows. During forward motion, an elevator surface on the vehicle is deflected by a selected amount. This deflection causes the vehicle to rotate about the pitch axis. The pitch of the vehicle creates a vertical force that causes the vehicle to submerge or rise.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;A detailed block diagram for the pitch control system is shown in Figure 9 below.&lt;/p&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;/post/2017-08-18-control-systems-toolbox_files/Fig9_pitchcontrol.png&#34; /&gt;

&lt;/div&gt;
&lt;p&gt;Figure 9: Block diagram for the pitch control system of UFSS&lt;/p&gt;
&lt;div id=&#34;rationale&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Rationale:&lt;/h4&gt;
&lt;p&gt;The subsystems of the UFSS vehicle are developed independently, and studied using computer simulation before integration into the vehicle [5]. Thus, for this reason, we are examining the pitch control system independently.&lt;/p&gt;
&lt;p&gt;For this case study, we shall use the developing &lt;code&gt;control&lt;/code&gt; library in R to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Obtain the closed-loop UFSS pitch control system by block diagram reduction of the system in Figure 9 above, using &lt;code&gt;series&lt;/code&gt;, &lt;code&gt;parallel&lt;/code&gt; and &lt;code&gt;feedback&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Obtain the step response of the pitch control system simplified by &lt;code&gt;series&lt;/code&gt;, &lt;code&gt;parallel&lt;/code&gt; and &lt;code&gt;feedback&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Obtain the closed-loop UFSS pitch control system by block diagram reduction of the system in Figure 9 above, using the algebraic operations provided by &lt;code&gt;TF()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Obtain the step response of the pitch control system from the method of algebraic operations.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;solution-using-series-parallel-and-feedback&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Solution using &lt;code&gt;series&lt;/code&gt;, &lt;code&gt;parallel&lt;/code&gt; and &lt;code&gt;feedback&lt;/code&gt;&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;K1 &amp;lt;- 1
K2  &amp;lt;- 1
G1 &amp;lt;- tf(-K1,1)
G2 &amp;lt;- tf(c(0,2), c(1,2))

numg3 &amp;lt;- -0.125*c(1, 0.435)
deng3 &amp;lt;- pracma::polymul(c(1, 1.23), c(1, 0.226, 0.0169))
G3 &amp;lt;- tf(numg3, deng3)

H1 &amp;lt;- tf(c(-K2, 0), c(0, 1))

G4 &amp;lt;- series(G2, G3)
G5 &amp;lt;- feedback(G4, H1)
Ge &amp;lt;- series(G1, G5)
T1 &amp;lt;- feedback(Ge, 1)
stepplot(T1, t = seq(0,40,0.1))&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;figure&#34;&gt;&lt;span id=&#34;fig:unnamed-chunk-7&#34;&gt;&lt;/span&gt;
&lt;img src=&#34;/post/2017-08-18-control-systems-toolbox_files/figure-html/unnamed-chunk-7-1.png&#34; alt=&#34;Figure 10: R plot showing UFSS vehicle system response - Block diagram reduction by series, parallel and feedback&#34; width=&#34;672&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;
Figure 3: Figure 10: R plot showing UFSS vehicle system response - Block diagram reduction by series, parallel and feedback
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;solution-via-algebraic-operations&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Solution via algebraic operations&lt;/h4&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;G4 &amp;lt;- TF(&amp;quot;G3*G2&amp;quot;)
G5 &amp;lt;- TF(&amp;quot;G4/(1+ G4*H1)&amp;quot;)
Ge &amp;lt;- TF(&amp;quot;G5*G1&amp;quot;)
T2 &amp;lt;- TF(&amp;quot;Ge/(1+Ge)&amp;quot;)
stepplot(T2, t = seq(0,40,0.1))&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;figure&#34;&gt;&lt;span id=&#34;fig:unnamed-chunk-8&#34;&gt;&lt;/span&gt;
&lt;img src=&#34;/post/2017-08-18-control-systems-toolbox_files/figure-html/unnamed-chunk-8-1.png&#34; alt=&#34;Figure 11: R plot showing UFSS vehicle system response - Block diagram reduction by Algebraic Operations&#34; width=&#34;672&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;
Figure 4: Figure 11: R plot showing UFSS vehicle system response - Block diagram reduction by Algebraic Operations
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Clearly, the step responses (Figure 10 and Figure 11) of the pitch control system using the two methods are identical to each other - a justification to the framework of the control systems toolbox.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Feedback&lt;/h3&gt;
&lt;p&gt;Interested users are welcome to install the development version of this package using &lt;code&gt;devtools::install_github(&amp;quot;benubah/control&amp;quot;)&lt;/code&gt;, and feel free to &lt;a href=&#34;https://github.com/benubah/control/blob/master/DESCRIPTION&#34;&gt;get in touch&lt;/a&gt; for any related issues.&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;conclusion&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;In this article, we have discussed on our progress with the Control Systems Toolbox in R as a GSoC 2017 project. We have highlighted the use of this toolbox to carry out the following tasks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create Transfer function models by evaluating transfer function expressions in the s-domain&lt;/li&gt;
&lt;li&gt;Obtain the poles and their associated damping and natural frequencies of a system&lt;/li&gt;
&lt;li&gt;Open-loop and closed-loop responses&lt;/li&gt;
&lt;li&gt;System Model Interconnections using series, parallel and feedback and algebraic functions in the UFSS vehicle case study.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Other functions that have been developed in this GSoC phase are: &lt;code&gt;givens_rot&lt;/code&gt;, &lt;code&gt;ordschur&lt;/code&gt;, &lt;code&gt;care&lt;/code&gt;, &lt;code&gt;ctrb&lt;/code&gt;, &lt;code&gt;acker&lt;/code&gt;, &lt;code&gt;place&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You may want to read about what was achieved in the first GSoC coding phase &lt;a href=&#34;https://rviews.rstudio.com/2017/07/06/control-systems-toolbox-in-r---a-gsoc-2017-project/&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;references&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;References&lt;/h3&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction&amp;amp;section=SystemModeling&#34; class=&#34;uri&#34;&gt;http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction&amp;amp;section=SystemModeling&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed&amp;amp;section=SystemModeling&#34; class=&#34;uri&#34;&gt;http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed&amp;amp;section=SystemModeling&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;http://ctms.engin.umich.edu/CTMS/index.php?example=MotorPosition&amp;amp;section=SystemAnalysis&#34; class=&#34;uri&#34;&gt;http://ctms.engin.umich.edu/CTMS/index.php?example=MotorPosition&amp;amp;section=SystemAnalysis&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Norman, S. Nise, Control Systems Engineering, 6th. Ed, 2011.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=&#34;http://www.navalunderseamuseum.org/ufss/&#34; class=&#34;uri&#34;&gt;http://www.navalunderseamuseum.org/ufss/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;

        &lt;script&gt;window.location.href=&#39;https://rviews.rstudio.com/2017/08/24/control-systems-toolbox/&#39;;&lt;/script&gt;
      </description>
    </item>
    
    <item>
      <title>Control Systems Toolbox in R - a GSoC 2017 Project</title>
      <link>https://rviews.rstudio.com/2017/07/06/control-systems-toolbox-in-r-a-gsoc-2017-project/</link>
      <pubDate>Thu, 06 Jul 2017 00:00:00 +0000</pubDate>
      
      <guid>https://rviews.rstudio.com/2017/07/06/control-systems-toolbox-in-r-a-gsoc-2017-project/</guid>
      <description>
        

&lt;div id=&#34;introduction&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Control theory is an interdisciplinary branch of mathematics and engineering that has the objective of controlling physical systems. A control system is a device or a collection of devices that manage, command, direct or regulate the behavior of other devices or systems. Control systems engineering is a major application of control theory, and involves the study, design/modeling of automatic control systems. Control theory has also been applied to several other fields such as finance, sociology, psychology, physiology and other sciences that analyze dynamic systems.&lt;/p&gt;
&lt;p&gt;In recent times, control systems have played a major role in the development and advancement of modern technology and civilization. Control systems are essential in any field of engineering and science, as they are an important and integral part of systems such as space-vehicle systems, robotic systems, modern manufacturing systems, nuclear reactors, navigation systems and industrial operations involving control of temperature, pressure, humidity, flow, speed/velocity, etc.&lt;/p&gt;
&lt;div id=&#34;example-of-a-control-system&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Example of a Control System&lt;/h3&gt;
&lt;p&gt;Imagine the operation of an Automatic Electric Iron where its heating elements are controlled by the temperature output of the iron. As long as there is power supply to the electric iron, and a desired heat-level is selected, the electric iron automatically controls at what time to turn-on and switch-off heating so as to maintain that temperature. This type of control system is called a feedback control system: a system in which the output is fed back to the input as a control signal.&lt;/p&gt;
&lt;p&gt;Figure 1 shows a simple block diagram depicting a sample feedback control system for a heating system.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;/post/2017-07-05-control-systems-toolbox_files/Figure1.png&#34; /&gt;&lt;br /&gt;
Figure 1: Block Diagram Model for a Heating System&lt;/p&gt;
&lt;p&gt;Another example is the control system for an aircraft or a space shuttle. Truly, such control system would be complex as there are several sub-systems that are interconnected in such transport systems. Therefore, it is very necessary to simulate how these systems could behave using a computer before implementing them physically. This is the reason why computer simulation of control systems have been proliferated.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;control-systems-r-gsoc-project&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Control Systems R-GSoC Project&lt;/h3&gt;
&lt;p&gt;For this &lt;a href=&#34;https://github.com/rstats-gsoc/gsoc2017/wiki/control%3A-Control-Systems-toolbox&#34;&gt;Google Summer of Code (GSoC) 2017 project&lt;/a&gt;, we are working to develop a control system toolbox for the R language. The rationale is that there is a control toolbox for most commercial and open-source technical computing platforms out there, and while the R language is experiencing tremendous growth in its capabilities and user base, it seems necessary to extend the language to serve other scientific and engineering communities. For example, in Python, the development of NumPy and the general SciPy stack, added some dimensions and attracted several scientific domains to the use of Python. This GSoC project hopes to make basic design, analysis and simulation of control systems possible within the R ecosystem.&lt;/p&gt;
&lt;p&gt;The major objective of this year’s GSoC project is to try to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Design and develop a framework for the package that defines data structures and creates flexibility of usage and extension for future users and interested contributors to easily adopt the package. The framework is also expected to mimic the I/O style of existing control systems toolkits.&lt;/li&gt;
&lt;li&gt;To port a set of functions from the &lt;a href=&#34;http://rlabplus.sourceforge.net&#34;&gt;RLabPlus&lt;/a&gt; control-toolbox and adapt them to the defined data structures and general framework.&lt;/li&gt;
&lt;li&gt;To test the functions, create documentation, usage examples and build them for distribution.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;benefits-of-a-control-systems-toolbox-in-r&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Benefits of a Control Systems Toolbox in R&lt;/h3&gt;
&lt;p&gt;Some benefits of having a control-systems-toolbox in R are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A control package in R could be useful to engineers and students who are looking to migrate to an open-source language like R that has better visualization options and interfaces to several technologies. Models for several dynamic systems could then be analyzed using R.&lt;/li&gt;
&lt;li&gt;The package could assist in further developments in areas like optimal control theory which has several applications to economics and management sciences.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;current-state-of-the-project&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Current State of the Project&lt;/h3&gt;
&lt;p&gt;At the time of writing this article, the first phase of coding for GSoC has elapsed, and we are delighted to meet our target of creating 18 functions that define the general framework and structures. Consequently, a user can, at this stage, perform the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create LTI system models of state-space, transfer function and zero-pole classes&lt;/li&gt;
&lt;li&gt;Conversions from one system model to other system models&lt;/li&gt;
&lt;li&gt;Convert continuous-time system models to discrete-time models&lt;/li&gt;
&lt;li&gt;Obtain time response for LTI systems&lt;/li&gt;
&lt;li&gt;Install the development version of the package using: &lt;code&gt;devtools::install_github(“benubah/control”)&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;practical-example&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Practical Example&lt;/h3&gt;
&lt;div id=&#34;analyzing-the-time-response-of-a-bandpass-rlc-filter-circuit&#34; class=&#34;section level4&#34;&gt;
&lt;h4&gt;Analyzing the Time Response of a Bandpass RLC Filter Circuit&lt;/h4&gt;
&lt;p&gt;&lt;a href=&#34;https://en.wikipedia.org/wiki/Band-pass_filter&#34;&gt;Wikipedia&lt;/a&gt;: “A bandpass filter is a device that passes frequencies within a certain range and rejects (attenuates) frequencies outside that range.” Bandpass filters are commonly used in wireless transmitters and receivers to prevent transmitters from interfering with other stations and to allow signals within selected frequency ranges to be decoded, while preventing signals at unwanted frequencies from passing through to the receiver. In astronomy, bandpass filters are used to allow only certain portion of light spectrum pass through to an instrument. They have several other applications in neuroscience, digital signal processing, atmospheric sciences, etc.&lt;/p&gt;
&lt;p&gt;The following example is taken from a &lt;a href=&#34;https://www.mathworks.com/help/control/examples/analyzing-the-response-of-an-rlc-circuit.html&#34;&gt;Mathworks web-page&lt;/a&gt; and it shows how to analyze the time response of a common RLC bandpass filter circuit using the current available functions of the Control Systems Toolbox in R. The attenuation properties of the filter circuit, G2 can be ascertained by simulating how this filter transforms sine waves with frequency 0.9, 1, and 1.1 rad/s.&lt;/p&gt;
&lt;div class=&#34;figure&#34;&gt;
&lt;img src=&#34;/post/2017-07-05-control-systems-toolbox_files/Figure2.png&#34; /&gt;

&lt;/div&gt;
&lt;p&gt;Figure 2: Bandpass RLC Filter Circuit.&lt;/p&gt;
&lt;p&gt;For this example, we will try to show how the following could be achieved using the developing &lt;code&gt;control&lt;/code&gt; library:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Creating a transfer function model&lt;/li&gt;
&lt;li&gt;Converting a transfer function to state-space representation&lt;/li&gt;
&lt;li&gt;Converting a continuous-time model to discrete-time model&lt;/li&gt;
&lt;li&gt;Performing Linear simulation using &lt;code&gt;lsim&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Obtaining step response using &lt;code&gt;lsim&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The following values are given R = 1, L = 1, C = 1, R2 = 20&lt;/p&gt;
&lt;p&gt;The transfer function for this circuit is:&lt;/p&gt;
&lt;p&gt;&lt;span class=&#34;math display&#34;&gt;\[
     G(s) = \frac{V_output}{V_input} =  \frac{s/(RC)}{s^2 + s/(RC) + 1/(LC)}
\]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;On the R Console (or in an R script), after installing the &lt;code&gt;control&lt;/code&gt; package, the following code obtains the time response of the circuit:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(control)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Attaching package: &amp;#39;control&amp;#39;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## The following object is masked from &amp;#39;package:base&amp;#39;:
## 
##     append&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;R &amp;lt;- C &amp;lt;- L &amp;lt;- 1
R2  &amp;lt;-  20
t  &amp;lt;-  seq(0,250,0.05)
G1 &amp;lt;-  tf(c(1/(R*C), 0), c(1, 1/(R*C), 1/(L*C) ) )
G2  &amp;lt;-  tf(c(1/(R2*C), 0), c(1, 1/(R2*C), 1/(L*C) ) )
print(G1)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## y1:
##              s 
##   - - - - - - - - -
##      s^2 +  s + 1 
## 
## 
## Transfer Function: Continuous time model&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;tf2ss(G1) # example: convert the transfer function to state-space representation&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
##  sys.A = 
## 
##      x1   x2
## x1   -1   -1
## x2    1    0
##    
## sys.B = 
## 
##      u1
## x1    1
## x2    0
##    
## sys.C = 
## 
##      x1   x2
## y1    1    0
##    
## sys.D = 
## 
##      u1
## y1    0
##    
## 
##  State-Space system: Continuous time model&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;c2d(G1, 0.1) # example: convert the system G1 from continuous-time to discrete-time model&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## y1:
##   0.09500408 z^1 - 0.09500408 
##   - - - - - - - - - - - - - - - - -
##      z^2 - 1.895329 z + 0.9048374 
## 
## 
## Sample Time = 0.1 
## Transfer function: Discrete time model&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;response &amp;lt;- lsim(G2,sin(t),t)
par(mfrow = c(3,1))
plot(t, sin(t), type = &amp;quot;l&amp;quot;, xlab = &amp;quot;Time, secs&amp;quot;, ylab = &amp;quot;Amplitude&amp;quot;, main = &amp;quot;Linear Simulation Response - w = 1&amp;quot;, col = &amp;quot;lightgray&amp;quot;)
lines(t, response$y, type = &amp;quot;l&amp;quot;, col = &amp;quot;blue&amp;quot;, lwd = 2)
grid(5,5, col = &amp;quot;lightgray&amp;quot;)

response2 &amp;lt;- lsim(G2, sin(0.9*t), t)
plot(t, sin(t), type = &amp;quot;l&amp;quot;, xlab = &amp;quot;Time, secs&amp;quot;, ylab = &amp;quot;Amplitude&amp;quot;, main = &amp;quot;Linear Simulation Response - w = 0.9&amp;quot;, col = &amp;quot;lightgray&amp;quot;)
lines(t, response2$y, type = &amp;quot;l&amp;quot;, col = &amp;quot;blue&amp;quot;, lwd = 2)
grid(5,5, col = &amp;quot;lightgray&amp;quot;)

response3 &amp;lt;- lsim(G2, sin(1.1*t), t)
plot(t, sin(t), type = &amp;quot;l&amp;quot;, xlab = &amp;quot;Time, secs&amp;quot;, ylab = &amp;quot;Amplitude&amp;quot;, main = &amp;quot;Linear Simulation Response - w = 1.1&amp;quot;, col = &amp;quot;lightgray&amp;quot;)
lines(t, response3$y, type = &amp;quot;l&amp;quot;, col = &amp;quot;blue&amp;quot;, lwd = 2)
grid(5,5, col = &amp;quot;lightgray&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;figure&#34; style=&#34;text-align: center&#34;&gt;&lt;span id=&#34;fig:unnamed-chunk-1&#34;&gt;&lt;/span&gt;
&lt;img src=&#34;/post/2017-07-05-control-systems-toolbox_files/figure-html/unnamed-chunk-1-1.png&#34; alt=&#34;Figure 3: R Plot for Linear Simulation Response of RLC bandpass circuit&#34; width=&#34;672&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;
Figure 1: Figure 3: R Plot for Linear Simulation Response of RLC bandpass circuit
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The output of the simulation displayed in Figure 3 shows a pure sine wave (in light-gray color) behind the wave response from our linear simulation (in blue). At w = 1 rad/s, after the transients have died off, the wave remains a pure sine wave – no attenuation observed. However, the waves at 0.9 and 1.1 rad/s are significantly attenuated.&lt;/p&gt;
&lt;p&gt;Please get the code here: &lt;a href=&#34;https://github.com/benubah/controldev/blob/master/R/lsimExample.R&#34; class=&#34;uri&#34;&gt;https://github.com/benubah/controldev/blob/master/R/lsimExample.R&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To obtain a &lt;em&gt;step response&lt;/em&gt; for the RLC filter circuit using &lt;code&gt;lsim&lt;/code&gt; as shown in Figure 4, the following code is used:&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;dims &amp;lt;- dim(as.matrix(t))
   u &amp;lt;- matrix(rep(1,dims[1]), dims[1], dims[2])
   stepresponse &amp;lt;- lsim(G2, u, t)
plot(t, stepresponse$y, type = &amp;quot;l&amp;quot;, xlab = &amp;quot;Time, secs&amp;quot;, ylab = &amp;quot;Amplitude&amp;quot;, main = &amp;quot;Step Response - G2&amp;quot;, col = &amp;quot;red&amp;quot;, lwd = 2)
grid(7,7, col = &amp;quot;lightgray&amp;quot;, lwd = 2)&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;figure&#34; style=&#34;text-align: center&#34;&gt;&lt;span id=&#34;fig:unnamed-chunk-2&#34;&gt;&lt;/span&gt;
&lt;img src=&#34;/post/2017-07-05-control-systems-toolbox_files/figure-html/unnamed-chunk-2-1.png&#34; alt=&#34;Figure 4: R Plot for Step Response of the RLC bandpass circuit&#34; width=&#34;672&#34; /&gt;
&lt;p class=&#34;caption&#34;&gt;
Figure 2: Figure 4: R Plot for Step Response of the RLC bandpass circuit
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;next-coding-phase&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Next Coding Phase&lt;/h3&gt;
&lt;p&gt;In the next coding stage, we plan to attempt creating functions that would perform the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Evaluate transfer function expressions in the &lt;em&gt;s-domain&lt;/em&gt; within R as part of the framework.&lt;/li&gt;
&lt;li&gt;Control system block diagram algebra functions – system interconnections&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;challenges&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Challenges&lt;/h3&gt;
&lt;p&gt;The expected challenge for this project is to accurately set up a framework that defines data structures and how functions operate within the framework in such a manner that would be attractive (due to simplicity, reusability and extensibility) to prospective users and contributors.&lt;/p&gt;
&lt;p&gt;To overcome this challenge, through the assistance of my mentors, we have examined the data architectures and plotting layout of other open-source scientific languages, and from these, designed a plan and framework that would integrate reasonably with the architecture of the R language while remaining open to improvements.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;dependencies&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Dependencies&lt;/h3&gt;
&lt;p&gt;The Control Systems Toolbox for the R language is expected to depend on R packages like, &lt;code&gt;pracma&lt;/code&gt;, &lt;code&gt;signal&lt;/code&gt; and &lt;code&gt;expm&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;feedback&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Feedback&lt;/h3&gt;
&lt;p&gt;We would be glad to hear from the R community – feel free to &lt;a href=&#34;https://github.com/rstats-gsoc/gsoc2017/wiki/control%3A-Control-Systems-toolbox#mentors&#34;&gt;get in touch&lt;/a&gt; with any suggestions, opinions or comments.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;conclusion&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;In this article, we have introduced the Control Systems Toolbox GSoC 2017 project, its current state, benefits and practical examples showing some functions that are currently available. We have also listed the future coding plans for the next GSoC coding phase. We hope to be able to update the R community as things develop.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

        &lt;script&gt;window.location.href=&#39;https://rviews.rstudio.com/2017/07/06/control-systems-toolbox-in-r-a-gsoc-2017-project/&#39;;&lt;/script&gt;
      </description>
    </item>
    
  </channel>
</rss>
