Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 78 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
78
Dung lượng
3,14 MB
Nội dung
AProf.Dr Tu Diep Cong Thanh HCMC University of Technology IntroductiontoIntelligentControlIntroductiontoIntelligentControlIntroduction Neural Network (NN) 2.1 Overview 2.2 Neural Network Computation 2.3Training 2.4 Neural Network Controller 2.5 Building Neural Network Controller with Matlab 2.6 Summary Fuzzy Logic (FL) 3.1 Overview 3.2 Foundations of Fuzzy Logic 3.3 Fuzzy Inference System 3.4 Building systems with Fuzzy Logic Toolbox - Matlab 3.5 Sugeno-Type Fuzzy Inference 3.6 Summary Conclusions Page: IntroductiontoIntelligentControl AProf.Dr Tu Diep Cong Thanh HCMC University of Technology Page: Introduction The subject of automatic controls is enormous, covering the control of variables such as temperature, pressure, flow, level, and speed Example 1.1: Control the velocity of motor U Fig 1.1 A Simple control motor’s velocity Assume here are the velocity speeds of motor: Control signal Set point Control value (assume) U=15 Voltage 2000 RPM 2000 (t=0:1500s) 1800 1600 1400 1200 1000 800 600 400 200 U=18 Voltage (t=0:3s) 2000 RPM 10 10 10 2500 2000 U=15 Voltage (t=3:10s) 1500 1000 500 U=24 Voltage (t=0:1.5s) 2000 RPM 3000 2500 U=10 Voltage (t=1.6 – 3.5s) 2000 1500 U=18 Voltage (t=3.6 :5.5s) 1000 500 U=15 Voltage (t=5.6 : 10s) AProf.Dr Tu Diep Cong Thanh HCMC University of Technology IntroductiontoIntelligentControl Page: And therefore, control signal is the most important for your control strategies Assume )݅(ݑis control signal at present time, and it is given ݅(ݑ = )݅(ݑ− 1) + ∆( ݑ1.1) Here, ∆ ݑis the value added and it is depended on your control methods Example 1.2: A simple of control system (*) Fig 1.2 Manual control of a simple process In the process example shown (Figure 1.2), the operator manually varies the flow of water by opening or closing an inlet valve to ensure that: The outcome of this is that the water runs out of the tank at a rate within a required range At an initial stage, the outlet valve in the discharge pipe is fixed at a certain position The operator has marked three lines on the side of the tank to enable him to manipulate the water supply via the inlet valve The ideal level between level and level The Example (Figure 1.1) demonstrates that: o The flow valve is referred to as the Controlled Device o To operate the controlled device is known as Control Signal o The water itself is known as the Control Agent o The change in water level is known as the Controlled Variable o The level of water trying to be maintained is known as the Set Point o The water level at steady state conditions, referred to as the Control Value o The difference between the Set Point and the Control Value is Deviation o If the inlet valve is closed to a new position, the water level will drop and the deviation will change A sustained deviation is known as Offset (*):http://www.spiraxsarco.com/resources/steam-engineering-tutorials/basic-control-theory/an-introduction-to-controls.asp AProf.Dr Tu Diep Cong Thanh HCMC University of Technology IntroductiontoIntelligentControl Page: Elements of automatic control Fig 1.3 Elements of automatic control o The operator's eye detects movement of the water level against the marked scale indicator His eye could be thought of as a Sensor o The eye (sensor) signals this information back to the brain, which notices a deviation The brain could be thought of as a Controller o The brain (controller) acts to send a signal to the arm muscle and hand, which could be thought of as an Actuator o The arm muscle and hand (actuator) turn the valve, which could be thought of as a Controlled Device AProf.Dr Tu Diep Cong Thanh HCMC University of Technology IntroductiontoIntelligentControl Page: Example 1.3: Depicting a simple manual temperature control system (*) The task is to admit sufficient steam (the heating medium) to heat the incoming water from a temperature of Tଵ ; ensuring that hot water leaves the tank at a required temperature of Tଶ Fig 1.4 Simple manual temperature control Fig 1.5 Typical mix of process control devices with system element AProf.Dr Tu Diep Cong Thanh HCMC University of Technology IntroductiontoIntelligentControl Page: (*):http://www.spiraxsarco.com/resources/steam-engineering-tutorials/basic-control-theory/an-introduction-to-controls.asp Note: There are three major reasons why process plant or buildings require automatic controls: o Safety - The plant or process must be safe to operate o Stability - The plant or processes should work steadily, predictably and repeatably, without fluctuations or unplanned shutdowns o Accuracy - This is a primary requirement in factories and buildings to prevent spoilage, increase quality and production rates, and maintain comfort These are the fundamentals of economic efficiency Other desirable benefits such as economy, speed, and reliability are also important, but it is against the three major parameters of safety, stability and accuracy that each control application will be measured How tocontrol the system? A closed-loop controller uses feedback tocontrol states or outputs of a dynamical system Its name comes from the information path in the system: process inputs (e.g voltage applied to an electric motor) have an effect on the process outputs (e.g velocity or torque of the motor), which is measured with sensors and processed by the controller; the result (the control signal) is used as input to the process, closing the loop Closed-loop controllers have the following advantages over open-loop controllers: o Disturbance rejection (such as unmeasured friction in a motor) o Guaranteed performance even with model uncertainties, when the model structure does not match perfectly the real process and the model parameters are not exact o Unstable processes can be stabilized o Reduced sensitivity to parameter variations o Improved reference tracking performance In some systems, closed-loop and open-loop control are used simultaneously In such systems, the open-loop control is termed feed-forward and serves to further improve reference tracking performance AProf.Dr Tu Diep Cong Thanh HCMC University of Technology IntroductiontoIntelligentControl Page: Classical Control Theory: (*) o Classical control techniques can be broken up into Frequency Domain techniques and Time Domain techniques Frequency Domain techniques are a suite of analysis and design tools that include Root Locus, Pole Placement, Bode Plots, and Nyquist State-Space techniques are the only part of Classical control that is done in the Time Domain o The limitations of Classical Control are: Assume that the system we are trying tocontrol is a linear system and model (the transfer function of the system) should be given as well as initial condition should be equal by zero Modern Control Theory: (*) o In contrast to the frequency domain analysis of the classical control theory, modern control theory utilizes the time-domain state space representation, a mathematical model of a physical system as a set of input, output and state variables related by first-order differential equations o To abstract from the number of inputs, outputs and states, the variables are expressed as vectors and the differential and algebraic equations are written in matrix form (the latter only being possible when the dynamical system is linear) The state space representation (also known as the "time-domain approach") provides a convenient and compact way to model and analyze systems with multiple inputs and outputs With inputs and outputs, we would otherwise have to write down Laplace transforms to encode all the information about a system o Unlike the frequency domain approach, the use of the state space representation is not limited to systems with linear components and zero initial conditions "State space" refers to the space whose axes are the state variables The state of the system can be represented as a vector within that space IntelligentControl Theory: (**) o Intelligentcontrol is a class of control techniques, that use various artificial intelligent computing approaches like neural networks, Bayesian probability, fuzzy logic, machine learning, evolutionary computation and genetic algorithms (*):http://en.wikipedia.org/wiki/Control_theory#Classical_control_theory (**):http://www.nd.edu/~pantsakl/control.html AProf.Dr Tu Diep Cong Thanh HCMC University of Technology IntroductiontoIntelligentControl Page: o Intelligentcontrol does not restrict itself only to those methodologies In fact, according to some definitions of intelligentcontrol (not all neural/fuzzy controllers) would be considered intelligent The fact is that there are problems of control which cannot be formulated and studied in the conventional differential/difference equation mathematical framework To address these problems in a systematic way, a number of methods have been developed that are collectively known as intelligentcontrol methodologies o The area of intelligentcontrol is in fact interdisciplinary, and it attempts to combine and extend theories and methods from areas such as control, computer science and operations research to attain demanding control goals in complex systems o In intelligentcontrol problems there may not be a clear separation of the plant and the controller; the control laws may be imbedded and be part of the system to be controlled This opens new opportunities and challenges as it may be possible to affect the design of processes in a more systematic way Conclusions o Goal: Control system that works the same our desire o System: Complex, uncertainty and nonlinearity and cannot derive the mathematic equations o Control strategies: Computing the value added for next step that help the system reaches to the desire goal o Control method: Intelligentcontrol that uses artificial intelligent computing without regard the mathematic model of system IntroductiontoIntelligentControl AProf.Dr Tu Diep Cong Thanh HCMC University of Technology Page: Neural Network (NN) 2.1Overview (*) An artificial neural network is a system based on the operation of biological neural networks, in other words, is an emulation of biological neural system Neural networks were started about 60 years ago Their early abilities were exaggerated, casting doubts on the field as a whole There is a recent renewed interest in the field, however, because of new techniques and a better theoretical understanding of their capabilities Human Brain: The human brain contains about 10 billion nerve cells, or neurons On average, each neuron is connected to other neurons through about 10 000 synapses The brain's network of neurons forms a massively parallel information processing system Biological neuron: The basic computational unit in the nervous system is the nerve cell, or neuron A neuron has: Dendrites (inputs), Cell body, Axon (output) and is shown in Fig 2.1 Fig 2.1 Biological neuron A neuron receives input from other neurons (typically many thousands) Inputs sum (approximately) Once input exceeds a critical level, the neuron discharges a spike - an electrical pulse that travels from the body, down the axon, to the next neurons or other receptors (*)http://www.willamette.edu/~gorr/classes/cs449/brain.html IntroductiontoIntelligentControl AProf.Dr Tu Diep Cong Thanh HCMC University of Technology Page: 10 The axon endings (Output Zone) almost touch the dendrites or cell body of the next neuron Transmission of an electrical signal from one neuron to the next is effected by neurotransmitters, chemicals which are released from the first neuron and which bind to receptors in the second This link is called a synapse The extent to which the signal from one neuron is passed on to the next depends on many factors, e.g the amount of neurotransmitter available, the number and arrangement of receptors, amount of neurotransmitter reabsorbed, etc Synaptic Learning: Brains learn Of course, from what we know of neuronal structures, one way brains learn is by altering the strengths of connections between neurons, and by adding or deleting connections between neurons Furthermore, they learn "on-line", based on experience, and typically The efficacy of a synapse can change as a result of experience, providing both memory and learning through long-term potentiation One way this happens is through release of more neurotransmitter Many other changes may also be involved Fig 2.2 Synaptic Learning Artificial Neuron Models Once modeling an artificial functional model from the biological neuron, we must take into account three basic components First off, the synapses of the biological neuron are modeled as weights Let’s remember that the synapse of the biological neuron is the one which interconnects the neural network and gives the strength of the connection IntroductiontoIntelligentControl AProf.Dr Tu Diep Cong Thanh HCMC University of Technology 2.5 Building Neural Network Controller with Matlab Taking advance of Z transform At first, we think about how to compute the output of system? Fig 2.65 Example of system From Newton’s Law, we have: ࢌ(࢚) = ࡹ࢟ሷ (࢚) + ࢟ሶ (࢚) + ࡷ࢟(࢚) To solve y=dsolve ('M*D2y+B*Dy+K*y=F') With initial condition y = dsolve ('M*D2y+B*Dy+K*y=F','y(0)=0', 'y(1)=0') Assume: M=1, B=0.8 K=0.7, F=1 y = dsolve ('1*D2y+0.8*Dy+0.7*y=1','y(0)=0', 'y(1)=0') And we can see the output which is given from Simulink: Fig 2.66 Simulation results Page: 64 IntroductiontoIntelligentControl AProf.Dr Tu Diep Cong Thanh HCMC University of Technology Page: 65 The question is how the Simulink does? Another example: Fig 2.67 Example of variant system In case of damping parameter changes, can we simulate the system? The limitations of Simulink are as follows: - We not exactly know how does the Simulink work And It may be using numerical method or another solution which are so difficult to use - It is difficult to simulate the system with the frequently change of parameters - We cannot touch the Simulink for convenience Note: It is needed to know the output of system in every step of sampling time as well as the initial condition we can simulate the system in every step by step of sampling time 1.8 1.6 1.4 1.2 0.8 0.6 0.4 0.2 0 Fig 2.68 Simulation result with Matlab 10 IntroductiontoIntelligentControl AProf.Dr Tu Diep Cong Thanh HCMC University of Technology Page: 66 Matlab code(lsim fuction) Ts=0.01 t=0:Ts:10 u=ones(size(t)); num=[1] den=[1 0.8 0.7] [a,b,c,d]=tf2ss(num,den) x0=[0 0]; Y=[0] utam=[0 0]; for i=2:length(t) [y,x]=lsim(a,b,c,d,utam,[0 0.01],x0); Y=[Y y(2,:)]; x0=x(2,:); utam=[utam(1,2) u(i)]; end plot(t,Y,'r') hold on plot(t,u) 1.8 1.6 1.4 1.2 0.8 0.6 0.4 0.2 0 10 Fig 2.69 Simulation result with Matlab – lsim function AProf.Dr Tu Diep Cong Thanh HCMC University of Technology Matlab code(lsim fuction with variant system) Ts=0.01 t=0:Ts:10 u=ones(size(t)); num=[1] den=[1 0.8 0.7] [a,b,c,d]=tf2ss(num,den) x0=[0 0]; Y=[0] utam=[0 0]; for i=2:length(t) [y,x]=lsim(a,b,c,d,utam,[0 0.01],x0); if i==500 den=[1 0.3 0.7] [a,b,c,d]=tf2ss(num,den) end Y=[Y y(2,:)]; x0=x(2,:); utam=[utam(1,2) u(i)]; end plot(t,Y,'r') hold on plot(t,u) IntroductiontoIntelligentControl Page: 67 IntroductiontoIntelligentControl AProf.Dr Tu Diep Cong Thanh HCMC University of Technology Page: 68 Problem with simulating LSIM function? - We cannot know exactly how about of LSIM as well as how LSIM works? - Can we find another solution to compute the output of system and especially in case of the parameters of system change frequently The advantages of Z transform Let’s taking advantages of Z transform as follows: - Convert S to Z transform using c2dm num=[1] den=[1 0.8 0.7] tf=tf(num,den) Ts=0.01 [NUMd,DENd]=c2dm(num,den,Ts,'zoh') We have: NUMd = 1.0e-004 * 0.4987 0.4973 b=[b0 b1 b2 …] DENd = 1.0000 -1.9920 0.9920 a=[a0 a1 a2 ….] ܻ(ܾ ݀ܯܷܰ )ݖ0 + ܾ1 ∗ ି ݖଵ + ܾ2 ∗ ି ݖଶ = ) ݖ( ܩ = = ܷ(ܽ ݀ܰܧܦ )ݖ0 + ܽ1 ∗ ି ݖଵ + ܽ2 ∗ ି ݖଶ a0*Y(0) + a1*Y(1) + a2*y(2) + …= b0*U(0) + b1*U(1) + b2*U(2) + Note: Y(1) is Y(0) which is delayed one sampling time Matlab code (digital control – z transform) clear Ts=0.01 t=0:Ts:10 r=ones(size(t)); num=[1] den=[1 0.8 0.7] [NUMd,DENd]=c2dm(num,den,Ts,'zoh'); b0=NUMd(1,1); b1=NUMd(1,2); b2=NUMd(1,3); a0=DENd(1,1); IntroductiontoIntelligentControl AProf.Dr Tu Diep Cong Thanh HCMC University of Technology Page: 69 a1=DENd(1,2); a2=DENd(1,3); y1=0; y2=0; y3=0; u1=0; u2=0; u3=0; Y=[]; for i=1:length(t) u0=r(1,i); y0=-a1*y1-a2*y2 + b0*u0 + b1*u1 + b2*u2 ; y2=y1;y1=y0; u2=u1;u1=u0; Y=[Y;y0]; end plot(t,Y,'r') hold on plot(t,r) 1.8 1.6 1.4 1.2 0.8 0.6 0.4 0.2 0 Fig 2.70 Simulation result with Matlab – (z transform) 10 AProf.Dr Tu Diep Cong Thanh HCMC University of Technology IntroductiontoIntelligentControl Page: 70 Remark: - We can directly compute the output of system using Z transform - The equation is simple - We can compute the output of system at every step of sampling time, and it is convenience for simulating system even if the parameters of system frequently change - From that idea, it is helpful to compute the output of any function at anytime by using z transform - Using z transform, we can simulate any control system Fig 71 Example with various controller and plant IntroductiontoIntelligentControl AProf.Dr Tu Diep Cong Thanh HCMC University of Technology Page: 71 Simulation with simple neural network controller Nonlinear PID based on neural network This is the schematic diagram of control system Fig 2.72 Nonlinear PID based on neural network Where neural network controller is as follow: f ( x) = 2(1 − e − x*Yg ) Yg (1 + e − x*Yg ) Fig 2.73 Structure of simple neural network Form of f(x) is given as below Fig 2.74 active function u = f (x) IntroductiontoIntelligentControl AProf.Dr Tu Diep Cong Thanh HCMC University of Technology Page: 72 x( k ) = K p (k ) e p ( k ) + K i ( k )ei (k ) + K d (k ) ed ( k ) Fig 2.75 Computation of neural network E (k ) = (θ f (k ) − θ (k ) )2 K p (k + 1) = K p (k ) − η p ∂E (k ) ∂K p K i (k + 1) = K i (k ) −η i ∂E (k ) ∂K i K d (k + 1) = K d (k ) − η d ∂E (k ) ∂K d ∂E (k ) ∂E (k ) ∂θ (k ) ∂u (k ) ∂x(k ) = ∂K p ∂θ ∂u ∂x ∂K p ∂E (k ) ∂E (k ) ∂θ (k ) ∂u (k ) ∂x(k ) = ∂K i ∂θ ∂u ∂x ∂K i ∂E (k ) ∂E (k ) ∂θ (k ) ∂u (k ) ∂x(k ) = ∂K d ∂θ ∂u ∂x ∂K d ∂E (k ) = −(θ f (k ) − θ (k )) = −e p (k ) ∂θ ∂u (k ) = f ' ( x(k )) ∂x ∂x(k ) = e p (k ); ∂K p e p (k ) = θ f (k ) − θ (k ) k ei (k ) = ∑ e p (n)∆T n =1 e p (k )(1 − z −1 ) ∆T ∆T : sampling time, z : operator of Z − transform ed ( k ) = k : discrete sequence ∂E (k ) ∂E (k ) ∂θ (k ) ∂u (k ) ∂x(k ) = ∂K p ∂θ ∂u ∂x ∂K p ∂θ (k ) f ' ( x(k ) )e p (k ) ∂u ∂θ (k ) =− f ' ( x(k ) )e 2p (k ) ∂u ∂E (k ) ∂E (k ) ∂θ (k ) ∂u (k ) ∂x(k ) = ∂K i ∂θ ∂u ∂x ∂K i = −e p ( k ) = −e p ( k ) ∂θ (k ) f ' ( x(k ) )e p (k )ei (k ) ∂u ∂E (k ) ∂E (k ) ∂θ (k ) ∂u (k ) ∂x(k ) = ∂K d ∂θ ∂u ∂x ∂K d =− ∂x(k ) = ei (k ); ∂K i = −e p ( k ) ∂x(k ) = ed (k ) ∂K d =− f ′( x) = e − x*Yg (1 + e − x*Yg ) ∂θ (k ) f ' ( x(k ) )e i (k ) ∂u ∂θ (k ) f ' ( x(k ) )e d (k ) ∂u ∂θ (k ) f ' ( x(k ) )e p (k )ed (k ) ∂u ∂θ (k ) =1 ∂u IntroductiontoIntelligentControl AProf.Dr Tu Diep Cong Thanh HCMC University of Technology K p (k + 1) = K p (k ) + η p e p (k )e p (k ) K i (k + 1) = K i (k ) + ηi e p (k )ei (k ) Page: 73 4e − x*Yg (1 + e − x*Yg ) 4e − x*Yg (1 + e − x*Yg ) K d (k + 1) = K d (k ) + η d e p (k )ed (k ) 4e − x*Yg (1 + e − x*Yg ) Simulation with Matlab 1.4 1.2 0.8 0.6 0.4 0.2 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 -3 70 1.2 x 10 60 50 0.8 40 Kp Ki 0.6 30 0.4 20 0.2 10 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.05 0.1 0.15 0.45 0.5 0.2 0.25 0.3 0.35 0.4 0.25 0.2 0.15 0.1 Kd 0.05 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 Fig 2.76 Simulation results of simple neural network controller 0.45 0.5 AProf.Dr Tu Diep Cong Thanh HCMC University of Technology IntroductiontoIntelligentControl %nonlinear PID COntroller using Neural Network clear Time=.5; Ts=0.001; t=0:Ts:Time; %input of system: r r=ones(size(t)); wo=50; Ao=[0 1; -wo*wo -2*wo]; Bo=[0 wo*wo]'; Co=[1 0]; Do=0; [numd,dend]=ss2tf(Ao,Bo,Co,Do); [numdd,dendd]=c2dm(numd,dend,Ts,'tustin'); b0=numdd(1,1); b1=numdd(1,2); b2=numdd(1,3); a0=dendd(1,1); a1=dendd(1,2); a2=dendd(1,3); y1=0; y2=0; y3=0; u1=0; u2=0; u3=0; Y=[]; for i=1:length(t) Page: 74 AProf.Dr Tu Diep Cong Thanh HCMC University of Technology u0=r(1,i); y0=-a1*y1-a2*y2 + b0*u0 + b1*u1 + b2*u2 ; %Update y2=y1; y1=y0; u2=u1; u1=u0; Y=[Y;y0]; end ym=Y; ymdot(1)=0; for i=2:length(t) ymdot(i)=(ym(i)-ym(i-1))/Ts; end t_tmp=[0 Ts]; x0=[0 0]'; y0=[0 0]'; u_tmp=[0 0]; y_tmp=[0 0]; X=x0'; Y=y0'; num=740; dem=[1 13 0]; [As Bs Cs Ds]=tf2ss(num,dem); %initial start Kp(1)=0; Ki(1)=0; Kd(1)=0; Kp(2)=1; IntroductiontoIntelligentControl Page: 75 AProf.Dr Tu Diep Cong Thanh HCMC University of Technology IntroductiontoIntelligentControl Ki(2)=0.001; Kd(2)=0.1; %neural papameter n1=15; n2=0.002; n3=0.001; %%initial t_tmp=[0 Ts]; x0=[0 0]'; X=x0'; u_tmp=[0 0]; ep(1)=0; ei(1)=0; ed(1)=0; x(1)=0; u(1)=0; eisum=0; xg=10; y(1)=0; ydot(1)=0; alpha=0.9; delta_kp=0; delta_ki=0; delta_kd=0; for i=2:length(t) [ytmp,ztmp]=lsim(As,Bs,Cs,Ds,u_tmp,t_tmp,x0); y(i)=ytmp(2,:); ydot(i)=(y(i)-y(i-1))/Ts; Page: 76 AProf.Dr Tu Diep Cong Thanh HCMC University of Technology IntroductiontoIntelligentControl state_now=ztmp(2,:); x0=state_now'; X=[X;state_now]; ep(i)=ym(i)-y(i); ei(i)=ep(i)*Ts+ eisum; eisum=ei(i); ed(i)=(ymdot(i)-ydot(i)); x(i)=Kp(i)*ep(i)+Ki(i)*ei(i)+Kd(i)*ed(i); u(i)=(xg*(1-exp(-4*x(i)/xg)))/(2*(1+exp(-4*x(i)/xg))); u_tmp=[u_tmp(1,2) u(i)]; fdot=(4*exp(-4*x(i)/xg)/(2+2*exp(-4*x(i)/xg))+ 8*(1-exp( 4*x(i)/xg))/(2+2*exp(4*x(i)/xg))^2*exp(-4*x(i)/xg)); delta_kp=alpha*delta_kp-n1*(y(i)-ym(i))*ep(i)*fdot; delta_ki=alpha*delta_ki-n2*(y(i)-ym(i))*ei(i)*fdot; delta_kd=alpha*delta_kd-n3*(y(i)-ym(i))*ed(i)*fdot; if i