Matlab question for control loop

There's a tutorial on YouTube, if you search for "matlab bode plot".

--




----Android NewsGroup Reader---- 
http://www.piaohong.tk/newsgroup
Reply to
bitrex
Loading thread data ...

I would like to use Matlab to help design feedback loops for power converters. I am a little weak in this area (never had one take off on me though).

I would like to plug in the transfer functions and have Matlab derive Bode plots.

Beyond the Matlab install do I need any other tool box for this basic function?

thank you Bob

Reply to
Yzordderrex

Why not just Spice the actual circuit? The only practical way to transport models into Matlab, for Bode plots, is to assume linearity, very much a dicey thing to do in a switcher.

--

John Larkin                  Highland Technology Inc 
www.highlandtechnology.com   jlarkin at highlandtechnology dot com    

Precision electronic instrumentation
Reply to
John Larkin

rters. I am a little weak in this area (never had one take off on me though ).

de plots.

nction?

t

icey

I do the spice simulations for the converters. I just want another tool. I did some stuff with Matlab when I was an undergraduate (Go Badgers!)takin g a control class. I have since migrated to Mathcad for most everything ma th. I can do them in Mathcad, but I think Matlab may be easier. I just wan t the plots, nothing else. Boss is willing to load it into my machine, so w hy the heck not I say.

Reply to
Yzordderrex

octave is a free clone of Matlab and many people bounce back and forth between them.

I've got two functions I use to do a bit of what you're doing, to simplify the process.

In order to bounce back and forth between time waveforms and frequency spectrum and filtering, etc I wrote two functions: time2freq and freq2time

Advantage? take a time waveform, say that comes out of a mixer, or some nonlinear source. Uniform time steps t and time waveform called vt. then remember that t matches the time sampling so that plot(t,vt) produces the waveform in actual time [vf,ford]=time2freq(vt); dt=max(diff(t)); if you want, you can look at the spectrum now, or..you want to run that signal through some filtering, like a simple, single low pass like

1/(1 + 1i*f/fc), or make filter as complicated as you want where rolloff, fc is in Hz filter=1./(1+1i*ford/dt/fc);

now let's find out how well the filter worked.... vvf=filter.*vf; and vvt=freq2time(vvf); now to look at the effect of the filter: plot(t,vt); hold on; plot(t,vvt,'b'); hold off; and the two are overlaid, shows you reduction of peaks and the phase shift from your filter. Easy to use and kind of fun to see all that textbook stuff come to reality.

oh, if you want to see the filter as a bode plot: plot(log10(ford(2:end)/dt/fc),20*log10(abs(filter(2:end)))); that will look EXACTLY like the expenected bode plot with ordinate zero being the cutoff frequency. Why 2:end? because the frequency at 1 is DC and doesn't plot well in log format.

Reply to
RobertMacy

Getting Bode plots from transfer functions is easy in MathCad. I can't remember how to do it, but I remember it being easy!

I strongly recommend Scilab over Matlab. Scilab has fewer bells and whistles, but it has a lot more built-in control systems functionality and it's free. One way that it's nice is that in Scilab you can type in a transfer function in fairly natural form, then do a Bode plot. To do that in Matlab (instead of writing a function and doing a lot of lower- level array operations) you need the Control Systems Toolbox, which is even more $$$ for your boss to spend.

Here's a PI controller transfer function in Scilab, with kp = 1 and ki =

100:

H = 1 + 100/%s

Here's how to do its Bode plot from 1Hz to 1kHz:

bode(H, 1, 1000)

You don't get the "I'll do your work for you" approach to things that Matlab is selling -- which means that you're at the mercy of your care and competence, not the questionable competence and care of a bunch of guys at the Math Works.

--

Tim Wescott 
Wescott Design Services 
http://www.wescottdesign.com
Reply to
Tim Wescott

"Need", no. You can do anything in Matlab. You could also do it in C, for that matter.

formatting link

The Control Toolbox would obviously make it ea$ier.

--sp

Reply to
Spehro Pefhany

IIRC you make a vector of frequencies, then you make a vector of values

w = e^(2 * pi * i * f / Fs)

where Fs is the sampling frequency.

Then you plot abs(H(w)) and arg(H(w)) against frequency on an appropriately-scaled plot.

For quite a while I was designing control loops for sampled-time systems with the aid of MathCad. I'd do a swept-sine plant response, get the numbers into MathCad (there's a file read if the file is formatted right), then get a Bode plot of plant-wrapped-with-controller.

I don't know that it would be worthwhile to do that with switchers, though, because of the nonlinearities.

--
Tim Wescott 
Control system and signal processing consulting 
www.wescottdesign.com
Reply to
Tim Wescott

Or, you could use the free control package in free Octave:

s=tf('s')

Transfer function 's' from input 'u1' to output ... y1: s Continuous-time model.

H=20000/(s+20000);

bode(H)

My Octave under Fedora has the control package preloaded; if yours complains about nonexistent tf() you may need to do pkg load control or even pkg install control.

Reply to
Przemek Klosowski

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.