智能控制概論報(bào)告_第1頁
智能控制概論報(bào)告_第2頁
智能控制概論報(bào)告_第3頁
智能控制概論報(bào)告_第4頁
智能控制概論報(bào)告_第5頁
已閱讀5頁,還剩14頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、原堯燊東南大學(xué)自動(dòng)化學(xué)院08010439智能控制概論報(bào)告模糊控制器設(shè)計(jì)原堯燊08010439目錄一、 設(shè)計(jì)要求.3二、控制器設(shè)計(jì).31. 確定模糊控制器輸入輸出變量.32. 確定各輸入輸出變量的變化范圍、量化等級(jí)和量化因子.33. 在各輸入和輸出語言變量的量化域內(nèi)定義模糊子集.44. 模糊控制規(guī)則的確定55. 求模糊控制表.5三、程序設(shè)計(jì).6四、測(cè)試與仿真.71. Simulink搭建.72. 比例因子K3對(duì)響應(yīng)曲線的影響.7五、總結(jié).10六、使用方法.10七、代碼附錄.11一、設(shè)計(jì)要求:已知被控對(duì)象模型,給定階躍響應(yīng)幅值為30,系統(tǒng)初值為0,完成以下內(nèi)容:(a) 設(shè)計(jì)常規(guī)的模糊邏輯控制器;(

2、b) 當(dāng)通過改變模糊邏輯控制器比例因子時(shí),分析系統(tǒng)響應(yīng)有什么變化?(c) 聯(lián)系、結(jié)合模糊邏輯控制器設(shè)計(jì)過程(結(jié)構(gòu)設(shè)計(jì)、模糊化設(shè)計(jì)、規(guī)則設(shè)計(jì)、精確化設(shè)計(jì))以及控制系統(tǒng)響應(yīng)情況,談?wù)劚救藢?duì)模糊邏輯控制系統(tǒng)的一些認(rèn)識(shí)和看法。要求:(1) 先進(jìn)行系統(tǒng)分析,然后給出完整詳細(xì)的設(shè)計(jì)過程,可參見P59-61 頁直流調(diào)速系統(tǒng)的模糊邏輯控制器設(shè)計(jì)過程;(2) 提交完整的報(bào)告,包括:封面(題目、個(gè)人學(xué)號(hào)姓名等信息)、目錄、任務(wù)要求敘述、系統(tǒng)分析及控制設(shè)計(jì)原理(包括控制系統(tǒng)原理圖及文字分析)、完整的設(shè)計(jì)實(shí)現(xiàn)過程(包括模糊控制器每部分的選擇與實(shí)現(xiàn)、計(jì)算、原理過程等)、仿真驗(yàn)證(算法流程圖、軟件實(shí)現(xiàn)手段介紹、系統(tǒng)參數(shù)選

3、擇、響應(yīng)曲線圖、結(jié)合調(diào)參對(duì)響應(yīng)曲線的影響給出必要的分析)、討論與分析,其中對(duì)(b)(c)部分的分析字?jǐn)?shù)要求在5002000 字以內(nèi)。(3) 提交可運(yùn)行的軟件程序,計(jì)算機(jī)上可檢驗(yàn)結(jié)果;必須在根目錄下附軟件/程序使用說明,運(yùn)行說明(可能的話,附那些參數(shù)可調(diào)及具體效果的說明)二、控制器設(shè)計(jì)1. 確定模糊控制器輸入輸出變量本控制器設(shè)計(jì)參考中文書P54P61中的二維控制器設(shè)計(jì),輸入為偏差E和偏差變化量ES來進(jìn)行調(diào)節(jié)。另外模糊控制器通過查表法實(shí)現(xiàn)??刂票矸绞降哪:壿嬁刂破骰窘Y(jié)構(gòu)圖K3模糊控制表量化量化K2K1對(duì)象e+zu T-de圖2-12. 確定各輸入輸出變量的變化范圍、量化等級(jí)和量化因子取三個(gè)語言

4、變量的量化等級(jí)都為7級(jí),即x, y, z, = -3, -2, -1, 0, 1, 2, 3 。由于在設(shè)計(jì)控制器的時(shí)候已經(jīng)把量化因子涵蓋在程序中了,所以三個(gè)量化因子并沒有出現(xiàn)在simulink當(dāng)中。初始設(shè)定誤差e的論域?yàn)?30,30,誤差變化de的論域?yàn)?60,60,控制輸出u的論域?yàn)?9,9,此處的u是控制變化量。K1=3/30=0.1, K2=3/60, K3=9/3=33. 在各輸入和輸出語言變量的量化域內(nèi)定義模糊子集這里采用5個(gè)模糊子集,包括:PB, PS, ZE, NS, NB。模糊子集通過隸屬度函數(shù)來定義。這里采用非線性量化以提高控制精度。誤差ee-30-15-5051530-3-

5、2-10123NB10.500000NS00.50.50000ZE000.510.500PS00000.50.50PB000000.51表2-1誤差率dede-60-20-5052060-3-2-10123NB10.500000NS00.50.250000ZE000.7510.7500PS00000.250.50PB000000.51表2-2控制變化量uu-9-4.5-1.501.54.59-3-2-10123NB10.500000NS00.50.50000ZE000.510.500PS00000.50.50PB000000.51表2-34. 模糊控制規(guī)則的確定根據(jù)模糊控制規(guī)則可得出控制規(guī)則庫

6、,如下表所示。控制規(guī)則表UNBNSZEPSPBNB*PBPBPSNBNSPBPSPSZENBZEPBPSZENSNBPSPBZENSNSNBPBPBNSNBNB*表2-45. 求模糊控制表通過模糊控制表,模糊控制器可以快速地通過判斷輸入量的等級(jí)來得出相應(yīng)的輸出量,從而避免了影響實(shí)時(shí)控制的復(fù)雜計(jì)算。比如當(dāng)系統(tǒng)無處e的量化值為假設(shè)系統(tǒng)誤差e的量化值為1、誤差變化de的量化值為-2。則由控制規(guī)則表2-4可得出相應(yīng)的隸屬度值,如:對(duì)于誤差e, Unb(-2)=0.5 Uns(-2)=0.5; 誤差變化de, Uze(0)=1通過查表可知,對(duì)應(yīng)NB和ZE的控制輸出為PB;對(duì)應(yīng)NS和ZE的控制輸出為PS;

7、由模糊邏輯推理可得:Upb(-2, 0)=min(0.5, 1)=0.5, 即U1=0.5/PB;Ups(-2, 0)=min(0.5, 1)=0.5, 即U2=0.5/PS;最終通過并運(yùn)算得到輸出量U。U=U1U2=0.5/PB + 0.5/PS最后通過重心法得出U= 1×0.5+2×0.5+3×0.50.5+0.5+0.5=2同理可得其他輸出等級(jí)U,如下表模糊控制表-3-2-10123-32.672.52.52.672-0.5-2.67-22.52221-0.5-2.5-12.62.140.50.25-0.22-1.375-2.602.6720.50-0.5-

8、2-2.6712.61.3750.22-0.25-0.5-2.14-2.622.50.5-1-2-2-2-2.532.670.5-2-2.67-2.5-2.5-2.67表2-5通過找到輸出等級(jí)后再乘以相應(yīng)的量化因子K3即可得出實(shí)際的輸出量。三、程序設(shè)計(jì)程序設(shè)計(jì)流程圖3-1fuzzy_tabledegree_dedegree_edegree_dedegree_eESE開始U=U*K3Y=Y+U圖3-1四、 測(cè)試與仿真1. Simulink搭建2. 比例因子K3對(duì)響應(yīng)曲線的影響這里PID控制器選取的P=1, I=1, D=0。通過控制PID數(shù)值來研究比例因子K3對(duì)系統(tǒng)的影響。由于這里采取的是非線性

9、量化,所以輸出將由一組分段函數(shù)構(gòu)成。(1) u=-9 (degree-3)4.5×degree+4.5 (-3<degree-2)3×degree+1.5 (-2<degree-1)1.5×degree (-1<degree0)1.5×degree (0<degree<1)3×degree-1.5 (1degree<2)4.5×degree-4,5 2degree<39 (degree3)(2) u=-18 (degree-3)9×degree+9 (-3<degree-2)6

10、×degree+3 (-2<degree-1)3×degree (-1<degree0)3×degree (0<degree<1)6×degree-3 (1degree<2)9×degree-9 2degree<318 (degree3)(3) u=-30 (degree-3)15×degree+15 (-3<degree-2)10×degree+5 (-2<degree-1)5×degree (-1<degree0)5×degree (0<de

11、gree<1)10×degree-5 (1degree<2)15×degree-15 2degree<330 (degree3)(4) u=-36 (degree-3)18×degree+18 (-3<degree-2)12×degree+6 (-2<degree-1)6×degree (-1<degree0)6×degree (0<degree<1)12×degree-6 (1degree<2)18×degree-18 2degree<336 (degr

12、ee3)(5) u=-42 (degree-3)21×degree+21 (-3<degree-2)14×degree+7 (-2<degree-1)7×degree (-1<degree0)7×degree (0<degree<1)14×degree-7 (1degree<2)21×degree-21 2degree<342 (degree3)如果進(jìn)一步增大量化因子K3值,響應(yīng)曲線將會(huì)變得越來越不穩(wěn)定。因此最終數(shù)值K3取第(4)、(5)個(gè)分段函數(shù)比較好,響應(yīng)速度快,其中tp和ts都相對(duì)于不加

13、模糊控制器的曲線小,并且超調(diào)量也比不加模糊控制器的系統(tǒng)小。五、 總結(jié)這次上機(jī)編程實(shí)驗(yàn)主要目的是模糊控制器的實(shí)現(xiàn),把理論知識(shí)轉(zhuǎn)換為實(shí)際仿真運(yùn)算。由于畢竟是仿真實(shí)驗(yàn),與實(shí)際操作仍不相同,在一些數(shù)值選取,比如論域、隸屬度函數(shù)的確定,都是通過主觀意愿而不是實(shí)際經(jīng)驗(yàn)來操作的。但是關(guān)鍵部分的運(yùn)算比如模糊控制表的生成的確增強(qiáng)了我對(duì)模糊控制的理解。通過仿真可以發(fā)現(xiàn)增加了模糊控制器的系統(tǒng)的確比單純地PID調(diào)節(jié)有著更強(qiáng)的控制效果,這也是學(xué)習(xí)的成果和目標(biāo)之一。由于個(gè)人較為熟悉C語言,所以這次是用s-function中的C語言來實(shí)現(xiàn)模糊控制器的。以后可以是用.m文件來進(jìn)行編程,以利用matlab自帶的強(qiáng)大功能。六、使

14、用方法(1) 用simulink打開Artificial_Control_Design(2) 再在Matlab的Command Window中選取將要導(dǎo)入s-function中的.c文件所在的文件,如下圖。(這里的.c文件是fuzzy_control.c)(3) 編譯fuzzy_control.c,在Command Window中輸入mex fuzzy_control.c,等待編譯完成(4) 雙擊sinmulink中的s-function模塊,在s-function name中輸入fuzzy_control,然后點(diǎn)擊確定(5) 保存,并編譯(6) 運(yùn)行(7) 雙擊示波器觀測(cè)波形七、 代碼附錄/

15、* 1st: mex fuzzy_control.c 2nd: save simulink 3rd: compile simulink and run */* * sfuntmpl_basic.c: Basic 'C' template for a level 2 S-function. * * - * | See matlabroot/simulink/src/sfuntmpl_doc.c for a more detailed template | * - * * Copyright 1990-2002 The MathWorks, Inc. * $Revision: 1.

16、27.4.2 $ */ /* * You must specify the S_FUNCTION_NAME as the name of your S-function * (i.e. replace sfuntmpl_basic with the name of your S-function). */ #define S_FUNCTION_NAME fuzzy_control /modified name#define S_FUNCTION_LEVEL 2 /* * Need to include simstruc.h for the definition of the SimStruct

17、 and * its associated macro definitions. */#include "simstruc.h"char degree_e=0,degree_de=0;double degree_u=0,delta_u=0; /delta_u: the variable added to the controlled variabledouble fuzzy_table77=3, 3, 2.5, 2.67, 2, -0.5, -2.67, 2.5, 2, 2, 2, 1, -0.5, -2.5, 2.6, 2.14, 0.5, 0.25, -0.22, -1

18、.375, -2.6, 2.67, 2, 0.5, 0, -0.5, -2, -2.67, 2.6, 1.375, 0.22, -0.25, -0.5, -2.14, -2.6, 2.5, 0.5, -1, -2, -2, -2, -2.5, 2.67, 0.5, -2, -2.67, -2.5, -3, -3; /* Error handling * - * * You should use the following technique to report errors encountered within * an S-function: * * ssSetErrorStatus(S,&

19、quot;Error encountered due to ."); * return; * * Note that the 2nd argument to ssSetErrorStatus must be persistent memory. * It cannot be a local variable. For example the following will cause * unpredictable errors: * * mdlOutputs() * * char msg256; ILLEGAL: to fix use "static char msg256

20、;" * sprintf(msg,"Error due to %s", string); * ssSetErrorStatus(S,msg); * return; * * * See matlabroot/simulink/src/sfuntmpl_doc.c for more details. */ /*=* * S-function methods * *=*/ /* Function: mdlInitializeSizes = * Abstract: * The sizes information is used by Simulink to determi

21、ne the S-function * block's characteristics (number of inputs, outputs, states, etc.). */static void mdlInitializeSizes(SimStruct *S) /* See sfuntmpl_doc.c for more details on the macros below */ ssSetNumSFcnParams(S, 0); /* Number of expected parameters */MODIFIED if (ssGetNumSFcnParams(S) != s

22、sGetSFcnParamsCount(S) /* Return if number of expected != number of actual parameters */ return; ssSetNumContStates(S, 0); ssSetNumDiscStates(S, 0); if (!ssSetNumInputPorts(S, 3) return; /modified original:1 ssSetInputPortWidth(S, 0, 1); /demension of input0; ssSetInputPortRequiredContiguous(S, 0, t

23、rue); /*direct input signal access*/ ssSetInputPortWidth(S, 1, 1); /demension of input1; ssSetInputPortRequiredContiguous(S, 1, true); /*direct input signal access*/ ssSetInputPortWidth(S, 2, 1); /demension of input2; ssSetInputPortRequiredContiguous(S, 1, true); /*direct input signal access*/ /* *

24、Set direct feedthrough flag (1=yes, 0=no). * A port has direct feedthrough if the input is used in either * the mdlOutputs or mdlGetTimeOfNextVarHit functions. * See matlabroot/simulink/src/sfuntmpl_directfeed.txt. */ ssSetInputPortDirectFeedThrough(S, 0, 1); ssSetInputPortDirectFeedThrough(S, 1, 1)

25、; ssSetInputPortDirectFeedThrough(S, 2, 1); if (!ssSetNumOutputPorts(S, 1) return; ssSetOutputPortWidth(S, 0, 1); ssSetNumSampleTimes(S, 0.1); /SAMPLE TIME! ssSetNumRWork(S, 0); ssSetNumIWork(S, 0); ssSetNumPWork(S, 0); ssSetNumModes(S, 0); ssSetNumNonsampledZCs(S, 0); /* Specify the sim state compl

26、iance to be same as a built-in block */ ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE); ssSetOptions(S, 0); /* Function: mdlInitializeSampleTimes = * Abstract: * This function is used to specify the sample time(s) for your * S-function. You must register the same number of sample times as * speci

27、fied in ssSetNumSampleTimes. */static void mdlInitializeSampleTimes(SimStruct *S) ssSetSampleTime(S, 0, CONTINUOUS_SAMPLE_TIME); ssSetOffsetTime(S, 0, 0.0); #define MDL_INITIALIZE_CONDITIONS /* Change to #undef to remove function */#if defined(MDL_INITIALIZE_CONDITIONS) /* Function: mdlInitializeCon

28、ditions = * Abstract: * In this function, you should initialize the continuous and discrete * states for your S-function block. The initial states are placed * in the state vector, ssGetContStates(S) or ssGetRealDiscStates(S). * You can also perform any other initialization activities that your * S-

29、function may require. Note, this routine will be called at the * start of simulation and if it is present in an enabled subsystem * configured to reset states, it will be call when the enabled subsystem * restarts execution to reset the states. */ static void mdlInitializeConditions(SimStruct *S) #e

30、ndif /* MDL_INITIALIZE_CONDITIONS */ #define MDL_START /* Change to #undef to remove function */#if defined(MDL_START) /* Function: mdlStart = * Abstract: * This function is called once at start of model execution. If you * have states that should be initialized once, this is the place * to do it. *

31、/ static void mdlStart(SimStruct *S) #endif /* MDL_START */ /* Function: mdlOutputs = * Abstract: * In this function, you compute the outputs of your S-function * block. */static void mdlOutputs(SimStruct *S, int_T tid) /real_T *para1 = mxGetPr(ssGetSFcnParam(S,0); /real_T *para2 = mxGetPr(ssGetSFcn

32、Param(S,1); /real_T *para3 = mxGetPr(ssGetSFcnParam(S,2); const real_T *u1 = (const real_T*) ssGetInputPortSignal(S,0); const real_T *u2 = (const real_T*) ssGetInputPortSignal(S,1); const real_T *u3 = (const real_T*) ssGetInputPortSignal(S,2); real_T *y = ssGetOutputPortSignal(S,0); /*convert the in

33、put e into the degree of control*/ if(u10 > 0) if(u10 < 5) degree_e = 1;/5 else if(u10 < 15) degree_e = 2;/15 else degree_e = 3; else if(u10 < 0) if(u10 > -5) degree_e = -1; else if(u10 > -15) degree_e = -2; else degree_e = -3; else degree_e = 0; /*convert the input de into the deg

34、ree of control*/ if(u20 > 0) if(u20 < 5) degree_de = 1;/5 else if(u20 < 20) degree_de = 2;/20 else degree_de = 3; else if(u20 < 0) if(u20 > -5) degree_de = -1; else if(u20 > -20) degree_de = -2; else degree_de = -3; else degree_de = 0; degree_u = fuzzy_tabledegree_de+3degree_e+3; i

35、f(degree_u > 0) /delta_u=3*degree_u;/18.15 if(degree_u < 1) delta_u = 20*degree_u;/1.5 * degree_u;/6*degree_u;/7 * degree_u;/3*degree_u;/5 * degree_u; /1.5 * degree_u; else if(degree_u < 2) delta_u =40*degree_u-20;/3 * degree_u - 1.5;/12*degree_u-6;/14 * degree_u - 7;/ 6*degree_u-3;/10 * de

36、gree_u - 5;/3 * degree_u - 1.5; else if (degree_u < 3) delta_u = 60*degree_u-60;/4.5 * degree_u - 4.5;/18*degree_u-18;/21 * degree_u - 21;/9*degree_u-9;/15 * degree_u - 15;/4.5 * degree_u - 4.5; else delta_u = 120;/18;/9; else /delta_u=degree_u*3;/18.15 if(degree_u > -1) delta_u = 20 * degree_

37、u;/7 * degree_u;/ 3*degree_u;/ 5 * degree_u;/1.5 * degree_u; else if(degree_u > -2) delta_u = 40 * degree_u + 20;/14 * degree_u + 7;/6*degree_u+3;/10 * degree_u + 5;/3 * degree_u + 1.5; else if (degree_u > -3) delta_u = 60 * degree_u + 60;/18*degree_u+18;/21 * degree_u + 21;/ 9*degree_u+9;/15

38、* degree_u + 15;/4.5 * degree_u + 4.5; else delta_u = -120;/-42;/-18;/-9; y0 = u30 + delta_u;/+20; /*degree_e=0; degree_de=0; degree_u=0; delta_u=0;*/ #define MDL_UPDATE /* Change to #undef to remove function */#if defined(MDL_UPDATE) /* Function: mdlUpdate = * Abstract: * This function is called once for ev

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論