help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PID function in octave control not working.. why?


From: Doug Stewart
Subject: Re: PID function in octave control not working.. why?
Date: Fri, 26 Jun 2015 05:41:42 -0400



On Fri, Jun 26, 2015 at 1:23 AM, Lukas Reichlin <address@hidden> wrote:
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&section=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&section=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




_

For matlab compatibility  you should add this pid.m file


function PID=pid (Kp, Ki, Kd)
PID= tf ([Kd, Kp, Ki], [1, 0]);
endfunction


reply via email to

[Prev in Thread] Current Thread [Next in Thread]