plotting transfer function in octave 5.2: How to fix error: set: "dataaspectratio' must be finite

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

plotting transfer function in octave 5.2: How to fix error: set: "dataaspectratio' must be finite

shall689
Hello,

I am using Octave 5.2 and control pkg 3.2.0.  When I try to plot the step
response of a transfer funciton, octave is returning error: set:
"dataaspectratio' must be finite.  It also returns "warning:
opengl_renderer: data values greater than float capacity. (1) scale data, or
(2) use gnuplot.

The octave I am using only has two available graphics toolkits: qt and fltk.
graphic_toolkit() returns qt.

What is the best way to fix this issue?  

I don't have Octave on the computer that I am using to type this message, so
I don't have the exact transfer function, so I manually copied the transfer
function (shown below).

4.63e-12s^7+1.346e-07*s^6-0.02167*s^5-632.2*s^4+1.04e8*s^3
+3.035e12*s^2+1.284e16*s+3.225e20
---------------------------------------------------------------------------------------------------------------
6.25e-18*s^8+6.136e-12*s^7+2.875e-7*s^6-0.01399*s^5-448.9*s^4+1.057e8*s^3+3.068e12*s^2+1.293e16*s+3.241e20

Stephen





--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: plotting transfer function in octave 5.2: How to fix error: set: "dataaspectratio' must be finite

Doug Stewart-4


On Fri, Jul 31, 2020 at 3:28 PM shall689 <[hidden email]> wrote:
Hello,

I am using Octave 5.2 and control pkg 3.2.0.  When I try to plot the step
response of a transfer funciton, octave is returning error: set:
"dataaspectratio' must be finite.  It also returns "warning:
opengl_renderer: data values greater than float capacity. (1) scale data, or
(2) use gnuplot.

The octave I am using only has two available graphics toolkits: qt and fltk.
graphic_toolkit() returns qt.

What is the best way to fix this issue? 

I don't have Octave on the computer that I am using to type this message, so
I don't have the exact transfer function, so I manually copied the transfer
function (shown below).

4.63e-12s^7+1.346e-07*s^6-0.02167*s^5-632.2*s^4+1.04e8*s^3
+3.035e12*s^2+1.284e16*s+3.225e20
---------------------------------------------------------------------------------------------------------------
6.25e-18*s^8+6.136e-12*s^7+2.875e-7*s^6-0.01399*s^5-448.9*s^4+1.057e8*s^3+3.068e12*s^2+1.293e16*s+3.241e20

Stephen




The first problem is that  6.25e-18*s^8 is approximately 0
6.25e-18 is so small.

The 2nd point is:

In control theory there are dominant poles and zeros and non dominant ones.
I would suggest that you disregard the poles that are far away from the origin.
 

--
DASCertificate for 206392



Reply | Threaded
Open this post in threaded view
|

Re: plotting transfer function in octave 5.2: How to fix error: set: "dataaspectratio' must be finite

shall689
Hello Doug,

Won't s^8 counteract that small value.  What if the frequency is 500Hz, then
w=2pi*500= 1000pi and (1000pi)^8*6.25e-18 = 59303318850.

I would have to solve the denominator equation to determine which ones to
exclude?

Stephen




--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: plotting transfer function in octave 5.2: How to fix error: set: "dataaspectratio' must be finite

Doug Stewart-4


On Fri, Jul 31, 2020 at 4:49 PM shall689 <[hidden email]> wrote:
Hello Doug,

Won't s^8 counteract that small value.  What if the frequency is 500Hz, then
w=2pi*500= 1000pi and (1000pi)^8*6.25e-18 = 59303318850.

I would have to solve the denominator equation to determine which ones to
exclude?

Stephen


Here is what I tried. I am not saying this is the best, but it is a starting point. 

I do not know what you expect so just use it as a starting point.


s=tf('s')
n=4.63e-12*s^7+1.346e-07*s^6-0.02167*s^5-632.2*s^4+1.04e8*s^3+3.035e12*s^2+1.284e16*s+3.225e20
d=6.25e-5*s^8+6.136e-12*s^7+2.875e-7*s^6-0.01399*s^5-448.9*s^4+1.057e8*s^3+3.068e12*s^2+1.293e16*s+3.241e20
#Note ^^^^^^^^ I changed this number.
sys =n/d
#step(sys)

[nn,dd]=tfdata(sys,'v')

rn=roots(nn)
n1=rn(5:7)
n2=poly(n1)

rd=roots(dd)
[sr,idx]=sort(real(rd))
idx1=idx(1:4)
d1=rd(idx1)

d2=poly(d1)

sys2=tf(n2,d2)
step(sys2)





--
DASCertificate for 206392



Reply | Threaded
Open this post in threaded view
|

Re: plotting transfer function in octave 5.2: How to fix error: set: "dataaspectratio' must be finite

Octave - General mailing list
On Fri, 2020-07-31 at 16:59 -0400, Doug Stewart wrote:

>
>
> On Fri, Jul 31, 2020 at 4:49 PM shall689 <[hidden email]>
> wrote:
> > Hello Doug,
> >
> > Won't s^8 counteract that small value.  What if the frequency is
> > 500Hz, then
> > w=2pi*500= 1000pi and (1000pi)^8*6.25e-18 = 59303318850.
> >
> > I would have to solve the denominator equation to determine which
> > ones to
> > exclude?
> >
> > Stephen
> >
> >
>
> Here is what I tried. I am not saying this is the best, but it is a
> starting point.
>
> I do not know what you expect so just use it as a starting point.
>
>
> s=tf('s')
> n=4.63e-12*s^7+1.346e-07*s^6-0.02167*s^5-
> 632.2*s^4+1.04e8*s^3+3.035e12*s^2+1.284e16*s+3.225e20
> d=6.25e-5*s^8+6.136e-12*s^7+2.875e-7*s^6-0.01399*s^5-
> 448.9*s^4+1.057e8*s^3+3.068e12*s^2+1.293e16*s+3.241e20
> #Note ^^^^^^^^ I changed this number.
> sys =n/d
> #step(sys)
>
> [nn,dd]=tfdata(sys,'v')
>
> rn=roots(nn)
> n1=rn(5:7)
> n2=poly(n1)
>
> rd=roots(dd)
> [sr,idx]=sort(real(rd))
> idx1=idx(1:4)
> d1=rd(idx1)
>
> d2=poly(d1)
>
> sys2=tf(n2,d2)
> step(sys2)
>

First of all the coefficients a4 and a5 of the denominator are negative.
From the Hurwitz criterion, we can conclude that the system ist not
stable. Thus, no surprise that you can not plot  the step response.

Moreover, I think, it is not possible to really analyze the system based
on the transfer function coefficients printed with only 4 digits and due
to numerical issues resulting from very large and very small
coefficients (as already mentioned by Doug). When you calculate the
roots of the denominator (the original one, not the one adjusted by
Doug), you get two poles in the right s half plane, confirming the
instability of the system.

*But:* when computing the denominator at its "roots", the result is not
zero due to the numerical issues. Please try:

  s = tf('s')
  n = 4.63e-12*s^7+1.346e-07*s^6-0.02167*s^5-632.2*s^4+...
 
     1.04e8*s^3+3.035e12*s^2+1.284e16*s+3.225e20
  d = 6.25e-
18*s^8+6.136e-12*s^7+2.875e-7*s^6-0.01399*s^5-...
      448.9*s^4+1.057e8
*s^3+3.068e12*s^2+1.293e16*s+3.241e20
 
  [nn,dd] = tfdata (n/d)
 
  rd =
roots (dd{1})
  n = length (rd);
 
  for i = 1:n
    polyval (dd{1}, rd(i))
  end


Torsten




Reply | Threaded
Open this post in threaded view
|

Re: plotting transfer function in octave 5.2: How to fix error: set: "dataaspectratio' must be finite

shall689
Thanks Doug and Torsten.

I have been working on several things and I am not even sure how I got a 8th
order polynomial equation.  Currently, I am only getting a 3rd order
polynomial transfer function and I am able to plot its step response.  

Do either of you know of a good Digital Controls book?  I have a Inverter
Control diagram with both an inner current and outer voltage control loop
and I am stuck on whether or not to add zero order (ZOH) hold to both.
Currently I am only adding the ZOH transfer function right after the inner
current loop PI.  





--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: plotting transfer function in octave 5.2: How to fix error: set: "dataaspectratio' must be finite

Doug Stewart-4


On Mon, Aug 3, 2020 at 2:42 AM shall689 <[hidden email]> wrote:
Thanks Doug and Torsten.

I have been working on several things and I am not even sure how I got a 8th
order polynomial equation.  Currently, I am only getting a 3rd order
polynomial transfer function and I am able to plot its step response. 

Do either of you know of a good Digital Controls book?  I have a Inverter
Control diagram with both an inner current and outer voltage control loop
and I am stuck on whether or not to add zero order (ZOH) hold to both.
Currently I am only adding the ZOH transfer function right after the inner
current loop PI. 



My understanding is:
 When you convert analogue to digital you need a hold function because the ideal sampiler just knows the values at the sample point(time) but has no knowledge of the voltage between the samples. But a real a/d converter keeps the sampled voltage there until the next sample. thus we get the stair step pattern. Now there are many "hold functions" and which one to use depends on what your needs are. If you want accurate results for a step input then use the ZOH. If you want frequencies to be close then a tustun would be better. If you want impulse response then a different method must be used etc.

--
DASCertificate for 206392



Reply | Threaded
Open this post in threaded view
|

Re: plotting transfer function in octave 5.2: How to fix error: set: "dataaspectratio' must be finite

Octave - General mailing list
In reply to this post by shall689
On Mon, 2020-08-03 at 01:42 -0500, shall689 wrote:

> Thanks Doug and Torsten.
>
> I have been working on several things and I am not even sure how I got
> a 8th
> order polynomial equation.  Currently, I am only getting a 3rd order
> polynomial transfer function and I am able to plot its step
> response.  
>
> Do either of you know of a good Digital Controls book?  I have a
> Inverter
> Control diagram with both an inner current and outer voltage control
> loop
> and I am stuck on whether or not to add zero order (ZOH) hold to
> both.
> Currently I am only adding the ZOH transfer function right after the
> inner
> current loop PI.  
>

If you consider the complete control loop in discrete time (the system
has to be discretized), then you do not need any transfer function for
your hold device. Instead, it is considered in the calculation of the
discrete time system representation. If, e.g., the used D/A has a zero-
order hold, than the discretization method makes use of the fact that
the input u is constant during a sampling interval.

If you consider your control loop in continuous time (the controller has
to be represented in continuous time), the challenge is to compute the
laplace transfer function of your (discrete-time) controllers and of the
hold device you are using in your D/A converter. For the zero-order hold
this is

Gc(s) = Ghold(s) * G(z=exp(s*T))
      = (1 - exp(-s*T))/(s*T) * G(z=exp(s*T))

where G(z) is the z transfer function of the controller an T is the
sampling time.

Torsten
 


>
>
>
>
> --
> Sent from:
> https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
>
>



Reply | Threaded
Open this post in threaded view
|

Re: plotting transfer function in octave 5.2: How to fix error: set: "dataaspectratio' must be finite

shall689
Hello Torsten,

> If you consider the complete control loop in discrete time (the system
> has to be discretized), then you do not need any transfer function for
> your hold device. Instead, it is considered in the calculation of the
> discrete time system representation. If, e.g., the used D/A has a zero-
> order hold, than the discretization method makes use of the fact that
> the input u is constant during a sampling interval.

Yes, if I use the ZOH method when discretizing, the ZOH will be included.

What if there are two feedbacks, i.e a voltage and a current feedback (see
diagram below)?  Should the ZOH  be placed in both loops as shown in the
second diagram?  My system is sampling all feedbacks at the same time, so
there is essentially only one delay; however, I think two zero order holds
would add two delays.

Stephen

<https://octave.1599824.n4.nabble.com/file/t372348/TwoLoopControlDiagram.jpg>

<https://octave.1599824.n4.nabble.com/file/t372348/TwoLoopControlDiagramWithZOH.jpg>



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: plotting transfer function in octave 5.2: How to fix error: set: "dataaspectratio' must be finite

Octave - General mailing list
On 07/08/2020 18:31, shall689 wrote:

> Hello Torsten,
>
>> If you consider the complete control loop in discrete time (the system
>> has to be discretized), then you do not need any transfer function for
>> your hold device. Instead, it is considered in the calculation of the
>> discrete time system representation. If, e.g., the used D/A has a zero-
>> order hold, than the discretization method makes use of the fact that
>> the input u is constant during a sampling interval.
> Yes, if I use the ZOH method when discretizing, the ZOH will be included.
>
> What if there are two feedbacks, i.e a voltage and a current feedback (see
> diagram below)?  Should the ZOH  be placed in both loops as shown in the
> second diagram?  My system is sampling all feedbacks at the same time, so
> there is essentially only one delay; however, I think two zero order holds
> would add two delays.
>
> Stephen
>
> <https://octave.1599824.n4.nabble.com/file/t372348/TwoLoopControlDiagram.jpg>
>
> <https://octave.1599824.n4.nabble.com/file/t372348/TwoLoopControlDiagramWithZOH.jpg>
>
>
>
> --
> Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
>
>
"I think two zero order holds would add two delays" - before deciding on
adding delays think about the following. One delay stage adds 2 * pi *
delay / frequency phase shift, where 'frequency' is the frequency at
which you want to know phase shift.

In a control system magnitude and phase plots the most important area is
the area in which magnitude response is about 0db - this is where one
looks at phase margin. Let's call this frequency frequency_0db. So, if
frequency_0db is much less than sample rate, then one sample delay
introduces negligible phase shift.

--Sergei.



Reply | Threaded
Open this post in threaded view
|

Re: plotting transfer function in octave 5.2: How to fix error: set: "dataaspectratio' must be finite

Torsten Lilge
On Fri, 2020-08-07 at 22:06 +0300, Sergei Steshenko via Help-octave
wrote:

> On 07/08/2020 18:31, shall689 wrote:
> > Hello Torsten,
> >
> > > If you consider the complete control loop in discrete time (the
> > > system
> > > has to be discretized), then you do not need any transfer function
> > > for
> > > your hold device. Instead, it is considered in the calculation of
> > > the
> > > discrete time system representation. If, e.g., the used D/A has a
> > > zero-
> > > order hold, than the discretization method makes use of the fact
> > > that
> > > the input u is constant during a sampling interval.
> > Yes, if I use the ZOH method when discretizing, the ZOH will be
> > included.
> >
> > What if there are two feedbacks, i.e a voltage and a current
> > feedback (see
> > diagram below)?  Should the ZOH  be placed in both loops as shown in
> > the
> > second diagram?  My system is sampling all feedbacks at the same
> > time, so
> > there is essentially only one delay; however, I think two zero order
> > holds
> > would add two delays.
> >
> > Stephen
> >
> > <
> > https://octave.1599824.n4.nabble.com/file/t372348/TwoLoopControlDiagram.jpg
> > >
> >
> > <
> > https://octave.1599824.n4.nabble.com/file/t372348/TwoLoopControlDiagramWithZOH.jpg
> > >
> >
> >
> >
> > --
> > Sent from:
> > https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
> >
> >
> "I think two zero order holds would add two delays" - before deciding
> on
> adding delays think about the following. One delay stage adds 2 * pi
> *
> delay / frequency phase shift, where 'frequency' is the frequency at
> which you want to know phase shift.
>
> In a control system magnitude and phase plots the most important area
> is
> the area in which magnitude response is about 0db - this is where one
> looks at phase margin. Let's call this frequency frequency_0db. So,
> if
> frequency_0db is much less than sample rate, then one sample delay
> introduces negligible phase shift.
>
> --Sergei.
>

One of the most common misunderstandings when doing discrete-time
control is, that ZOH aren't really "added" to the control. In general, a
D/A converter *is* a ZOH and has to be modeled as such.

You have a cascaded control with the voltage control in the outer loop,
right? Then G2 is a discrete-time controller and its output is the
setpoint for the inner, namely the current controller (also discrete-
time). This, the real, continous-time system is H1, H2, F1, and F2. Is
this correct?

When considering the complete control loop in discrete-time, you have
ZOH1 as a real D/A converter. You would have to discretize the systems
ZOH1-H1-F1 and ZOH1-H1-H2-F2 and you can represent the complete comtrol
loop in discrete-time.

Torsten






Reply | Threaded
Open this post in threaded view
|

Re: plotting transfer function in octave 5.2: How to fix error: set: "dataaspectratio' must be finite

shall689
Hello Torsten,

I was going analyze everything the continuous domain and then convert to the
discrete domain.

Analysis would consist of doing the following:
1. first, find P and I gains for G1(s) that gives a good step response and
also makes the inner current loop stable.
2. Reduce the inner and outer loop to one block.
3. Next, find P and I gains for G2(s) that gives a good step response and
also makes system stable.
4. Convert everything to discrete time domain and compare continuous to
discrete response.  Before converting the continuous time to the discrete
time I would remove the continuous zero order hold from the system and then
use the ZOH method to convert the final equation to discrete domain.  Is
that the correct way to do it?  Or should I just convert G1(s) and G2(s)
using the ZOH method and convert the others using the tustin method?

The whole process might take several iterations.
I have been using https://www.youtube.com/watch?v=yetLPW9sQaI,
https://www.youtube.com/watch?v=rNMlaq8xABE and several other youtube video
and websites to gain an understanding of how to analyze the system.

The actual diagram is a little bit more complicated than what is shown in
diagram I posted.  There are actually two feedbacks in the inner current
loop: an inductor current feedback (positive feedback) and an output current
feedback (negative feedback).  Adding these two together you will get
capacitor current (Icap = Iinductor - Ioutput).  Also, the voltage reference
is fed forward and summed right after ZOH2(s) or G2(s) depending on which
diagram is being used.

Stephen


 



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: plotting transfer function in octave 5.2: How to fix error: set: "dataaspectratio' must be finite

Torsten Lilge
On Sun, 2020-08-09 at 15:33 -0500, shall689 wrote:

> Hello Torsten,
>
> I was going analyze everything the continuous domain and then convert
> to the
> discrete domain.
>
> Analysis would consist of doing the following:
> 1. first, find P and I gains for G1(s) that gives a good step response
> and
> also makes the inner current loop stable.
> 2. Reduce the inner and outer loop to one block.

Do mean reducing innerloop (G1, H1, F1) to one block?

> 3. Next, find P and I gains for G2(s) that gives a good step response
> and
> also makes system stable.
> 4. Convert everything to discrete time domain and compare continuous
> to
> discrete response.  Before converting the continuous time to the
> discrete
> time I would remove the continuous zero order hold from the system and
> then
> use the ZOH method to convert the final equation to discrete
> domain.  Is
> that the correct way to do it?  Or should I just convert G1(s) and
> G2(s)
> using the ZOH method and convert the others using the tustin method?

G1 and G2 actually are digital controllers, right? Therefore, they
already are discrete-time. If there is a ZOH after G1 (the DAC at the
boundary from discrete- to continuous-time), the continuous-time system
(H1, H2, F1, F2) has to be discretized using the ZOH-method.

If you design G1 and G2 in the Laplace-domain, I think it would not be
correct to use the ZOH-method for getting the algorithm you have to use
for the controllers, since the input of the controllers is not constant
during two samples.



> The whole process might take several iterations.
> I have been using https://www.youtube.com/watch?v=yetLPW9sQaI,
> https://www.youtube.com/watch?v=rNMlaq8xABE and several other youtube
> video
> and websites to gain an understanding of how to analyze the system.
>
> The actual diagram is a little bit more complicated than what is shown
> in
> diagram I posted.  There are actually two feedbacks in the inner
> current
> loop: an inductor current feedback (positive feedback) and an output
> current
> feedback (negative feedback).  Adding these two together you will get
> capacitor current (Icap = Iinductor - Ioutput).  Also, the voltage
> reference
> is fed forward and summed right after ZOH2(s) or G2(s) depending on
> which
> diagram is being used.
>

Why is there a second ZOH? Do you have two control inputs into the
continuous-time system?

Torsten





Reply | Threaded
Open this post in threaded view
|

Re: plotting transfer function in octave 5.2: How to fix error: set: "dataaspectratio' must be finite

shall689
> Do mean reducing innerloop (G1, H1, F1) to one block?
Yes (also includes ZOH1).  There would be two variables in that equation, P
and I.  I would adjust P and I so that the equation is in the stable region
and has a good step response.

> G1 and G2 actually are digital controllers, right? Therefore, they
> already are discrete-time. If there is a ZOH after G1 (the DAC at the
> boundary from discrete- to continuous-time), the continuous-time system
> (H1, H2, F1, F2) has to be discretized using the ZOH-method.
Yes, G1 and G2 will be implemented on an FPGA.
I thought it would be easier to work with the equation in the s domain.
Also, from what I have seen (PSIM
(https://www.youtube.com/watch?v=rNMlaq8xABE) and
https://www.youtube.com/watch?v=yetLPW9sQaI&list=PLUMWjy5jgHK0MLv6Ksf-NHi7Ur8NRNU4Z&index=3),
you can do the analysis/simulation in the s domain and then convert to the z
domain.

> If you design G1 and G2 in the Laplace-domain, I think it would not be
> correct to use the ZOH-method for getting the algorithm you have to use
> for the controllers, since the input of the controllers is not constant
> during two samples.
Doesn't ZOH1(s) account for the hold/delay in the Laplace-domain?  

Are saying that I should do the following (e.g. inner loop):
Discretize G1(s)*H1(s)/(1+G(s)*H1(s)) using ZOH method and then perform the
analysis on the stability and step response?  One issue is that the s domain
has two variables (i.e. P and I) and that would make the conversion from the
s domain to z domain a little more cumbersome.

What steps would you take to come up with good P and I gains for both the
inner and outer loop?

>>Why is there a second ZOH? Do you have two control inputs into the
>>continuous-time system?

After thinking about it, there probably only needs to be one ZOH in the
model.  In the digital domain it will be inherent in the z domain equations
because the z domain equations will be converted from the s domain using the
ZOH method.

The FPGA will get all the feedback from a simultaneous sampling multichannel
ADC.  Therefore all the feedbacks will be read a the same time.  Three
feedbacks are used: inverter current and inductor current (both for the
inner loop and can be thought of as capacitor current) and output voltage
for the outer loop.  
Both controllers (inner and outer) operate in parallel.  The outer loop uses
the voltage reference and the current  output voltage feedback sample.  The
inner loop uses the previous output of the inner loop and the current
inverter and inductor current feedbacks.

Stephen

 



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html