# Control System Design methods using Octave.

14 messages
Open this post in threaded view
|

## Control System Design methods using Octave.

 This post was updated on . I mainly work with PSIM. PSIM has a general control system design software named smartctrl.  Matlab has something simlar, I think. According to https://www.youtube.com/watch?v=tpoCpC-oX7Q, the following steps in smartctrl can be taken to determine the design parameters for a specific control system: 1. import the bode plot obtained from an AC sweep of your simulation into smartctrl. 2. Select a sensor (voltage divider and ect) from the smartctrl. 3. Select a controller (PI or etc). 4. Afterwards, select a point from the cross over frequency vs Phase Margin solution map that gives a specific step response.  Smartctl also shows the bode plots for the closed loop response. Smartctrl gives the P and I for the specific point picked in the solution map. Is there anyway to get octave to give the same type of information?   Thanks, Stephen -- Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html_______________________________________________ Help-octave mailing list Help-octave@gnu.org https://lists.gnu.org/mailman/listinfo/help-octave
Open this post in threaded view
|

## Re: Control System Design methods using Octave.

 Hello, I did some searching and found invfreqz and invfreqs. It seems they can be used to convert gain/phase data from the system to a transfer function in the discrete (=G(z)) and continuous (=G(s)) domain respectively.  I could then find out the total closed loop response by G/(1+G*H), where H is the PID transfer function. So, I am assuming I could use complex samples from the bode diagram as inputs to either of these two functions,i.e h=[(1+i),(2+2i),...], w=[1,1.01,..], n=?,m=?,invfreqz(h,w,n,m).  Is that correct?  How would I determine n and m?  I am thinking that selecting n=1 and m = 2 would be a good start.   if the plot of the transfer function doesn't give a good match to the original transfer function, I would just increase m and then increase n the next time if match is still not good.  Would that work? Am I working in the right direction? Thanks, Stephen -- Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html_______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave
Open this post in threaded view
|

## Re: Control System Design methods using Octave.

 Hello, The frequency response data given in buckVfreqResp.csv (see attached file) is the result of a frequency sweep in PSIM.  The attached m file, converts that data to a descrete system and plots its bode plot (See Bode Plot of Descrete System Image). The two bode plots somewhat match each other on the left side of the bode plot; however, the frequency range on the discrete system bode plot doesn't match the frequency range on frequency sweep bode plot.  the buck converter sample rate is 20kHz.  The max frequency on the discrete system bode plot is 2e-4 rad/seconds, which is equivalent to 0.64Hz.   Why am I getting such small frequencies on the discrete system bode plot? Stephen buckVfreqResp.csv   CreateTFfromFreqResponse.m   -- Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html_______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave
Open this post in threaded view
|

## Re: Control System Design methods using Octave.

 Ok, I removed SampleFrequency from the tf function, i.e. tf(b,a) instead of tf(b,a,SampleFrequency). The bode plot seem to match each other much better and the frequency range is a little better, with the only issue is that the max discrete frequency is 10 (>> pi). Is there some type of issue with the bode() function? -- Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html_______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave
Open this post in threaded view
|

## Re: Control System Design methods using Octave.

 On Wed, Dec 6, 2017 at 4:57 PM, shall689 wrote:Ok, I removed SampleFrequency from the tf function, i.e. tf(b,a) instead of tf(b,a,SampleFrequency). The bode plot seem to match each other much better and the frequency range is a little better, with the only issue is that the max discrete frequency is 10 (>> pi). Is there some type of issue with the bode() function? Hi ShallIf you would post your exact code, for me to run, then I am sure that I can answer your questions.https://pastebin.com/   is one way to post it.-- DAS _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave
Open this post in threaded view
|

## Re: Control System Design methods using Octave.

Open this post in threaded view
|

## Re: Control System Design methods using Octave.

 In reply to this post by Doug Stewart-4 I updated my code to use the 1/SampleFrequency in the tf() function.  It seems to give me much better results. The code in my last post had n am m values for invfreqz() that were not related to my previous post.  I had been playing around with those values to see if I could get a bode plot that was closer to the bode plot generated from the PSIM simulation frequency sweep.   The code below uses the n and m values I had in my original code.  How do I decide the n and m value --- by trial and error? Stephen pkg load control; pkg load signal; clear all x = csvread('buckVfreqResp.csv'); SampleFrequency = 20000; T = 1/SampleFrequency; f = x(:,1); r = x(:,2); phase_rad = x(:,3).*(pi/180); h = r.*cos(phase_rad) + r.*(sin(phase_rad)*i); w = f.*(2*pi*T); [b,a] = invfreqz(h,w,2,3) sys = tf(b,a) bode(sys) -- Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html_______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave
Open this post in threaded view
|

## Re: Control System Design methods using Octave.

 In reply to this post by Doug Stewart-4 Doug Stewart-4 wrote > On Wed, Dec 6, 2017 at 4:57 PM, shall689 < > sahallacy@ > > wrote: > >> Ok, I removed SampleFrequency from the tf function, i.e. tf(b,a) instead >> of >> tf(b,a,SampleFrequency). >> >> The bode plot seem to match each other much better and the frequency >> range >> is a little better, with the only issue is that the max discrete >> frequency >> is 10 (>> pi). >> >> Is there some type of issue with the bode() function? >> >> >> <http://octave.1599824.n4.nabble.com/file/t372348/BodePlot2.png>>> >> >> >> -- >> Sent from: http://octave.1599824.n4.nabble.com/Octave-General->> f1599825.html >> >> > Hi Shall > If you would post your exact code, for me to run, then I am sure that I > can > answer your questions. > https://pastebin.com/   is one way to post it. > > > > -- > DAS > > <https://linuxcounter.net/user/206392.html>> > _______________________________________________ > Help-octave mailing list > Help-octave@ > https://lists.gnu.org/mailman/listinfo/help-octavehttps://pastebin.com/HwYAq4f6-- Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html_______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave
Open this post in threaded view
|

## Re: Control System Design methods using Octave.

 In reply to this post by Doug Stewart-4 Doug Stewart-4 wrote > On Wed, Dec 6, 2017 at 4:57 PM, shall689 < > sahallacy@ > > wrote: > >> Ok, I removed SampleFrequency from the tf function, i.e. tf(b,a) instead >> of >> tf(b,a,SampleFrequency). >> >> The bode plot seem to match each other much better and the frequency >> range >> is a little better, with the only issue is that the max discrete >> frequency >> is 10 (>> pi). >> >> Is there some type of issue with the bode() function? >> >> >> <http://octave.1599824.n4.nabble.com/file/t372348/BodePlot2.png>>> >> >> >> -- >> Sent from: http://octave.1599824.n4.nabble.com/Octave-General->> f1599825.html >> >> > Hi Shall > If you would post your exact code, for me to run, then I am sure that I > can > answer your questions. > https://pastebin.com/   is one way to post it. > > > > -- > DAS > > <https://linuxcounter.net/user/206392.html>> > _______________________________________________ > Help-octave mailing list > Help-octave@ > https://lists.gnu.org/mailman/listinfo/help-octaveI looked at invfreqz.m and found out that that function is missing the "superior algorithm that guarantees stability of the resulting linear system and searches for the best fit using a numerical, iterative scheme" as mentioned in matlab's documentation. Stephen -- Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html_______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave
Open this post in threaded view
|

## Re: Control System Design methods using Octave.

 In reply to this post by shall689 On Wed, Dec 6, 2017 at 6:30 PM, shall689 wrote:I updated my code to use the 1/SampleFrequency in the tf() function.  It seems to give me much better results. The code in my last post had n am m values for invfreqz() that were not related to my previous post.  I had been playing around with those values to see if I could get a bode plot that was closer to the bode plot generated from the PSIM simulation frequency sweep.   The code below uses the n and m values I had in my original code.  How do I decide the n and m value --- by trial and error? I don't see how you are using n and m in this code?Doug    pkg load control; pkg load signal; clear all x = csvread('buckVfreqResp.csv'); SampleFrequency = 20000; T = 1/SampleFrequency; f = x(:,1); r = x(:,2); phase_rad = x(:,3).*(pi/180); h = r.*cos(phase_rad) + r.*(sin(phase_rad)*i); w = f.*(2*pi*T); [b,a] = invfreqz(h,w,2,3) sys = tf(b,a) bode(sys) _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave -- DAS _______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave
Open this post in threaded view
|

## Re: Control System Design methods using Octave.

 Doug Stewart-4 wrote > On Wed, Dec 6, 2017 at 6:30 PM, shall689 < > sahallacy@ > > wrote: > >> I updated my code to use the 1/SampleFrequency in the tf() function.  It >> seems to give me much better results. >> >> The code in my last post had n am m values for invfreqz() that were not >> related to my previous post.  I had been playing around with those values >> to >> see if I could get a bode plot that was closer to the bode plot generated >> from the PSIM simulation frequency sweep.   The code below uses the n and >> m >> values I had in my original code.  How do I decide the n and m value --- >> by >> trial and error? >> >> I don't see how you are using n and m in this code? > Doug > > > > >> >> >> > > >> >> pkg load control; >> pkg load signal; >> clear all >> x = csvread('buckVfreqResp.csv'); >> SampleFrequency = 20000; >> T = 1/SampleFrequency; >> f = x(:,1); >> r = x(:,2); >> phase_rad = x(:,3).*(pi/180); >> h = r.*cos(phase_rad) + r.*(sin(phase_rad)*i); >> w = f.*(2*pi*T); >> [b,a] = invfreqz(h,w,2,3) >> sys = tf(b,a) >> bode(sys) >> >> >> >> -- >> Sent from: http://octave.1599824.n4.nabble.com/Octave-General->> f1599825.html >> >> _______________________________________________ >> Help-octave mailing list >> > Help-octave@ >> https://lists.gnu.org/mailman/listinfo/help-octave>> > > > > -- > DAS[image: Certificate for 206392] > > <https://linuxcounter.net/user/206392.html>> > _______________________________________________ > Help-octave mailing list > Help-octave@ > https://lists.gnu.org/mailman/listinfo/help-octaveHello Doug, n and m represent n and m in the function [b,a] = invfreqz(h,w,n,m). Thanks, Stephen -- Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html_______________________________________________ Help-octave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-octave
Open this post in threaded view
|