Jump to content



Photo

Automatic Control:bode Diagram + Three Previous Functions


  • Please log in to reply
10 replies to this topic

#1 Aristos

Aristos

    Newbie

  • Members
  • Pip
  • 14 posts
  • Location:Europe

  • Calculators:
    fx-9750G
    ClassPad 300

Posted 17 December 2007 - 11:08 AM

After hard work, especially in the graphics and due to lack of time, I have managed to put in place a program to draw diagrams of Bode and calculating gain and phase margins.
You can see up to 3 transfer functions at once (for example: the uncompensated system, the compensator and the compensated system) with separate areas for gain and phase. The program calculates automatically the scales of frequency, gain and phase to show the plots. The user can introduce a different frequency scale to better see details.
The gain and the phase margins are displayed in graphical and numerical form.

This function is comented with examples, how in the previous functions, in a pdf file. The examples are in the folder: LACexam.
All of this in the file sharing area.

#2 girdeux

girdeux

    Casio Addict

  • Members
  • PipPipPip
  • 88 posts
  • Location:Spain / Castell?n

  • Calculators:
    casio fx-115ms;
    casio classpad 300

Posted 23 December 2007 - 11:53 PM

Very good job, it's a good library. I was looking for the residue function and solve poly equations with imaginary numbers. It's a pity that I have made the exam of this subject in June jeje.

#3 Aristos

Aristos

    Newbie

  • Members
  • Pip
  • 14 posts
  • Location:Europe

  • Calculators:
    fx-9750G
    ClassPad 300

Posted 15 January 2008 - 06:09 PM

Very good job, it's a good library. I was looking for the residue function and solve poly equations with imaginary numbers. It's a pity that I have made the exam of this subject in June jeje.


I thought in you (not only) when I was developing the LAC, but it was not possible to finish on time... 6 months later. :(
In any case, thank you for your congratulations.

#4 Aristos

Aristos

    Newbie

  • Members
  • Pip
  • 14 posts
  • Location:Europe

  • Calculators:
    fx-9750G
    ClassPad 300

Posted 15 January 2008 - 06:31 PM

Congratulations !!! It's very good and useful for students ! I am waiting for that and you do it.

Bode diagrams, step diagrams, all works fine.

Thanks again !

Patrick


I'm sorry for the delay in responding your mail sent to the forum of CPlua on December 26. I was very busy after time dedicated to develop the Bode program.

Firstly thanks for your congratulations. I hope that LAC will be very useful.

To make more friendly the LAC I think that your proposal (made by email) is very interesting.
All my functions in LUA use local variables and all are declared on top of the function, I don't use any global variable. You can see the functions and deduct the variable function but this is very annoying. It's better that I give you the calling variables for a given function (a lot of functions in Bode program) or how to access to a given function and what are the return values. In this case you would tell me about which functions you want more information.

To get the margins directly without drawing diagrams you have to add a new variable 'mg' in the return on last function (Bode) and comment the line 'BodeGraph(mag,pha,frq,mg) like this:

"
mag,pha=BodeMagPha(kb,nr,nm,dr,dm,frq) -- untouched
mg=GaiPhaMargin(mag,pha,frq) -- untouched
--BodeGraph(mag,pha,frq,mg) -- add comment --
return mag,pha,frq,mg -- add variable mg
end -- untouched
export{Bode=Bode} -- untouched
"

The calling function could be:

--ExBode7 jan2007
require("LAC/Bode","LACutils/Series","LNAutils/LinSpace","LACutils/FBack","LAC/StepUnit")

local n={400}
local d={1,15,50,0}
local nc={1,3}
local dc={1,8}
local nt,dt,nf,df
local nh,dh={1},{1}
local sys={}
local gn,ph,fr,mg
local aux,i

nt,dt=Series(n,d,nc,dc)
sys={n,d,nc,dc,nt,dt}
gn,ph,fr,mg=Bode(sys)
--print margins
print(' bode gain-dB freq-r/s')
for i=1,#gn do
if mg.mg[i] 1 ==nil
then
printf(' %1d %s %s\n',i,'inf','-')
else
aux=20*math.log10(mg.mg[i] 1 )
printf(' %1d %5.2f %3.1f\n',i,aux,mg.mgf[i] 1 )
end
end
print()
print(' bode phase freq-r/s')
for i=1,#gn do
if mg.mp[i] 1 ==nil
then
printf(' %1d %s %s\n',i,'inf','-')
else
aux=mg.mp[i] 1
printf(' %1d %5.1f %3.1f\n',i,aux,mg.mpf[i] 1 )
end
end


The variable 'mg' is a table:

mg.mg[#bode] 1 gain margin of bode (1,2 or 3) natural gain, not in dB
mg.mgf[#bode] 1 frequency of bode (1,2 or 3) at gain margin
mg.mp[#bode] 1 phase margin of bode (1,2 or 3) in degrees
mg.mpf[#bode] 1 frequency of bode (1,2 or 3) at phase margin


In another release I will improve the access and return to Bode function.

#5 Aristos

Aristos

    Newbie

  • Members
  • Pip
  • 14 posts
  • Location:Europe

  • Calculators:
    fx-9750G
    ClassPad 300

Posted 21 January 2008 - 11:03 AM

Hi,

I would like to print formated text. I know print and printf functions but these functions only operate on console window. On a graphic window there is drawtext function with a text parameter but is there a way to format text before drawing it on the gaphic window ?

Thank you for your answer.

Patrick

In Lua language there are some libraries like 'math', 'string', 'table', 'io', 'os', 'debug', 'draw'.
CPLua includes 'math' by default.
In your case, you must include 'string' and 'draw' libraries with the 'require' statement. With 'string' you can format a string variable in similar mode that 'printf'.

Example:

require("draw","string")

local txt
local m=3

txt=string.format('%s%1d%s %5.2f','val(',m,')=',3.18)
draw.text(25,40,txt,1,9,0)
showgraph()
waitkey()



Documentation about 'string' and others libraries is on Lua Manual.

#6 Guest_casicasio_*

Guest_casicasio_*
  • Guests

Posted 05 April 2011 - 11:15 PM

i am from peru and I just bought a ClassPad 330 urgent need help
to run the program three functions + diagram bode well
please explain

#7 MicroPro

MicroPro

    Casio Overlord

  • Deputy
  • PipPipPipPipPipPipPip
  • 640 posts
  • Gender:Male
  • Location:Iran

  • Calculators:
    Casio ClassPad 300

Posted 06 April 2011 - 08:40 AM

Hello!

First download CPLua from THIS PAGE, I don't know which version of CPLua the program is compatible with, so download both 0.8 and 0.9E versions and try them. Install it using your ClassPad Manager. If you don't know how to use ClassPad Manager, search the web and there are several sites teaching how to use ClassPad Manager, in many languages including spanish.

Download the program from HERE.
Use WinRAR or 7-zip to extract the contents of the rar file to your computer. Use ClassPad Manager to transfer the contents of the LAC.mcs file to your ClassPad.

You also need LNA, which you can find HERE (thanks to PAP and unique33).

And finally, you need to know a bit programming to use the progs, and i think the instructions and examples inside the PDF file and in the above posts can help you start.

#8 javsalo

javsalo

    Newbie

  • Members
  • Pip
  • 9 posts
  • Location:iran,gorgan

Posted 15 August 2011 - 02:26 PM

i have bad error after opening and run bode :

runtime error
main:439:scripts are not authorized to export symbols
press[<-] or <span class=EXE' />...


such this error i have another problem with thermo tables....that unique write....

my casio classpaad 330 updated 3.06 version

anybody help?

Edited by javsalo, 15 August 2011 - 02:27 PM.


#9 MicroPro

MicroPro

    Casio Overlord

  • Deputy
  • PipPipPipPipPipPipPip
  • 640 posts
  • Gender:Male
  • Location:Iran

  • Calculators:
    Casio ClassPad 300

Posted 22 August 2011 - 09:27 AM

Hello.
You are running the wrong programs!

LAC is a library, which means you should write programs that use the functions in the LAC library to use it. There are example programs in its LACexam folder that you can run.

For CATT, read the manual: It says you should run the DRIVER program which is in CATTD folder.

Hope this helps.


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users