LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error in Mathscript (FOPDT Transfer Function)

Solved!
Go to solution

Hi all, i am trying to write a First Order Plus Dead Time system into the mathscript, unfortunetaly i found that it appear an error (please refer to the attachements), do anyone have idea or approach to write an FOPDT Transfer function in mathscript? 

Thankyou veery much.

 

0 Kudos
Message 1 of 14
(4,784 Views)

Yuki

 

You have to substitute the function:

 

plant = tf(num,den,'inputdelay',0.06)

 

with

 

Gp=set(plant,'inputdelay',0.06);

 

This will set the input delay for the transfer function model. The third argument for the tf command is used to set 'discrete' system with its sampling time. So, the whole script should be:

 

s=tf('s');

num=58;

den=0.33*s+1;

Gp =num/den;

Gp =set(plant,'inputdelay',0.06);

contr = Kp*(1/Ti*s);

sys_cl=feedback (contr*Gp,1);

 

hope this helps

Barp - Control, Simulation, RTT and HIL - National Instruments
0 Kudos
Message 2 of 14
(4,733 Views)
Solution
Accepted by topic author YukiWong

One more thing... this could be easier if you go 100% graphical... Smiley Happy

 

This below is a snippet and you can just drag and drop in your LabVIEW 2011 block diagram and this will copy this code into it.

 

CreateFODwithPID.png

Barp - Control, Simulation, RTT and HIL - National Instruments
0 Kudos
Message 3 of 14
(4,731 Views)

Thank you very much barp, both method work for me, but now i had face another problem.

I had try your method and design the PI controller, but the result (overshoot) is different compare to the result (overshoot) by using Matlab.

I had try to copy and paste the code from the Mathscript to the Matlab and step plot it. Consequently, the overshoot shown different value. 

I also had try to check all the value and i found that everything is ok until the last line sys_cl=feedback(Gf,1), Labview has given the answer in transfer function but Matlab has show the answer in continuous time state space model. 

 

The value of the transfer function : Gain = 58.46; Time constant = 0.55 and time delay = 0.06.

The value of Pi controller : Kp = 0.0784 and the Ti = 0.24. 

I had attach some picture which show the difference.

Am i did something wrong in the mathscript and should i do it in Labview by different way?

 

Thankyou very much 🙂

 

Download All
0 Kudos
Message 4 of 14
(4,715 Views)

This is the regarding Labview file, could you please help me take a look?

 

Thankyou very much barp :).

0 Kudos
Message 5 of 14
(4,713 Views)

Yuki

 

The problem is the delay from the First Order Model. If you look at the output error of "Unit Feedback Function", you will see a warning that says

 

Warning 41504 occurred at NI_CD_Model Interconnection.lvlib:cd_Feedback (TF and TF).vi

Possible reason(s):

Control Design and Simulation:  The delay information was ignored.

 

The main reason is that feedback function doesn't support delays. If you try to develop the model based on algebra, we can't represent the result as "exp (-D.s) *Num/Den".

 

To allow you to analyze such systems, you have two options:

1. Use Pade Approximation to obtain an equivalent model that of the delay and then, you can do the analysis as usual

ModelWithDelay.png

2. Use the function "Pade" in MathScript RT to convert the model. The command line is "Gp = pade (Gp, 3)";

 

This should allow you to analyze the model.

Barp - Control, Simulation, RTT and HIL - National Instruments
Message 6 of 14
(4,687 Views)

thanks barp, thankyou very much, i had try out and it iss very useful for me, according to the previous graph u show me, there is a non-minimum phase behaviour occur in the response, i dont have zero on the right hand s-plane, but why the graph shown non-minimum phase behaviour? i mean it go opposite direction from the final direction. 

 

thankyou very much barp :).

0 Kudos
Message 7 of 14
(4,647 Views)

Yuki

 

The non-minimum behavior comes from applying the pade approximation to convert the delay [exp (-0.06 s)] into a polynomial. For example, for order 3, the model has the following approximation:

pade_3.png

 

Which shows 3 zeros on the left side. If you increase this to 7, you will notice the pattern of zeros being formed on the left like this:

pade7.png

 

Here is the code related to this approximation, so you can 'play' with this code to understand.

 

padecode.png

 

Does it make sense?

Barp - Control, Simulation, RTT and HIL - National Instruments
0 Kudos
Message 8 of 14
(4,635 Views)

Yuki

 

Just to be complete here. The reason you have to convert to pade approximation is because when you have a model with delay and you try to do the feedback loop operation, defined as:

 

Gcc = Gp*Gc/ ( 1 + Gp*Gc)

 

and you have a delay on Gp, you can't separated the exp (- Td*s) from the closed-loop equation and, in our toolkit, we can't use that. To overcome this problem, you can do the pade approximation we discussed above or you can try to use do nonlinear simulation. Then, you can develop the code as:

 

simulation with delay_simple.png

 

and you will see the response without the 'nonminimum phase effect'.

 

 

Barp - Control, Simulation, RTT and HIL - National Instruments
0 Kudos
Message 9 of 14
(4,633 Views)

Here is the VI, to save you time.

Barp - Control, Simulation, RTT and HIL - National Instruments
0 Kudos
Message 10 of 14
(4,628 Views)