[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PID function in octave control not working.. why?
From: |
Tatsuro MATSUOKA |
Subject: |
Re: PID function in octave control not working.. why? |
Date: |
Fri, 26 Jun 2015 17:24:47 +0900 (JST) |
----- Original Message -----
> From: Lukas Reichlin
> To: Abdul Rahman Riza <
> Cc: "address@hidden" <; shahin35ju; help-octaveg
> Date: 2015/6/26, Fri 14:23
> Subject: Re: PID function in octave control not working.. why?
>
> On 25.06.2015, at 21:21, Abdul Rahman Riza <address@hidden> wrote:
>
>> Dear All,
>>
>> I'm using octave 3.8.2 in debian jessie 64 bit trying to run matlab
> example here
> http://ctms.engin.umich.edu/CTMS/index.php?example=Suspension§ion=ControlPID
>>
>> hereunder my suspension.m files:
>> =============================
>> m1 = 2500;
>> m2 = 320;
>> k1 = 80000;
>> k2 = 500000;
>> b1 = 350;
>> b2 = 15020;
>>
>> nump=[(m1+m2) b2 k2];
>> denp=[(m1*m2) (m1*(b1+b2))+(m2*b1) (m1*(k1+k2))+(m2*k1)+(b1*b2)
> (b1*k2)+(b2*k1) k1*k2];
>> G1=tf(nump,denp);
>>
>> num1=[-(m1*b2) -(m1*k2) 0 0];
>> den1=[(m1*m2) (m1*(b1+b2))+(m2*b1) (m1*(k1+k2))+(m2*k1)+(b1*b2)
> (b1*k2)+(b2*k1) k1*k2];
>> G2=tf(num1,den1);
>>
>> numf=num1;
>> denf=nump;
>> F=tf(numf,denf);
>>
>> Kd = 208025;
>> Kp = 832100;
>> Ki = 624075;
>> C = pid(Kp,Ki,Kd);
>>
>> sys_cl=F*feedback(F*G1,C);
>>
>> t=0:0.05:5;
>> step(0.1*sys_cl,t)
>> title('Closed-Loop Response to 0.1-m High Step w/ PID Controller')
>> =================================
>>
>> I already installed and load the latest octave-control package and found
> this error message
>>
>> octave:1> pkg load control
>> octave:2> suspension
>> warning: the 'pid' function belongs to the control package from
> Octave Forge but
>> has not yet been implemented.
>>
>> Please read <http://www.octave.org/missing.html> to learn how you can
>> contribute missing functionality.
>>
>>
>> error: 'pid' undefined near line 23 column 5
>> error: called from:
>> error: /home/riza/Codes/Octave/suspension.m at line 23, column 3
>> octave:2>
>>
>> then I tried to change pid function into optiPID
>>
>> =============================
>> m1 = 2500;
>> m2 = 320;
>> k1 = 80000;
>> k2 = 500000;
>> b1 = 350;
>> b2 = 15020;
>>
>> nump=[(m1+m2) b2 k2];
>> denp=[(m1*m2) (m1*(b1+b2))+(m2*b1) (m1*(k1+k2))+(m2*k1)+(b1*b2)
> (b1*k2)+(b2*k1) k1*k2];
>> G1=tf(nump,denp);
>>
>> num1=[-(m1*b2) -(m1*k2) 0 0];
>> den1=[(m1*m2) (m1*(b1+b2))+(m2*b1) (m1*(k1+k2))+(m2*k1)+(b1*b2)
> (b1*k2)+(b2*k1) k1*k2];
>> G2=tf(num1,den1);
>>
>> numf=num1;
>> denf=nump;
>> F=tf(numf,denf);
>>
>> Kd = 208025;
>> Kp = 832100;
>> Ki = 624075;
>> C = optiPID(Kp,Ki,Kd);
>>
>> sys_cl=F*feedback(F*G1,C);
>>
>> t=0:0.05:5;
>> step(0.1*sys_cl,t)
>> title('Closed-Loop Response to 0.1-m High Step w/ PID Controller')
>> =================================
>>
>> but there's another error message appears
>>
>> octave:2> edit suspension.m
>> octave:3> suspension
>> error: invalid use of script
> /usr/share/octave/packages/control-2.8.2/optiPID.m in index expression
>> error: called from:
>> error: /home/riza/Codes/Octave/suspension.m at line 23, column 3
>> octave:3>
>>
>>
>> Please advise how to use PID function therefore I may run matlab examples
> here
> http://ctms.engin.umich.edu/CTMS/index.php?example=Suspension§ion=ControlPID
>>
>> Regards,
>>
>> Riza
>
> There is no such thing as a "pid" function or class in the control
> package, but you can easily define one yourself:
>
> pid = @(Kp, Ki, Kd) tf ([Kd, Kp, Ki], [1, 0])
>
> Just put the expression above in your script file before your first usage of
> the
> "pid" function:
>
> C = pid (Kp, Ki, Kd)
>
> Hope this helps,
> Lukas
***********************************************************************
> I add the information of the Nabble archive.
> http://octave.1599824.n4.nabble.com/Need-solution-td4671186.html
>
>
> Your post is included above the archive.
> You perhaps do not intended to do so.
>
> Please separate your post.
>
> Tatsuro
***********************************************************************
Ah! Split to two different threads miss the timing.
For those who read this thread on the Nabble, please care that the thread
contains two different initial posts.
1. http://octave.1599824.n4.nabble.com/Need-solution-tp4671186.html
2. http://octave.1599824.n4.nabble.com/Need-solution-tp4671186p4671229.html
Tatsuro
Re: Need solution, address@hidden, 2015/06/24