Home
LabVIEW Control Design User Manual
Contents
1. fever b fo i a Evo y F MPC Controller CD Create MPC FIFO vi MPC Controller CO Read MPC FIFO vi CD Implement MPC Controller vi 2 a Xj Re Build Array om MPC FIFO m Output Reference luik ios Signal Type E FIFO Loop 2 Discrete State Space Plant Lie Collector J Closed Loop el rol Response IPC Controller CD write MPC FIFO vi zo T ap Gj IMPC FIFO m Interleaved Profile peu m Figure 18 5 Updating Profile Information Dynamically Note The example in Figure 18 5 is similar to the CDEx MPC with RT FIFO VI located in the labview examples Control and Simulation Control Design MPC directory The example in Figure 18 5 executes the following steps 1 The CD Create MPC FIFO VI creates a FIFO for the specified MPC Controller The Signal Type parameter specifies that this FIFO contains information about the output setpoint profile You also can create a FIFO for input setpoint and disturbance profiles 2 The CD Write MPC FIFO VI writes values of the Interleaved Profile to the FIFO This profile contains output setpoint values you specify 3 The CD Read MPC FIFO VI reads values from the FIFO removes these values from the FIFO and sends these values to the Output Reference Window input of the CD Implement MPC Controller VI This step occurs
2. Continuous Nonlinear Noisy Plant seje Ez o o bchat t E al Ha Continuous Extended Kalman Filter Figure 16 4 Implementing the Continuous Extended Kalman Filter Function The Continuous Extended Kalman Filter function calculates the estimated states and estimated outputs of the plant model The following figure illustrates the resulting graph of the estimated states and estimated outputs National Instruments Corporation 16 13 Control Design User Manual Chapter 16 Using Stochastic System Models Control Design User Manual x_trueft im xit x_msmt t AF Simulation Time 1 40 00 Simulation Time Figure 16 5 Estimated States and Outputs Calculated by the Continuous Extended Kalman Filter Function In the previous figure note that the state dynamics are linear but the measurements are nonlinear The x and y positions of the estimated states closely match the true system states Using the Discrete Extended Kalman Filter Function The Discrete Extended Kalman Filter function calculates the estimated states predicted states and estimated outputs of a discrete nonlinear stochastic state space model The Discrete Extended Kalman Filter function estimates the states for a discrete nonlinear plant model defined by the following equations x k 1 f x u k w k y k A x u k v
3. Figure 14 12 Standalone without Estimator State Regulator with Integral Action The states inputs and outputs of the state regulator with integral action are l i and f respectively Z LY y Example System Configurations 3 Control Design User Manual The following equations define an example second order SISO state space model with poles at 0 2 and 0 1 ate vel y 1 ox ol You can implement a full state controller for this system because this system is controllable To implement a state controller for this system you must calculate the controller gain matrix K for the model of the system Use the CD Ackermann VI to calculate K by placing the poles of the matrix A BK at 1 1 This location is to the left of the original pole location in the complex plane You can use this controller gain matrix K along with the CD State Space Controller VI to study the performance of the compensator Note Use the CD Controllability Matrix VI to verify that this system is observable Use the CD Pole Zero Map VI to determine the initial location of the system poles 14 20 ni com Chapter 14 Defining State Space Controller Structures Figure 14 13 shows the response of the example system to initial conditions of 2 1 This system is unstable because the response increases exponentially and does not settle at a steady state value State Trajectory Graph 4 5 xiModel x2Mode
4. While Loop amplitude Vv DELH lost Sine Wave PtByPt vi CEN foput ul Output yik i ma fe XScale Multiplier i pe gt Discrete Stochastic State Space output y k State x k gs ee marl ing Ti Ty iti eters bxScale Multiplier Initial State x 0 fieu 1u pe Construct and E Discretize Models vi Erop TER Figure 16 14 Simulating the Discrete Stochastic State Space Model In Figure 16 14 the Construct and Discretize Models subVI contains the block diagram code shown in Figure 16 13 The Wait Until Next ms Multiple function adjusts the speed of the simulation Also this example uses Property Nodes to adjust the scale of the resulting graphs based on the Frequency of the sine wave National Instruments Corporation 16 27 Control Design User Manual Chapter 16 Using Stochastic System Models Figure 16 15 shows the Output y k and the State x k of the model when you run this example Figure 16 15 Output and State Trajectories of the Discrete Stochastic State Space Model In Figure 16 15 notice the noise present in the graph of Output y k Control Design User Manual 16 28 ni com Chapter 16 Using Stochastic System Models Implementing a Kalman Filter As defined in Table 16 3 the state in this example represents the current flowing through the RL circuit If this example were a real world circuit you could use an ammeter to measure the current flowing through the circuit
5. ICD Ackermann vi Compensator Y bs re er la Fa to EHE eE Gaussian White Noise vi cos Figure 14 16 System Included with Noise State Compensator gt Controller Gain_ The system included with noise configuration analyzes the effect of output noise on the system This example has a total of three inputs to the compensator structure The first two inputs are setpoints to the controller given by r 1 0 The last input represents the output noise r which has a standard deviation of 0 01 Figure 14 17 shows the response to these inputs State Trajectory Graph 900m 800m 700m n 600m E 500m 4 TF 400m 2 300m xiSystem x2System Time s Figure 14 17 State Trajectory of System Included State Compensator with Noise Control Design User Manual 14 24 ni com Chapter 14 Defining State Space Controller Structures Notice that the state compensator lacks integral action which originates the offsets on the state responses with respect to their respective setpoints Therefore the states do not reach the specified setpoints r 1 0 Example Standalone with Estimator State Compensator Most systems are complex and have many parameters and uncertainties You often do not know all the parameters of a system when you create a model of that system or you cannot create a model that encompasses all the uncertainties of the system Thus the actua
6. Figure 5 9 Initial Response Graph of the Spring Mass Damper System Notice that the displacement begins at the initial condition of 0 3 cm National Instruments Corporation 5 9 Control Design User Manual Chapter 5 Time Response Analysis Analyzing a General Time Domain Simulation A general time domain simulation of a system involves input signals that are more general than step impulse or initial input signals Refer to the Calculating the Time Domain Solution section of this chapter for equations representing the time response of continuous and discrete systems Use the CD Linear Simulation VI to solve these equations in response to an arbitrary input signal u into a system This VI determines the response by numerically integrating these equations at the specified time steps You can define the time steps with the Delta t input The system model can be continuous or discrete but the CD Linear Simulation VI converts continuous models to discrete models using either the exponential Zero Order Hold or the First Order Hold method Refer to the Converting Continuous Models to Discrete Models section of Chapter 3 Converting Models for more information about these methods If this conversion is necessary you must specify Delta t which becomes the sampling time If no conversion is necessary Delta t must be equal to the sampling time of the output data u t 3 Note For accurate results use a sampling interval that is sma
7. Figure 4 18 Two Models with Output Connections Defined Control Design User Manual 4 16 ni com Chapter 4 Connecting Models Feedback Connections Defined Output Connections Undefined If you define Feedback Connections but not Output Connections the CD Feedback VI feeds the outputs specified for Model 2 back to the specified inputs for Model 1 You define whether the feedback connection is positive or negative Because you have not defined Output Connections the CD Feedback VI tries to connect all outputs of Model 1 positively to the inputs in Model 2 The resulting model shown in Figure 4 19 contains a new reference input ro for each feedback connection you have defined Up lo Up Vo gt gt Vo uy gt O Feedback A Model 1 d Connections p i Vo mI gt 2 Output i l v 4 Connections ___ 1a Model 2 R gt Figure 4 19 Two Models with Feedback Connections Defined National Instruments Corporation 4 17 Control Design User Manual Chapter 4 Connecting Models Both Feedback and Output Connections Defined If you specify connections in both Feedback Connections and in Output Connections you define all connections Based on the connections you specified in Output Connections the outputs specified for Model 1 are connected to the inputs specified for Model 2 You define whether the c
8. On the block diagram of the SIM Discrete Nonlinear Plant Model template VI you can use either VIs and functions or text based scripts in the MathScript Node to define this model The following figure defines this discrete model using the SIM Discrete Nonlinear Plant Model template VI Example Lab IEW Code State x t CD Generalized Ax vi Figure 16 7 SIM Discrete Nonlinear Plant Model Template VI Modified with Example LabVIEW Code 16 18 ni com Chapter 16 Using Stochastic System Models Adding Noise to the Discrete Plant Model After you define the plant model use the Discrete Nonlinear Noisy Plant function to add noise to the model Wire a reference to the SIM Discrete Nonlinear Plant Model template VI to the Plant Model input of the Discrete Nonlinear Noisy Plant function to simulate the plant model corrupted by additive noise Control amp Simulation Loop Figure 16 8 The SIM Discrete Nonlinear Plant Model template VI modified with LabVIEW code and wired to the Discrete Nonlinear Noisy Plant function The Discrete Nonlinear Noisy Plant function simulates the plant dynamics according to the following equations x t f x u t w t y t A x u t v t x k 1 f x u k w k y k A x u k v k where w is the process noise vector and v is the measurement noise vector You can use the Internal Noise instance of the Discrete Nonlinear Noisy Plant function to genera
9. Chapter 2 Constructing Dynamic System Models The CD Construct State Space Model VI creates a continuous model You create a discrete state space model in the same way you create a discrete transfer function model Refer to the SISO Transfer Function Models section of this chapter for more information about creating a discrete state space model SIMO MISO and MIMO State Space Models You construct a SIMO MISO or MIMO state space model by ensuring the output matrix C and the input matrix B have the appropriate dimensions For a SIMO system construct an output matrix C with more than one row For a MISO system construct an input matrix B with more than one column For a MIMO system construct matrices C and B with more than one row and column respectively When you create a SIMO MISO or MIMO system ensure that the direct transmission matrix D has the appropriate dimensions If you leave D empty or unwired the Control Design and Simulation Module replaces the missing values with zeros Symbolic State Space Models You create symbolic state space models the same way you create a symbolic transfer function model Refer to the Symbolic Transfer Function Models section of this chapter for more information about creating a symbolic system model Obtaining Model Information Each of the Model Construction VIs creates not only a data structure that defines the model but also a set of properties that provide information about the
10. p Model 2 y 1 e e i e e i 1 o e Vk Yi i e Figure 4 8 Appended Models For example consider the two tanks from the Creating a SIMO System in Series section of this chapter The following equations define the transfer functions of the tanks K K Hae Hos K and are the gains of their respective transfer functions Appending H s and Hp s results in the following appended matrix transfer function H A s 0 0 HAy s H t National Instruments Corporation 4 7 Control Design User Manual Chapter 4 Connecting Models Figure 4 9 uses the block diagram from Figure 4 5 but replaces the Tanks input with H As in Figure 4 5 the two valves are connected in series with each other In Figure 4 9 however the two tanks now are appended to each other Figure 4 9 Appending the Two Tanks Connecting Models in Parallel Control Design User Manual A parallel connection creates a single model from two separate systems that share common inputs You also can use a parallel connection to add or subtract outputs of two subsystems and represent them as a single output Use the CD Parallel VI to connect systems in parallel For example consider the circuit system in Figure 4 10 i Ry 3 R3 alle H h v Li by Figure 4 10 Circuit System 4 8 ni com Chapter 4 Connecting Models The input of this system is the voltage v The output of
11. Discrete State Space Model x k 1 Ax k Bu k y k Cx k Du k Table 2 2 describes the dimensions of the vectors and matrices of a state space model Table 2 2 Dimensions and Names of State Space Model Variables Variable Dimension Name k Discrete time n Number of states m Number of inputs r Number of outputs A nx n matrix State matrix B n X m matrix Input matrix C r Xn matrix Output matrix D r x m matrix Direct transmission matrix x n vector State vector u m vector Input vector y r vector Output vector National Instruments Corporation 2 15 Control Design User Manual Chapter 2 Constructing Dynamic System Models Use the CD Construct State Space Model VI to create SISO SIMO MISO and MIMO system models in state space form This VI creates a data structure that uses matrices to define the state space model The matrices are zero based two dimensional arrays of numbers where the ij element of the array corresponds to the ij element of matrices in a state space model You can assume that an n order system with m inputs and r outputs has state input and output vectors as defined in the following equations Xo Ug Yo x u x 1 1 y Y Xn 1 Um 1 Vr i State space models also contain additional information about the system such as the sampling time input or output delays and input and output names Refer to the Obtaining Model Information
12. In this example Lis the inductor i f is the current v f is the input voltage v f is the output voltage and R is the resistor n f is process noise that affects the resistor R and e t is measurement noise that affects the sensor that measures v f The result of this noise is a corrupted measurement Vo n t The process noise n f is modeled as a white Gaussian stochastic process with spectral density S 2kTR where k is the Boltzmann constant T is the absolute temperature of the resistor and R is the nominal resistance of the noiseless resistor The measurement noise e t is modeled as a white Gaussian stochastic process with spectral density S s where s is the standard deviation of the measurement noise In this example e t is uncorrelated with n The following sections construct a stochastic state space model and noise model for this example simulate the model output and implement a Kalman filter to estimate the model states 1 In this example the Boltzmann constant equals 1 38 x 10 3 Joules per Kelvin Control Design User Manual 16 22 ni com Chapter 16 Using Stochastic System Models Constructing the System Model Constructing a model for this system involves defining the values of the A B C D G and H matrices To define these matrices you can write equations that describe the system behavior and transform those equations into stochastic state space form After the equations a
13. ety P O 1 Ti Disctete Extended Kalman Filter Jacobians A Jacobianl vi path Figure 16 9 Implementing the Discrete Extended Kalman Filter function In the previous figure the Discrete Extended Kalman Filter function calculates the filtered state estimates using only known inputs and noisy measurements of the plant The following figure illustrates the resulting graph of the filtered state estimates Control Design User Manual 16 20 ni com Chapter 16 Using Stochastic System Models x_true k xhattk E Simulation Time y_true k iw y vhat a 3 2 2 a 1 40 00 Simulation Time Figure 16 10 Estimated States and Outputs Calculated by the Discrete Extended Kalman Filter Function In the previous figure note that the state dynamics are linear but the measurements are nonlinear The x and y positions of the estimated states closely match the true system states National Instruments Corporation 16 21 Control Design User Manual Chapter 16 Using Stochastic System Models Noisy RL Circuit Example This example in this section modifies the RLC circuit from the RLC Circuit Example section of Chapter 2 Constructing Dynamic System Models by removing the capacitor adding process noise n f and adding measurement noise e t Figure 16 11 shows this noisy RL circuit i t SESE gt o O C vi t Figure 16 11 Noisy RL Circuit
14. parameters of the CD Parametric Time Response VI Control Design User Manual 5 4 ni com Chapter 5 Time Response Analysis Figure 5 2 shows a sample step response graph and the locations of the parametric response data Figure 5 2 Step Response Graph and Associated Parametric Response Data For example consider the system described in the Spring Mass Damper Example section of this chapter Figure 5 3 shows how you determine the step response and associated parametric response data of this system ametric Time Response vi CD Par Figure 5 3 Step Response Block Diagram of the Spring Mass Damper System National Instruments Corporation 5 5 Control Design User Manual Chapter 5 Time Response Analysis Control Design User Manual Figure 5 4 shows the Step Response Graph resulting from this block diagram 0 04 0 03 0 02 Displacement cm o o 1 1 1 1 1 1 0 25 50 75 100 125 150 175 Time s Figure 5 4 Step Response Graph of the Spring Mass Damper System You can see that the step input causes this system to settle at a steady state value of 0 02 cm When you use the CD Parametric Time Response VI to analyze the step response of this system you obtain the following response data Rise time 1 42 seconds Maximum overshoot M 79 90 Peak time t 4 54 seconds Settling time 89 89 seconds Steady stat
15. The system included configuration monitors the response of the actual states of the system to a set of initial conditions The CD Initial Response VI uses 0 0 2 1 as the initial conditions These initial conditions mean that the initial conditions of the actual states are 2 1 whereas the initial conditions of the estimated states are 0 0 Therefore the Initial Conditions vector of the Estimator Model is 0 0 2 1 The State Trajectory Graph as shown in Figure 13 5 displays the response of the system and state estimator to the initial conditions 0 0 2 1 State Trajectory Graph 25 See ee x1Model x2Model xiSystem oP ee x2System 2 Es a i 500m I I 1 0 2 4 6 8 10 12 14 16 18 2 Time s Figure 13 5 State Trajectory of System Included State Estimator National Instruments Corporation 13 9 Control Design User Manual Chapter 13 Defining State Estimator Structures The initial conditions of the actual states are 2 1 The response of the actual states therefore starts at 2 and 1 The initial conditions of the estimated states are 0 0 The response of the estimated states therefore starts at the origin The estimated states promptly begin to track the actual states as the response of the actual system settles to steady state This state estimator takes approximately six seconds to track the response of the system Example System Included with Noise State Estimato
16. and multiple input multiple output MIMO system models have more than one input output pair and the delay might be different between each pair Conversely because single input single output SISO systems only have one input output pair the delay factor in a SISO system model always has the same value Refer to the Residual Delay Information section of this chapter for more information about systems that do not have a common delay factor Use the CD Convert Delay with Pade Approximation VI to incorporate delay information into continuous models Use the CD Convert Delay to Poles at Origin VI to incorporate delay information into discrete models If you incorporate the delays in the model using one of these VIs the Dynamic Characteristics VIs and the State Feedback Design VIs account for the delays in their results Refer to the LabVIEW Help available by selecting Help Search the LabVIEW Help for more information about which VIs account for delays The following sections provide information about using the Control Design and Simulation Module to incorporate delay into continuous and discrete system models Delay Information in Continuous System Models Mathematically incorporating delay into a continuous system model involves evaluating that model at t4 units in the past where is the current time For example consider the continuous SISO system model A t To represent this model at f units in the past subtract t4 from tin the eva
17. Estimating Model States Predictive Obs rvese r a la de alesse debe ke Oecd ee oa wate a Tew aaah oes ae se wees 15 2 Current Observers Sexes cote ee lees Hick tei a Eeu a E Aue E E EAEE EAE E E Nees 15 7 CONTINUOUS ODSELVEL ss sna a a a E E E ee eee 15 9 National Instruments Corporation ix Control Design User Manual Contents Chapter 16 Using Stochastic System Models Constructing Stochastic Models eee cseeseceseeseeeseeseceseeaeessecaeseeeesessesesesseseaeeseens 16 1 Constructing Noise Models rusies ariii i iaa Raa 16 3 Converting Stochastic ModelSisssisstiesstsiissisiseetiiesossi iseis essart ansietas roissa 16 3 Converting between Continuous and Discrete Stochastic Models 16 4 Converting between Stochastic and Deterministic Models 0 0 0 0 eee 16 4 Simulating Stochastic Models 0 eee ceeeeeeesesseeeseesecseeeaeeeeeeaeceeesececesesseeeseeeenseeneens 16 4 Using Kalman Filters to Estimate Model States eee ee eeeeseceeeeseseeeeeeeseeeseeeeees 16 5 Using an Extended Kalman Filter to Estimate Model States 16 6 Using the Continuous Extended Kalman Filter Function 16 8 Defining the Continuous Plant Model eee 16 9 Adding Noise to the Continuous Plant Model 0 0000 16 11 Implementing the Continuous Extended Kalman Filter Function 0 ccc ee ec eeeeeeeeeseeseeeneeneees 16 12 Using the Discrete Extended Kalman Filter Function eee eseeseeseceseseeeeseseeeeseeseeeaeeneee 16 1
18. However for the purposes of this example assume you do not have an ammeter or cannot connect an ammeter to the circuit In this situation you can use a Kalman filter to estimate the current given only the noisy voltage measurements Output y k that Figure 16 15 shows Figure 16 16 shows a block diagram that demonstrates a Kalman filter for this discrete stochastic state space model while Loop EALE PxScale Multiplier Estimation Error e k amplitude XScale Multiplier gt Pen Filtered State Estimate xhat k k i XScale Multiplier pine Wave Ptbyrt vi PLByPt vi Output yik ELE gt XScale Multiplier State x k 73 Sampling Time s XScale Multiplier Construct and Discretize Models vi Figure 16 16 Implementing a Kalman Filter National Instruments Corporation 16 29 Control Design User Manual Chapter 16 Using Stochastic System Models Figure 16 17 compares the actual model State x k with the Corrected State Estimate xhat klk the Discrete Kalman Filter function calculates Figure 16 17 Actual Model States vs Corrected State Estimates Control Design User Manual 16 30 ni com Chapter 16 Using Stochastic System Models In Figure 16 17 notice the actual state appears to equal the corrected state at every time step To confirm this analysis you can look at the graph of the estimation error e k defined as x k xhat klk Figure 16 18 shows the grap
19. In the standalone with estimator configuration the system model detaches from the controller The system outputs y become inputs to the estimator Unlike the system included and system included with noise configurations the standalone configuration with estimator does not account for output error You must wire a value to the Estimator Gain L input of the CD State Space Controller VI to include the estimator in the standalone state regulator with integral action National Instruments Corporation 14 17 Control Design User Manual Chapter 14 Defining State Space Controller Structures The following equations describe the standalone configuration i _ 4 B LD K LC D B K x 0 L yep v Zz L 0 T Z I0 y u _ K 10 Ol Yrer y y C DK DK z oo y Use the following substitution to make the input independent Pee This process results in the following equations that describe the standalone configuration PEN _ A B LD K LC D B K H 7 f a Veer 0 T z U NLy uj _ K x 0 0v y C DK DK z 0 0 y This configuration does not include the original system This configuration considers the system output y as another input to the estimator Figure 14 11 represents the dynamic system that these equations describe Vref u Controller gt S gt y a Estimator Figure 14 11 Standalone with Estimator State Regulator with Int
20. Nn Up Vo Feedback Connections i r amp Yo p Uy gt i 3 A a Model 1 y i e a gt E l i Yo Zo Output g ME i Connections v Zi i EEE gt Model 2 oar i oi gt K Figure 4 17 Two Models with No Connections Defined National Instruments Corporation 4 15 Control Design User Manual Chapter 4 Connecting Models Feedback Connections Undefined Output Connections Defined If you do not define Feedback Connections but define Output Connections the CD Feedback VI connects the specified outputs for Model to the specified inputs for Model 2 You define whether each connection is positive or negative Because you have not defined Feedback Connections the CD Feedback VI connects all outputs of Model 2 to the corresponding inputs in Model 1 based on the Feedback Sign B Note All outputs of Model 1 whether they are connected to Model 2 outputs or not remain as outputs in the resulting model Conversely Model 2 outputs do not remain in the resulting model when fed back to Model 1 inputs The resulting model shown in Figure 4 18 contains new reference inputs ro and r for each feedback connection Feedback Connections amp Vo Model 1 7 y Loi Zo Vo a 2 gt Pf wre j oo Output wa a i H Connections gt Modai i ai Vo ay gt ioci
21. Predicted State Estimate The discrete Kalman filter also predicts states at time k 1 given all measurements up to and including time k The following equation defines defines the predicted state estimate x k 1 k Ax k k 1 Bx k k 1 LIy k y 4 y k Cx k k 1 Duk In these equations L is the Kalman prediction gain matrix of the Kalman filter The Kalman filter estimates the accuracy of the updated states by calculating the steady state covariance of the predicted estimation error The following equations define this covariance matrix P and the predicted estimation error e k 11k P lim Efe k 1Jk e k 1 k e k 1 k x k x k 1 k You calculate the Kalman prediction gain L that minimizes P Use the CD Kalman Gain VI to calculate the value of L for a given model affected by noise Refer to the LabVIEW Help for more information about the equations this VI uses to calculate M Z L and P for continuous and discrete models National Instruments Corporation 12 7 Control Design User Manual Chapter 12 Designing State Space Controllers Discretized Kalman Gain If you wire a continuous model to the CD Kalman Gain VI the VI returns a continuous version of L If you wire a discrete model to the CD Kalman Gain VI the VI returns discrete versions of L and M You also can configure this VI to calculate discrete versions of L and M for a continuous model To calculate these discretized gain matrices sele
22. Q B 00 0 9 2 ni com Chapter 9 Analyzing State Space Characteristics This matrix is row rank deficient for n gt 1 The null eigenvalue represents an uncontrollable mode of the system From the definition of a controllable system you can conclude that to place the system states at zero at any time t gt 0 indicates that you can place all system poles anywhere to make the closed loop response reach zero at time t as quickly as possible When you can adjust all system poles locations to a point you want you can calculate a full state feedback controller gain K to arbitrarily place the eigenvalues of the closed loop system A A BK Conversely the eigenvalues associated with modes that are not controllable cannot be adjusted regardless of the value you choose for K Stabilizability is related to controllability A system is stabilizable if all the unstable eigenvalues are controllable Controllability implies stabilizability but stabilizability does not imply controllability Use the CD Controllability Matrix VI to calculate the controllability matrix of the model and determine if the system is controllable and or stabilizable Use the CD Controllability Staircase VI to transform a state space model into a model that you can use to identify controllable states in the system You also can use the CD Controllability Staircase VI to inspect the A and B matrices of the transformed model to determine the controllable states D
23. function icon Also notice the In Range and Coerce function You can use this function to account for saturation effects in the dynamic system National Instruments Corporation 17 7 Control Design User Manual Chapter 17 Deploying a Controller to a Real Time Target Example State Space Controller with Predictive Observer Code Figure 17 5 shows a LabVIEW block diagram that implements a state space controller that depends on estimated state information ms Bere fB Error be E TN a l Sampling Time s Dig fritialize n fa foBLp Sensor Measurement vi Controller Output vi i H i c CD Construct State Disfrete CD State Feedback ke ace Model vi Obrerver bchat k 1 k Controller vi g SS a E lu k 1 K xhat k 1 k e om fe Numeric Y Single Output Y Initial State Estimate xhat O 1 i oBLy i Heero CD Pole Placement vi H coed Observer Gain Predictive v CD Pole Place toler Poles Een Controller Gain v rg Oo ao Control Design User Manual Figure 17 5 Implementing a Predictive Observer on an RT Target The example in Figure 17 5 uses the Discrete Observer function to estimate state information x k 1 k during execution This example also uses the CD Pole Placement VI to calculate the predictive observer gain Lp such that the current Observer Poles are in the location you specify Another CD Pole Placement VI calculates the controller gain K based on the Contr
24. j 0 In this equation A x 0 denotes the discrete free response k 1 yay 7 Bu j denotes the discrete forced response j 0 3 Note The VIs discussed in this chapter automatically convert transfer function and zero pole gain models to state space form before calculating the time domain solution Spring Mass Damper Example To illustrate the different time responses you can obtain from a model consider the following example of a spring mass damper shown in Figure 5 1 Control Design User Manual 5 2 ni com Chapter 5 Time Response Analysis b mm Figure 5 1 Spring Mass Damper System In this example k is the spring constant u is a force m is the mass and b is the damper coefficient x is the displacement which is the distance from the normal state of the spring to the current position of the spring You can represent this spring mass damper system with the following state space model 0 1 0 X Ax Bu k bl t 1 4 mm m y Cx Du i o x o x For this example consider the following values kN a0 penie gan cm cm The following equations define the state space model x 0 x 0 u 0 5 0 1 0 01 y 1 ojx o v x National Instruments Corporation 5 3 Control Design User Manual Chapter 5 Time Response Analysis The following sections show how this system responds to different inputs Analyzing a Step Response The ste
25. you can use discrete models to implement a digital controller or to simulate the behavior of a physical system at discrete instants You also can use discrete models in the accurate model based design of a discrete controller for a plant The Control Design and Simulation Module supports continuous and discrete models 2 4 ni com Model Forms Chapter 2 Constructing Dynamic System Models You can use the Control Design and Simulation Module to represent dynamic system models in the following three forms transfer function zero pole gain and state space Refer to the Constructing Transfer Function Models section the Constructing Zero Pole Gain Models section and the Constructing State Space Models section of this chapter for information about creating and manipulating these system models Table 2 1 shows the equations for the different forms of dynamic system models Table 2 1 Definitions of Continuous and Discrete Systems Model Form Continuous Discrete Transfer ba bis b 8 4b s ba biz b 1z 4b z Function H s 0 1 une m 1 m H z 0 1 fea m 1 m ag aS tes fas ttre uth oz saz a u u Zero Pole k 25 k z Z5 z Gain H s s Z1 s Z2 s Zm H z 2 z Z Z Z2 z Zig s p S Po S Py H a z p1 Zz P2 Z P H e State Space x Ax Bu y Cx Du x k 1 Ax k Bu k y k Cx k Du k 3 Note Conti
26. 12 4 ni com Chapter 12 Designing State Space Controllers To calculate this discretized gain matrix select the Discretized Linear Quadratic Regulator instance of the CD Linear Quadratic Regulator VI This instance automatically converts a continuous model to a discrete model before calculating K that minimizes the discrete version of the cost function you specified This VI first discretizes the A B C and D matrices using the Zero Order Hold method This VI then calculates the discrete equivalents of the Q R and N matrices using the numerical integration method proposed by Van Loan You specify the Sampling Time s this VI uses for both conversions Refer to the Zero Order Hold and First Order Hold Methods section of Chapter 3 Converting Models for information about the Zero Order Hold conversion method Refer to JEEE Transactions on Automatic Control as listed in the Related Documentation section of this manual for information about the numerical integration method proposed by Van Loan Q is asymmetric positive semi definite matrix that penalizes the state vector x in the control objective R is a positive definite matrix usually symmetric that penalizes the input vector u in the control objective N is a matrix that penalizes the cross product between input and state vectors Combine the controller gain matrix K with the CD State Space Controller VI to define a controller structure for the system Refer to Chapter 14 Defining
27. 2 E 1 Time s Figure 14 15 State Trajectory of a System Included State Compensator Notice that the time the estimator takes to track the actual states is much shorter than the time the actual states take to reach a steady state The estimator takes between 1 and 1 5 seconds to track the actual states whereas the actual states take approximately six seconds to reach a steady state The estimator tracks the actual states faster than the controller stabilizes the system because the estimator poles are at 5 5 and the controller poles are at 1 1 Placing the poles of the estimator farther to the left than the controller poles makes the performance of the estimator faster than the controller National Instruments Corporation 14 23 Control Design User Manual Chapter 14 Defining State Space Controller Structures Example System Included with Noise State Compensator In general the compensator accepts two inputs r and r The input ry represents state references The input r represents measurement noise and is available only in the system included with noise configuration Figure 14 16 shows the use of both types of inputs for the compensator Observer Gain Current Y i Estimator Poles m i ICD Ackermann vi gt System Included with Noise v State Space Model CD State Space Controller vi CD Linear Simulation vi aeeeanaet Eea oe tate Trajectory Graph
28. Control Design National Instruments also provides products for I O and signal conditioning that you can use to gather and process data Using these tools which are built on the LabVIEW platform you can experiment with different approaches at each phase in model based control design and quickly identify the optimal design solution for a control system 1 2 ni com Chapter 1 Introduction to Control Design Developing a Plant Model The first phase of model based control design involves developing and analyzing a mathematical model of the plant you want to control You can use a process called system identification to obtain and analyze this model The system identification process involves acquiring data from a plant and then numerically analyzing stimulus and response data to estimate the parameters and order of the model The system identification process requires a combination of the following components e Signal generation and data acquisition National Instruments provides software and hardware that you can use to stimulate and measure the response of the plant e Mathematical tools to model a dynamic system The LabVIEW System Identification Toolkit contains VIs to help you estimate and create accurate mathematical models of dynamic systems You can use this toolkit to create discrete linear models of systems based on measured stimulus and response data ay Note This manual does not provide a comprehensive discussion of system
29. Defined 4 16 Feedback Connections Defined Output Connections Undefined 4 17 Both Feedback and Output Connections Defined 0 0 4 18 Control Design User Manual vi ni com Contents Chapter 5 Time Response Analysis Calculating the Time Domain Solution eee eeeseceeeeseeseeeseeseceseeaeeeeeeaesneeeaeenees 5 1 Spring Mass Damper Example cece eecceseesecescneeeseeesecseceseeseeseeeaecnsecaeeeaeeesseeeaees 5 2 Analyzing a Step Response ss ic sicsesiesescdsessescsseiegcesesideescesdesesescepessiveaves icia iite Sanes thous 5 4 Analyzing an Impulse Response eceeeeceeseeseeseceseeseeeseeseceseeseceseeaesnsesseeseeeeenseeaees 5 7 Analyzing an Initial Response sssini iae i u aeee aias 5 8 Analyzing a General Time Domain Simulation ssesseesssesssessseerestsresrsrtsresrsresreseseesres 5 10 Obtaining Time Response Data ssssssesssseseseserestestsrtsteststrsreresterestesrerentesrstesresesestsres 5 12 Chapter 6 Working with Delay Information Accounting for Delay Information eee eee eeeeseeseeecceseceeeeseseeeeaeesaeeaecseseaseneenaes 6 2 Setting Delay Information eee eseceeeeeeseeaecsecnsesseeesesseesseeseeseeeas 6 2 Incorporating Delay Information eee eee eee ceceseeeseeseeesecaeenseeseenaeesees 6 2 Delay Information in Continuous System Models eee 6 3 Delay Information in Discrete System Models eee eens 6 7 Representing Delay Information ieee ceeeseeseeseenecesecsecesesseense
30. K C DK 0 ac DK px c DK Mm Ses The reference vector r has as many elements as the number of states Also this configuration calculates the control action u internally and then gives u as an output of the state compensator Figure 14 1 represents the dynamic system that these equations describe u Fx y eX Controller System gt F x tA gt Estimator Y gt x Figure 14 1 System Included State Compensator z u The states inputs and outputs of the state compensator are al r and y 5 x tively respectively y 14 4 ni com Chapter 14 Defining State Space Controller Structures System Included with Noise Configuration The system included configuration with noise incorporates noise r into the system included configuration The following equation defines the output error y y C x x r By substituting the output error in the general system configuration you obtain the following equations that describe the system included with noise configuration gt l _ 4 BK LC Lc x BK L rx BK Aj x BK 0 r Tyee K olr K 0 x ry px o oxo pK Cc pK 1 Mm Ses The reference vector r has as many elements as the number of states Also this configuration calculates the control action u internally and then gives u as an output of the compensator Figure 14 2 represents the dynamic sys
31. Ly The following sections show how to derive each configuration System Included Configuration In the system included configuration the following equations define the output error and system output y y C x x y D K x K z Cx By substituting the output error and system output in the general system configuration and removing the sensor noise r from the system you obtain the following equations that describe the system included configuration Control Design User Manual 14 14 ni com Chapter 14 Defining State Space Controller Structures i 4 BK LC BK LC j To DK P DK C z 1 dre x BK BK A x o ul K K O x Jo y C DK DK 0 z 0 Vref y DK DK C x 0 The reference vector y has as many elements as the number of outputs Also this configuration calculates the control action u internally and then gives u as an output of the state regulator with integral action Figure 14 9 represents the dynamic system that these equations describe gt Yref Controller amp System y Z x Estimator Y e x Figure 14 9 System Included Regulator with Integral Action The states inputs and outputs of the state regulator with integral action are A x u zl Vref and y respectively x J National Instruments Corporation 14 15 Control Design User Manual Chapter 14 Cont
32. MPC controller model You also can estimate model states by using the Discrete Observer function outside the MPC controller Refer to the Current Observer section of Chapter 15 Estimating Model States for more information about estimating model states The following sections provide information about other parameters you use to define the MPC controller Defining the Prediction and Control Horizons When constructing an MPC controller you must provide the following information e Prediction horizon N The number of samples in the future during which the MPC controller predicts the plant output This horizon is fixed for the duration of the execution of the controller e Control horizon N The number of samples within the prediction horizon during which the MPC controller can affect the control action This horizon is fixed for the duration of the execution of the controller 3 Note The value you specify for the control horizon must be less than the value you specify for the prediction horizon National Instruments Corporation 18 3 Control Design User Manual Chapter 18 Creating and Implementing a Model Predictive Controller Figure 18 1 shows these horizons Output Setpoint Predicted Output Past Output p Control Action Past Control J Action T gt k k N k N Time Control Horizon Prediction Horizon Figure 18 1 Predicti
33. Manual For example consider the following transfer function that represents a linear time invariant system Applying the sinusoidal input x f sin f to this previous system produces the following equation y t Ysin wt 0 Using this equation the following equation represents the complex frequency response H i A e You can separate the complex frequency response equation into two parts the magnitude A q and the phase 6 You obtain the magnitude from the absolute value of the response You obtain the phase value from the four quadrant arctangent of the response The following equations illustrate these operations A H io ZH i en aa These two equations represent the magnitude and the phase of the frequency response respectively Plotting these equations results in two subplots the Bode magnitude plot and the Bode phase plot The Bode magnitude plot shows the gain plotted against the frequency The Bode phase plot shows the phase in degrees as a function of the frequency Use a linear scale when dealing with phase information When using a linear scale you can add the individual phase elements together to determine the phase angle Because you can add the magnitude and phase plots for systems in series you can add Bode plots of an open loop plant and potential compensators to determine the frequency response characteristics of the dynamic system Bode plots also illustrate
34. National Instruments Corporation 4 1 Control Design User Manual Chapter 4 Connecting Models Connecting SISO Systems in Series Consider a valve that controls the flow rate of water into a tank Figure 4 1 represents this system Ks Input Signal DA Q s Flow Rate H s EO L s Level Figure 4 1 Flow of Water into a Tank If you assume that the incoming water pressure to the valve is constant only the valve input signal affects the level of the water in the tank You can model the flow rate of water into the tank using the following transfer functions where H s is a model of the valve and H s is a model of the tank Q s _ K L s H S E H eraud OG I s Q s and L s represent the Laplace transform of the input signal the flow rate and the level of water in the tank respectively The constants K T C and K are parameters of the models that describe the valve and tank To obtain the effect of the input signal on the water level place the two systems in series and multiply their transfer functions L s _ H s H s ss K H m I s vs 20ts 1 S Control Design User Manual 4 2 ni com Chapter 4 Connecting Models This equation represents the output of H s connecting to the input of HAs Figure 4 2 illustrates this relationship Ks Q s L s gt Hs Q s s c H s L s Q s _ Ks L s gt H s
35. This section uses a MIMO dynamic system model as an example Consider the two input two output system shown in Figure 2 6 Mational Instruments Corporation 2 9 Control Design User Manual Chapter 2 Constructing Dynamic System Models Control Design User Manual MIMO System U Y gt H ac oop gt Ha U 1 gt Ho ai y gt H gt O 1 ie Figure 2 6 MIMO System with Two Inputs and Two Outputs You can define the transfer function of this MIMO system by using the following transfer function matrix H where each element represents a SISO transfer function A Hp A Ay H Suppose the following equations define the SISO transfer functions between each input output pair 1 2 H H i S 12 1 s 3 Hy es Hy 4 s 454 6 Select the MIMO instance of the CD Construct Transfer Function Model VI to create a MIMO transfer function model You then can specify each transfer function between the j input and the i output as the ij element of the two dimensional Transfer Function s input array Figure 2 7 shows that the numerator denominator pair of the first row and first column corresponds to H the numerator denominator pair of the first row and second column corresponds to Hj and so on 2 10 ni com Chapter 2 Constructing Dynamic System Models Transfer Function s Figure 2 7 C
36. a Current Observer In Figure 15 6 notice the error oscillates less than the error of the predictive observer shown in Figure 15 4 Also the current observer error generally is less than the predictive observer error at a given time step This decrease in error occurs because the current observer uses the current output y k to estimate the current states xhat klk whereas the predictive observer uses the current output y k to predict the next state estimate xhat k 1Ik Refer to the LabVIEW Help for the general forms of the equations the Discrete Observer function uses to calculate the outputs Continuous Observer Estimating the states of a continuous state space model requires solving the following ordinary differential equation x 1 Ax t Bult Liy t y O y t Cx t Du t National Instruments Corporation 15 9 Control Design User Manual Chapter 15 Estimating Model States To estimate the states you must integrate this equation over time To perform this integration you must use the Continuous Observer function with an ordinary differential equation ODE solver You specify the ODE solver to use and parameters of the ODE solver by placing the Continuous Observer function inside a Control amp Simulation Loop For example consider the following continuous state space model X t k kos Po 1 0 1 y t 1 o x This model has two states x1 and x2 Figure 15 7 shows a LabVIEW block diagram that
37. back to the Input u t input of the Continuous Kalman Filter function Finding Example NI DAQmx 1 0 Code If you installed NI DAQmx refer to the labview examples DAQmx Control Control 11b for examples of writing I O block diagram code for National Instruments DAQ devices National Instruments Corporation 17 13 Control Design User Manual Creating and Implementing a Model Predictive Controller Traditional feedback controllers operate by adjusting control action in response to a change in the output setpoint of a system also called a plant Model predictive control MPC is a technique that focuses on constructing controllers that can adjust the control action before a change in the output setpoint actually occurs This predictive ability when combined with traditional feedback operation enables a controller to make adjustments that are smoother and closer to the optimal control action values For example consider a cruise control system in a car This controller adjusts the amount of gas sent to the engine The amount of gas is based on the following two values e The velocity at which you set the cruise control system e The velocity of the car The velocity of the car is based on the slope of the road along which the car moves Therefore a change in slope or disturbance affects the velocity of the car which affects the amount of gas the controller sends to the engine Table 18 1 shows the terms this example uses
38. cannot exceed the speed limits This specification is equivalent to placing hard constraints on the maximum value of the plant output When you use the dual optimization method all constraints are weighted equally and above any cost weightings you specify For example in the cruise control system the MPC algorithm places equal emphasis on trying not to exceed the specified maximum amount of gas or the specified maximum velocity If you also specify an output error weighting the National Instruments Corporation 18 7 Control Design User Manual Chapter 18 Creating and Implementing a Model Predictive Controller Control Design User Manual algorithm prioritizes the control action and plant output constraints over the output error weighting In other words the algorithm tries not to exceed the specified amount of gas or the specified maximum velocity even if meeting these constraints results in a large difference between the desired and actual velocity of the car When you use the dual optimization method the MPC algorithm adjusts the controller such that the specified constraints are never exceeded Because all constraints are weighted equally when you use the dual optimization method you cannot reflect differences in cost or importance for different parameters For example suppose you want to build a controller that maintains the car at a specific velocity You want to prioritize minimizing the output error above meeting any other con
39. contained in it EXCEPT AS SPECIFIED HEREIN NATIONAL INSTRUMENTS MAKES NO WARRANTIES EXPRESS OR IMPLIED AND SPECIFICALLY DISCLAIMS ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE CUSTOMER S RIGHT TO RECOVER DAMAGES CAUSED BY FAULT OR NEGLIGENCE ON THE PART OF NATIONAL INSTRUMENTS SHALL BE LIMITED TO THE AMOUNT THERETOFORE PAID BY THE CUSTOMER NATIONAL INSTRUMENTS WILL NOT BE LIABLE FOR DAMAGES RESULTING FROM LOSS OF DATA PROFITS USE OF PRODUCTS OR INCIDENTAL OR CONSEQUENTIAL DAMAGES EVEN IF ADVISED OF THE POSSIBILITY THEREOF This limitation of the liability of National Instruments will apply regardless of the form of action whether in contract or tort including negligence Any action against National Instruments must be brought within one year after the cause of action accrues National Instruments shall not be liable for any delay in performance due to causes beyond its reasonable control The warranty provided herein does not cover damages defects malfunctions or service failures caused by owner s failure to follow the National Instruments installation operation or maintenance instructions owner s modification of the product owner s abuse misuse or negligent acts and power failure or surges fire flood accident actions of third parties or other events outside reasonable control Copyright Under the copyright laws this publication may not be reproduced or transmitted in any form electronic or mechanic
40. eh Y eta Y Sta y 9 0p Y e Y e s National Instruments Corporation 6 9 Control Design User Manual Chapter 6 Working with Delay Information To represent the delay of each element you can use the following matrices ti t t T 11 412 I 1 0 a b21 top ty ly Because the number of rows and columns of T4 are the same as the dimension of vectors I and O4 you can represent all the delay information of a model using the following structure a tii Cy a tay top fo In this delay matrix the input delay vector Z is on top Each input uses one column The output delay vector O is on the right hand side Each output uses one row Manipulating Delay Information The Control Design and Simulation Module provides two VIs to help you manipulate the delay information of a system model Use the CD Distribute Delay VI to minimize the transport delay of a system model by distributing the transport delay information to the inputs and outputs of a system model Use the CD Total Delay VI to distribute the input and output delay of a model to the transport delay The following sections provide information about using these VIs to manipulate delay information Accessing Total Delay Information The CD Total Delay VI transfers delay information from the inputs and outputs of a system model to the transport delay of a system model by adding the input and output delays to the delay in the transport delay matrix W
41. error weighting larger than either constraint penalty the MPC algorithm prioritizes minimizing the output error above minimizing either constraint penalty The barrier function method is useful when you need to prioritize the constraints on different parameters in order to reflect a more realistic system However tuning all the necessary constraints penalties and tolerances for the barrier function can become complicated To reduce this complexity use the dual optimization method instead Refer to the Dual Optimization Method section of this chapter for more information about the dual optimization method Refer to the CDEx MPC with Barrier Constraints VI located in the labview examples Control and Simulation Control Design MPC directory for an example of using the barrier function method to set constraints for a controller Refer to the CDEx MPC Dual vs 18 12 ni com Chapter 18 Creating and Implementing a Model Predictive Controller Barrier Constraints VI in this same directory for a comparison of the dual optimization and barrier function methods Specifying Input Setpoint Output Setpoint and Disturbance Profiles MPC controllers operate by comparing plant input and plant output values to setpoint profiles These setpoint profiles contain predicted values of the control action and plant output setpoints at certain points in time You send these profiles to the MPC controller which calculates error by comparing the predicted p
42. for Za z is the value of the control action or of the plant output Zsp is the setpoint value of z q is the cost weighting on z ay Note Refer to the Specifying Input Setpoint Output Setpoint and Disturbance Profiles section of this chapter for information about providing setpoint information for a controller When z is the control action this expression becomes Pau Aumas tOlmax Au Au r Au gt Au tol max max where Pay 18 the penalty constant for Au Au tol nax is the tolerance for Au max is the maximum constraint on Au max max Au is the value of the rate of change in control action r is the cost weighting on Au The first term in the previous expression represents the cumulative effect of the penalty The second term represents the cumulative effect of the cost weightings National Instruments Corporation 18 11 Control Design User Manual Chapter 18 Creating and Implementing a Model Predictive Controller Control Design User Manual Consider again the cruise control system in which y is 71 miles per hour with a penalty constant of five and a tolerance of five miles per hour Suppose the desired plant output is 70 miles per hour and the output error weighting is one If the velocity of the car is 60 miles per hour the MPC algorithm attempts to increase the velocity to 70 miles per hour thereby reducing the output error When the velocity of the car reaches 66 mile
43. identification Refer to the resources listed in the Related Documentation section of this manual for more information about developing a plant model Designing a Controller The second phase of model based control design involves two steps The first step is analyzing the plant model obtained during the system identification process The second step is designing a controller based on that analysis You can use the Control Design VIs and tools to complete these steps These VIs and tools use both classical and state space techniques Figure 1 3 shows the typical steps involved in designing a controller Determine Specifications one Analyze Synthesize gt Mathematical gt y E y Model System Controller Figure 1 3 Control Design Process National Instruments Corporation 1 3 Control Design User Manual Chapter 1 Introduction to Control Design You often iterate these steps to achieve an acceptable design that is physically realizable and meets specific performance criteria Simulating the Dynamic System The third phase of model based control design involves validating the controller design obtained in the previous phase You perform this validation by simulating the dynamic system For example simulating a jet engine saves time labor and money compared to building and testing an actual jet engine You can use the Control Design and Simulation Module to simulate linear time i
44. models and vice versa You also can convert stochastic models to deterministic models and vice versa The following sections provide information about these conversions National Instruments Corporation 16 3 Control Design User Manual Chapter 16 Using Stochastic System Models Converting between Continuous and Discrete Stochastic Models Use the CD Convert Continuous Stochastic to Discrete VI to discretize a continuous stochastic model and the associated noise model This VI first converts the deterministic matrices A B C and D using the Zero Order Hold method Refer to Chapter 3 Converting Models for information about this method This VI then converts the G H Q R and N matrices according to the Method you specify You can choose either the Numerical Integration method as proposed by Van Loan or the Truncation of Taylor Series Expansion TSE method Refer to the LabVIEW Help and to IEEE Transactions on Automatic Control as listed in the Related Documentation section of this manual for information about the equations these methods use Converting between Stochastic and Deterministic Models Use the CD Convert Stochastic to Deterministic Model VI to convert a stochastic state space model to a deterministic state space model This VI removes G and H from the stochastic model equations Use the CD Convert Deterministic to Stochastic Model VI to convert a deterministic state space model to a stochastic state space mo
45. must select or click in the software such as menu items and dialog box options Bold text also denotes parameter names Italic text denotes variables emphasis a cross reference or an introduction to a key concept Italic text also denotes text that is a placeholder for a word or value that you must supply Text in this font denotes text or characters that you should enter from the keyboard sections of code programming examples and syntax examples This font is also used for the proper names of disk drives paths directories programs subprograms subroutines device names functions operations variables filenames and extensions National Instruments Corporation xiii Control Design User Manual About This Manual monospace bold Bold text in this font denotes the messages and responses that the computer automatically prints to the screen This font also emphasizes lines of code that are different from the other examples Related Documentation The following documents contain information that you might find helpful as you use the Control Design and Simulation Module LabVIEW Help available by selecting Help Search the Lab VIEW Help LabVIEW Real Time Module documentation LabVIEW PID and Fuzzy Logic Toolkit User Manual available by navigating to the labview manuals directory and opening PID_User_Manual pdf You must have the LabVIEW PID and Fuzzy Logic Toolkit installed to access this manual LabVIEW Control Desig
46. not change over short periods of time The Control Design and Simulation Module supports time invariant models only Continuous versus Discrete Models Dynamic system models are either continuous or discrete Both continuous and discrete system models can be linear or nonlinear and time invariant or time variant Continuous models describe how the behavior of a system varies continuously with time which means you can obtain the properties of a system at any certain moment from the continuous model Discrete models describe the behavior of a system at separate time instants which means you cannot obtain the behavior of the system between any two sampling points Continuous system models are analog You derive continuous models of a physical system from differential equations of the system The coefficients of continuous models have clear physical meanings For example you can derive the continuous transfer function of a resistor capacitor RC circuit if you know the details of the circuit The coefficients of the continuous transfer function are the functions of R and C in the circuit You use continuous models if you need to match the coefficients of a model to some physical components in the system Discrete system models are digital You derive discrete models of a physical system from difference equations or by converting continuous models to discrete models In computer based applications signals and operations are digital Therefore
47. of inputs and outputs Use the Weighting Type parameter to choose the cost function you want to minimize You can choose from the following cost functions e State Weighting This cost function weights the model states Output Weighting Dim Q Ny This cost function weights the model outputs y when Q is in terms of y If you choose this cost function the dimensions of Q must equal the number of model outputs e Output Weighting Dim Q Nx This cost function weights the model outputs when Q is in terms of the model states x If you choose this cost function the dimensions of Q must equal the number of model states Refer to the LabVIEW Help available by selecting Help Search the LabVIEW Help for more information about the cost functions this VI minimizes and for the equations of each of these cost functions This VI returns the value of K that minimizes the cost functions you choose Because calculating K involves solving the continuous or discrete algebraic Riccati equation this VI also returns the solution to the appropriate Riccati equation You can use the CD Linear Quadratic Regulator VI with continuous and discrete models If you wire a continuous model to the State Space Model input of this VI this VI returns a continuous version of K If you wire a discrete model to this input this VI returns a discrete version of K You also can configure the this VI to return a discretized version of K for a continuous model
48. outputs of the state regulator are i respectively 14 10 ni com Chapter 14 Defining State Space Controller Structures Standalone with Estimator Configuration In the standalone with estimator configuration the system model detaches from the controller The system outputs y become inputs to the estimator Unlike the system included and system included with noise configurations the standalone with estimator configuration does not account for output error You must wire a value to the Estimator Gain L input of the CD State Space Controller VI to include the estimator in the standalone state compensator The following equations describe the standalone with estimator configuration x A BK L C DK lt B LD 1 K J uj K lee T On y C DK D O0 y This configuration does not include the original system This configuration considers the system output y as another input to the estimator Figure 14 7 represents the dynamic system that these equations describe Ty Ys y gt Controller gt a a Estimator x lt Figure 14 7 Standalone with Estimator State Regulator The states inputs and outputs of the state regulator are Xx and H Y respectively Y y National Instruments Corporation 14 11 Control Design User Manual Chapter 14 Defining State Space Controller Structures Standalone without Estimator Configuration The standalone without estimat
49. section of this chapter for information about other properties that state space models contain SISO State Space Models Using the example in the RLC Circuit Example section of this chapter the following equations define a continuous state space model o ailn lo 7 RII a ly Ve ZC L d LC Ve y ve 1 ol o v Ve In these equations y equals the voltage of the capacitor v and u equals the input voltage v v x equals the voltage of the capacitor and the derivative of that voltage Ve Control Design User Manual 2 16 ni com Chapter 2 Constructing Dynamic System Models The following matrices define a state space model where R 20 Q L 50 mH and C 10 uF gal i r E 2 x 10 400 2x10 c o a fol When you plug these matrices into the equations for a continuous state space model defined in the Constructing State Space Models section of this chapter you get the following equations 0 1 Pe 0 x di 2 x 10 400 v 2x10 y i o o Ve Figure 2 10 shows how you use the CD Construct State Space Model VI to create this continuous state space model btate Space Model pe Figure 2 10 Creating a Continuous State Space Model 3 Note Although B is a column vector C is a row vector and D is a scalar you must use the 2D array data type when connecting these inputs to the VI National Instruments Corporation 2 17 Control Design User Manual
50. solvers Control Design User Manual 15 12 ni com Using Stochastic System Models The model forms in Chapter 2 Constructing Dynamic System Models are deterministic Deterministic models do not account for random disturbances or noise present in the system Because noise affects most real world systems deterministic models might not represent these systems sufficiently Stochastic system models are models that represent the effects of noise on the plant actuators and or sensors Each stochastic system model has an associated noise model that characterizes the first and second order statistical behavior of the noise affecting the system You use stochastic system models and noise model to test that a controller performs adequately in the presence of noise This chapter provides information about constructing and converting stochastic state space models and noise models This chapter also describes simulating stochastic models and implementing a Kalman filter to estimate model states in the presence of noise 3 Note Refer to the labview examples Control and Simulation Control Design Implementation directory for example VIs that demonstrate the concepts explained in this chapter Constructing Stochastic Models In addition to the state space matrices A B C and D stochastic models contain the following variables e Vectors w and v represent process noise and measurement noise respectively Process noise reflects error
51. states inputs and outputs of state compensator are x e and E 5 respectively Y Y Control Design User Manual 14 6 ni com Chapter 14 Defining State Space Controller Structures Standalone without Estimator Configuration In the standalone without estimator configuration you calculate the control action u using the states As such you do not need an estimator In the CD State Space Controller VI do not wire a value to the Estimator Gain L input to exclude the estimator in the standalone state compensator The following equations describe the standalone configuration x A BK x BKr Pl cake al The states and outputs of the standalone without estimator compensator correspond to the states and outputs of the actual system Figure 14 4 represents the dynamic system that these equations describe I gt R Controller System gt 4 x Figure 14 4 Standalone without Estimator State Compensator The states inputs and outputs of the state compensator are x r and ki respectively Y National Instruments Corporation 14 7 Control Design User Manual Chapter 14 State Regulator Defining State Space Controller Structures A general system configuration appends the original model states x to the estimation model states x to represent the state regulator with an estimator The following equations show this process _ 4 BK o x BK Al x K olr C_D
52. system These properties are common in all three model forms Table 2 3 lists the properties and their corresponding data types Table 2 3 Model Properties Property Data Type Description Model Name String Assigns a name to a specific model Input Names 1D array of strings The i element of the array defines the name of the i input to the model Output Names 1D array of strings The i element of the array defines the name of the i output of the model Control Design User Manual 2 18 ni com Chapter 2 Constructing Dynamic System Models Table 2 3 Model Properties Continued Property Data Type Description Input Delays 1D array of double precision The i element of the array defines the time floating point numeric values delay of the i input of the model Output Delays 1D array of double precision The i element of the array defines the time floating point numeric values delay of the i output of the model Transport Delay 1D array of double precision The ij element of the array defines the time floating point numeric values delay between the i output and j input of the model Notes String A string for storing additional data The string can contain comments or other information that you want to store with the model Sampling Time Double precision Represents the sampling time in seconds floating point numeric value of the system If a model repre
53. the CD Kalman Gain VI to calculate the value of L for a given model affected by noise If the noise affecting the model is Gaussian then L is the optimal gain If the noise affecting the model is not Gaussian L results in the optimal linear least square estimates Discrete Models For discrete models the Kalman filter not only estimates the current state vector at time k but also predicts the state vector at time k 1 The following sections describe the gain matrices you calculate in these situations Updated State Estimate The updated state estimate which is the current state estimate is given by x k k This notation translates as the estimated state vector at time k given all measurements up to and including k The following equation defines the updated state estimate for a discrete Kalman filter x k k x k k 1 M y k y 4 y k Cx k k 1 Du k 12 6 ni com Chapter 12 Designing State Space Controllers In these equations M is the innovation gain matrix of the Kalman filter The Kalman filter estimates the accuracy of the updated states by calculating the steady state covariance of the updated estimation error The following equations define this covariance matrix Z and the updated estimation error e klk Z lim Efe k k e k k e k k x k x k k You calculate the innovation gain matrix M that minimizes Z Use the CD Kalman Gain VI to calculate the value of M for a given model affected by noise
54. the discrete transfer function model you can enter in the appropriate values for Numerator and Denominator and set the Sampling Time s to a value greater than zero Figure 2 4 shows this process using a sampling time of 10 us 1E 5 Discrete Transfer Function Model CD Construct Transfer Function Model vi Figure 2 4 Using Coefficients to Create a Discrete Transfer Function Model Control Design User Manual 2 8 ni com Chapter 2 Constructing Dynamic System Models If you do not know the coefficients of the discrete transfer function model you must use the CD Convert Continuous to Discrete VI for the conversion Set the Sampling Time s parameter of this VI to a value greater than zero Figure 2 5 shows this process using a sampling time of 10 us Numerator Discrete Transfer Function Model Figure 2 5 Using the CD Convert Continuous to Discrete VI to Create a Discrete Transfer Function Model Converting from a continuous model to a discrete model results in the following equation _ 9 9865 x 10 z 9 9732 x 10 H z z 1 9958z 0 996 Refer to the Converting Continuous Models to Discrete Models section of Chapter 3 Converting Models for more information about converting continuous models to discrete models SIMO MISO and MIMO Transfer Function Models You can use the CD Construct Transfer Function Model VI to create SIMO MISO and MIMO dynamic system models
55. the estimator gain L enhances the convergence of the error to zero x A R x L y p A LO e Lr Without the noise input the following equation defines the error convergence A LO e L is designed to place the poles of the matrix A LC in the specified complex plane location To include the estimator in the composed system model you append the original model states x to the estimated model states x The following equations show this process Ga Gales eee Given this general system configuration the following sections provide information about deriving the possible configurations of a state estimator National Instruments Corporation 13 3 Control Design User Manual Chapter 13 Defining State Estimator Structures Configuring State Estimators Use the Configuration parameter of the CD State Estimator VI to define the structure of an estimator using one of the following three configurations System Included Appends the actual states of the system to the estimated states System Included with Noise Incorporates noise r into the system included configuration Standalone Defines a structure of the estimator that analyzes a system model mismatch Table 13 1 summarizes the different state estimator configurations and their corresponding states inputs and outputs Table 13 1 State Estimator Configurations Configuration Type States Inputs Outputs System Included
56. the previous illustration u is the control input vector and y is the measurement vector of the model states The extended Kalman filter receives a plant model of the system dynamics and measurements The extended Kalman filter then estimates the internal states of the system based on the plant model the control input u and the measurement y The internal states are represented by x In feedback control applications the state estimates are used to design the control input u Extended Kalman filters linearize the nonlinear system by computing a matrix of partial derivatives called a Jacobian matrix The Extended Kalman filter evaluates the Jacobian matrix with the current estimated states at each time step In the LabVIEW Control Design and Simulation Module use the Continuous Extended Kalman Filter and the Discrete Extended Kalman Filter functions to implement an extended Kalman filter First use the SIM Discrete Nonlinear Plant Model template VI or the SIM Continuous Nonlinear Plant Model template VI located in the labview templates Control and Simulation directory to define the system model Then use the Discrete Nonlinear Noisy Plant function or the Continuous Nonlinear Noisy Plant function to simulate the discrete or continuous nonlinear model respectively with the addition of noise Finally use the Continuous Extended Kalman Filter function or the Discrete Extended Kalman Filter function to estimate the states of the model Nat
57. the system bandwidth as the frequency at which the output magnitude is reduced by three decibels or attenuated to approximately 70 7 of its original value You also can use the CD Bandwidth VI to determine the system bandwidth 7 2 ni com Chapter 7 Frequency Response Analysis You can measure how close a system is to instability by examining the value of the magnitude and phase at critical values These values gain margin and phase margins are important because real life models and controllers are prone to uncertainties Low gain or phase margins indicate potential instability The following sections provide information about gain and phase margins Gain Margin The gain margin indicates how much you can increase the gain before the closed loop system becomes unstable This critical gain value which causes instability indicates the location of the closed loop poles of the system on the imaginary axis You often use this analysis on systems where G s consists of a gain K and a dynamic model H s in series For cases where increasing the gain leads to system instability the system is stable for a given value of K only if the magnitude of KH s is less than 0 dB at any frequency where the phase of KH s is 180 The Bode magnitude plot displays the gain margin as the number of decibels by which the gain exceeds zero when the phase equals 180 as shown in Figure 7 1 Phase Margin The phase margin represents the amount
58. there is one negative counter clockwise encirclement Figure 7 2 shows a system with one unstable pole Equation Nyquist Plot Ploto AV ties 1 s 8 s 3 1 s 95 2 0 8 0 6 a 1 02s Imaginary Axis 5 N o I 1 1 1 1 5 1 0 5 0 0 5 1 Real Axis Figure 7 2 Nyquist Plot of One Unstable Pole Often you want to determine a range of gain values for which the system is stable rather than testing the stability of the system at a specific value of K To determine the stability of a closed loop system you must determine how a range of gain values affects the stability of the system Consider the following closed loop transfer function equation with output Y s and input U s where K is the gain Y s _ _KH s U s 1 KH s The closed loop poles are the roots of the equation 1 KH s 0 The complex frequency response of KH s evaluated for s i in continuous systems and e for discrete systems encircles 1 0 in the complex plane if 1 KH s encircles 0 0 If you examine the Nyquist plot of H s you can see that an encirclement of 1 K 0 by H s is the same as an encirclement of 1 0 by KH s Thus you can use one Nyquist plot to determine the stability of a system for any and all values of K 7 6 ni com Chapter 7 Frequency Response Analysis Obtaining Frequency Response Data The Frequency Response VIs discussed in this chapter return frequency response data that
59. this block diagram 0 06 i are 0 75 E 0 02 lee X i 0 25 T o 0 3 z 0 02 Eea a 0 5 0 04 0 75 0 06 1 1 I 1 1 1 tml 0 25 50 75 1005 125 So 7s Time s Figure 5 11 Linear Simulation Graph of the Spring Mass Damper System Using a Square Wave Input The scale for the square wave input is on the right hand side of the graph whereas the scale for the linear simulation output is on the left hand side of the graph You can specify any input and use the CD Linear Simulation VI to observe how the system responds to that input National Instruments Corporation 5 11 Control Design User Manual Chapter 5 Time Response Analysis Obtaining Time Response Data The Time Response VIs return time response data that contains information about the time response of all input output pairs in the model Use the CD Get Time Response Data VI to access this information for a specified input output pair a list of input output pairs or all input output pairs of the system Refer to the LabVIEW Help available by selecting Help Search the LabVIEW Help for more information about the CD Get Time Response Data VI Control Design User Manual 5 12 ni com Working with Delay Information Delays in a system model account for the fact that the inputs and outputs of a system often do not respond immediately to excitation For example chemical plants transfer fluid and materials between the proce
60. this chapter Configuring State Controllers Use the CD State Space Controller VI to define a controller structure This VI integrates K into a dynamic system for analyzing and simulating the controller performance Use the polymorphic VI selector to define one of the following three controller types e Compensator Places a reference on the state Defines the control action using u K r x where r is a state reference If you estimate any states u K r x defines the state compensator control action National Instruments Corporation 14 1 Control Design User Manual Chapter 14 Defining State Space Controller Structures Regulator Places a reference on the input Defines the control action using u r Kx where r is an input reference If you estimate any states u r Kx defines the state regulator control action Regulator with Integral Uses the following equation to define the control action x ae le K fow In this equation y is the output reference or setpoint The difference in these controllers is in how you calculate the control action u You can implement any of these controller types using one of four different configurations Use the Configuration parameter of the CD State Space Controller VI to define a controller structure using one of the following four configurations Control Design User Manual System Included Appends the actual states of the system to the estimated
61. this estimation X k 1 k x 6 5 Ax 5 4 Bx 5 4 L y 5 y 5 y 5 Cx 5 4 Du 5 In these equations the predictive observer applies the observer gain L to the difference between the measured output y k and the estimated output y k You can use the CD Ackermann VI or the CD Pole Placement VI to calculate L Refer to the Pole Placement Technique section of Chapter 12 Designing State Space Controllers for more information about using these VIs At the next time step k 6 the state estimate x 6 5 becomes the predicted state estimate x k k 1 The predictive observer uses this information to estimate the model states at time k 7 or x 7 6 Use the Discrete Observer function to implement a predictive observer For example consider the following discrete state space model x k 1 ths 01 y k 1 ox where T is a sampling time of 0 1 seconds 15 2 ni com Chapter 15 Estimating Model States Figure 15 1 shows the front panel controls that define this state space model Figure 15 1 Defining the Discrete State Space Model This model has two states x1 and x2 Figure 15 2 shows a block diagram that implements a predictive observer for this model E State x k bep CD Construct State Space Model vi W a ia eel eed fuer 7 be Error e k ki i Predicted State Estimate Initial State iscretel xhat k k 1 stimate xhat O 1 ees aes gie Figure 15 2
62. types State Compensator A general system configuration appends the original model states x to the estimation model states x to represent the compensator with an estimator The following equations show this process x 4 BK 0 x Bx r BK A x BK 0 y 5 u K olrg x olp 7 0 C DK 0 Ac DKO 0 x y DK C DKO HP ir Table 14 1 summarizes the different state compensator configurations and their corresponding states inputs and outputs Table 14 1 State Compensator Configurations Configuration Type States Inputs Outputs Fx u System Included x r y 1 LY r p J u System Included with Noise x i y LX ry 7 LY Standalone with Estimator x Mx LY LY Standalone without Estimator x F i LY The following sections show how to define each configuration of a state compensator National Instruments Corporation 14 3 Control Design User Manual Chapter 14 Control Design User Manual Defining State Space Controller Structures System Included Configuration In the system included configuration the following equation defines the output error y y C x x By substituting the output error in the general system configuration and removing the sensor noise r from the system you obtain the following equations that describe the system included configuration _ 4 BK Lc Lc x BK x BK A x BK K olr
63. weight matrix e Nis the control action error weight matrix e k i k is the predicted plant output at time k i given all measurements up to and including those at time k e r k i k is the output setpoint profile at time k i given all measurements up to and including those at time k e Au k i k is the predicted rate of change in control action at time k i given all measurements up to and including those at time k e u k i k is the predicted optimal control action at time k i given all measurements up to and including those at time k e s k i k is the input setpoint profile at time k i given all measurements up to and including those at time k You specify soft constraints Q R and N by using the MPC Cost Weights parameter of the CD Create MPC Controller VI Refer to the Implementing the MPC Controller section of this chapter for information about specifying r k i k and s k i k The CD Implement MPC Controller VI calculates the values of u k i k Au k i k and P k i k 18 6 ni com Chapter 18 Creating and Implementing a Model Predictive Controller Specifying Constraints In addition to weight matrices in the cost function you can specify constraints on the parameters of an MPC controller Remember that weight matrices adjust the priorities of the control action rate of change in control action and plant outputs Constraints are limits on the values of each of these parameters Use the CD Create MPC Contro
64. where k is discrete time Table 18 1 Example Terms and Definitions Term Physical Component Variable Controller Cruise control system Control action Amount of gas sent to the engine u k Plant Car Plant output Velocity of the car y k Plant output Velocity at which you set the r k setpoint cruise control system Disturbance Slope of the road d k National Instruments Corporation 18 1 Control Design User Manual Chapter 18 Creating and Implementing a Model Predictive Controller Consider what happens when the slope of the road increases as the car moves up a hill This slope increase reduces the velocity of the car This decrease in velocity causes the controller to send more gas to the engine If the cruise control system is a traditional feedback controller this controller reacts to the disturbance only after the velocity of the car drops To match the output setpoint this controller might increase the control action sharply This sharp increase can result in oscillation or even instability If the cruise control system has predictive ability this controller knows in advance that the velocity of the car will drop soon The controller might obtain this information from sensors on the front of the car that measure the slope of the road ahead A feedback controller with this predictive ability is called an MPC controller To match this predicted output setpoint the MPC controller gradu
65. 0 are the roots of the transfer function denominator D s As K becomes larger the roots of the previous characteristic equation approach either the roots of N s the zeros of the open loop system or infinity For a closed loop system with a non zero finite gain K the solutions to the preceding equation are given by the values of s that satisfy both of the following conditions KH s 1 ZH s 2k 1 n k 0 1 Use the CD Root Locus VI to compute and draw root locus plots for continuous and discrete SISO models of any form You also can use this VI to synthesize a controller Refer to the Root Locus Design Technique section of Chapter 11 Designing Classical Controllers for information about using the CD Root Locus VI to design a controller 8 2 ni com Analyzing State Space Characteristics 3 State space analysis involves analyzing the state variables of a system State variables describe the relationship between the inputs and outputs of a system These variables often have physical meaning and represent some internal state of the system under analysis For example consider a motor that has power as its input and speed as its output If you represent this system as a state space model the state variables are speed and rotation angle To design an effective controller you must perform a state space analysis on the controller model State space analysis determines whether a system is stable controllable obse
66. 4 Defining the Discrete Plant Model eee eee 16 17 Adding Noise to the Discrete Plant Model ee 16 19 Implementing the Discrete Extended Kalman Filter Function 0 ec eee ee ceeeeeseeeeseeseeeseeeeees 16 20 Noisy RL Circuit Example mnnn a cutee coeecsudactends coved ened ste E EEEE 16 22 Constructing the System Model cee eceeeeseeseceeceseeeeecseseseeeeeaeeseesseeaeees 16 23 Constructing the Noise Model 0 0 eee ceceeeesecseceeeeseeeeecseeeeeesessaesseesseeaeees 16 24 Converting the Model s s cc2 cscsce ss scsscetesezscbesiessesssubsvscgadnestdevessuctcaass era Taa aa 16 26 Simulating The Model i ssdcccisccescssnnss tvasescaestesscovtee Soa scouavveveceetvaceescetacsegeeueues 16 27 Implementing a Kalman Filter 0 eee cece eeeeeseceeeeseeseeeaeceeessesseeeaeesees 16 29 Chapter 17 Deploying a Controller to a Real Time Target Defining Controller Models spirer i 17 3 Defining a Controller Model Interactively cece eee eseeeeeeeeceeeeseeeaeesees 17 3 Defining a Controller Model Programmatically 00 0 ee eee eeeeseeeeeereeeees 17 4 Writing Controller Codex saints en ile ise ell Mai ies ae allah 17 4 Example Transfer Function Controller Code cece eeeeseeseeeeeseseeeeeeeees 17 5 Example State Compensator Code eeceeeseeseeeseeseeeseeseeesecseneeeseeeaeesees 17 6 Example SISO Zero Pole Gain Controller with Saturation Code 17 7 Example State Space Controller with Predictive Observer Code 17
67. 4 ni com Chapter 1 Introduction to Control Design You also can use the Control Design Assistant to create a project In one project you can load or create a model of a plant into the Control Design Assistant analyze the time or frequency response and then calculate the controller parameters With the Control Design Assistant you immediately can see the mathematical equation and graphical representation that describe the model You also can view the response data and the configuration of the controller Using the Control Design Assistant you can convert a project to a LabVIEW block diagram and customize that block diagram in LabVIEW You then can use LabVIEW to enhance and extend the capabilities of the application Refer to the LabVIEW SignalExpress Help for more information about using the Control Design Assistant to analyze models that describe a physical system and design controllers to achieve specified dynamic characteristics Control Design Vis The Control Design and Simulation Module also provides VIs that you can use to create and develop control design applications in LabVIEW You can use these VIs to develop mathematical models of a dynamic system analyze the models to learn about their dynamic characteristics and create controllers to achieve specified dynamic characteristics You use these VIs to customize a LabVIEW block diagram to achieve specific goals You also can use other LabVIEW VIs and functions to enhance the funct
68. 5s Figure 4 4 illustrates this relationship Q Q L ee Hals aly Has Q 1 A Q L aisle SE ris IQ ea aa Figure 4 4 Two Valve Models and Two Tank Models in Series This combined system which now is a SIMO system has one input s and two outputs L s and L s Figure 4 5 is a LabVIEW block diagram that illustrates this system Figure 4 5 Block Diagram of the Two Valves and Tanks in Series Control Design User Manual 4 4 ni com Chapter 4 Connecting Models Connecting MIMO Systems in Series When connecting MIMO systems you can connect any output of the first model to any input s of the second model Figure 4 6 shows an example of two MIMO system models connected in series Ug Zo lt r uy Z4 Zi i i gt m up Z2 n _ _ Model 1 Lp e 7 o TE uj Z a4 ZI i i p AEA T wi Yo o gt My y i i gt 1 Vo Yo 3 1 e e i e e e e i Vk p Viet Figure 4 6 MIMO System Models in Series Figure 4 6 shows how the outputs of Model 1 that are connected to the inputs of Model 2 do not appear as outputs of the resulting series model For example because z connects to the Model 2 inputs v and vy zy is no longer an output of the resulting series model Similarly because zz connects to vo Z2 is no longer an output of the resulting series model N
69. 8 Example State Space Controller with Current Observer Code 17 9 Example State Space Controller with Kalman Filter for Stochastic System Code ees cise sis sde reverands a ia evap a dhstt enone 17 11 Example Continuous Controller Model with Kalman Filter Code 17 12 Control Design User Manual X ni com Contents Finding Example NI DAQmx I O Code eee eeeecceseeecceneceeceseseeeeseseeesaeesaeeeeeseeaees 17 13 Chapter 18 Creating and Implementing a Model Predictive Controller Creating the MPC Controller icc2i cc ccsescctesccscssecescesn states Sendessseacepatesces seb iaaa sea ra ika irist 18 3 Defining the Prediction and Control Horizons eee eee ceeeeeeeeeeeteeeeeees 18 3 Specifying the Cost FUNCtion 2 0 0 ec eeeesccseeeecseceeeceeseseeseesaeeseesaeeasenaeens 18 5 Specifying Constraints ei eiaa aie i a EENEN 18 7 Dual Optimization Method sssseesesessersesesresresesrrsrsresrssesrrsrsresreeess 18 7 Barrier Function Method sesessessseesssrseresesreresrrsrsresrsresresrsresrsrese 18 8 Relationship Between Penalty Tolerance and Parameter Values 00 0 cece eseeseeeeeeeseeeeseeseeeneeeees 18 9 Prioritizing Constraints and Cost Weightings 18 10 Specifying Input Setpoint Output Setpoint and Disturbance Profiles 0 0 18 13 Implementing the MPC Controller eeeeseeseeeecsecesecseeeaeesesesecseeeaeeeseaseeeeaes 18 14 Providing Setpoint and Disturbance Profiles to the MPC Controll
70. Cov w v If you choose the External Noise instance of the Continuous Nonlinear Noisy Plant function you must generate the samples of the noise vectors w and v and wire them to the Process noise w t input and the Measurement noise v t input of the Continuous Nonlinear Noisy Plant function respectively Refer to the Constructing Noise Models section of this chapter for more information about constructing noise models in the Control Design and Simulation Module Implementing the Continuous Extended Kalman Filter Function After you define the plant model and add noise to the model you can use the Continuous Extended Kalman Filter function to estimate the states of the nonlinear stochastic state space model The following figure illustrates how to use the Continuous Extended Kalman Filter function with the Nonlinear Continuous Noisy Plant function The following figure uses the Internal Jacobian instance of the Continuous Extended Kalman Filter function Note that the Continuous Extended Kalman Filter function utilizes the plant model along with the measurements made on the plant to produce state estimates x f 16 12 ni com Chapter 16 Using Stochastic System Models Control amp Simulation Loop Cezar Ei Plant Model pat mo i enor os on Model vi path Input u t pen Simulation Time Waveform x1 t x1
71. Estimating Model States In Figure 15 3 notice the predictive observer starts estimating both model states correctly after about one second To confirm this analysis you can look at the Error e k graph defined as x k xhat klk 1 for each model state Figure 15 4 shows the error graph of this example Bee et E CCRC Figure 15 4 Estimation Error of a Predictive Observer Figure 15 4 confirms the estimation error of this predictive observer becomes zero after about one second Refer to the LabVIEW Help available by selecting Help Search the LabVIEW Help for information about the general forms of the equations the Discrete Observer function uses to calculate the outputs Control Design User Manual 15 6 ni com Chapter 15 Estimating Model States Current Observer The difference between a predictive and current observer is that a predictive observer uses measured output y k to estimate the predicted state x k 1 k However a current observer uses y k to estimate the current state x k k and uses that information to estimate x k 1 k This extra calculation means that a current observer is more accurate than a predictive observer Consider an example at time step k 5 At this time step the Discrete Observer function estimates x 5 5 using x 5 4 measured output y 5 estimated output y 5 and known input u 5 The following equations show this estimation x k k x 5 5 x 5 4 L 9 5 5
72. HXs H s L s I s _ Figure 4 2 Valve Model and Tank Model in Series The resulting SISO system H s now represents the relationship between the input signal s and the level of water L s in the tank Creating a SIMO System in Series You can create a SIMO system by connecting two or more SISO systems with a SIMO subsystem For example adding another valve and tank to the example in the Connecting SISO Systems in Series section of this chapter results in a SIMO system that divides the flow rate between two different tanks Figure 4 3 shows this system Ks Input Signal i Q s Flow Rate H4 s EO Ht2 s EO L4 s Level Tank 1 Lo s Level Tank 2 Figure 4 3 Dividing the Flow of Water between Two Tanks National Instruments Corporation 4 3 Control Design User Manual Chapter 4 Connecting Models H s is a SIMO transfer function matrix that represents the relationship of the flow rates By connecting H 2 s to H s and Q s the entire system becomes SIMO The total flow rate Q s is equal to the sum of the parts Q s and Q s O s O s Q s AO s 1 A NO s The constant A represents the fraction of flow sent to the first tank whereas 1 A is the remaining fraction of flow sent to the second tank H s A When you connect these models in series the output of the first system H s connects to the input of the second system H 2
73. I Control Design User Manual 16 10 ni com Chapter 16 Using Stochastic System Models Example LabVIEW Code CD Generalized Ax vi error in no error Fach Figure 16 2 SIM Continuous Nonlinear Plant Model Template VI Modified With Example LabVIEW Code Adding Noise to the Continuous Plant Model After you define the plant model use the Continuous Nonlinear Noisy Plant function to add noise to the model Wire a reference to the SIM Continuous Nonlinear Plant Model template VI to the Plant Model input of the Continuous Nonlinear Noisy Plant function to simulate the plant model corrupted by additive noise Control amp Simulation Loop Figure 16 3 Adding Noise to the Continuous Plant Model National Instruments Corporation 16 11 Control Design User Manual Chapter 16 Control Design User Manual Using Stochastic System Models The Continuous Nonlinear Noisy Plant function simulates the plant dynamics according to the following equations x t f x u t w t y t A x u t v t where w is the process noise vector and v is the measurement noise vector of the model You can use the Internal Noise instance of the Continuous Nonlinear Noisy Plant function to generate uncorrelated samples of the Gaussian noise vectors w and v automatically You must specify the mean vectors Efw and E v the auto covariance matrices Q Cov w w and R Cov v v and the cross variance matrix N
74. ING USE OF NATIONAL INSTRUMENTS PRODUCTS 1 NATIONAL INSTRUMENTS PRODUCTS ARE NOT DESIGNED WITH COMPONENTS AND TESTING FOR A LEVEL OF RELIABILITY SUITABLE FOR USE IN OR IN CONNECTION WITH SURGICAL IMPLANTS OR AS CRITICAL COMPONENTS IN ANY LIFE SUPPORT SYSTEMS WHOSE FAILURE TO PERFORM CAN REASONABLY BE EXPECTED TO CAUSE SIGNIFICANT INJURY TO A HUMAN 2 IN ANY APPLICATION INCLUDING THE ABOVE RELIABILITY OF OPERATION OF THE SOFTWARE PRODUCTS CAN BE IMPAIRED BY ADVERSE FACTORS INCLUDING BUT NOT LIMITED TO FLUCTUATIONS IN ELECTRICAL POWER SUPPLY COMPUTER HARDWARE MALFUNCTIONS COMPUTER OPERATING SYSTEM SOFTWARE FITNESS FITNESS OF COMPILERS AND DEVELOPMENT SOFTWARE USED TO DEVELOP AN APPLICATION INSTALLATION ERRORS SOFTWARE AND HARDWARE COMPATIBILITY PROBLEMS MALFUNCTIONS OR FAILURES OF ELECTRONIC MONITORING OR CONTROL DEVICES TRANSIENT FAILURES OF ELECTRONIC SYSTEMS HARDWARE AND OR SOFTWARE UNANTICIPATED USES OR MISUSES OR ERRORS ON THE PART OF THE USER OR APPLICATIONS DESIGNER ADVERSE FACTORS SUCH AS THESE ARE HEREAFTER COLLECTIVELY TERMED SYSTEM FAILURES ANY APPLICATION WHERE A SYSTEM FAILURE WOULD CREATE A RISK OF HARM TO PROPERTY OR PERSONS INCLUDING THE RISK OF BODILY INJURY AND DEATH SHOULD NOT BE RELIANT SOLELY UPON ONE FORM OF ELECTRONIC SYSTEM DUE TO THE RISK OF SYSTEM FAILURE TO AVOID DAMAGE INJURY OR DEATH THE USER OR APPLICATION DESIGNER MUST TAKE REASONABLY PRUDENT STEPS TO PROTECT AGAINST SYSTEM FAILURES INCLUDING B
75. Implementing a Predictive Observer for the State Space Model National Instruments Corporation 15 3 Control Design User Manual Chapter 15 Estimating Model States The example in Figure 15 2 uses the Discrete State Space function to calculate the actual states of this model At each time step this example compares the actual State x k to the Predicted State Estimate xhat klk 1 which is the state this function estimated at the previous time step The difference between these two values is the Error e k This example also uses the CD Pole Placement VI to calculate the observer gain L such that the Poles of the predictive observer are in a location you define In this example the predictive observer poles are located at 0 4 0 41 Because this example has an Initial State x 0 value of 0 017 both model states return a constant value of zero The Wait Until Next ms Multiple function determines the speed at which the While Loop executes Note This model is adapted from pp 292 93 of Digital Control of Dynamic Systems as listed in the Related Documentation section of this manual Control Design User Manual 15 4 ni com Chapter15 Estimating Model States If you execute this example with an Initial State Estimate xhat 0l 1 of 0 1 this example returns the graphs shown in Figure 15 3 Figure 15 3 Actual Model States vs Estimated Model States National Instruments Corporation 15 5 Control Design User Manual Chapter15
76. K 0 N pK c BI r B 0 y 9 Tor ry p Doe Table 14 2 summarizes the different state regulator configurations and their corresponding states inputs and outputs Table 14 2 State Regulator Configuration Types Configuration Type States Inputs Outputs r u System Included x r y x al BA E P 4 u System Included with Noise x y B3 ry y Standalone with Estimator x Pu t Ly LY Standalone without Estimator x r 4 The following sections show how to define each configuration Control Design User Manual 14 8 ni com Chapter 14 Defining State Space Controller Structures System Included Configuration In the system included configuration the following equation defines the output error y y C x x By substituting the output error in the general system configuration and removing the sensor noise r from the system you obtain the following equations that describe the system included configuration x _ 4 BK LC LC x Bl S BK A i u K OJ I A x y c px o fofr x y DK C The reference vector or actuator noise r has as many elements as the number of inputs Also this configuration calculates the control action u internally and then gives u as an output of the state regulator Figure 14 5 represents the dynamic system that these equations describe ry u a J y gt Co
77. LabVIEW Control Design User Manual June 2009 7 NATIONAL 371057G 01 INSTRUMENTS Worldwide Technical Support and Product Information ni com National Instruments Corporate Headquarters 11500 North Mopac Expressway Austin Texas 78759 3504 USA Tel 512 683 0100 Worldwide Offices Australia 1800 300 800 Austria 43 662 457990 0 Belgium 32 0 2 757 0020 Brazil 55 11 3262 3599 Canada 800 433 3488 China 86 21 5050 9800 Czech Republic 420 224 235 774 Denmark 45 45 76 26 00 Finland 358 0 9 725 72511 France 01 57 66 24 24 Germany 49 89 7413130 India 91 80 41190000 Israel 972 3 6393737 Italy 39 02 41309277 Japan 0120 527196 Korea 82 02 3451 3400 Lebanon 961 0 1 33 28 28 Malaysia 1800 887710 Mexico 01 800 010 0793 Netherlands 31 0 348 433 466 New Zealand 0800 553 322 Norway 47 0 66 90 76 60 Poland 48 22 328 90 10 Portugal 351 210 311 210 Russia 7 495 783 6851 Singapore 1800 226 5886 Slovenia 386 3 425 42 00 South Africa 27 0 11 805 8197 Spain 34 91 640 0085 Sweden 46 0 8 587 895 00 Switzerland 41 56 2005151 Taiwan 886 02 2377 2222 Thailand 662 278 6777 Turkey 90 212 279 3031 United Kingdom 44 0 1635 523545 For further support information refer to the Technical Support and Professional Services appendix To comment on National Instruments documentation refer to the National Instruments Web site at ni com info and enter the info code feedback 2004 2009 National Instruments Corporation All
78. Order Hold This VI does not support the First Order Hold or Matched Pole Zero methods Refer to Table 3 1 for the equations for each mapping method The Z Transform method also is a reverse calculation to map a model in the z plane to the s plane You calculate the impulse response of the continuous transfer function by dividing the inverse z transform of the discrete transfer function by the sampling time T National Instruments Corporation 3 13 Control Design User Manual Chapter 3 Converting Models Resampling a Discrete Model Use the CD Convert Discrete to Discrete VI to resample a discrete model This VI converts the discrete model to a continuous model and then converts the continuous model back to a discrete model The first conversion uses the initial sampling time T The second conversion uses the final sampling time T The CD Convert Discrete to Discrete VI supports the following conversion methods Forward Rectangular Backward Rectangular Tustin s Prewarp Zero Order Hold and Z Transform This VI does not support the First Order Hold or Matched Pole Zero methods Control Design User Manual 3 14 ni com Connecting Models You typically create a dynamic system model by connecting many models or subsystems together Connecting many models together makes developing a model of a complicated dynamic system less complicated because you can describe the dynamics of individual pieces You can connect continuous mo
79. P 0I 1 parameter this function sets this parameter as the identity matrix Refer to the Discrete Models section of Chapter 12 Designing State Space Controllers for more information about how a Kalman filter uses the gain and estimation error covariance matrices Refer to LabVIEW Help for the equations the Discrete Kalman Filter function uses to calculate the outputs The LabVIEW Control Design and Simulation Module also includes the Continuous Kalman Filter function Use this function to implement a Kalman filter for a continuous stochastic model Because continuous Kalman filters must solve differential equations over time you only can place the Continuous Kalman Filter function inside a Control amp Simulation Loop Using an Extended Kalman Filter to Estimate Model States Control Design User Manual Kalman filters estimate model states based on noisy sensor measurements Regular Kalman filters estimate model states of linear systems If you need to estimate model states for a nonlinear system you must use an extended Kalman filter An extended Kalman filter filters and estimates the model states of a partially observable plant based on noisy measurements The following diagram depicts the process of using an extended Kalman filter in a control system 16 6 ni com Chapter 16 Using Stochastic System Models Plant Model Extended Kalman Filter Figure 16 1 The Process of Using an Extended Kalman Filter In
80. Response VIs to analyze the response of a system to step and impulse inputs You can apply initial conditions to both of these responses You also can use the Time Response VIs to simulate the response of the system to an arbitrary input This chapter provides information about using the Control Design and Simulation Module to measure and analyze the time response of a system This chapter also provides information about solving the time domain equations and simulating arbitrary inputs 3 Note Refer to the labview examples Control and Simulation Control Design Time Analysis directory for example VIs that demonstrate the concepts explained in this chapter Calculating the Time Domain Solution The following equation represents the time domain solution for a continuous state space model t A A t x t e xot fe 9 Bu t dt 0 Xo represents any initial conditions of the states in the model e4 x9 represents the solution of the model at the initial conditions This solution is known as the free response National Instruments Corporation 5 1 Control Design User Manual Chapter 5 Time Response Analysis t Alt f e Bu t dt represents the state response for stable systems over 0 time as the inputs u t drive the dynamic system from time t t to t This solution is the forced response The following equation represents the time domain solution for a discrete state space model k 1 x k A x 0 5A Bul
81. State Space Controller Structures for more information about defining a controller structure Kalman Gain The Kalman gain is the value of L that minimizes the covariance of estimation error for a given continuous or discrete state space model affected by noise An estimator that uses the Kalman gain is called a Kalman filter Kalman filters estimate model states despite the presence of noise Use the CD Kalman Gain VI to calculate the optimal steady state value of L The following sections provide information about calculating the Kalman gain matrices to apply to continuous and discrete Kalman filters National Instruments Corporation 12 5 Control Design User Manual Chapter 12 Control Design User Manual Designing State Space Controllers Continuous Models For continuous models the Kalman filter estimates the model states at time t The following equation defines the estimated state vector x t the Kalman filter calculates x t Ax t Bu t L y t y 2 y t Cx t Du t In these equations L is the gain matrix of the Kalman filter The Kalman filter estimates the accuracy of the estimated states by calculating the steady state covariance of the estimation error The following equations define this covariance matrix P and the estimation error e t P lim E e t e t tr e t x t x t where E denotes the expected mean of the enclosed terms You calculate the Kalman gain L that minimizes P Use
82. UT NOT LIMITED TO BACK UP OR SHUT DOWN MECHANISMS BECAUSE EACH END USER SYSTEM IS CUSTOMIZED AND DIFFERS FROM NATIONAL INSTRUMENTS TESTING PLATFORMS AND BECAUSE A USER OR APPLICATION DESIGNER MAY USE NATIONAL INSTRUMENTS PRODUCTS IN COMBINATION WITH OTHER PRODUCTS IN A MANNER NOT EVALUATED OR CONTEMPLATED BY NATIONAL INSTRUMENTS THE USER OR APPLICATION DESIGNER IS ULTIMATELY RESPONSIBLE FOR VERIFYING AND VALIDATING THE SUITABILITY OF NATIONAL INSTRUMENTS PRODUCTS WHENEVER NATIONAL INSTRUMENTS PRODUCTS ARE INCORPORATED IN A SYSTEM OR APPLICATION INCLUDING WITHOUT LIMITATION THE APPROPRIATE DESIGN PROCESS AND SAFETY LEVEL OF SUCH SYSTEM OR APPLICATION Contents About This Manual GONVENEIONS earan en ENNE E E cube lek cohen Lavedeabeniu EE EAE be desea haces eases ee xiii Related Docume ntati f nsei iritisa EE Eai N EE aSa xiv Chapter 1 Introduction to Control Design Model Based Control Design sssseeesseesesessesesresreresresrsresrsrestestsrestsresrernresreesreeesestsees 1 2 Developing a Plant M odels iiiiiiiissisiitiiiscisii inrsin iior 1 3 Designing a Controller sssrini ie e e A ed tote A a vetoes 1 3 Simulating the Dynamic System sssssssssssseesssesesesrrsrsrestsrestrsrsresrsresresesresrses 1 4 Deploying the Controller scc eee niiina inani 1 4 Overview of LabVIEW Control Design eseesssesssessseerssrsrrsrsresrestsresteresresreresreseseeneeses 1 4 Control Design Assistant sciinta iia 1 4 Control Design VIS erren
83. a continuous model to a discrete one first approximate the value of the derivative in the continuous equation over each change in time Then find the area of the geometric region having width dt and height equal to the derivative For example consider the following first order continuous differential equation y f t 3 6 ni com Chapter 3 Converting Models To convert this continuous model to a discrete model evaluate the derivative function f t at different points to approximate y at time t Figure 3 1 illustrates the function f t between t and t T where T is the sampling time Kd Figure 3 1 Discretizing a Differential Equation Integrating between time and T results in the following difference equation t T t T sat yer T y Moar t t Integrating f t for T t to t T represents the area under the curve The CD Convert Continuous to Discrete VI provides the following mathematical methods to approximate this area e Forward Rectangular e Backward Rectangular e Tustin s e Prewarp e Zero Order Hold e First Order Hold Z Transform e Matched Pole Zero The following sections provide information about each of these methods National Instruments Corporation 3 7 Control Design User Manual Chapter 3 Converting Models Control Design User Manual Forward Rectangular Method The Forward Rectangular method considers f t constant and equal to f t along th
84. a naaa a a a 1 5 Control Design MathScript RT Module Functions ssesseeeeseeeseeseeeesrseeereeree 1 6 Chapter 2 Constructing Dynamic System Models Constructing Accurate Models 00 cee ecesseeseeseeeeceeeseeeseceeeesecseeesesseeesecsaeeaeeeseaseeeeaes 2 2 Model Representation mei eioen oiii EE EE EE E AEEA A E E 2 3 Model Types rrain tan E a E aT 2 3 Linear versus Nonlinear Models cccc ccccccssssccecesssseecceesssseeeees 2 3 Time Variant versus Time Invariant Models ccccccccccsessseeeee 2 4 Continuous versus Discrete Models cccccccccesssecceesssssceceesessseees 2 4 Model PO S a a ch ehecda sta tahaces Seiad tags ood ee ware 2 5 REC Circuit Examiple ii ie sii need bai dete n a a a a a alae iaa 2 6 Constructing Transfer Function Models 0 cece eeceseeseceeceseseeeeseseeeeseeeeeaeeseeesseneeaes 2 6 SISO Transfer Function Models ccccsccccccsssssceccceessseeceeesssseeeceeesssseeeceeees 2 7 SIMO MISO and MIMO Transfer Function Models cccccsesseeeeeeeees 2 9 Symbolic Transfer Function Models cece eeeeeeseeseceeceseseeeeseseesseeeeneeens 2 11 Constructing Zero Pole Gain Models eceeeeseesescesecesceseceeeesesseseaecseeeaeeseeeeeeneenaes 2 12 SISO Zero Pole Gain Models ccccccccssssccceeessssceccesesseceecesssseeeceeessseeecesees 2 13 SIMO MISO and MIMO Zero Pole Gain Models cccccscccccessssseeeeeeees 2 14 Symbolic Zero Pole Gain Model
85. acement VI to determine which kind of gain matrix these VIs return This section uses the controller gain matrix K as an example Note The Control Design and Simulation Module refers to the pole placement technique as an observer because this technique does not estimate measurements given random noise This distinction does not affect the interaction between the CD Ackermann VI or the CD Pole Placement VI and other VIs Consider the following SISO state space system with u Kx as the control action x Ax Bu Cx Du 12 2 ni com Chapter 12 Designing State Space Controllers Figure 12 1 shows how you apply the gain matrix K to a controller X Ax Bu _ gt gt y Cx Du a Figure 12 1 Using Kto Regulate the Input of a State Feedback System Given a specification of the closed loop pole locations A A An you can calculate the controller gain matrix K that achieves this goal The system in question must be controllable For example consider a closed loop continuous system that has the following form eS Ax A A BK Because A satisfies the characteristic polynomial equation that the specified closed loop pole locations Ay As A define you can state the following relationships s as 0 1S A E 5 A s A 5 A A A 0 A 0 Aa 0 The locations of are based on the locations of i s is the Laplace variable You can use these eq
86. ack configuration Figure 17 1 shows This structure also ensures the controller code you write executes in real time Refer to the LabVIEW Help for information about configuring and executing a Timed Loop ay Note If you designed a continuous controller model you must convert that model to a discrete one before deploying that model to an RT target The sampling time you use in this conversion must equal the Period of the Timed Loop Refer to Chapter 3 Converting Models for more information about converting models The following sections show example transfer function state space and zero pole gain controller code These examples also define and convert models in different ways The following sections also describe how to implement observers and Kalman filters on an RT target Control Design User Manual 17 4 ni com Chapter 17 Deploying a Controller to a Real Time Target Example Transfer Function Controller Code The example in Figure 17 2 constructs a continuous transfer function model in the form of a phase lead controller This example then converts the model to a discrete one using the Zero Order Hold Method and implements that discrete controller model on an RT target Refer to Chapter 3 Converting Models for more information about the Zero Order Hold method Output Node Sampling Time 5 _ B Error __ ees be Es T aa Pery ii oett Lead 7 pe high i i Controller Output
87. aircase VI to inspect the A and C matrices of the transformed model to determine the observable states Analyzing Controllability and Observability Grammians Control Design User Manual An alternative and numerically more stable approach to assessing controllability and observability is to compute the Grammians of the state space matrices The controllability Grammian is an n X n matrix that determines how dependent the state responses are on the different inputs of the system Independent state responses indicate that there always is a set of inputs that can drive the states to zero at a certain time In this case the system is controllable Calculate the eigenvalues of the controllability Grammian to check the dependency of the state responses If the controllability Grammian is positive definite meaning all eigenvalues are real and greater than zero the chosen state space form is controllable Similarly the observability Grammian is an n x n matrix that determines how dependent the state effects are on the different outputs of the system Independent state effects indicate that there always is a set of outputs that you can use to estimate the states at time 0 In this case the system is observable Calculate the eigenvalues of the observability Grammian to check the dependency of the responses of the states If the observability Grammian is positive definite meaning all eigenvalues are real and greater than zero the chosen
88. al Chapter 3 Converting Models Control Design User Manual You obtain the following equation after integrating a linear time invariant system between sampling times t and T t T x t T ef x f e T D Bucq dt y t Cx t Du t In this equation u t is the input to the system and is not necessarily constant between sampling times t and t T The following equation shows the Zero Order Hold method approximating the input to a constant value u t during the integration time t T x t T e47x 1 A Batu t Conversely the following equation shows the First Order Hold method ramping the input values with a constant slope u t T u t T during integration time t T x t T ex t ft ay ue 7 wo har t Refer to Digital Control of Dynamic Systems as listed in the Related Documentation section of this manual for more information about the Zero Order Hold and First Order Hold methods Z Transform Method The Z Transform method is defined such that the continuous and discrete impulse responses maintain major similarities You calculate the impulse response of the discrete transfer function by multiplying the inverse Laplace transform of the continuous transfer function by the sampling time T Refer to Discrete Time Control Systems as listed in the Related Documentation section of this manual for more information about the Z Transform method 3 12 ni com Chapter 3 Converting Models Matche
89. al including photocopying recording storing in an information retrieval system or translating in whole or in part without the prior written consent of National Instruments Corporation National Instruments respects the intellectual property of others and we ask our users to do the same NI software is protected by copyright and other intellectual property laws Where NI software may be used to reproduce software or other materials belonging to others you may use NI software only to reproduce materials that you may reproduce in accordance with the terms of any applicable license or other legal restriction Trademarks National Instruments NI ni com and LabVIEW are trademarks of National Instruments Corporation Refer to the Terms of Use section on ni com legal for more information about National Instruments trademarks MATLAB is a registered trademark of The MathWorks Inc Other product and company names mentioned herein are trademarks or trade names of their respective companies Members of the National Instruments Alliance Partner Program are business entities independent from National Instruments and have no agency partnership or joint venture relationship with National Instruments Patents For patents covering National Instruments products technology refer to the appropriate location Help Patents in your software the patents txt file on your media or the National Instruments Patent Notice at ni com patents WARNING REGARD
90. alculates and returns the value of M k that minimizes the covariance of the estimation error This covariance is a matrix P klk The Discrete Kalman Filter function also calculates the predicted state estimate x k 1 k Calculating the predicted state estimate involves applying a gain matrix L k to the difference between the measured output and the estimated output This function calculates and returns the value of National Instruments Corporation 16 5 Control Design User Manual Chapter 16 Using Stochastic System Models L k that minimizes the covariance of the prediction estimation error This covariance is a matrix P k 1Ik You can assist the Kalman filter by specifying the Initial State Estimate xhat 0l 1 This parameter specifies the state values you think the stochastic model returns at the first time step k 0 Providing this function with initial state estimates helps this function converge on the true state values quicker than if you do not provide an initial estimate If you do not wire a value to this parameter this function sets all initial state values to Zero You also can specify the Initial Estimation Error Covariance P OI 1 This parameter defines the covariance of the estimation error at the first time step A low value of this parameter indicates you have a high degree of confidence in any Initial State Estimate xhat 0I 1 you provide and vice versa If you do specify the Initial Estimation Error Covariance
91. ally increases the control action as the car approaches the change in slope This increase can be smoother and more stable than the increase a traditional feedback controller provides This chapter provides information about using the LabVIEW Control Design and Simulation Module to design and implement a predictive controller iy Note Refer to the Llabview examples Control and Simulation Control Design MPc directory for examples that demonstrate the concepts explained in this chapter Refer to UKACC Control 2006 Mini Symposia as listed in the Related Documentation section of this manual for information about the algorithms these VIs use Control Design User Manual 18 2 ni com Chapter 18 Creating and Implementing a Model Predictive Controller Creating the MPC Controller You use the CD Create MPC Controller VI to create an MPC controller This VI bases the MPC controller on a state space model of the plant that you provide 3 Note Ifyou want to create an MPC controller for a transfer function model or a zero pole gain model you must first convert the model to a state space model Providing an accurate model improves the performance of the MPC controller this VI creates You can specify that the MPC controller incorporates integral action to compensate for any differences between the plant model and the actual plant You can use the State Estimator Parameters input of this VI to define a state estimator that is internal to the
92. an determine the effect of the system model mismatch Consider the following state space model ngih y i s ole This model is similar to the model in the Example System Configurations section of this chapter For this example however assume that the actual system contains uncertainties that cause this state space model to be an inaccurate representation of the system The difference is in the first entry of the system matrix A 0 1 Figure 13 8 shows how the CD State Estimator VI uses the mismatched model State Space Model to create the standalone estimator This configuration connects the actual system System and the mismatched model State Space Model in series so the actual system can provide the output y to the standalone state estimator Observer Gain Current Y Figure 13 8 Standalone State Estimator National Instruments Corporation 13 13 Control Design User Manual Chapter 13 Defining State Estimator Structures The example uses the CD Initial Response VI to evaluate the effectiveness of the state estimator The State Trajectory Graph in Figure 13 9 shows the response of the actual and estimated states to the same set of initial conditions as in the Example System Included State Estimator section of this chapter Figure 13 9 State Trajectory of Standalone State Estimator Notice that a mismatch in the actual system and the model of the system greatly impacts the estimation of the second sta
93. andalone v CD Initial Response vi m State Trajectory Graph ies vi ICD Seri E ee Control Design User Manual Figure 14 18 Standalone with Estimator State Compensator This example sends the input u which the compensator calculates to the actual system using the CD Feedback VI The CD Initial Response VI uses the same initial conditions to test the effectiveness of the controller and estimator Figure 14 19 shows the effect of a using a model that does not match the actual system State Trajectory Graph 6 xiModel x2Model a xiSystem 3 2 x2System 0 2 ior 1 1 1 1 1 1 I 1 a i 2 3 4 5 6 7 8 Figure 14 19 State Trajectory of Standalone with Estimator State Compensator Notice how Figure 14 15 and Figure 14 19 respond differently even though both figures represent responses to the same system with the same initial conditions The example in Figure 14 15 takes 1 to 1 5 seconds to track the actual states The example in Figure 14 19 however takes approximately four seconds to track the actual states The system model mismatch in the latter example accounts for this difference 14 26 ni com Chapter 14 Defining State Space Controller Structures This example is similar to real world applications where you do not know what the actual system is Therefore these tests are important in determining ho
94. ate calculated at time k for the next time step k 1 given all the measurements and inputs up to and including time k e M is the Kalman predictor gain Px 1 x 18 the prediction error covariance matrix calculated at time step k 1 s F Xx p Up k is the Jacobian matrix of f x u k with respect to x evaluated at Xkjk 1 A Xk b Uy k is the Jacobian matrix of h x u k with respect to x evaluated at Xr k 1 If you choose the Internal Jacobian instance of the Discrete Extended Kalman Filter function the Discrete Extended Kalman Filter function internally computes a Jacobian matrix to estimate the states of the nonlinear system If you choose the External Jacobian instance of this function you must define the Jacobian matrix manually Use the SIM Discrete Jacobians template VI located in the labview templates Control and Simulation directory to define the Jacobian matrix Then wire a reference to the SIM Discrete Jacobians template VI to the Jacobians input of the Discrete Extended Kalman Filter function On the block diagram of the SIM Discrete Jacobians template VI you can use either VIs and functions or text based scripts in the MathScript Node to define the external Jacobian matrix The following figure defines a Jacobian matrix using the SIM Discrete Jacobians template VI 16 16 ni com Chapter 16 Using Stochastic System Models lerror in no error Example LabVIEW Code piara E s
95. ate space control design techniques such as the pole placement technique Refer to Chapter 11 Designing Classical Controllers and Chapter 12 Designing State Space Controllers for more information about classical and state space control design techniques National Instruments Corporation 3 1 Control Design User Manual Chapter 3 Converting Models The following sections discuss the Model Conversion VIs you can use to convert between model forms Converting Models to Transfer Function Models Use the CD Convert to Transfer Function Model VI to convert a zero pole gain or state space model to a transfer function model This section uses a state space model as an example aye Note Because transfer function models do not include state information you lose the state vector x when you convert a state space model to a transfer function model Additionally the Control Design and Simulation Module might not be able to recover the same states if you convert the model back to state space form Consider the continuous state space model defined in the Constructing State Space Models section of Chapter 2 Constructing Dynamic System Models x Ax Bu y Cx Du For continuous systems you can use the Laplace transform to convert from the time domain to the Laplace domain model representation 3 Note The equations in this section convert model forms within both the continuous and discrete domains Refer to the Converting between Continuous an
96. ational Instruments Corporation 4 5 Control Design User Manual Chapter 4 Connecting Models This same principle applies to the inputs of Model 2 Inputs of Model 2 that are connected to an output of Model 1 no longer appear as inputs of the resulting series model Because the input vg of Model 2 is connected to the output of z2 of Model 1 neither vp nor zz appear in the resulting series model You define the connections between two models using the Connections control of the CD Series VI Figure 4 7 shows the settings this control used to connect the models in Figure 4 6 Connections Figure 4 7 Connection Definitions for Models in Series The control in Figure 4 7 indicates that the Model 1 output zo connects to the Model 2 inputs v and v You also can see how the Model 1 output z connects to the Model 2 input vp Appending Models You can append models together to compare the time or frequency response of two models in the same plot Use the CD Append VI to produce an augmented model from connections between two models This augmented model contains all inputs and outputs of both models With state space models states of the first model are combined with states of the second model Control Design User Manual 4 6 ni com Chapter 4 Connecting Models Figure 4 8 shows two appended system models Up 2 Uy Zi EE ee Model 1 i i o eo i i e e i Uj Z e 1 Vo Yo 1 Vy y Vo Y2
97. ays from Model VI This VI returns the input output and transport delays of a model in the Input Delays Output Delays and Transport Delays outputs respectively Incorporating Delay Information After you define any delay information in a model you then can make that delay a permanent part of the model Incorporating delay information into a model works differently for continuous system models and discrete system models In both cases you represent a common delay factor and multiply the system model by this factor The process by which you determine this factor however varies depending on the type of system model With continuous system models you apply the Laplace transformation to the system to represent the delay as an exponential factor With discrete system models you apply the shift operator to the system to represent the delay as a factor The delay factor for a continuous system is e The delay factor for a discrete system is z Refer to the Delay Information in Continuous System Models section and the Delay Information in Discrete System Control Design User Manual 6 2 ni com Chapter 6 Working with Delay Information Models section of this chapter for information about these delay factors and incorporating them into system models 3 Note These delay factors do not always have the same value in systems with more than one input output pair Single input multiple output SIMO multiple input single output MISO
98. conditioner In this example the room is the plant the thermometer is the sensor the thermostat is the controller and the heater or air conditioner is the actuator National Instruments Corporation 1 1 Control Design User Manual Chapter 1 Introduction to Control Design Other common examples of control systems include the following applications e Automobile cruise control systems e Robots in manufacturing e Refrigerator temperature control systems e Hard drive head control systems This chapter provides an overview of model based control design and describes how you can use the LabVIEW Control Design and Simulation Module to design a controller Model Based Control Design Control Design User Manual Model based control design involves the following four phases developing and analyzing a model to describe a plant designing and analyzing a controller for the dynamic system simulating the dynamic system and deploying the controller Because model based control design involves many iterations you might need to repeat one or more of these phases before the design is complete Figure 1 2 shows how National Instruments provides solutions for each of these phases Plant Modeling Control Design Deployment and Analysis and Simulation LabVIEW System LabVIEW LabVIEW Identification Control Design and Real Time Toolkit Simulation Module Module LabVIEW Figure 1 2 Using LabVIEW in Model Based
99. configurations The examples in these sections use the CD Ackermann VI to calculate the estimator gain matrix L You also can calculate L using the CD Pole Placement VI or the CD Kalman Gain VI Example System Included State Estimator Figure 13 4 shown below uses the CD Ackermann VI to determine the estimator gain matrix L of the second order SISO State Space Model You then use L with the CD State Estimator VI to create the state estimator represented by the Estimator Model for the system btate Space Model Configuration System Included Y ICD Ackermann vi stimator Model CD State Estimator vi CD Pole Zero Map vi Greco oles in Estimator Model Observer Gain Current Figure 13 4 System Included State Estimator ay Note You can study the performance of the state estimator with the CD Initial Response VI Control Design User Manual 13 8 ni com Chapter 13 Defining State Estimator Structures This configuration creates an Estimator Model that represents the original or actual states of the system and the estimated states in the same model The Estimator Model consists of four states because this configuration appends the original second order SISO state space model to the state estimator as shown in the following expression peg A Note The direct transmission matrix D is not part of the expression because it is null in this example gt lt
100. constant accelerating and decelerating 3 Note You can reduce these aggressive changes by using weight matrices in the cost function Refer to the Specifying the Cost Function section of this chapter for information about weight matrices You provide horizon information by using the MPC Controller Parameters parameter of the CD Create MPC Controller VI Specifying the Cost Function The MPC controller calculates a sequence of future control action values such that a cost function is minimized You can specify weight matrices in this cost function These weight matrices adjust the priorities of the control action rate of change in control action and plant outputs Mational Instruments Corporation 18 5 Control Design User Manual Chapter 18 Creating and Implementing a Model Predictive Controller Control Design User Manual For specified prediction and control horizons N and N the MPC controller attempts to minimize the following cost function J k Np J k gt k ilk r k ilk Q Lk ilk r k il k i Nw Ne 1 Np 5 Au k ik R Au k i k u k i k s k i k i 0 i Nw N u k ilk s k i k where e kis discrete time e iis the index along the prediction horizon e N is the number of samples in the prediction horizon e N is the beginning of the prediction horizon e WN is the control horizon e Q is the output error weight matrix e Ris the rate of change in control action
101. contains information about the frequency response of all input output pairs in the model The frequency response information for the CD Bode VI returns information about the Bode magnitude and Bode phase The frequency response information for the CD Nichols VI returns information about the real and imaginary parts of the frequency response The frequency response information for the CD Nyquist VI returns information about the open loop gain and open loop phase Use the CD Get Frequency Response Data VI to access this information for a specified input output pair a list of input output pairs or all input output pairs of the system The CD Get Frequency Response Data VI uses the Frequency Response Data input which contains the frequency response information for all the input output pairs of a system model For state space models the CD Get Frequency Response Data VI returns the frequency response of the input state pair s Because transfer function and zero pole gain models do not have states the frequency response data for an input state pair of these forms is an empty array Refer to the LabVIEW Help available by selecting Help Search the LabVIEW Help for more information about using the CD Get Frequency Response Data VI National Instruments Corporation 7 7 Control Design User Manual Analyzing Dynamic Characteristics Any given dynamic system has numerous dynamic characteristics such as stability DC gain damping ratio na
102. controller models to an RT target you must use a Control amp Simulation Loop Refer to the Example Continuous Controller Model with Kalman Filter Code section of this chapter for more information about deploying continuous models to an RT target 3 Note Deploying controller code to an RT target involves the LabVIEW Real Time Module This chapter is not intended to provide a a comprehensive discussion of using the Real Time Module If you installed the Real Time Module refer to the LabVIEW Help available by selecting Help Search the LabVIEW Help for information about deploying a VI to an RT target using the Timed Loop and creating I O code to and from RT hardware National Instruments Corporation 17 1 Control Design User Manual Chapter 17 Deploying a Controller to a Real Time Target Figure 17 1 shows where you place a controller in a closed loop dynamic system Control System Reference ee Oid Physical System Plant Digital to Analog Controller li Converter DAC LP Actuators Analog to Digital Converter ADC Sensors a Figure 17 1 Closed Loop Dynamic System In Figure 17 1 the controller represents an RT target running a VI that contains the controller code you designed Because the RT target is digital you need a digital to analog converter DAC to convert the digital controller output into an analog signal the actuator recognizes If the sensor is a
103. ct one of the Discretized Kalman Gain instances of the CD Kalman Gain VI These instances automatically convert a continuous model to a discrete model before calculating L and M This VI first discretizes the A B C and D matrices using the Zero Order Hold method This VI then calculates the discrete equivalents of the Q R and N matrices using the numerical integration method proposed by Van Loan You specify the Sampling Time s this VI uses for both conversions Refer to the Zero Order Hold and First Order Hold Methods section of Chapter 3 Converting Models for information about the Zero Order Hold conversion method Refer to JEEE Transactions on Automatic Control as listed in the Related Documentation section of this manual for information about the numerical integration method proposed by Van Loan Defining Kalman Filters Control Design User Manual After you use the CD Kalman Gain VI to calculate L and or M you can use those values with the CD State Estimator VI to define a Kalman filter Refer to Chapter 13 Defining State Estimator Structures for more information about the different estimator configurations The Control Design and Simulation Module also includes the Discrete Kalman Filter function and the Continuous Kalman Filter function These functions implement Kalman filters for discrete and continuous models respectively These functions also calculate the appropriate gain matrices internally However you can use thes
104. d Discrete Models section of this chapter for information about converting between continuous and discrete domains Applying the Laplace transform to the state space model results in the following equation Y s CUs A B D U s In this equation s is the Laplace variable and J is the identity matrix with the same dimensions as A Control Design User Manual 3 2 ni com Chapter 3 Converting Models The ratio between the output Y s and input U s defines the following matrix transfer function model H s mos C Is A B D For example consider the following second order MISO state space system model x Axa fu 0 l 01 y 1 o x o o u Using the Laplace transform you obtain the transfer function matrix H s 1 2 H s al a SI 42s 1 Converting Models to Zero Pole Gain Models Use the CD Convert to Zero Pole Gain Model VI to convert a transfer function or state space model to a zero pole gain model This section uses a transfer function model as an example 3 Note When you convert a state space model to a zero pole gain model the CD Convert to Zero Pole Gain Model VI converts the state space model to a transfer function model first To convert the transfer function matrix H s to the zero pole gain form the Control Design and Simulation Module calculates the numerator and denominator polynomial roots and the gain of each SISO transfer function in H s National Instruments Corporation 3 3 Cont
105. d Pole Zero Method The Matched Pole Zero method uses the following relationship between the continuous s and discrete z frequency domains sT z In this equation T is the sampling time used for the discrete system The Matched Pole Zero method maps continuous time poles and finite zeros to the z plane using this relation This method also maps zeros at infinity to z 0 so these zeros do not affect the frequency response After the algorithm maps the poles and zeros the algorithm then attempts to make sure the system gains are equivalent at some critical frequency If the systems have no poles or zeros at s 0 or z 1 the Matched Pole Zero method selects a discrete time gain such that the system gains match at these locations Alternatively if the systems have no poles or zeros at s p i T or z 1 where p is the location of a pole this method equalizes the gains at that frequency If the Matched Pole Zero method cannot match either of these gains the algorithm does not choose a gain Refer to Digital Control of Dynamic Systems as listed in the Related Documentation section of this manual for more information about the Matched Pole Zero method Converting Discrete Models to Continuous Models Use the CD Convert Discrete to Continuous VI to convert a discrete model to a continuous model This VI supports the following conversion methods Forward Rectangular Backward Rectangular Tustin s Prewarp Z Transform and Zero
106. d by a new input w in the resulting model Likewise any combined outputs of the original models are replaced by a new output x in the resulting model Placing Models in a Closed Loop Configuration Control Design User Manual Use the CD Feedback VI to place one or two models in a closed loop configuration The Feedback Connections and Output Connections parameters define the connections between the outputs of a model to the inputs of the same model or a second model If the models have an unequal number of inputs and outputs the CD Feedback VI establishes a number of connections equal to the smaller number of inputs or outputs The remaining inputs or outputs remain unmodified 4 12 ni com Chapter 4 Connecting Models For example a model with m inputs and r outputs where m lt r has m number of reference inputs Similarly a model with m inputs and r outputs where m gt r has r number of reference inputs All original y outputs remain in the resulting model The following sections provide information about how the CD Feedback VI configures the closed loop feedback when you have one or two models in the closed loop configuration The following sections also describe the behavior of this VI when you leave connections undefined Single Model in a Closed Loop Configuration When you only have one model in a closed loop configuration the CD Feedback VI connects the outputs to the inputs of the same model You define these con
107. del When you execute this VI you specify matrices G and H This VI then incorporates G and H into the deterministic model equations ays Note When using either of these VIs if the model you are converting is discrete the resulting model has the same sampling time Simulating Stochastic Models Control Design User Manual Before you deploy a controller to an RT target you can test that the controller performs as expected in the presence of noise To perform this test you can simulate the behavior of a stochastic system model Use the Internal Noise instance of the Discrete Stochastic State Space function to simulate the behavior of a discrete stochastic state space model This function uses the Second Order Statistics Noise Model to generate values of w k and v k You also can use the External Noise instance of the Discrete Stochastic State Space function and wire values of w k and v k to the Process Noise w k and Measurement Noise v k inputs respectively In this situation 16 4 ni com Chapter 16 Using Stochastic System Models you can use the CD Correlated Gaussian Random Noise VI to generate Gaussian distributed values of w k and v k that fit a statistical profile you specify In either instance you test a controller model by wiring the output of the controller model to the Input u k input of the Discrete Stochastic State Space function You also can provide initial state information by wiring values to the Ini
108. del Conversion VIs provide a number of mathematical methods that perform these conversions Table 3 1 summarizes these methods which are substitutions between the continuous Laplace transform operator and the discrete z transform operator Table 3 1 Mapping Methods for Converting between Continuous and Discrete Method of Approximation Continuous to Discrete Discrete to Continuous Forward Rectangular z l z314 sT Method oe T Backward Rectangular z 1 1 Method S zT ead T National Instruments Corporation 3 5 Control Design User Manual Chapter 3 Converting Models Table 3 1 Mapping Methods for Converting between Continuous and Discrete Continued Method of Approximation Continuous to Discrete Discrete to Continuous Tustin s Method ustin s Metho 2 z 1 149l T z 1 2 z gt T 1 2 2 Prewarp Method z z 1 L sT T z 1 se 2tan x 1 2tan a T T LESS Pa w w In these equations T represents the sample time and w represents the prewarp frequency T is a modified sample time that the Prewarp method uses in converting between continuous and discrete models The following sections provide information about the methods that you can use to perform continuous to discrete conversions discrete to continuous conversions and discrete to discrete conversions Converting Continuous Models to Discrete Models Control Design User Manual To convert
109. dels Model based control design relies upon the concept of a dynamic system model A dynamic system model is a mathematical representation of the dynamics between the inputs and outputs of a dynamic system You generally represent dynamic system models with differential equations or difference equations Obtaining a model of the dynamic system you want to control is the first step in model based control design You analyze this model to anticipate the outputs of the model when given a set of inputs Using this analysis you then can design a controller that affects the outputs of the dynamic system in a manner that you specify For example consider the temperature regulation example in the introduction of Chapter 1 Introduction to Control Design You can analyze the open loop dynamics of the plant to design an effective controller for this closed loop dynamic system A model for this closed loop dynamic system describes the input to the plant as the air flow from the vent The output of the plant is the temperature of the room By analyzing the relationship between the inputs and output of the plant you can predict how the plant reacts when given certain inputs Based on this analysis you then can design a controller for this dynamic system This chapter provides information about using the LabVIEW Control Design and Simulation Module to create dynamic system models This chapter also describes the different forms that you can use to represen
110. dels only to other continuous models To connect discrete models together each model must have the same sampling time Connected models might however be of any form For example you can connect a transfer function model to a state space model or a state space model to a zero pole gain model Furthermore you can make connections between single input single output SISO single input multiple output SIMO multiple input single output MISO and multiple input multiple output MIMO systems This chapter provides information about using the LabVIEW Control Design and Simulation Module to connect models in the following four ways in series by appending in parallel and with feedback 3 Note Refer to the labview examples Control and Simulation Control Design Model Connection directory for example VIs that demonstrate the concepts explained in this chapter Connecting Models in Series A series connection joins the outputs of the first model to the inputs of a second model Use the CD Series VI to connect two models in series aye Note When connecting models of different forms the Series Model output returns a model based on the following hierarchy state space gt transfer function gt zero pole gain For example if you connect a zero pole gain model to a state space model Series Model returns a state space model The following sections provide information about the kinds of connections you can make with the CD Series VI
111. der Reduction for more information about minimizing state space realizations Using the example in the Converting Models to Transfer Function Models section of this chapter the following equation gives the minimal realization when converting a zero pole gain model to a state space model o 0 33 0 94 gee 0 41 0 u 0 47 1 67 0 29 0 87 y 2 45 0 x o o u 3 4 ni com Chapter 3 Converting Models This model numerically differs from the initial state space model From the input output model perspective however the state space models are identical Refer to the LabVIEW Help available by selecting Help Search the LabVIEW Help for more information about the Model Conversion VIs Converting between Continuous and Discrete Models Continuous models are analog and operate using physical components Discrete models are digital and operate on a computer or real time RT target To determine how an analog model performs on a digital target you can convert the continuous model to a discrete model You also can convert a discrete model to a continuous model Additionally you can resample a discrete model Resampling involves converting a discrete model to a discrete model with a different sampling time Resampling is useful when the sampling time of a model does not match the sampling time of the target on which that model operates In this situation you resample the model to use the sampling time of the target The Mo
112. ds eee 3 11 Z Transform Method 0 0 cece eseeceseeesceeeeseeesecseeseeeseesseeseeseenaeees 3 12 Matched Pole Zero Method ou cee ee eecceseeseeseceeceseseeeeseeseeeaeeseees 3 13 Converting Discrete Models to Continuous Models eee eeeeeeeeeereeeees 3 13 Resampling a Discrete Modelo eee ec cececeseeeeeeseeeseeseeseeeaeseseeseeseeeaeesees 3 14 Chapter 4 Connecting Models Connecting Models Series kiserni nat buen nt wenn EE EREE 4 1 Connecting SISO Systems in Series essessesessseseesrssrserersresrrstsresrsresrssesreses 4 2 Creating a SIMO System in Series seeesseseseseeseserseseesesreseseeresserreserreressenseees 4 3 Connecting MIMO Systems in Series ee cece eeeeeseceeceeeeseeeneeeeeaeeneees 4 5 Appending Models lt su sccsceenestent tote ene e sacs bee eee Gs Ss ects Ses eS 4 6 Connecting Models in Parallel oo eee eee ceeesecseeesececeseeseeeaecseeeaeseseaesseseseeseeeaees 4 8 Placing Models in a Closed Loop Configuration cc ceceeeeseeeeseeseeeseseeeeseeseeeneesees 4 12 Single Model in a Closed Loop Configuration cece eeeeeeeeseeseeereeneees 4 13 Feedback Connections Undefined 00 0 eee eeeeeeeeeeseeseeseeeneeeeees 4 13 Feedback Connections Defined 000 0 eee eeeeeeeereeeeeesetseeeneeneees 4 14 Two Models in a Closed Loop Configuration 0 cece eeceseeseeseceeeseeeeesees 4 14 Feedback and Output Connections Undefined eee 4 15 Feedback Connections Undefined Output Connections
113. e functions only with stochastic state space models Refer to the Using Kalman Filters to Estimate Model States section of Chapter 16 Using Stochastic System Models for more information about using a Kalman filter with stochastic state space models 12 8 ni com Chapter 12 Designing State Space Controllers Linear Quadratic Gaussian Controller A linear quadratic Gaussian LQG controller utilizes the LQR technique to build the controller and the Kalman gain technique to filter out any system noise Use the CD Linear Quadratic Regulator VI and the CD Kalman Gain VI together with the CD State Space Controller VI to synthesize a LQG controller Using an arbitrary estimator with a design such as LQR might not result in the most optimal design of the controller If the estimator starts with the same initial condition as the unmeasured states x 0 x 0 and if the system satisfies a number of controllability and observability conditions the closed loop system with the observer based controller has the same response as the LQR design This form of state feedback controller when combined with a estimator defined with the Kalman gain function is called the LQG controller Certainty equivalence is the property that enables this combined usage of optimal estimator and controller Certainty equivalence is important because you can synthesize a controller gain matrix K and estimator gain matrix L independently You can build a controller assumin
114. e gain 0 02 cm Peak value y 0 04 cm 5 6 ni com Chapter 5 Time Response Analysis Figure 5 5 shows the output of the CD Parametric Time Response VI cm Fo 6 Jo G om Je fo G m E lo lo Cm fo Figure 5 5 Parametric Data of the Spring Mass Damper System Analyzing an Impulse Response The impulse response of a dynamic system measures how the system responds to an impulse input signal You define an impulse input signal in the following manner e Continuous systems Also known as the Dirac delta function a continuous impulse input is a unit area signal with an infinite amplitude and infinitely small duration occurring at a specified time At all other times the input signal value is zero e Discrete systems Also known as the Kronecker delta function a discrete impulse input is a physical pulse that has unit amplitude at the first sample period and zero amplitude for all other times Use the CD Impulse Response VI to calculate the impulse response of a dynamic system to a standard impulse input Because the impulse signal excites all frequencies and the duration of this signal is infinitely small the impulse response is the natural response of the system National Instruments Corporation 5 7 Control Design User Manual Chapter 5 Time Response Analysis For example consider the system described in the Spring Mass Damper Example section of this chapter Figure 5 6 shows how you determine the impulse response
115. e integral action y is the reference variable that you are tracking and y is the output variable that you use to track y In these equations I varies depending on whether the model describes a continuous or discrete system If the system is continuous IT 0 If the system is discrete J When you define the control action for a state regulator with integral action using the output error integrator z you obtain the following control action equation ae Substituting the control action into state dynamics of the general system configuration defined in the previous equation you obtain the following equation that also defines the general system configuration 4 Bk 0 BK 0 oz i 0 0 of r o pe BK BK Al x 0 ojt ul K K 0 oo 0 y C DK DK 0 z 0 0 Pe a 0 yey DK DK C x 00 r National Instruments Corporation 14 13 Control Design User Manual Chapter 14 Defining State Space Controller Structures Table 14 3 summarizes the different state regulator with integral action configurations and their corresponding states inputs and outputs Table 14 3 State Regulator with Integral Action Configuration Types Configuration Type States Inputs Outputs rq u System Included x Yref y x a Ly x u System Included with Noise z Pref y r x ea y Standalone with Estimator x Vref LJ Ly Standalone without Estimator x Yref n
116. e integration range This consideration results in the following equation y t T y t f T This method considers the incremental area term between sampling times t and T as a rectangle of width T and height equal to f t as shown in Figure 3 2 Forward Figure 3 2 Forward Rectangular Method Figure 3 2 shows that for this example the Forward Rectangular method underestimates the area under the curve To minimize this underestimation use a small sampling interval Depending on the direction and size of the curve you are measuring this underestimation might not occur Backward Rectangular Method The Backward Rectangular method considers f t constant and equal to f t T along the integration range This consideration results in the following equation y t T yO ft T T 3 8 ni com Chapter 3 Converting Models This method considers the incremental area term between sampling times t and t T as a rectangle of width T and height equal to f t T as shown in Figure 3 3 Backward t T At t t T Figure 3 3 Backward Rectangular Method Figure 3 3 shows that for this example the Backward Rectangular method overestimates the area under the curve To minimize this overestimation use a small sampling interval Depending on the direction and size of the curve you are measuring this overestimation might not occur Tustin s Method Tustin s method also
117. e of the pole decays over time If the response becomes larger over time the pole is unstable If the response remains unchanged over time the pole is marginally stable To describe a system as stable all the closed loop poles of a system must be stable National Instruments Corporation 8 1 Control Design User Manual Chapter 8 Analyzing Dynamic Characteristics Continuous and discrete systems are marginally stable if they contain only one pole at the origin and no positive poles Use the CD Pole Zero Map VI to obtain all the poles and zeros of a system and plot their corresponding locations in the complex plane Use the CD Stability VI to determine if a system is stable unstable or marginally stable Using the Root Locus Method Control Design User Manual The root locus method provides the closed loop pole positions for all possible changes in the loop gain K Root locus plots provide an important indication of what gain ranges you can use to keep the closed loop system stable The root locus is a plot on the real imaginary axis showing the values of s that correspond to pole locations for all gains starting at the open loop poles K 0 and ending at K You can rewrite the characteristic equation of a closed loop system using the following equation where Ms is the numerator and D s is the denominator 1 KH s D s KN s 0 This equation restates the fact that the open loop system poles which correspond to K
118. e the Control amp Simulation Loop Refer to the labview examples Control and Simulation Control Design MPC directory for examples that use the Timed Loop Providing Setpoint and Disturbance Profiles to the MPC Controller Control Design User Manual Providing information in advance is useful if you already know the disturbances that affect the system or if you know certain setpoints for the controller You might have this information for example if you are performing an offline simulation of the MPC controller To provide these values to the MPC controller use the CD Update MPC Window VI This VI provides the appropriate portion or window of the setpoint or disturbance profile of a signal from time k to time k Prediction Horizon You then can wire the Predicted Profile Window output of this VI to the 18 14 ni com State Space Model MPC Controller EGH controlle the MPC Chapter 18 Creating and Implementing a Model Predictive Controller CD Implement MPC Controller VI for the current sample time k The size of the window is based on the length of the prediction horizon At the next sample time k 1 the prediction horizon moves forward one value The CD Update MPC Window VI then sends the next window to the CD Implement MPC Controller VI Figure 18 4 shows how you use these VIs together Control Action Response Discrete CD Update CD Implement State Space MPC Window vif MPC Controller vi Fi
119. ears in any analysis you perform on the model This chapter provides information about using the Control Design and Simulation Module to account for delay information in a model and to manipulate delay information within a model National Instruments Corporation 6 1 Control Design User Manual Chapter 6 Working with Delay Information B Note Refer to the labview examples Control and Simulation Control Design Model Delay directory for example VIs that demonstrate the concepts explained in this chapter Accounting for Delay Information Accounting for delay information in a model involves the following two steps setting delay in the properties of a model and transferring that delay from the model properties to the mathematical model The following sections provide information about the Control Design VIs that you can use to accomplish these tasks Setting Delay Information By default when you construct a model in the Control Design and Simulation Module the properties of that model have a delay of zero Use the CD Set Delays to Model VI to define any non zero delays in a model You can use the Input Delays Output Delays and Transport Delays inputs of this VI to define the input output and transport delays in a model The properties of the resulting Model Out output contain the original model with the delay information you defined You also can retrieve the delay information from the properties of a model with the CD Get Del
120. efore you can use a continuous observer only with a Control amp Simulation Loop 3 Note The examples in this chapter compare actual model states with the estimated states These comparisons are for example purposes only because in real world control systems you rarely have all state information However if you are able to measure all state information you do not need an observer This chapter provides information about using predictive current and continuous observers l Note Refer to the labview examples Control and Simulation Control Design Implementation directory for example VIs that demonstrate the concepts explained in this chapter National Instruments Corporation 15 1 Control Design User Manual Chapter 15 Estimating Model States Predictive Observer Control Design User Manual At each time step k a predictive observer estimates the state information for the next time step or k 1I k This notation translates as the estimated states at time step k 1 given all measurements up to and including time step k Consider an example at time step k 5 At this time step the predictive observer estimates x k 1 k or x 6 5 Estimating this information requires x k k 1 or the current state estimate given all measurements up to and including time step k 1 which is x 5 4 The predictive observer also uses measured output y 5 estimated output y 5 and known input u 5 The following equations show
121. egral Action Control Design User Manual 14 18 ni com Chapter 14 Defining State Space Controller Structures The states inputs and outputs of the state regulator with integral action are x P and p respectively y Y Standalone without Estimator Configuration The standalone without estimator configuration uses states to calculate of the control action u As such you do not need an estimator In the CD State Space Controller VI do not wire a value to the Estimator Gain L input to exclude the estimator in the standalone state regulator with integral action The following equations describe the standalone configuration A BK BK PALL le 0 Zz 0 r fiz U K K K 7 aiy Taa y C DK DK z 0 Use the following substitution to make the inputs independent fom de be This process results in the following equations that describe the standalone without estimator configuration x _ A BK BK j x 4 0 Of reg Z 0 T JZ I y uy _ K K x 0 0 Ve y C DK DK z 0 0 y Using this configuration the states and outputs of the standalone state regulator with integral action correspond to the states and outputs of the actual system National Instruments Corporation 14 19 Control Design User Manual Chapter 14 Defining State Space Controller Structures Figure 14 12 represents the system that these equations describe Vref y a Controller gt System Z
122. el and the CD Ackermann VI to determine the estimator gain matrix L The CD State Estimator VI then uses the system included with noise configuration to implement the state estimator represented by the Estimator Model Use the Gaussian White Noise VI to view the effects of Gaussian noise on the system and the state estimator ay Note The CD Linear Simulation VI provides the response to a Gaussian noise with the same initial conditions as in Figure 13 4 National Instruments Corporation 13 11 Control Design User Manual Chapter 13 Control Design User Manual State Trajectory Graph Defining State Estimator Structures The State Trajectory Graph as shown in Figure 13 7 displays the response of the system and state estimator to the same initial conditions 0 0 2 1 used in the Example System Included State Estimator section of this chapter AIS xlEstimated x2Estimated 27 x1System x2System Amplitude Time s Figure 13 7 State Trajectory of System Included with Noise State Estimator Similar to the graph in the Example System Included State Estimator section of this chapter this State Trajectory Graph shows the response of the actual states starting at 2 and 1 The graph also shows the response of the estimated states starting at the origin Notice the effect of the output noise r on the state estimation Without noise the state estimator took approximately six seconds to begin tracki
123. ell and A Emami Naeini 2005 Feedback Control of Dynamic Systems 5th ed Upper Saddle River NJ Prentice Hall e Franklin G F J D Powell and M Workman 2006 Digital Control of Dynamic Systems 3d ed Menlo Park CA Ellis Kagle Press e Kuo Benjamin C 1995 Digital Control Systems 2d ed Oxford University Press e Nise Norman S 2007 Control Systems Engineering 5th ed New York Wiley e Ogata Katsuhiko 1995 Discrete Time Control Systems 2d ed Englewood Cliffs N J Prentice Hall e Ogata Katsuhiko 2001 Modern Control Engineering 4th ed Upper Saddle River NJ Prentice Hall e Van Loan C 1978 Computing integrals involving the matrix exponential IEEE Transactions on Automatic Control 23 3 395 404 e Zhou K and J C Doyle 1997 Essentials of Robust Control Upper Saddle River NJ Prentice Hall The following books contain information about the ordinary differential equation ODE solvers the Control Design and Simulation Module uses e Ascher U M and L R Petzold 1998 Computer Methods for Ordinary Differential Equations and Differential Algebraic Equations Philadelphia Society for Industrial and Applied Mathematics e Shampine Lawrence F 1994 Numerical Solution of Ordinary Differential Equations New York Chapman amp Hall Inc National Instruments Corporation XV Control Design User Manual Introduction to Control Design Control design is a process that invo
124. er 18 14 Updating Setpoint and Disturbance Information Dynamically 18 16 Modifying an MPC Controller at Run Time eee eececeeseceeeeeceeesseeeeeeeeseetaees 18 18 Appendix A Technical Support and Professional Services National Instruments Corporation xi Control Design User Manual About This Manual Conventions This manual contains information about the purpose of control design and the control design process This manual also describes how to develop a control design system using the LabVIEW Control Design and Simulation Module This manual requires that you have a basic understanding of the LabVIEW environment If you are unfamiliar with LabVIEW refer to the Getting Started with LabVIEW manual before reading this manual This manual refers to control design and deployment concepts only For information about using the Control Design and Simulation Module to simulate the behavior of dynamic systems refer to the LabVIEW Help available by selecting Help Search the LabVIEW Help bold italic monospace The following conventions appear in this manual The symbol leads you through nested menu items and dialog box options to a final action The sequence File Page Setup Options directs you to pull down the File menu select the Page Setup item and select Options from the last dialog box This icon denotes a note which alerts you to important information Bold text denotes items that you
125. er on a real time RT target you typically cannot provide setpoint and or disturbance profile information in advance To address this issue you can configure the MPC controller to receive profile information dynamically i Note Updating profile information dynamically also is useful when the MPC controller might execute for such a long time that a computer cannot handle millions of output setpoints at once Control Design User Manual To accomplish this task you use either a LabVIEW queue or a real time RT FIFO The Control Design and Simulation Module provides four VIs for this purpose one VI each that creates reads from writes to and deletes the queue FIFO You write to the queue FIFO in a While Loop that executes in 18 16 ni com Chapter 18 Creating and Implementing a Model Predictive Controller parallel with the loop in which the MPC controller reads from the queue FIFO This parallelism enables the MPC controller to receive new profile information at any time during execution Note This VI creates a queue when running on a Windows computer This VI creates an RT FIFO when running on a real time RT target Use the CD Write MPC FIFO to construct a profile dynamically Use the CD Read MPC FIFO to send portions or windows of the profile to the CD Implement MPC Controller VI Figure 18 5 shows how you use these VIs together CD Delete MPC FIFO vi Input Node Simulation Loop Output Node Ls error out 1m
126. etermining Observability and Detectability A system is observable if you can estimate each state of the system by looking only at the output response If you can determine the states at time fo by observing the output from time fp to t the system is observable Observability depends on the output matrix C and the state matrix A of the system You can check observability by verifying that the observability matrix O defined in the following equation is full column rank or is nonsingular for a SISO system National Instruments Corporation 9 3 Control Design User Manual Chapter 9 Analyzing State Space Characteristics Use a state estimator to calculate the states of any observable system with acolumn deficient matrix C Refer to Chapter 13 Defining State Estimator Structures for information about state estimators Detectability is related to observability A system is detectable if all the unstable eigenvalues are observable Observability implies detectability but detectability does not imply observability Use the CD Observability Matrix VI to calculate the observability matrix of a model and determine if the system is observable and or detectable Use the CD Observability Staircase VI to transform a state space model into a model that you can use to identify observable states in the system Use the CD Observability Staircase VI to calculate the observability matrix of the transformed model You also can use the CD Observability St
127. fferential equations over time You use the Control amp Simulation Loop to configure the ODE solver and time step settings to use Control Design User Manual 17 12 ni com Chapter 17 Deploying a Controller to a Real Time Target Figure 17 10 shows a LabVIEW simulation diagram that uses the Control amp Simulation Loop to deploy a continuous controller model and Kalman filter to an RT target Input Node Simulation Loo Output Node fever even b mo i Sensor Measurement vi Meron t Controller Output vi Ax B vi Stochastic State Space Model Continuous Kalman Filter Ky Tele u t Kxhat t a EH ES a Sa xhat t x Vector Second Order Statistics Noise Model Sue initial State Estimate xhat t0 pst initial Estimation Error Covariance P t0 ost Controller Gain K TE Figure 17 10 Implementing a Continuous Controller Model and a Continuous Kalman Filter on an RT Target In Figure 17 10 the blue D on the Sensor Measurement and Controller Output subVI icons indicate these subVIs execute as discrete functions You can configure the sample period and sample skew or offset of these functions individually The black C on the A x B VI icon indicates this VI executes continuously Also notice this example does not need feedback nodes or shift registers to feed the output of the A x B VI
128. g all states are measurable and then estimate unmeasured states using an optimal estimator The resulting design is optimal for the specified problem 3 Note Because an LQG controller uses an estimator the robustness properties of an LQG controller are not the same as that of an LQR controller You have no guarantee that robustness properties can be established for an estimated state feedback controller You only can guarantee robustness by changing the way you measure the states of the system to remove the need for an estimator National Instruments Corporation 12 9 Control Design User Manual Defining State Estimator Structures State estimators reconstruct unmeasurable state information To define the structure of a state estimator you need a model of the system and an estimator gain matrix L You can calculate L using the CD Pole Placement VI the CD Ackermann VI or the CD Kalman Gain VI Refer to Chapter 12 Designing State Space Controllers for more information about these VIs You use L to define the structure of an estimator You can design an estimator structure to take various factors such as input noise or input disturbances into consideration This chapter provides information about using the LabVIEW Control Design and Simulation Module to define the structure of a state estimator This chapter also discusses known inputs and measurable outputs ay Note Refer to the labview examples Control and Simulation Control De
129. grt x 2 y 2 t cs Be Bei Si yf sqrt x 2 y 2 x 2 y 2 Ey Piz y 2 bey 1 x yA2fx b gt lerror out Figure 16 6 SIM Discrete Jacobian Template VI Modified with Example LabVIEW Code Defining the Discrete Plant Model To use the Discrete Extended Kalman Filter function first define the plant model whose states you want to estimate Use the SIM Discrete Nonlinear Plant Model template VI located in the labview templates Control and Simulation directory to define the plant model The following equations define a discrete version of the plant model described in the Defining the Continuous Plant Model section of this chapter National Instruments Corporation x k 1 x k 1 x3 k 1 x4 k 1 16 17 yi k y2 k oio ji 0 0101 x k 0 0010 ka w 0001 x4 k w k x k 23 k tan x k x k Control Design User Manual Chapter 16 Control Design User Manual Using Stochastic System Models where x and x are the x and y position in the Cartesian frame system x3 and x are the x and y velocities and y and y are the range r of bearing angle 0 respectively You define the system model by specifying the vector valued functions f x u k and h x u k for the discrete plant model where x k x k x3 k x4 k 1010 0101 0010 0001 fx u k xq x k h x u k tan a x k
130. gure 18 4 Providing Profile Information in Advance The example in Figure 18 4 executes the following steps 1 This example sends an Initial Profile Window and an array of Predicted Values to the Single instance of the CD Update MPC Window VI The Initial Profile Window specifies the profile of the signal for a time period equivalent to the Prediction Horizon prior to the current time The Predicted Values input specifies the interleaved values of the setpoint profile from time k to time k Prediction Horizon At each sample time k the CD Update MPC Window VI parses the Predicted Values and sends the Predicted Profile Window to the Output Reference Window input of the CD Implement MPC Controller VI The size of the window is based on the length of the prediction horizon You specify these lengths when you create the MPC controller Note This example provides a setpoint profile of plant output values to the MPC r If you also want to provide a disturbance profile or a different setpoint profile to controller use a separate instance of the CD Update MPC Window VI for each profile and wire the appropriate output of each instance to the corresponding input of the CD Impl National Instruments Corporation ement MPC Controller VI 18 15 Control Design User Manual Chapter 18 Creating and Implementing a Model Predictive Controller 3 The CD Implement MPC Controller VI predicts the output of the plant and sends the necessary c
131. h of e k for this example Estimation Error e k 1 8E 7 ek TU 1 6E 7 1 4E 7 1 2E 7 1E 7 8E 8 6E 8 4E 8 2E 8 o Amplitude 2E 8 1 1 1 1 1 1 1 0 000 0 000 0 001 0 001 0 001 0 001 0 002 0 002 Time s Figure 16 18 Estimation Error of Kalman Filter In Figure 16 18 notice the estimation error is extremely small This small error confirms the ability of the Kalman filter to estimate model states despite the presence of noise Refer to the Example State Space Controller with Kalman Filter for Stochastic System Code section of Chapter 17 Deploying a Controller to a Real Time Target for example block diagram code that implements a Kalman filter on a real time RT target National Instruments Corporation 16 31 Control Design User Manual Deploying a Controller to a Real Time Target After you design a controller using the techniques this manual describes you then can deploy the block diagram code for that controller to a real time RT target The RT target acquires sensor measurements executes the controller code and sends the appropriate output to the actuators The LabVIEW Control Design and Simulation Module includes functions that you use to deploy discrete linear time invariant LTI system models to National Instruments RT Series hardware You can use these functions to define discrete controller models in transfer function zero pole gain or state space form To deploy continuous
132. he gain to satisfy the stated objectives You use these parameters to design a controller This chapter provides information about using the LabVIEW Control Design and Simulation Module to implement the root locus design technique This chapter also describes the proportional integral derivative PID controller and how to design a PID controller analytically aye Note Refer to the labview examples Control and Simulation Control Design Classical Control Design directory for example VIs that demonstrate the concepts explained in this chapter Root Locus Design Technique Root locus is a technique that shows how the roots of a system vary with respect to the gain K Taking into account a control objective you decide on the locations of the roots of the system From the locations of these roots you infer the optimal value of K You then can use the gain K to design a controller for a single input single output SISO system Use the CD Root Locus VI to apply the root locus technique to a system You can use the root locus technique to design SISO systems by analyzing the variation of closed loop pole positions for all possible changes in a controller variable The closed loop zeros of a system between any two points in the control system are a subset of the open loop zeros and poles of the feedback element The root locus plot depicts the path that the roots follow as you vary the gain You use this relationship to analyze the closed loo
133. hen you use the CD Total Delay VI other Control Design VIs can access the total delay information of a system Control Design User Manual 6 10 ni com Chapter 6 Working with Delay Information For example consider a model with the following delay information Refer to the Representing Delay Information section of this chapter for the derivation of this matrix and these vectors nal o ig ti fio fea _ 2 11 toy tnl to 1 0 2 The CD Total Delay VI first transfers the input delay information to the transport delay matrix The following equations show this process 1 12 2 oo rete bal The CD Total Delay VI then transfers the output delay information to the 0 0 transport delay matrix The following equations show this process 3 1 3 1 1 1 _ 1440 2 2 2 2 2 4 4 10 Figure 6 6 shows the output of the CD Total Delay VI Total Delay f Ho 4 0000 14 0000 Afo 4 0000 14 0000 Figure 6 6 Resulting Total Delay The input and output delay vectors are now o o and o respectively 0 National Instruments Corporation 6 11 Control Design User Manual Chapter 6 Working with Delay Information Distributing Delay Information The CD Distribute Delay VI calculates the total delay of a system model then uses a common delay factor to distribute the total delay between the inputs and outputs This operation minimizes the non zero elements of the transport delay matrix The CD Distribute Delay VI transfers delay informa
134. ify values of the numerator and denominator coefficients in the variables input as shown in Figure 2 8 Symbolic Numerator PIZZZZZZIZZZIZIIZZZIIIIIZIIIIIT Figure 2 8 Creating a SISO Symbolic Transfer Function Model Constructing Zero Pole Gain Models Control Design User Manual Zero pole gain models are rewritten transfer function models When you factor the polynomial functions of a transfer function model you get a zero pole gain model This factoring process shows the gain and the locations of the poles and zeros of the system The locations of these poles determine the stability of the dynamic system You analyze zero pole gain models in the frequency domain The following equations define continuous and discrete zero pole gain models where the numerators and denominators are products of first order polynomials 2 12 ni com Chapter 2 Constructing Dynamic System Models Continuous Zero Pole Gain Model m s Bosk ee s p s pp 8 p s 2 i 0 Discrete Zero Pole Gain Model m e 2 Hees ea i z p1 Z P2 Z Pn IF Pi i 0 In these equations k is a scalar quantity that represents the gain z represents the locations of the zeros and p represents the locations of the poles of the system model Numerators of zero pole gain models describe the location of the zeros of the system Denominators of zero pole gain models describe the locat
135. implements a continuous observer for this model ost BI ost IC pst D bey c06 Observer Poles Gain Type Observer Gain Current v initial states lestimate xhat t0 Input Node b m i Output Node M Error gt Simulation Loo a State Space Simulation Time Waveform Actual state xt e fante cio ete Numeric v Simulation Time Waveform 2 Ead fror e t Ew CD Pole Placement vi rg Continuous Observer erar xhat t ost initial state Simulation Time Waveform 3 imated state xhat t ew DBL Figure 15 7 Implementing a Continuous Observer for a State Space Model The example in Figure 15 7 uses the State Space function to calculate the actual states of this model At each time step this example compares the Actual state x t to the Estimated state xhat t The difference between these two values is the Error e t This example also uses the CD Pole Placement VI to calculate the observer gain L such that the Poles of the continuous observer are in a location you define In this example the observer poles are located at 10 Oi Control Design User Manual 15 10 ni com Chapter 15 Estimating Model States B Note This model is adapted from Feedback Control of Dynamic Systems as li
136. in parallel with step 2 National Instruments Corporation 18 17 Control Design User Manual Chapter 18 Creating and Implementing a Model Predictive Controller 4 The CD Implement MPC Controller VI predicts the output of the plant and sends the necessary control action u k to the input input of the Discrete State Space function which represents the plant 5 The Discrete State Space function returns the actual output y k of the plant and sends these values to the Measured Output y k input of the CD Implement MPC Controller VI This function also sends the measured plant states x k to this VI This VI then uses the difference between the plant output and the output setpoint to adjust the control action for the next time step 6 The Collector function builds an array of control action and output values during the entire simulation After the Control amp Simulation Loop finishes executing this function returns the array so you can plot the data on an XY graph 7 The CD Delete MPC FIFO VI deletes the FIFO Modifying an MPC Controller at Run Time Control Design User Manual During the implementation of an MPC controller the model might become out of date or the objectives of the controller might change For example some parameters might become more costly than others and you therefore must update the cost weightings of those parameters accordingly You also might receive data during implementation that can help you improve y
137. ion of the poles of the system Use the CD Construct Zero Pole Gain Model VI to create SISO SIMO MISO and MIMO system models in zero pole gain form This VI creates a data structure that defines the zero pole gain model and contains additional information about the system such as the sampling time input or output delays and input and output names Refer to the Obtaining Model Information section of this chapter for information about other properties of zero pole gain models SISO Zero Pole Gain Models Using the example in the RLC Circuit Example section of this chapter the following equation defines a continuous zero pole gain model where R 20Q L 50 mH and C 10 uF Hs 2x 10 _ 2x 10 s 200 14001 s 20014001 s 200 14007 National Instruments Corporation 2 13 Control Design User Manual Chapter 2 Constructing Dynamic System Models This equation defines a model with one pair of complex conjugate poles at 200 14007 Figure 2 9 shows how you use the CD Construct Zero Pole Gain Model VI to create this continuous zero pole gain model CD Construct Zero Pole Gain Model vi Eerto Pole Gain Model ae Figure 2 9 Creating a Continuous Zero Pole Gain Model The CD Construct Zero Pole Gain Model VI creates a continuous model You create a discrete zero pole gain model in the same way you create a discrete transfer function model Refer to the SISO Transfer Function Models section of
138. ional Instruments Corporation 16 7 Control Design User Manual Chapter 16 Control Design User Manual Using Stochastic System Models Using the Continuous Extended Kalman Filter Function The Continuous Extended Kalman Filter function calculates the estimated states and estimated outputs of a continuous nonlinear stochastic state space model You can use the Continuous Extended Kalman Filter function only with continuous stochastic state space models The Continuous Extended Kalman Filter receives a model of the plant represented by the Continuous Nonlinear Noisy Plant function and uses the measurement made on the plant to estimate the internal states of the plant You can place the continuous Kalman filter functions including the Continuous Extended Kalman Filter function only inside a simulation diagram The Continuous Nonlinear Extended Kalman Filter function estimates the states of a continuous nonlinear plant model defined by the following equations x t f x u t w t y t A x u t v t where x is the state vector u is the control input vector t is the time vector y is the measurement vector w is the process noise vector and v is the measurement noise vector The noise vectors are zero mean temporally uncorrelated and uncorrelated with the system initial condition x 0 The auto covariance matrices of w and v defined within the Continuous Nonlinear Noisy Plant function are called Q and R respectively The c
139. ionality of the application Refer to the LabVIEW Help available by selecting Help Search the LabVIEW Help for information about the Control Design VIs Unlike creating a project with the Control Design Assistant creating a LabVIEW application using the Control Design VIs requires basic knowledge about programming in LabVIEW Refer to the LabVIEW Help for more information about the LabVIEW programming environment National Instruments Corporation 1 5 Control Design User Manual Chapter 1 Introduction to Control Design Control Design MathScript RT Module Functions Control Design User Manual The Control Design and Simulation Module also includes numerous functions that extend the functionality of the LabVIEW MathScript Window Use these functions to design and analyze controller models in a text based environment The LabVIEW MathScript Window is able to process files you create using the current LabVIEW MathScript syntax and for backwards compatibility files you created using legacy MathScript syntaxes The LabVIEW MathScript Window also can process certain of your files that use other text based syntaxes such as files you created using the MATLAB software Because the MathScript RT Module engine is used to process scripts in the LabVIEW MathScript Window and because the MathScript RT Module engine does not support all syntaxes not all existing text based scripts are supported 1 6 ni com Constructing Dynamic System Mo
140. ious equation is the percentage of the input range of the controller that causes a change equal to the maximum range of the output National Instruments Corporation 11 5 Control Design User Manual Chapter 11 Designing Classical Controllers You can use the root locus and Bode design methods to determine appropriate gain values for the PID controller Refer to PID Controllers Theory Design and Tuning as listed in the Related Documentation section of this manual for more information about these techniques Refer to the LabVIEW PID and Fuzzy Logic Toolkit User Manual for information about determining controller gain parameters experimentally You also can determine appropriate PID gain values analytically by using the CD Design PID for Discrete Systems VI The following section describes how to use this VI Designing PID Controllers Analytically 3 Control Design User Manual Finding the proper values for the PID gains is a process known as tuning the PID controller PID tuning typically is an ad hoc process that involves trial and error However the Control Design and Simulation Module provides the CD Design PID for Discrete Systems VI You can use this VI to find tuples of stable PID gain values automatically for a given model or family of models The input to this VI is one or more discrete system models in transfer function zero pole gain or state space form These models must be single input single output SISO a
141. is stochastic model Constructing the Noise Model Because w t and v t are white these variables have a mean of zero and are temporally uncorrelated Therefore the auto covariance matrices Q t and R t are equivalent to the inverse Fourier transform of the respective spectral densities S and S Additionally E w t 0 and E v t 0 The following equations show the definition of the noise model E w t 0 Ef v t 0 Q t F S 2kTRE E R t F S 8 8 1 N t 0 where 6 f is the Dirac delta function N f is 0 because w t and v t are uncorrelated with each other Control Design User Manual 16 24 ni com Chapter 16 Using Stochastic System Models Figure 16 12 shows a block diagram that constructs this noise model and the stochastic system model when R 1 KQ L 500 uH s 0 000001 and T 290 K Symbolic A f Btochastic State Space Model F CD Construct Stochastic Model vi Ho GE eee ene at _ gen mbolic or mbolic Eiw z 7 6 d Order Statistics Noise Model out Symbolic CD Construct Noise Model vi Besen m Bo iie Ho fragu Symbohe Symbolic E v Ao R Ho Symboic 7 Ho a 2 96 2 fie 3_ fie s _jifoe o Figure 16 12 Constructing the Stochastic State Space Model and a Noise Model for National Instruments Corporation the Noisy RL Circuit Example 16 25 Control Design User Ma
142. k where x is the state vector u is the control input vector k is the time index y is the measurement vector w is the process noise vector and v is the measurement noise vector The noise vectors are zero mean temporally 16 14 ni com Chapter 16 Using Stochastic System Models uncorrelated and uncorrelated with the system initial condition x 0 The auto covariance matrices of w and v are called Q and R respectively The cross covariance matrix between w and v is N a third matrix representing cross covariance in the noise model The following set of equations illustrates the computations that the Discrete Extended Kalman Filter function performs to produce the predicted states and the estimated states Xuk ik Mly yd Ve A Xe nv Up k Zkraje Sup Me k M Pie Hy Cren Uys KA Xie p Up Pye Hy Oe up k R Prailk EG Up kK Pg iF Grp Up k Oy z Fyre pup k P ap fA ype p Up k NOTE 4 b Up kK Pak Hy ye p Uy k RJ 7 Paes T E kk Me HP e up k N t a Of Xj Up k Pak Ue k a x Xk Xen x Oh x U k A X Kv Uj k eee Xk as a Xk Xkk 1 where e z xk 18 the current estimated state at time k given all the measurements and inputs up to and including time k A e y is the estimated output at time k National Instruments Corporation 16 15 Control Design User Manual Chapter 16 Using Stochastic System Models Control Design User Manual e x k 1 S the predicted state estim
143. known as the trapezoid method uses trapezoids to provide a balance between the Forward Rectangular and Backward Rectangular methods Tustin s method takes the average of the rectangles defined by the Forward and Backward Rectangular methods and uses the average value as the incremental area to approximate the area under the curve Tustin s method considers f t constant and equal to the average between f and f t T along the integration range which results in the following equation yee y o MOHA Dig National Instruments Corporation 3 9 Control Design User Manual Chapter 3 Converting Models The last term in this equation is identical to the area of a trapezoid of height T and bases f t and f t T Figure 3 4 shows the area under a curve using Tustin s method Tustin Figure 3 4 Tustin s Method Figure 3 4 shows that for this example Tustin s method provides a balance between the underestimation of the Forward Rectangular and the overestimation of the Backward Rectangular method Prewarp Method The Prewarp method is a trapezoidal type of transformation that uses the prewarp frequency to adjust the sampling time 7 This adjustment results in a separate sampling time T This adjustment also compensates for errors introduced in the discretizing process This method also considers f t constant and equal to the average between f t and f t T along the integration range which resu
144. l k o in e fy Amplitude N in 1 Time s Figure 14 13 Unstable Open Loop System Even though this system is unstable the system is still controllable Because the system is controllable you can use a state compensator to place the closed loop poles in the left hand side of the complex plane to make the response stable You can calculate the controller gain matrix K by using the CD Ackermann VI to place the poles of the matrix A BK at 1 1 You can use K to study the performance of the compensator by selecting the Compensator instance of the CD State Space Controller VI The following sections use this example system model to illustrate the different state controller configurations These examples are state compensators You can define a state regulator or state regulator with integral action by selecting the Regulator or Regulator with Integral instance of the CD State Space Controller VI respectively The examples in these sections use the CD Ackermann VI to calculate the controller gain matrix K You also can calculate K using the CD Pole Placement VI or the CD Linear Quadratic Regulator VI National Instruments Corporation 14 21 Control Design User Manual Chapter 14 Defining State Space Controller Structures Example System Included State Compensator In theory you cannot always measure the system states directly for control purposes Therefore you must synthesize a controller using the sy
145. l system and the model of the system do not match When you build a state compensator based on a model that does not match the actual system the result is a system model mismatch In this situation you need to use the standalone with estimator configuration This configuration detaches the system from the model so you can determine the effect of the system model mismatch Consider the following state space model P E oslas Plu 01 0 2 li y 1 ox ola This model is similar to the model in the Example System Configurations section of this chapter For this example however assume that the actual system contains uncertainties that cause this state space model to be an inaccurate representation of the system The difference is in the last entry of the system matrix A 0 2 Figure 14 18 shows how this configuration uses the mismatched model State Space Model to create the standalone with estimator state compensator Note that the CD State Space Controller VI uses the Compensator instance This configuration connects the actual system System and the mismatched model State Space Model in series System uses this connection to provide the output y to the state compensator National Instruments Corporation 14 25 Control Design User Manual Chapter 14 Defining State Space Controller Structures p Observer Gain Current Y Estimator Poles Controller Gain_ Configuration St
146. lant inputs and outputs to the setpoint profiles The MPC controller then attempts to reduce this error by minimizing a cost function that takes this error into account Refer to the Specifying the Cost Function section of this chapter for information about the cost function the MPC controller attempts to minimize If you know how disturbances affect the plant outputs and or states you also can provide future profiles of these disturbances to the MPC controller The Control Design and Simulation Module supports creating and using an MPC controller for multiple input multiple output MIMO plants However the profiles are one dimensional arrays or vectors If you are providing profile information for a MIMO plant the profile vectors are interleaved For example consider a plant with two inputs The first element of the input setpoint profile corresponds to the first input at the first sample time The second element of this profile corresponds to the second input at the first sample time The third element of this profile corresponds to the first input at the second sample time The fourth element of this profile corresponds to the second input at the second sample time and so on The output setpoint and disturbance profiles also are interleaved You can use the Interleave 1D Arrays function to interleave setpoint or disturbance profiles for a MIMO plant You can use the Decimate 1D Array function to divide an interleaved array into the compone
147. ler Models The Control Design and Simulation Module includes the following three functions you use to define a controller model e Discrete Transfer Function e Discrete State Space e Discrete Zero Pole Gain You use these functions to deploy a controller model on an RT target You also can use these functions to perform an offline simulation that does not involve an RT target Refer to the LabVIEW Help for information about these functions You can define a controller model interactively or programmatically The following sections use the Discrete Transfer Function function to provide information about each of these methods Defining a Controller Model Interactively Place the Discrete Transfer Function function on the block diagram and double click the function icon to launch the Discrete Transfer Function Configuration dialog box After you launch this dialog box complete the following steps to define the controller model 1 Specify whether the model is single input single output SISO or multiple input multiple output MIMO by selecting the appropriate option from the Polymorphic instance pull down menu 2 Select the Transfer Function parameter from the Parameters listbox The Parameter Information section updates to show the configuration options for the model 3 Select Configuration Dialog Box from the Parameter source pull down menu 4 Ifthe model is MIMO define the dimensions of the model using the Inputs and Ou
148. ll enough to minimize the effects of converting a continuous system to a discrete one Select this sampling time based on the location of the poles of the system Refer to Chapter 8 Analyzing Dynamic Characteristics for more information about locating the poles of a system Also verify that the sampling interval matches the sampling time of the output data u t Control Design User Manual For example consider the system described in the Spring Mass Damper Example section of this chapter Figure 5 10 shows how you simulate the response of this system to a square wave input 5 10 ni com Chapter 5 Time Response Analysis Symbolic A 2 ICD Construct State Space Model vi ICD Linear Simulation vi labo Ee P caz a amanea CIO Symbolic B 2 f Symbolic Square Wave vi Build Array inear Simulation Graph Square Wave Input ma f ces l Symbolic C 2 d samples gt 4 i566 Symbolic D 2 3 E Build Arra q Bae Figure 5 10 Linear Simulation Block Diagram of the Spring Mass Damper System Using a Square Wave Input Notice that the CD Linear Simulation VI converts the continuous state space model to a discrete model using the Zero Order Hold method This conversion uses a Delta t input of approximately 0 3 This block diagram bundles the state space model and the square wave as the input to the Linear Simulation Graph Figure 5 11 shows the Linear Simulation Graph resulting from
149. ller Refer to Feedback Control of Dynamic Systems and Modern Control Engineering as listed in the Related Documentation section of this manual for more information about using the root locus technique to design controllers National Instruments Corporation 11 3 Control Design User Manual Chapter 11 Designing Classical Controllers Proportional Integral Derivative Controller Architecture The PID controller also known as the three term controller is the most widely used controller architecture PID controllers compare the output against the reference input and initiate the appropriate corrective action PID controllers combine proportional P integral J and derivative D compensation Use the CD Construct PID Model VI to construct a PID controller The following equation defines control action for a general PID controller t u t K a jdt r In this equation K is the gain Ty is the derivative time constant and 7 is the integral time constant The following equation defines the error e t R t B In this equation R t is the reference input and B is the output Because the control action is a function of the error the following equation defines the transfer function for the PID controller U s _ i E s K 1 Ts tas This transfer function is improper which means the transfer function has more zeros than poles You cannot physically realize an improper transfer function You can place a pole a
150. ller VI to specify constraints for a controller You can specify constraints using either the dual optimization or the barrier function method The following sections describe each of these two methods Note You also can update the constraints of a controller at run time Refer to the Modifying an MPC Controller at Run Time section of this manual for information about updating a controller at run time Dual Optimization Method Use the Dual instance of the CD Create MPC Controller VI to set constraints using the dual optimization method You can specify these constraints in the MPC Constraints Dual parameter of the CD Create MPC Controller VI The dual optimization method specifies initial and final minimum and maximum value constraints for the control action the rate of change in control action and the plant output Use these constraints to represent real world limitations on the values of these parameters For example consider the cruise control system again In this example the control action or the amount of gas provided to the engine is unconstrained In reality however cars can send only a certain amount of gas to the engine at once You can design an MPC controller to take this constraint into account which is equivalent to placing a hard constraint on the maximum value of the control action Additionally the road might have speed limits at certain intervals If you know these limits in advance you can specify that the car
151. ller that accounts for these inaccuracies A robust controller is one that functions as expected despite some differences between the dynamic system and the model of the dynamic system A controller that is not robust might fail when such differences are present The more accurate a model is the more complex the mathematical relationship between inputs and outputs At times however increasing the complexity of the model does not provide any more benefits For example if you want to control the interacting forces and friction of a mechanical dynamic system you might not need to include the thermodynamic effects of the system These effects are complicated features of the system that do not affect the friction enough to impact the robustness of the controller A model that incorporates these effects can become unnecessarily complicated 2 2 ni com Chapter 2 Constructing Dynamic System Models Model Representation Model Types You can represent a dynamic system using several types of dynamic system models You also can represent each type of dynamic system model using three different forms The following sections provide information about the different types and forms of dynamic system models that you can construct with the Control Design and Simulation Module You base the type of dynamic system model on the properties of the dynamic system that the model represents The following sections provide information about the different type
152. lts in the following equation paT ye HOUT Control Design User Manual 3 10 ni com Chapter 3 Converting Models The last term in this equation is identical to the area of a trapezoid of height T and bases f t and f t T Figure 3 5 shows the area under a curve using the Prewarp method Prewarp t t T t T Figure 3 5 Prewarp Method Figure 3 5 shows that for this example the Prewarp method compensates for the integration error by adjusting the sampling time to 7 The area between t T and T is roughly equal to the integration error which is represented by the unshaded portion of the area under the curve Use a particular conversion method based on the model that you are converting and the requirements of the application for which you are designing a control system Zero Order Hold and First Order Hold Methods The Zero Order Hold and First Order Hold methods assume properties of the continuous differential equation f t The Zero Order Hold method assumes that f t consists of an input that you can hold constant during the integration period between sampling times t and t T The First Order Hold method assumes that you can increase this input over time during this same period These methods also integrate the remaining terms of f t not related to the input because these terms refer to the internal state dynamics National Instruments Corporation 3 11 Control Design User Manu
153. luation of the system model A t The expression h t ty represents this operation The first step in incorporating delay into a continuous system model is factoring a common delay out of the system model Applying the Laplace transformation to the system model accomplishes this step The following equation gives the Laplace transformation of h t t LIh t 1 f h t t e dt ht tpe da ti H s e 0 0 National Instruments Corporation 6 3 Control Design User Manual Chapter 6 Control Design User Manual Working with Delay Information This equation shows that the Laplace transform of a function delayed t4 units of time in the past is identical to the product of the Laplace transform of the original function and the factor e where s is the Laplace variable Thus you can incorporate delay into h t by multiplying H s by the delay factor e For example consider the continuous SISO transfer function H s with output Y s and input U s Because e represents the delay factor H s e defines a system that has a transport delay Sl Ys H s e UG You also can represent the delay as an input delay or output delay Applying the delay factor e to the input U s results in an input delay as shown in the following equation His 3 2 e U s Conversely applying the delay factor to the output Y s results in an output delay shown in the following equation e Y s U s A s Figure 6 1
154. lves developing mathematical models that describe a physical system analyzing the models to learn about their dynamic characteristics and creating a controller to achieve certain dynamic characteristics Control systems contain components that direct command and regulate the physical system also known as the plant In this manual the control system refers to the sensors the controller and the actuators The reference input refers to a condition of the system that you specify The dynamic system shown in Figure 1 1 refers to the combination of the control system and the plant Control System hee e eRe CdR See RR EES See Ree eee Hee Cee Hee ee Rete eee ee ee See eee Physical System Plant Ref SIGIENCS gt x gt Controller gt Actuators gt Sensors Figure 1 1 Dynamic System The dynamic system in Figure 1 1 represents a closed loop system also known as a feedback system In closed loop systems the control system monitors the outputs of the plant and adjusts the inputs to the plant to make the actual response closer to the input that you designate One example of a closed loop system is a system that regulates room temperature In this example the reference input is the temperature at which you want the room to stay The thermometer senses the actual temperature of the room Based on the reference input the thermostat activates the heater or the air
155. mator error in the general system configuration you obtain the following equations that describe the system included with noise configuration eee ball seeded bdh Figure 13 2 represents the dynamic system that these equations describe ry Lak m gt System gt S Estimator x Figure 13 2 System Included with Noise State Estimator The states inputs and outputs of the estimator are at H and P respectively x y Standalone Configuration In the standalone configuration the system model detaches from the estimator The system outputs y become inputs to the estimator Unlike the system included and system included with noise configurations the standalone configuration does not account for output noise ry The primary purpose of the standalone configuration is to implement the estimator on a real time RT target A secondary purpose of the standalone configuration is to perform offline simulation and analysis of the estimator Offline simulation and analysis are useful for testing the estimator with mismatched models and systems Mismatched models and systems have a calculated estimator gain that applies to a model with uncertainties Control Design User Manual 13 6 ni com Chapter 13 Defining State Estimator Structures The following equations describe the standalone configuration x A LC x B LD L k J y ce fp d J This configuration does not include the origi
156. n MPC Controller at Run Time In the previous figure the CD Create MPC Controller VI creates an MPC controller according to the specified MPC controller parameters input model cost weightings and parameter constraints The CD Create MPC Controller VI passes the created controller to a While Loop containing the CD Set MPC Controller VI If you do not click the Reset button the CD Set MPC Controller VI does not modify the controller If you specify different parameters for the controller and then click the Reset button the VI updates the controller accordingly and passes the updated information to a shared variable Another VI can read this shared variable and implement the controller The VI in Figure 18 6 is similar to the CDEx MPC Basic AirHeater VI located in the labview examples Control and Simulation Control Design MPC directory National Instruments Corporation 18 19 Control Design User Manual Technical Support and Professional Services Visit the following sections of the award winning National Instruments Web site at ni com for technical support and professional services National Instruments Corporation Support Technical support at ni com support includes the following resources Self Help Technical Resources For answers and solutions visit ni com support for software drivers and updates a searchable KnowledgeBase product manuals step by step troubleshooting wizards thousands of example programs tu
157. n and Simulation Module Algorithm Reference manual available by navigating to the Llabview manuals directory and opening CDreference pdf LabVIEW SignalExpress Help available by selecting Help LabVIEW SignalExpress Help in LabVIEW SignalExpress Example VIs located in the labview examples Control Design and Simulation directory You also can access these VIs by selecting Help Find Examples and selecting Toolkits and Modules Control and Simulation in the NI Example Finder window 3 Note The following resources offer useful background information on the general concepts discussed in this documentation These resources are provided for general informational purposes only and are not affiliated sponsored or endorsed by National Instruments The content of these resources is not a representation of may not correspond to and does not imply current or future functionality in the Control Design and Simulation Module or any other National Instruments product Control Design User Manual str m K and T Hagglund 1995 PID Controllers Theory Design and Tuning 2d ed ISA Balbis Luisella 2006 Predictive Control Tool Kit UKACC Control 2006 Mini Symposia 87 96 Bertsekas Dimitri P 1999 Nonlinear Programming 2d ed Belmont MA Athena Scientific Dorf R C and R H Bishop 2007 Modern Control Systems 11th ed Upper Saddle River NJ Prentice Hall xiv ni com About This Manual e Franklin G F J D Pow
158. nal system This configuration does not generate the system output internally but considers the output as another input to the estimator Figure 13 3 represents the dynamic system that these equations describe gt j u Estimator gt gt x Figure 13 3 Standalone State Estimator The states inputs and outputs of the estimator are x k and y respectively Example System Configurations The following equations define an example second order SISO state space model with poles at 0 2 and 0 1 teak fh y 1 ol ol You can implement a full state estimator for this system because this system is observable To implement a state estimator for this system you must calculate the estimator gain matrix L for the model of the system Use the CD Ackermann VI to calculate L by placing the poles of the matrix A LC at 1 1 This location is to the left of the original pole location in the complex plane You can use this estimator gain matrix L along with the CD State Estimator VI to study the performance of the estimator National Instruments Corporation 13 7 Control Design User Manual Chapter 13 Defining State Estimator Structures B Note Use the CD Observability Matrix VI to verify that this system is observable Use the CD Pole Zero Map VI to determine the initial location of the system poles The following sections use this example system model to illustrate the different state estimator
159. nalog you also need an analog to digital converter ADC to convert the analog sensor measurement into a digital signal the controller hardware recognizes You can eliminate the need for a separate ADC by using a digital sensor such as a digital multimeter DMM The wire leading to the controller in Figure 17 1 represents block diagram code that acquires a sensor measurement The wire leading away from the controller represents block diagram code that sends the controller output to the actuator Depending on the hardware installed in the RT target these wires represent different code For example if the RT target is using National Instruments DAQ devices these wires represent NI DAQmx code 3 Note National Instruments provides hardware and software to test and implement controllers actuators analog sensors DMMs DACs and ADCs Refer to the National Instruments Web site at ni com for information about these products Control Design User Manual To deploy a controller on an RT target you must define the controller model and then write the block diagram code that implements that controller model on an RT target This chapter provides information about both of these steps 17 2 ni com Chapter 17 Deploying a Controller to a Real Time Target B Note Refer to the labview examples Control and Simulation Control Design Implementation directory for example VIs that demonstrate the concepts explained in this chapter Defining Control
160. nd discrete This VI returns the following information e The boundary between the set of stable PID gain values and all unstable gain values e Tuples of PID gain values within this boundary Each tuple guarantees closed loop stability e The centroid or average of these tuples Note You can specify options relating to how this VI searches for tuples of stable values You also can specify performance criteria in the form of minimum gain and phase margins that these stable values must satisfy 11 6 ni com Chapter 11 Designing Classical Controllers For example consider the following discrete transfer function models H z K2 and J z 1 A z S z 0 25 1 Kz z 0 5 1 J z 7 z 0 75 Whereas traditional tuning provides one tuple of PID gains for one model the CD Design PID for Discrete Systems VI provides the set of all stable PID gains for all three models This set is the Stable Set Interior Points parameter of the VI Figure 11 2 shows an example Stable Set Interior Points output that corresponds to these models Stable Set Interior Points Figure 11 2 Set of Stable PID Gain Values for the Three Specified Models In Figure 11 2 each point on the graph represents a stable tuple of proportional integral and derivative gain values These points also satisfy any performance criteria you specify National Instruments Corporation 11 7 Control Design User Manual Chapter 11 Desig
161. nections using the Feedback Connections and the Feedback Sign parameters The following sections provide information about the configuration of the model when you define and do not define connections Feedback Connections Undefined If you do not define Feedback Connections all outputs from Model 1 are fed back to the inputs of Model 1 Additionally the Feedback Sign input determines if these outputs are fed back negatively or positively The resulting model shown in Figure 4 15 contains new reference inputs ro and r for each feedback connection you specify Feedback Connections gt Yo Model 1 p y1 Figure 4 15 One Model with No Connections Defined National Instruments Corporation 4 13 Control Design User Manual Chapter 4 Connecting Models Feedback Connections Defined If you define Feedback Connections each specified output in Model 1 is fed back to each specified input of Model 1 You also define whether the connection is positive or negative In this situation the CD Feedback VI ignores the Feedback Sign input The resulting model shown in Figure 4 16 contains a new reference input r for each feedback connection you specify Up eV Feedback Uy Connections rp Model 1 r y lo gt C i Up Figure 4 16 One Model with Connections Defined Two Models in a Closed Loop Configuration When yo
162. neeeseeeeees 12 7 Discretized Kalman Gait ceeccesccesceesseceseeeeeeceaeeeseeeseeeeeeeseeesaes 12 8 Defining Kalman Filters ereina ea cdescov A aai 12 8 Linear Quadratic Gaussian Controller c cccccccesessceeesseeseneeeeeseeesseeenseeens 12 9 Chapter 13 Defining State Estimator Structures Measuring and Adjusting Inputs and Outputs 0 0 eee eeseeeecereeseeeeeteeteeeseeeaeesees 13 1 Adding a State Estimator to a General System Configuration 0 0 0 0 eeeeeeeeeees 13 2 Control Design User Manual viii ni com Contents Configuring State Estimators kosete ennie aiy e e a E e paua iS 13 4 System Included Configuration ccccceccsesscesessesscsscssesessesseesessesecesesseseegs 13 4 System Included with Noise Configuration ssssssssssssessesissseseressrsesesesessees 13 5 Standalone Configuration eee eecesesesesseescesssseccecesessesesscceeseesesserasees 13 6 Example System Configurations 0 ccc eceeesseeseeseeeseesceeaeceseeseceeeeaeseeesaeesaeeeeseeeaees 13 7 Example System Included State Estimator cess esseseeseseeseeseeseeeeee 13 8 Example System Included with Noise State Estimator eee 13 10 Example Standalone State Estimator ec ceeeceeseeseeeseceeeeeeseeeneeeeeeees 13 13 Chapter 14 Defining State Space Controller Structures Configuring State Controllers 0 0 eee es esescesecesceseceeessecesecseseaeesesesecseeeaesseseaseneesaes 14 1 State COMpPensator cisssccsecesisscacaecvesstesssessddse
163. new models from old ones and for quickly removing zero states from a large state space model representation Zero states are states for which the state matrix A has zeros in an input row and the corresponding output column Use the CD Minimal National Instruments Corporation 10 3 Control Design User Manual Chapter 10 Model Order Reduction State Realization VI to perform this operation Figure 10 1 shows an example of a zero state e e e e 0 0 A Figure 10 1 A Zero State in A If the matrix has no zero rows or columns consider using another method to reduce the model order 3 Note When you work with transfer function and zero pole gain models you generally do not select and remove specific inputs and outputs to reduce the model order You mainly use this method with state space models Control Design User Manual 10 4 ni com Designing Classical Controllers Classical control design involves creating controllers based on the input output behavior of a system In classical control design you select one or more specific gain values to achieve one or more control objectives The first step in designing a controller is identifying a control objective For example you might focus on the rise time overshoot and damping ratio of a controller model Based on this objective you specify the location of the poles of the system You then select an appropriate set of parameters such as t
164. ng the actual system With noise the state estimator takes much longer to track the actual system and the state estimator cannot track the actual system perfectly You can place the estimator poles closer to the origin to reduce the effect of the noise However when you move the estimator poles closer to the origin on the left side of the complex plane you diminish the performance of the estimator in tracking the actual states One solution is to use the Kalman gain function to obtain an estimator gain matrix that effectively tracks the system states with an acceptable level of noise rejection Refer to the Kalman Gain section of Chapter 12 Designing State Space Controllers for information about using the Kalman gain function to find an optimal solution to this state estimator problem 13 12 ni com Chapter 13 Defining State Estimator Structures Example Standalone State Estimator Most systems are complex and have many parameters and uncertainties You often do not know all the parameters of a system when you create a model of that system or you cannot create a model that encompasses all the uncertainties of the system Thus the actual system and the model of the system do not match When you build a state estimator based on a model that does not match the actual system the result is a system model mismatch In this situation you need to use the standalone configuration This configuration detaches the system from the model so you c
165. ning Classical Controllers This VI also finds the centroid of these points and returns the point closest to this centroid This point is the Design PID Gains parameter Figure 11 3 shows the Design PID Gains output that corresponds to the set of points in Figure 11 2 Design PID Gains Kp 0 224462 Ki 0 460137 Kd jo 108035 Figure 11 3 Most Stable Tuple of PID Gain Values Therefore the design PID gains are 0 224462 0 460137 and 0 108035 respectively These values guarantee simultaneous closed loop stability of H z I z and J z You can use these design PID gains with the PID VI included with the LabVIEW PID and Fuzzy Logic Toolkit to implement a PID controller on a real time RT target B Note Refer to the LabVIEW Help available by selecting Help Search the LabVIEW Help for more information about the algorithms the CD Design PID for Discrete Systems VI uses Refer to the Labview examples Control and Simulation Control Design Analytical PID Design directory for examples that demonstrate the concepts explained in this section Control Design User Manual 11 8 ni com Designing State Space Controllers State space control design uses state space models to synthesize and analyze controllers based on the relationship between the inputs states and outputs of a system Because all states are not directly measurable you sometimes need to use an estimator An estimator infers the states with which yo
166. nitialize u k 1 and ensure a bumpless start by wiring an initial value to the initializer terminal of the Feedback Node National Instruments Corporation 17 11 Control Design User Manual Chapter 17 Deploying a Controller to a Real Time Target The example in Figure 17 9 implements a Kalman filter without feedthrough that is when D 0 Sampling Time s rosy las the Stochastic State Space Model Sensor Measurement vi Single Output Y Figure 17 9 Implementing a Kalman Filter without Feedthrough on an RT Target Because the example in Figure 17 9 does not have feedthrough you must select the Indirect option in the Feedthrough pull down menu in the configuration dialog box of the Discrete Kalman Filter function You then can use the current state estimate x k to calculate the control action at the current time step u k The Discrete Kalman Filter function calculates u k at the current time step k and applies this control action at the current time step k Refer to the Implementing a Kalman Filter section of Chapter 16 Using Stochastic System Models for more information about the Discrete Kalman Filter function Example Continuous Controller Model with Kalman Filter Code You must use a Control amp Simulation Loop to deploy a continuous controller model to an RT target The Control amp Simulation Loop uses ordinary differential equation ODE solvers to integrate continuous di
167. nt profiles National Instruments Corporation 18 13 Control Design User Manual Chapter 18 Creating and Implementing a Model Predictive Controller Implementing the MPC Controller After you create the MPC controller you then can implement this controller either in a simulation or a real world scenario You implement the controller by using the CD Implement MPC Controller VI with a Timed Loop or Control amp Simulation Loop The examples in this chapter use a Control amp Simulation Loop 3 Note Refer to Chapter 17 Deploying a Controller to a Real Time Target for more information about implementing controllers in real world scenarios You provide the following information to this VI e Profiles of the input setpoints output setpoints and or disturbances Refer to the Defining the Prediction and Control Horizons section of this chapter for information about these profiles e The measured output of the plant The CD Implement MPC Controller VI then returns the following information e The control action necessary to react to the change in the output setpoint profile e The predicted output of the plant along the prediction horizon e The rate of change in control action You can provide setpoint and disturbance profile information either in advance of controller execution or dynamically as the controller executes The following sections describe each of these methods 3 Note The examples in the following sections us
168. nt time step u k Instead you must use the predicted state estimate x k 1 k to calculate the control action at the next time step u k 1 The Discrete Observer function calculates u k 1 at the current time step k but applies this control action at the next time step k 1 Because this example has feedthrough you can initialize u k 1 and ensure a bumpless start by wiring an initial value to the initializer terminal of the Feedback Node National Instruments Corporation 17 9 Control Design User Manual Chapter 17 Deploying a Controller to a Real Time Target The example in Figure 17 7 implements a current observer without feedthrough that is when D 0 Initialize Sensor Measurement vi lu k K xhat k k Sampling Time s Feedback CD Construct State apace Model vi Ios p hath Controller vi Single Output Output Single Output P ment vi oof oe H KF Figure 17 7 Implementing a Current Observer without Feedthrough on an RT Target al Observer co State Initial State Estimate xhat O 1 CD Pole Plad Observer Gain Current Y ontroller Poles f Because the example in Figure 17 7 does not have feedthrough you must select the Indirect option in the Feedthrough pull down menu in the configuration dialog box of the Discrete Observer function You then can use the current state estimate x k k to calculate the control action at the curren
169. ntroller gt X gt System gt x Estimator Figure 14 5 System Included State Regulator The states inputs and outputs of the state regulator are At r and respectively x gt National Instruments Corporation 14 9 Control Design User Manual Chapter 14 Control Design User Manual Defining State Space Controller Structures System Included Configuration with Noise The system included with noise configuration incorporates noise r into the system included configuration The following equation defines the output error y y C x x r By substituting the output error in the general system configuration you obtain the following equations that describe the system included with noise configuration _ 4 BK LC LC x B ru x BK A x B 0j r x gt l K O IO x ry C DK 0 Fl o oF pK qd p S The reference vector or actuator noise r has as many elements as the number of inputs Also this configuration calculates the control action u internally and then gives u as an output of the state regulator Figure 14 6 represents the dynamic system that these equations describe ry u ry E a a y m gt Controller gt gt gt System gt lt gt x A Estimator S x ao a gt oy SS z3 o 5 a The states inputs and
170. nual Chapter 16 Using Stochastic System Models Converting the Model Before you can simulate this stochastic model using the Control Design and Simulation Module you must discretize the stochastic model and the associated noise model Use the CD Convert Continuous Stochastic to Discrete to discretize these models Figure 16 13 shows a block diagram that discretizes both models using a Sampling Time s of 0 000001 TA 3 gt f ic A D S 3 gt f w 3 3 gt gt f f A A ke A i gL Cele Cele CE is 3 Oy lies A a TINZEN mE EA CD Construct Stochastic Model vi ICD Convert Continuous Stochastic to Discrete vi Symbolic i Symbolic E w mm H Discrete Stochastic Symbolic E v H Btate Space Model fo be Numerical Integration Discrete Second Order Statistics Noise Model EEE Control Design User Manual Figure 16 13 Discretizing the Stochastic State Space Model and the Noise Model The example in Figure 16 13 uses the conversion Method of Numerical Integration to discretize the models 16 26 ni com Chapter 16 Using Stochastic System Models Simulating The Model Figure 16 14 shows a block diagram that simulates the discrete Stochastic State Space Model defined in the Converting the Model section of this chapter The Input u k to this model is a sine wave with an Amplitude of 0 01 volts and a Frequency of 1 KHz
171. nual 4 10 ni com Chapter 4 Connecting Models Figure 4 13 illustrates how some inputs from Model 1 and Model 2 share the same inputs The outputs of Model 1 are added to or subtracted from the outputs of Model 2 to provide one combined parallel model Wo Wy Vk Model 1 Model 2 Zo E gt 7 Zo e p m i gt 2 eee ere Xi pO 1 U X y Y2 r e e e p Ji National Instruments Corporation Figure 4 13 MIMO Models in Parallel 4 11 Control Design User Manual Chapter 4 Connecting Models Use the CD Parallel VI to define the relationship between the inputs and outputs of the models Figure 4 14 displays the Input Connections and Output Connections controls that define the parallel interconnections shown in Figure 4 13 Cm gao Ea E Ma E F Je Figure 4 14 Connection Definitions for Models in Parallel These controls indicate that the input for ug of Model 1 is the same as the input for v of Model 2 the input for u of Model 1 is the same as the input for vy of Model 2 and so on You can see how the y output of Model 2 is subtracted from the zg output of Model 1 You also can see how the Zp output of Model 1 is added to the y output of Model 2 You define addition and subtraction by specifying the output as a Positive or Negative connection In Figure 4 13 notice that any common inputs from the original models are replace
172. numbers for our worldwide offices are listed at the front of this manual You also can visit the Worldwide Offices section of ni com niglobal to access the branch office Web sites which provide up to date contact information support phone numbers email addresses and current events Control Design User Manual A 2 ni com
173. nuous and discrete types This chapter provides information about using the LabVIEW Control Design and Simulation Module to convert between model forms and to convert between continuous and discrete models 3 Note Refer to the labview examples Control and Simulation Control Design Model Conversion directory for example VIs that demonstrate the concepts explained in this chapter Converting between Model Forms You can use three different model forms transfer function zero pole gain and state space to describe the same dynamic system Refer to Chapter 2 Constructing Dynamic System Models for more information about these model forms You can use the Control Design and Simulation Module to convert from one form to another Converting between model forms is important because each form provides different information about the system For example state space models use the states of a system to show physical information about the system Thus observing physical information about a dynamic system is less complicated when the model for that dynamic system is in state space form You also can use different analysis and synthesis techniques depending on the form of the model For example if a model for a system is in transfer function form you can synthesize a controller for that system using classical control design techniques such as the root locus technique If the model is in state space form you can design a controller using st
174. nuous and discrete transfer function models Continuous Transfer Function Model m l m numerator s by tbys b 48 b s H s a0 1 m1 m denominator s ag tajs a s a s Discrete Transfer Function Model m 1 m numerator z ba bz b _ z b z H z e 22 1 m 1 m denominator z Agtajzt a _ zt a z Control Design User Manual 2 6 ni com Chapter 2 Constructing Dynamic System Models Numerators of transfer function models describe the locations of the zeros of the system Denominators of transfer function models describe the locations of the poles of the system Use the CD Construct Transfer Function Model VI to create continuous SISO SIMO MISO and MIMO system models in transfer function form This VI creates a data structure that defines the transfer function model and contains additional information about the system such as the sampling time input or output delays and input and output names Refer to the Obtaining Model Information section of this chapter for information about other properties of transfer function models SISO Transfer Function Models Using the example in the RLC Circuit Example section of this chapter you can describe the voltage of the capacitor v using the following second order differential equation LCV RCV v v After taking the Laplace transform and rearranging terms you then can write the transfer function between the input voltage V and the capacit
175. nuous transfer function and zero pole gain models use the s variable to define time whereas discrete models in these forms use the z variable Continuous state space models use the variable to define time whereas discrete state space models use the k variable You can use these forms to describe single input single output SISO single input multiple output SIMO multiple input single output National Instruments Corporation 2 5 MISO and multiple input multiple output MIMO systems The number of sensors and actuators determines whether a dynamic system is a SISO SIMO MISO or MIMO system Control Design User Manual Chapter 2 Constructing Dynamic System Models The following sections provide information about an example dynamic system and how to represent this dynamic system using all three model forms RLC Circuit Example Figure 2 2 shows an example circuit consisting of a resistor R an inductor L a current i f a capacitor C a capacitor voltage v t and an input voltage v t vi t C velt Figure 2 2 RLC Circuit The following sections use this example to illustrate the creation of three forms of dynamic system models Constructing Transfer Function Models Transfer function models use polynomial functions to define the dynamic relationship between inputs and outputs of a system You analyze transfer function models in the frequency domain The following equations define conti
176. nvariant systems This module also provides a variety of numerical integration schemes for simulating more elaborate systems such as nonlinear systems You also can use this module to determine how a system responds to complex time varying inputs Deploying the Controller The fourth phase of model based control design involves deploying the controller to a real time RT target LabVIEW and the LabVIEW Real Time Module provide a common platform that you can use to implement the control system Refer to the National Instruments Web site at ni com for information about the National Instruments products mentioned in this section Overview of LabVIEW Control Design The Control Design and Simulation Module provides an interactive Control Design Assistant a library of VIs and a library of MathScript RT Module functions for designing a controller based on a model of a plant You can use all these tools to complete the entire control design process from creating a model of the controller to synthesizing the controller on an RT target Control Design Assistant Control Design User Manual You can use the Control Design Assistant to synthesize and analyze a controller for a user defined model without knowing how to program in LabVIEW You access the Control Design Assistant through the Lab VIEW SignalExpress environment LabVIEW SignalExpress is a framework that can host multiple interactive National Instruments tools and assistants 1
177. of delay that you can add to a system before the system becomes unstable Mathematically the phase margin is the amount by which the phase exceeds 180 when the gain is equal to 0 dB The phase margin also indicates how close a closed loop system is to instability A stable system must have a positive phase margin National Instruments Corporation 7 3 Control Design User Manual Chapter 7 Frequency Response Analysis Figure 7 1 shows Bode plots with corresponding gain and phase margins Figure 7 1 Gain and Phase Margins Depending on the complexity of the system a Bode plot might return multiple gain and or phase margins Control Design User Manual 7 4 ni com Chapter 7 Frequency Response Analysis Nichols Frequency Analysis Use Nichols frequency analysis to obtain the closed loop frequency response of a system from the open loop response Open loop response curves or loci of constant magnitude and phase often provide reference points that help you analyze a Nichols plot Each point on the open loop response curve corresponds to the response of the system at a given frequency You then can read the closed loop magnitude response at that frequency from the Nichols plot by identifying the value of the magnitude locus at which the point on the curve intersects Similarly you can determine the closed loop phase by identifying the phase locus at which the open loop curve crosses Use the CD Nichols VI to create a Nichols pl
178. of this system Vesseree PZIIIIIIIIIIIIIIIIIIT Figure 5 6 Impulse Response Block Diagram of the Spring Mass Damper System Figure 5 7 shows the Impulse Response Graph resulting from this block diagram 0 02 z 0 017 Z ie 2 o o 5 a 0 01 0 02 1 1 1 1 I 1 1 0 2 50 75 100 125 150 175 Time s Figure 5 7 Impulse Response Graph of the Spring Mass Damper System Analyzing an Initial Response The initial response of a dynamic system measures how the system responds to a set of non zero initial conditions Use the CD Initial Response VI to determine the initial response of a dynamic system Control Design User Manual 5 8 ni com Chapter 5 Time Response Analysis B Note The CD Step Response VI and the CD Impulse Response VI support initial conditions Use the Initial Conditions parameter of these VIs to see how a set of initial conditions affects the step and or impulse responses For example consider the system described in the Spring Mass Damper Example section of this chapter Figure 5 8 shows how you determine the response of this system to an initial condition of 0 3 cm EE Figure 5 8 Initial Response Block Diagram of the Spring Mass Damper System Figure 5 9 shows the Initial Response Graph resulting from this block diagram Displacement cm oO 1 0 25 0 3 1 1 i 1 1 1 1 0 25 50 75 100 125 150 175 Time s
179. oller Gain Figure 14 20 Standalone without Estimator Compensator AJA Note To view both the original response of the actual system and the response of the system controlled by the state compensator you must append the model of the actual system State Space Model to the model of the state compensator Therefore in the State Trajectory Graph shown in Figure 14 21 you can see the difference in the system response due to the effect of the compensator gain K By adding a state compensator to the actual system you create a closed loop model of the resulting system The actual system without a state compensator is an open loop system Figure 14 21 shows the response of the open loop and closed loop systems to initial conditions of 2 1 State Trajectory Graph xiClosed Loop x2Closed Loop xlOpenLoop x20pen Loop Amplitude Figure 14 21 State Trajectory for Standalone without Estimator Compensator Control Design User Manual 14 28 ni com Chapter 14 Defining State Space Controller Structures Notice that despite the instability of the actual system the state compensator is able to drive the closed loop states toward zero Thus the addition of a state compensator to the actual system stabilizes the resulting system Because the standalone state compensator stabilizes the actual system you must use a state compensator with this system National Instruments Corporation 14 29 C
180. oller Poles you specify This example calculates the control action to apply at the next time step or u k 1 which is defined as Kx k 1 k At the next iteration of the Timed Loop u k 1 becomes u k which the Discrete Observer function uses to estimate state information for the next time step The feedback node transfers this value from one iteration to the next Refer to Chapter 15 Estimating Model States for more information about observers 17 8 ni com Chapter 17 Deploying a Controller to a Real Time Target Example State Space Controller with Current Observer Code The example in Figure 17 6 shows a block diagram that implements a state space controller that depends on estimated state information Sampling Time s Ea i Error gt E a E ME EA es 4 ost Sensor Measure B i Controller Output vi x 0 be we C isi Ibe D ER n Aa x Le ju k 1 a K xhat k 1 k Single Output Initial State Estimate xhat O 1 1 oBLp CD Pole Place Observer Gain Current Y 4 Controle Palez CD Pole Fp at Poles i A Grop c0 Controller Gain v Gi rey Figure 17 6 Implementing a Current Observer with Feedthrough on an RT Target The example in Figure 17 6 implements a current observer with feedthrough that is when D 0 Because this example has feedthrough you cannot use the current state estimate x k k to calculate the control action at the curre
181. on and Control Horizons In Figure 18 1 notice that at time k the MPC controller predicts the plant output for time k N Also notice that the control action does not change after the control horizon ends At the next sample time k 1 the prediction and control horizons move forward in time and the MPC controller predicts the plant output again Figure 18 2 shows how the prediction horizon moves at each sample time k Prediction Horizon at Time k 1 Prediction Horizon at Time k gt k k 1 k No k No 1 Time Figure 18 2 Moving the Prediction Horizon Forward in Time 3 Note The control horizon moves forward along with the prediction horizon Before moving forward the controller sends the control action u k to the plant Control Design User Manual Because you cannot change the length of the prediction or control horizons while the controller is executing National Instruments recommends you set the prediction horizon length according to the needs of the control problem In general a short prediction horizon reduces the length of time during 18 4 ni com Chapter 18 Creating and Implementing a Model Predictive Controller which the MPC controller predicts the plant outputs Therefore a short prediction horizon causes the MPC controller to operate more like a traditional feedback controller For example consider the cruise control system again If the prediction horizon is short the controller
182. on of these eigenvalues determines the stability of the system A continuous system is stable if all eigenvalues of A have negative real parts A discrete system is stable if these eigenvalues fall within the unit circle Determining Controllability and Stabilizability Control Design User Manual A system is controllable if all the states that describe the system respond to an input of the system that is you can influence the states of the system independently by adjusting the inputs A system is not controllable if the system contains states that remain unaffected by any input If a system is controllable there is an input that forces the system states or linear combination of states to go from any initial condition at t 0 to zero at any time gt 0 If a system is open loop unstable you can adjust the input to affect the response of the states You can confirm the controllability of a system by verifying that the controllability matrix Q shown in the following equation has full row rank or is nonsingular The state matrix A and the input matrix B determine the controllability properties of a state space model You use these matrices to calculate Q as shown in the following equation 1 Q B AB A B A system is controllable if Q has full row rank or is nonsingular For example if B is an n dimensional column vector that is colinear to an eigenvector of null eigenvalues of A you obtain the following matrix
183. onnection is positive or negative Based on the connections you specified in Feedback Connections the outputs specified for Model 2 are fed back to the inputs specified for Model 1 You also define whether the feedback connection is positive or negative Outputs of Model 2 not specified in Feedback Connections are removed from the resulting model Again because you specified connections using the Feedback Connections the CD Feedback VI ignores the Feedback Sign input In the resulting model shown in Figure 4 20 you can see how the CD Feedback VI creates a new reference input r for each feedback connection you specified ii s p gt Yo uy lo gt Feedback Model 1 gt y Connections Up 4 Q Vo gt R Output pI 2 Connections _ gt Model 2 Vo gt 3 Control Design User Manual Figure 4 20 Two Models with Feedback and Output Connections Defined 4 18 ni com Time Response Analysis The time response of a dynamic system provides information about how the system responds to certain inputs You analyze the time response to determine the stability of the system and the performance of the controller Obtaining the time response of a system involves numerically integrating the system model in time The LabVIEW Control Design and Simulation Module provides VIs to help you find these time domain solutions You can use these Time
184. onstruct a stochastic state space model Refer to the LabVIEW Help available by selecting Help Search the LabVIEW Help for information about this VI 16 2 ni com Chapter 16 Using Stochastic System Models Constructing Noise Models A noise model characterizes the first and second order statistical behavior of the noise vectors w and v You construct a noise model by specifying the expected mean and auto covariance of each noise vector You also can specify any cross covariance between the two vectors A noise model is of the following form Q E w w E w E w R Elv y E v E v N Elw v Elw E v Table 16 2 describes these variables Table 16 2 Dimensions and Names of Noise Model Variables Variable Dimension Name Q q X q matrix Auto covariance matrix of w R rx r matrix Auto covariance matrix of v N q X r matrix Cross covariance between w and v E w qX 1 vector Mean vector of w E v rx 1 vector Mean vector of v Use the CD Construct Noise Model VI to construct a noise model for a given stochastic state space model Refer to the LabVIEW Help for information about this VI Converting Stochastic Models A noise model is associated with a particular stochastic model If the stochastic model is continuous the noise model is continuous whereas if the stochastic model is discrete the noise model is discrete You can convert continuous stochastic models to discrete
185. ontrol Design User Manual Estimating Model States Observers estimate the states of state space system models by using the model information any known inputs and measured outputs Use an observer when you cannot measure one or more model states directly You can use observers only with state space models because transfer function and zero pole gain models do not specify state information 3 Note Observers do not take noise into account when estimating system states If there is noise present in the system that is if the system is stochastic you use an estimator instead of an observer A Kalman filter is one type of estimator Refer to Chapter 16 Using Stochastic System Models for more information about stochastic systems and Kalman filters The LabVIEW Control Design and Simulation Module includes two types of observers for discrete models Predictive observers use only information from the previous time step to estimate state information Current observers use not only information from the previous time step but also information from the current time step This additional information improves the accuracy of current observers Use a current observer only when the extra computation time does not interfere with the next sampling time The Control Design and Simulation Module also includes an observer for continuous models However estimating state information of continuous models requires solving a differential equation over time Ther
186. ontrol action u k to the input u k input of the Discrete State Space function which represents the plant 4 The Discrete State Space function returns the actual output y k of the plant and sends these values to the Measured Output y k input of the CD Implement MPC Controller VI This VI uses y k to estimate the model states and account for any integral action Accounting for integral action involves calculating the error which is the difference between y k and the output setpoint The CD Implement MPC Controller VI uses the estimated model states calculated error and output of the internal controller model to adjust the control action for the next time step 5 Because u k and y k consist of interleaved values the Index Array functions separate the interleaved arrays into their component profiles After the For Loop finishes executing this example returns Control Action Response and Closed Loop Response arrays so you can plot the data on XY graphs At the next sample time k 1 the CD Update MPC Window VI accepts a new element corresponding to the setpoint at time k Prediction Horizon 1 from the Predicted Values control This example then executes steps 2 5 again The repetition occurs until the For Loop stops executing B Note Right click the VI or function and select Help for detailed information about these VIs and functions Updating Setpoint and Disturbance Information Dynamically When implementing an MPC controll
187. or voltage V using the following equation 1 VOD T a Hi Vis es ea L LC You then can use H s to study the dynamic properties of the RLC circuit The following equation defines a continuous transfer function where R 20 Q L 50 mH and C 10 uF 2x 10 i Ake eT ena ET s 4005 2 x 10 National Instruments Corporation 2 7 Control Design User Manual Chapter 2 Constructing Dynamic System Models Figure 2 3 shows how you use the CD Construct Transfer Function Model VI to create this continuous transfer function model Numerator CD Construct Transfer Function Model vi Transfer Function Model Figure 2 3 Creating a Continuous Transfer Function Model The Numerator and Denominator inputs are arrays with zero based indexes The i element of the array corresponds to the i order coefficient of the polynomial You define the coefficients in ascending order 3 Note The CD Construct Transfer Function Model VI does not automatically cancel polynomial roots appearing in both the numerator and the denominator of the transfer function Refer to Chapter 10 Model Order Reduction for information about cancelling pole zero pairs The CD Construct Transfer Function Model VI creates a continuous model You can create a discrete transfer function model in one of two ways The method you use depends on whether you know the coefficients of the discrete transfer function model If you know the coefficients of
188. or configuration uses states to calculate the control action u As such you do not need an estimator In the CD State Space Controller VI do not wire a value to the Estimator Gain L input to exclude the estimator in the standalone state regulator The following equations describe the standalone configuration x A BK x Br y C DK x Dr The states and outputs of the standalone without estimator state regulator correspond to the states and outputs of the actual system Figure 14 8 represents the dynamic system that these equations describe Y Yy H Controller System k Figure 14 8 Standalone without Estimator State Regulator The states inputs and outputs of the state regulator are x r and H respectively J Control Design User Manual 14 12 ni com Chapter 14 Defining State Space Controller Structures State Regulator with Integral Action A general system configuration appends the output error integrator z to the estimation model states x A general system configuration also augments the resulting vector x z with the original model states x to represent the state regulator with integral action and an estimator The following equations show this process x oola Boz u z JOT ollz 0 z olye y l 00 A lx Boo y u K K oll foooll u 0 xy C o Olfz t D0 O y 0 ly Lo o0 Clix D0O y y r In these equations K is the gain K is th
189. ot and examine system performance in dynamic systems The CD Nichols VI calculates and plots the open loop frequency response against the gain and phase on the Nichols plot Different points on the plot correspond to different values of the frequency Examine the Nichols plot to determine the gain and phase margins bandwidth and the effect of gain variations on the closed loop system behavior Nyquist Stability Analysis Use Nyquist stability analysis to examine the system performance of dynamic systems Nyquist plots consist of the real part of the frequency response plotted against the imaginary part of the response Nyquist plots indicate the stability of a closed loop system given an open loop system which includes a gain of K Use the CD Nyquist VI to create a Nyquist plot The Nyquist stability criterion relates the number of closed loop poles of the system to the open loop frequency response On the Nyquist plot the number of encirclements around 1 0 is equal to the number of unstable closed loop poles minus the number of unstable open loop poles National Instruments Corporation 7 5 Control Design User Manual Chapter 7 Control Design User Manual Frequency Response Analysis You can use this criterion to determine how many encirclements the plant requires for closed loop stability For example if the plant has all open loop stable poles there are no encirclements If the plant has one open loop unstable pole
190. our understanding of the plant model or of other parameters related to the controller If you do not want to stop execution to update the controller with this data you can modify the controller at run time instead Use the CD Set MPC Controller VI to update an MPC controller at run time You can update any aspect of the controller such as the input model the prediction and control horizons or the parameter constraints When you click the Reset button the controller updates with the changes that you specify You can use the Dual or Barrier instances of the CD Set MPC Controller VI to update a controller whose constraints are determined using the dual optimization method or the barrier function method respectively Refer to the Specifying Constraints section of this chapter for information about each of these methods Figure 18 6 illustrates how to use the CD Create MPC Controller VI and the CD Set MPC Controller VI to create an MPC controller and allow for controller updates at run time 18 18 ni com Chapter 18 Creating and Implementing a Model Predictive Controller MPC Controller Parameters f CD Create MPC Controller vi oat a ei 2 hefa MPC Controller Parameters f 8S pner ay State Space Model Ei eea J error in no error EH MPC Cost Weights State Space Model p MPC Cost Weights p d MPC Constraints Dual p MPC Constraints Dual E O Figure 18 6 Modifying a
191. ove all states that are not observable or controllable Use the CD Minimal State Realization VI to determine the minimal realization for a state space model Refer to Chapter 9 Analyzing State Space Characteristics for information about controllability and observability Reducing the Order of Models In certain situations you might want to work with a lower order model of the system The goal of model order reduction is to remove stable states that have the smallest impact on the input output model representation You might want to reduce a model order when the real part of stable system poles differ significantly From an input output standpoint you usually ignore fast dynamic modes which are modes that correspond to stable eigenvalues far from the imaginary axis because you only see the effects of these modes over a short initial period of time Use the CD Model Order Reduction VI to reduce high order models 3 Note Model order reduction applies only to a state space model of a system Control Design User Manual 10 2 ni com Chapter 10 Model Order Reduction You can reduce the order of the model by decreasing the order of the stable modes Reducing stable modes of the model does not affect the unstable modes of the model You have several options for reducing the order of a model You can match the DC gain between the reduced order model and the original model You also can delete the states directly Balancing the original sta
192. p behavior in terms of the value of a variable in the feedback transfer function National Instruments Corporation 11 1 Control Design User Manual Chapter 11 Designing Classical Controllers Control Design User Manual For example consider a system with the following open loop transfer function H s ee s 1 s 2 s 3 If a simple proportional feedback controller controls this system the following equation describes the characteristic equation K 1 A s K 1 _ 0 s 1 s 2 s 3 Figure 11 1 illustrates the root locus plot of this system 1 5 open loop poles lt 1 25 is J 0 75 i open loop zeros 5 bifurcation point 3 H in 1 0 25 Imaginary Axis j 0 25 0 57 0 75 1 1 25 ASH 1 i 1 1 1 1 1 I 35 3 25 2 15 1 05 0 Real Axis i Figure 11 1 Root Locus This graph shows the locations of the closed loop poles The pole locations are 1 2 and 3 You can use root locus design to synthesize a variety of different controller configurations including the following types e Lead compensator Lowers the rise time and decreases the transient overshoot e Lag compensator Improves the steady state accuracy of the system e Notch compensator Achieves stability in the system with lightly damped flexible modes This compensator adds a zero near the resonance point of the flexible mode 11 2 ni com Chapte
193. p response of a dynamic system measures how the dynamic system responds to a step input signal The following equations define a unit step input signal u t 0 when t lt 0 u t 1 when t20 The Control Design and Simulation Module contains two VIs to help you measure the step response of a system and then analyze that response The CD Step Response VI returns a graph of the step response The CD Parametric Time Response VI returns the following response data that helps you analyze the step response Rise time The time required for the dynamic system response to rise from a lower threshold to an upper threshold The default values are 10 for the lower threshold and 90 for the upper threshold Maximum overshoot M The dynamic system response value that most exceeds unity expressed as a percent Peak time The time required for the dynamic system response to reach the peak value of the first overshoot Settling time The time required for the dynamic system response to reach and stay within a threshold of the final value The default threshold is 1 Steady state gain The final value around which the dynamic system response settles to a step input Peak value y The value at which the maximum absolute value of the time response occurs 3 Note You can modify the default values for the rise time thresholds and the settling time threshold using the Rise Time Thresholds and Settling Time Threshold
194. r Control Design User Manual In theory you can place the poles of the state estimator as far left of the complex plane as necessary This placement leads to very aggressive state estimators Noise and system uncertainties however prevent you from configuring such aggressive estimators To account for noise and system uncertainties you can implement a state estimator using the system included with noise configuration Consider the following system included with noise configuration a B _ A LCLC x x 0 A x C 0 x 0 r y 0 C ix I The configuration of this system is essentially the same as the system in the Example System Configurations section of this chapter The only addition is the measurement noise r Assume that the measurement noise in this example is a Gaussian noise in the system The output noise influences the estimated model dynamics through the estimator gain matrix L gt gt lt 13 10 ni com Chapter 13 Defining State Estimator Structures Figure 13 6 shows how to account for a Gaussian noise of 0 1 standard deviation in the Estimator Model gt System Included with Noise v ptate Space Model CD State Estimator vi a ee F ooo stimator Model Initial Conditions o bbEeL Observer Gain Current standard deviation Figure 13 6 System Included with Noise State Estimator The example in Figure 13 6 uses the state space mod
195. r 11 Designing Classical Controllers e proportional integral derivative PID controller Forms a controller using the most common architecture Refer to the Proportional Integral Derivative Controller Architecture section of this chapter for more information about PID controllers The difference in these controller configurations is the form of the transfer function equations you use to synthesize the controller Different transfer function models result in different dynamic characteristics of the controlled system For example consider a controller transfer function model D s defined by the form of the following equation Dis KE stp If z lt p this transfer function results in a lead compensator You typically place this lead compensator in series with the plant H s in the feed forward path If z gt p this transfer function results in a lag compensator Refer to the CDEx Interactive Root Locus VI located in the labview examples Control and Simulation Control Design Dynamic Characteristic Analysis directory for an example that demonstrates root locus analysis You also can use other frequency domain tools such as Bode Nyquist and Nichols plots to design a system These plots show the specific locations and shape of key points You examine these locations to modify the controller parameters iteratively to meet these specifications The number and nature of the controller parameters depends on the topology of the contro
196. r Reduction 3 In most cases different models of a dynamic system can represent the same input output behavior of that system For example you can have two state space models with different numbers of states that represent the same input output behavior at varying degrees of accuracy Often you can simplify or reduce these models to obtain a less complicated representation of the system How you reduce a model depends on the representation of the model If the model is a state space model reducing the number of states reduces the order of the model If the model is a transfer function or zero pole gain model cancelling matching poles and zeros reduces the order of the model Use the Model Reduction VIs to reduce the order of a model This chapter provides information about the minimal realization and model order reduction techniques you can use to simplify a model Note Refer to the labview examples Control and Simulation Control Design Model Reduction directory for example VIs that demonstrate the concepts explained in this chapter Obtaining the Minimal Realization of Models The minimal realization of a system model involves cancelling all pairs of poles and zeros at the same location You refer to these pairs as pole zero pairs Use the CD Minimal Realization VI to calculate the minimal realization of a model For example consider the following transfer function model H s s 6s 8 _ s 2 s 4 _ 2 Hs Se Ni De
197. re in this form you can derive the values of the necessary matrices Applying Kirchoff s Voltage Law to the example in Figure 16 11 yields the following equations that represent the system input and output v t Ri t 18 n t Vo a t Ri t n t e t To obtain the values of the state space matrices transform these equations into the stochastic state space equations defined as the following X t Ax t Bu t Gw t y t Cx t Du t Hw t v t You can transform these equations by substituting equivalent terms and then rearranging those terms Table 16 3 shows the equivalent terms in both sets of equations Table 16 3 Equivalent Terms Variable Represents Equivalent Term i t State vector x t v t Input vector u t Von t Output vector y t n t Process noise vector w t e t Measurement noise vector v t Substituting variables with equivalent terms yields the following equations u t Rx t Lx t w t y t Rx t w t v t National Instruments Corporation 16 23 Control Design User Manual Chapter 16 Using Stochastic System Models Rearranging the terms in the first equation yields the following equations x t Ba n uo Fw y t Rx t w t v t From these equations you can obtain the following values of the state space matrices R B A C Mm i i The next step is constructing the noise model associated with th
198. reating a MIMO Transfer Function Model The elements in the Numerator and Denominator arrays correspond to the coefficients in ascending order of the numerator and denominator in the H transfer function model For example the numerator of H4 is 1 which corresponds to the zero order coefficient Therefore the first element in the Numerator array for H4 is 1 The denominator of H is s which means the value 0 corresponds to the zero order coefficient and the value 1 corresponds to the first order coefficient Therefore the first element in the Denominator array for H is 0 and the second element is 1 Symbolic Transfer Function Models Symbolic models define the transfer function using variables rather than numerical values If you want to change the value of R for example you only need to make the change in one location instead of several locations Select the SISO Symbolic or MIMO Symbolic instance of the CD Construct Transfer Function Model VI to create a SISO or MIMO symbolic transfer function model respectively National Instruments Corporation 2 11 Control Design User Manual Chapter 2 Constructing Dynamic System Models The following equation is a symbolic version of the transfer function originally defined in the SISO Transfer Function Models section of this chapter 1 LC Hes 2 R 1 s L LC Specify the Symbolic Numerator and Symbolic Denominator coefficients using the variable names R L and C You then spec
199. receives only a small amount of information about upcoming changes in the road slope and speed limit This small amount of information reduces the ability of the controller to provide the correct amount of gas to the engine A long prediction horizon increases the predictive ability of the MPC controller However a long prediction horizon decreases the performance of the MPC controller by adding extra calculations to the control algorithm Because the control action cannot change after the control horizon ends a short control horizon results in a few careful changes in control action Consider the cruise control system again After the control horizon ends the flow of gas to the engine remains constant which means the velocity of the car keeps changing until the velocity setpoint is reached If the control horizon is short the controller attempts to meet the velocity setpoint by changing the flow of gas only a few times and in small amounts A large control action in a short control horizon might overshoot the velocity setpoint after the control horizon ends However as the controller continues to execute the velocity eventually settles around the setpoint Conversely a long control horizon produces more aggressive changes in control action These aggressive changes can result in oscillation and or wasted energy For example if you set the control horizon of the cruise control system too long the cruise control system wastes gas due to
200. rights reserved Important Information Warranty The media on which you receive National Instruments software are warranted not to fail to execute programming instructions due to defects in materials and workmanship for a period of 90 days from date of shipment as evidenced by receipts or other documentation National Instruments will at its option repair or replace software media that do not execute programming instructions if National Instruments receives notice of such defects during the warranty period National Instruments does not warrant that the operation of the software shall be uninterrupted or error free A Return Material Authorization RMA number must be obtained from the factory and clearly marked on the outside of the package before any equipment will be accepted for warranty work National Instruments will pay the shipping costs of returning to the owner parts which are covered by warranty National Instruments believes that the information in this document is accurate The document has been carefully reviewed for technical accuracy In the event that technical or typographical errors exist National Instruments reserves the right to make changes to subsequent editions of this document without prior notice to holders of this edition The reader should consult National Instruments if errors are suspected In no event shall National Instruments be liable for any damages arising out of or related to this document or the information
201. rol Design User Manual Chapter 12 Designing State Space Controllers The following sections provide information about using the Control Design and Simulation Module to perform the pole placement technique and design a linear quadratic regulator The following sections also describe how to use the Kalman gain function and how to construct a linear quadratic Gaussian controller Pole Placement Technique Control Design User Manual Pole placement is a technique in which you specify the locations of the closed loop poles of a system and calculate the gain matrix based on these locations You can use the pole placement technique to calculate either the observer gain matrix L or the controller gain matrix K Use the CD Ackermann VI to apply this technique in the following situations e A single input single output SISO system e A single input multiple output SIMO system if you are defining the controller gain matrix K e A multiple input single output MISO system if you are defining the observer gain matrix L Use the CD Pole Placement VI in all other situations for example a multiple input multiple output MIMO system The computation of the gain for these systems is more complex and based on a Sylvester matrix equation Refer to the LabVIEW Control Design and Simulation Module Algorithm Reference manual for information about the Sylvester matrix equation Use the Gain Type parameter of the CD Ackermann VI and the CD Pole Pl
202. rol Design User Manual Chapter 3 Converting Models When you convert the transfer function matrix from the Converting Models to Transfer Function Models section of this chapter you obtain the following zero pole gain model 4 2 H s H aT This zero pole gain model is numerically identical to the transfer function model The zero pole gain form however shows the locations of the zeros and poles of a system Converting Models to State Space Models Use the CD Convert to State Space Model VI to convert a zero pole gain or transfer function model to a state space model This section uses a zero pole gain model as an example 3 Note When you convert a zero pole gain model to a state space model the CD Convert to State Space Model VI converts the zero pole gain model to a transfer function model first Control Design User Manual When converting a transfer function or zero pole gain model you can specify whether you want the resulting state space model to be full or minimal A full state space model does not reduce the number of states determined by a least common denominator calculation A minimal state space model reduces the number of states and produces a minimal representation of the original model Use the Realization Type parameter of the CD Convert to State Space Model VI to specify if you want the resulting model to be full or minimal Refer to the Obtaining the Minimal Realization of Models section of Chapter 10 Model Or
203. rol Design User Manual Defining State Space Controller Structures System Included with Noise Configuration The system included with noise configuration incorporates noise r into the system included configuration The following equations define the output error and system output y y Cx Cx r y D K x Kz Cz r By substituting the output error and system output in the general system configuration you obtain the following equations that describe the system included with noise configuration i 4 BK LC BK Lc or DK DK C z 10 P BK BK A x o oj L u AG AKOR oal C DK DK 0 z o 0 A y DK DK c x 0 7b The reference vector y has as many elements as the number of outputs Also this configuration calculates the control action u internally and then gives u as an output of the state regulator with integral action 14 16 ni com Chapter 14 Defining State Space Controller Structures Figure 14 10 represents the dynamic system described by these equations u ry r Yref T y Controller System a gt Zz x lt lt gt Estimator Y _ x Figure 14 10 System Included with Noise State Regulator with Integral Action The states inputs and outputs of the state regulator with integral action are r x ae Vref and y respectively x 7 J Standalone with Estimator Configuration
204. ross covariance matrix between w and v is N a third matrix representing cross covariance in the noise model The following equations illustrate the computations that the Continuous Extended Kalman Filter function performs to produce the estimated states x t of the plant x t fix u t LOD xD y t A x u t P t F x u t P t P t F E x u t O t L t P HE x u t N IR A 16 8 ni com Chapter 16 Using Stochastic System Models PDHE S u t N Q IR PHT u NO Pa ot tt x t x t He age x t x t where x t is the estimated state e y t is the estimated output e P t is the estimated error covariance e L t is the Kalman filter gain F x u t is the Jacobian matrix of f x u t with respect to x evaluated at x t HG u t is the Jacobian matrix of h x u t with respect to x evaluated at x t If you choose the Internal Jacobian instance of the Continuous Extended Kalman Filter function the Continuous Extended Kalman Filter function internally computes a Jacobian matrix to estimate the states of the nonlinear system If you choose the External Jacobian instance of this function you must define the Jacobian matrix manually Use the SIM Continuous Jacobians template VI located in the labview templates Control and Simulation directory to define the Jacobian matrix Then wire a reference to the SIM Continuous Jacobians template VI to the Jacobians inpu
205. rvable stabilizable or detectable You can use state space analysis to balance a system model Balancing a system model is useful in both analyzing and synthesizing a controller You also can use state space analysis to define different representations of the same system Because you can choose a variety of state variables to represent a single system the state space form for a given linear time invariant multiple input multiple output MIMO system is not unique You must determine which state variables are best for the analysis and design of a state space controller This chapter provides information about using the LabVIEW Control Design and Simulation Module to perform state space analysis Note Refer to the labview examples Control and Simulation Control Design State Space Analysis directory for example VIs that demonstrate the concepts explained in this chapter National Instruments Corporation 9 1 Control Design User Manual Chapter 9 Analyzing State Space Characteristics Determining Stability In state space form the time evolution of the states determines the stability of the system If you have initial conditions and you eliminate all inputs to the system only the state matrix A governs the response of the system You then apply control theory to find the counterparts of poles which you can use in transfer function and pole zero analysis The counterparts of poles are the eigenvalues of the state matrix A The locati
206. s eceeeeceseeseeseeeeesseeeseeseessesseeseeeseeseeens 2 14 National Instruments Corporation v Control Design User Manual Contents Constructing State Space Models eecesceseeseeseceeceseceeceeeceeceseseecesesseseaesseesaeeneens 2 14 SISO State Space Mod ls siiicar onses erisir oiii iiaii 2 16 SIMO MISO and MIMO State Space Models ecceecesscceseeeeteceneeeseeeenees 2 18 Symbolic State Space Models 20 0 eceeceescecceseceeceseceeeesesesesseseeeeseeeaeeaeens 2 18 Obtaining Model Information eee eee eseeeseeseeeecesecesenaeceeesecaesssesseesaeeseeeaeeatens 2 18 Chapter 3 Converting Models Converting between Model Forms 00 eceeeccsceeceeseeseceseeseceaeceeeeseceeesesseeeaeeseesseeseees 3 1 Converting Models to Transfer Function Models eee eceeeeseeeeeseeeeeees 3 2 Converting Models to Zero Pole Gain Models 0 eeeeeeseeeeseseeeseeeeenees 3 3 Converting Models to State Space Models eee ee eeeeeecseceesseeeeeseeeseeeeees 3 4 Converting between Continuous and Discrete Models 0 cc ceceseeseeseceeeeseeeeeeneesees 3 5 Converting Continuous Models to Discrete Models eee eeeseeeeeseereees 3 6 Forward Rectangular Method 00 eee eceeeeseeseceeceseeeeeeseeeeeseeaeees 3 8 Backward Rectangular Method 0 00 tees ceeeeeeseeeseeseeseeeneeeees 3 8 T stin s Method ariera aarnior arpapi agaaa ikopa saiia aean 3 9 Prewarp Method saiiocieimis miene a 3 10 Zero Order Hold and First Order Hold Metho
207. s 85 21s 108 s 4 s 3 s 9 s 3 s 9 sina Realization This model has a pole and zero in the same location 4 Wire this model into the CD Minimal Realization VI to cancel this pole zero pair This VI returns the minimal realization of the model in the Reduced Model output National Instruments Corporation 10 1 Control Design User Manual Chapter 10 Model Order Reduction This VI also returns the number of pole zero locations removed For state space models this VI returns the number of states removed Minimal realizations are minimal because the only modes represented in the model are those modes that you can infer by observing the inputs and outputs of the system The modes that you eliminate to obtain a minimal transfer function or zero pole gain model still exist in the system but you cannot infer their existence by simply observing the input and outputs of the model For this reason you do not want to cancel unstable pole zero pairs For example consider the following transfer function model G s G s a e 28 4 __ 2 so 1682 75s 108 8 4 s 3 s 9 s 3 s 9 nina Realization G s has the same minimal realization as H s but G s contains an unstable pole zero pair at 4 If you cancel this pole zero pair you no longer can observe any effects the pair has on the stability of the system A minimal realization for a state space model is a state space representation in which you rem
208. s active when the car reaches 69 miles per hour The penalty then increases from 0 to 5 in a shorter velocity interval than before In this case the MPC algorithm responds to the penalty and almost immediately tries to prevent the velocity from increasing above 69 miles per hour Because the penalty profile is steeper than in the previous case when the tolerance was five the MPC algorithm has a shorter interval in which to prevent the velocity from exceeding the constrained value Prioritizing Constraints and Cost Weightings Remember that all constraints you specify using the dual optimization method are weighted equally and above any cost weightings you specify With the barrier function method you can prioritize the constraints against each other and against any cost weightings you specify When an MPC algorithm recognizes that the penalty on a constraint is active the algorithm incorporates the penalty in the cost function and adjusts the control action accordingly For each constrained variable the MPC algorithm must balance the penalty with any cost weightings Control Design User Manual 18 10 ni com Chapter 18 Creating and Implementing a Model Predictive Controller The following expression illustrates this behavior in the case of amaximum constraint 2 2 P iis tol nax z z Z qZ 2 Z max a tol pax max where P is the penalty constant for Zmax Zmax 1S the maximum constraint on z tol nax is the tolerance
209. s introduced by the model you defined disturbances in the system states and actuator errors Measurement noise reflects sensor reading errors and disturbances directly affecting the sensor readings e Matrices G and H relate w to the states and outputs respectively National Instruments Corporation 16 1 Control Design User Manual Chapter 16 Using Stochastic System Models Control Design User Manual The following equations define continuous and discrete stochastic state space models Continuous Stochastic State Space Model X t Ax t Bu t Gw t y t Cx t Du t Hw t v t Discrete Stochastic State Space Model x k 1 Ax k Bu k Gw k y k Cx k Du k Hw k v k Table 16 1 describes these variables Table 16 1 Dimensions and Names of Stochastic State Space Model Variables Variable Dimension Name q Length of process noise vector w r Number of outputs n Number of states w q X 1 vector Process noise vector v rx l vector Measurement noise vector G nX q matrix Weighting matrix relating the process noise vector w to the system states H r x q matrix Weighting matrix relating the process noise vector w to the system outputs Refer to the Constructing State Space Models section of Chapter 2 Constructing Dynamic System Models for information about the A B C D x u and y variables Use the CD Construct Stochastic Model VI to c
210. s of models you can create with the Control Design and Simulation Module Linear versus Nonlinear Models Dynamic system models are either linear or nonlinear A linear model obeys the principle of superposition The following equations are true for linear models y f x Yo f x Y f x y1 y Conversely nonlinear models do not obey the principle of superposition Nonlinear effects in real world systems include saturation dead zone friction backlash and quantization effects relays switches and rate limiters Many real world systems are nonlinear though you can linearize the model to simplify a design or analysis procedure You can use the Trim amp Linearize VIs to perform this linearization task The Control Design and Simulation Module supports both linear and nonlinear models National Instruments Corporation 2 3 Control Design User Manual Chapter 2 Constructing Dynamic System Models Control Design User Manual Time Variant versus Time Invariant Models Dynamic system models are either time variant or time invariant The parameters of a time variant model change with time For example you can use a time variant model to describe the mass of an automobile As fuel burns the mass of the vehicle changes with time Conversely the parameters of a time invariant model do not change with time For an example of a time invariant model consider a simple robot Generally the dynamic characteristics of robots do
211. s per hour the penalty on Ymax becomes active Because the penalty constant is significantly greater than the output error weighting the MPC algorithm prioritizes the output constraint above the output error Therefore the controller attempts to reduce the velocity of the car to a level above but close to 66 miles per hour Suppose instead that the output error weighting is 100 Because the output error weighting is significantly greater than the penalty constant the MPC algorithm prioritizes the output error above the plant output Therefore the controller attempts to increase the velocity of the car to a level closer to 70 miles per hour despite the active penalty on the plant output Note that the velocity that best balances the penalty and the output error might even be greater than the constrained maximum velocity of 71 miles per hour The barrier function method also balances constraints against each other Consider a situation where you specify a maximum constraint on both the plant output and the control action of a controller The penalty you specify for Ymax 1S relative to the penalty you specify for umar If you specify a larger penalty for Ymax than for Umax the MPC algorithm prioritizes the plant output constraint above the control action constraint Therefore in a situation where both penalties are active the MPC algorithm attempts to minimize the penalty on Ymax before minimizing the penalty on u If you also specify an output
212. sents a continuous system the value of Sampling Time is zero For discrete system models the value must be greater than zero State Names Array of strings The i element of the array defines the name of the i state of the model This property is available with state space models only You can use these data structures with every VI in the Control Design and Simulation Module that accepts a system model as an input 3 Note Delay information exists in the model properties and not in the mathematical model Any analysis such as time or frequency domain analysis you perform on the model does not account for delay present in the model If you want the analysis to account for delay present in the model you must incorporate the delay into the model itself Refer to Chapter 6 Working with Delay Information for more information about accounting for model delay You can use the Model Information VIs to get and set various properties of the model Refer to the LabVIEW Help available by selecting Help Search the LabVIEW Help for more information about using the Model Information VIs to view and change the properties of a system model National Instruments Corporation 2 19 Control Design User Manual Converting Models Model conversion involves changing the representation of dynamic system models For example you can convert a zero pole gain model to a state space model You also can convert a model between conti
213. shows the mathematical representation of transport input and output delay factors for a continuous system Liuli Us gt H s eSta gt LIV s L u t ta U s e S gt H s gt Ys Uls gt H s gt LIVt ta s esta L Laplace Transform Figure 6 1 Mathematical Representation of Transport Input and Output Delay for a Continuous System 6 4 ni com Chapter 6 Working with Delay Information To accommodate the delay factor you can convert e from exponential form to a rational polynomial function You can perform this conversion using the Pad approximation method Use the CD Convert Delay with Pade Approximation VI to calculate a Pad approximation This VI incorporates the delay information of the input model into the Converted Model output model The delay becomes a part of the output model and thus is not in the model properties In the case of SIMO MISO and MIMO system models the CD Convert Delay with Pade Approximation VI calculates the total delay in all the input output pairs before incorporating the delay into the model This conversion process has several benefits First connecting models that contain all rational polynomial functions is less complicated than connecting models that contain a mixture of exponential factors and rational polynomial functions Second when you incorporate the delay into the polynomial function the controller struct
214. sign State Space Synthesis directory for example VIs that demonstrate the concepts explained in this chapter Measuring and Adjusting Inputs and Outputs The estimator gain L considers all inputs u and outputs y which are known and measured Also some inputs and outputs might be unavailable You therefore can divide the system into adjustable inputs measured outputs unknown inputs and unmeasured outputs You base this division on diagonal matrices such as A and A Diagonal matrices incorporate the effect of known unknown measured and unmeasured inputs and outputs into the equation A diagonal element in these matrices equals unity for the known and measured inputs and outputs and zero for the unknown and unmeasured inputs and outputs or National Instruments Corporation 13 1 Control Design User Manual Chapter 13 Defining State Estimator Structures states The following equation describes how you incorporate the diagonal elements for the inputs and outputs in the controller model x Ax B u L y y y Cx D u In this equation B BA D DA and L LA These substitutions apply to both estimators and controllers Controllers have an additional substitution when inputs are not adjustable For a controller the controller gain K is given by K KA where A is a diagonal matrix with the same characteristics as A and A Therefore a diagonal element in A equals unity for the adjustable input and zero for
215. ss equipment the actuators and the sensors This transportation process can cause long delays in the output response of the system To fully represent this system a model must incorporate this delay If a model of this system does not incorporate delay you cannot predict how well a controller based on that model performs A system model can have the following three types of delay Input delay The time a past input takes to affect the current output e Output delay tThe time an output takes to respond to the current system input e Transport delay tThe time the dynamics of a system take to respond to a particular excitation The total delay of a system model is the sum of all delays between each input output pair The total delay includes all input output and transport delays in the system model Another type of delay residual delay results from certain operations Refer to the Residual Delay Information section of this chapter for more information about residual delay Constructing a model in the LabVIEW Control Design and Simulation Module sets delay information but does not make that information part of the mathematical model The Control Design and Simulation Module provides several VIs that you can use to transfer delay information from the model properties into the mathematical model After you incorporate delay into a mathematical model the model properties no longer contain delay information and the delay information app
216. sseeeseeaeeseeeasenseeaes 6 8 Manipulating Delay Information eee eee cecesececeeseeeeecaeeeseeseeeseeseeeaeeaesneeeneenaes 6 10 Accessing Total Delay Information eee eee eceeseeeeeeeceeeeseteeeeseseeeeeees 6 10 Distributing Delay Information eee eee cece eseeseeeseeaeeesecaeseeeeaeeneeeaee 6 12 Residual Delay Information 000 eee ceseeseeseeeeeeseeeeeeaeceeeeaeeaeeeaeseeeeeees 6 13 Chapter 7 Frequency Response Analysis Bode Brequency Anal ysis s c i c innere k ch ices r A E suveutis teste leets sees 7 1 Gain Marsin snas a Hee i cet eee 7 3 Phase Mardin anane Sucve AREA E ETE EE E A NAE 7 3 Nichols Frequency Analysis 0 0 0 cceceececseeseessceceeseceeceseceeeeseceseesecseesseeseeeaeeseseasenseeateaes 7 5 Nyquist Stability A mally S18 aea ianea ne e E E ses eebevth ius Melee beetevoxs 7 5 Obtaining Frequency Response Data eee eseeeeseessceseeseceseeseeeeeesecsseeseeeeesseneeaes 7 7 Chapter 8 Analyzing Dynamic Characteristics Determining Stability serao e EER E E RE A 8 1 Using the Root Locus Method sisisi iisiiessreisceireinii riire ioar iaki arei ie 8 2 National Instruments Corporation vij Control Design User Manual Contents Chapter 9 Analyzing State Space Characteristics Determining Stability erenn eare a aaa ra akei 9 2 Determining Controllability and Stabilizability sseseseesseesseeessesrestsrrsrsresrssrsresresrsees 9 2 Determining Observability and Detectability eee ceeeseeeeeeseceee
217. stant Pmax of 5 Table 18 2 shows how the penalty P increases as y approaches ymax Table 18 2 Increasing Penalty as a Function of Plant Output Value of y Value of P for Pmax 5 ys nae View 0 Ymax Y tol lt lt Ymax 0 lt P lt 5 The value of P increases quadratically between 0 and 5 National Instruments Corporation 18 9 Control Design User Manual Chapter 18 Creating and Implementing a Model Predictive Controller Table 18 2 Increasing Penalty as a Function of Plant Output Continued Value of y Value of P for Pmax 5 Y Ymax 5 Y gt Ymax P continues increasing quadratically Consider again the cruise control system Suppose the speed limit in an area is 70 miles per hour You therefore specify a maximum constraint of 71 miles per hour on the velocity of the car Also suppose you impose a penalty constant of five on this constraint The penalty specifies the priority the MPC algorithm places on keeping the velocity below 71 miles per hour If you specify a tolerance of five miles per hour on this constraint the tolerance range begins at 66 miles per hour The penalty on the maximum output constraint therefore becomes active when the velocity of the car reaches 66 miles per hour The penalty then increases from 0 to 5 over a tolerance range of five miles per hour If you reduce the tolerance to two miles per hour the penalty on the maximum output constraint become
218. state space models incorporating delay information means creating ng additional states Use the CD Convert Delay to Poles at Origin VI to incorporate delays into discrete models This VI incorporates the delay information of the input model into the Converted Model output model The delay becomes a part of the output model and thus is not in the model properties In the case of SIMO MISO and MIMO system models the CD Convert Delay to Poles at Origin VI totals the delay in all the input output pairs before incorporating the delay into the model Figure 6 4 shows how you can create a transfer function model define an input delay for the model properties and then incorporate that delay directly into the model ransfer Function Model In CD Convert Delay to Poles at Origin vi f zq Transfer Function Converted Model EA FY TEY Figure 6 4 Adding Delay Information to a Discrete Transfer Function Model National Instruments Corporation 6 7 Control Design User Manual Chapter 6 Working with Delay Information Figure 6 5 shows the resulting transfer function model The CD Convert Delay to Poles at Origin VI accounted for the input delay by increasing the number of poles at the origin in the model Accordingly the Transfer Function Converted Model has a larger order denominator than the Transfer Function Model In Delay not in Model a Figure 6 5 Additional Poles Accounting for the Inpu
219. state space form is observable 9 4 ni com Chapter 9 Analyzing State Space Characteristics Use the CD Grammians VI to calculate the controllability and observability Grammians of a state space model for a stable system Balancing Systems A system is balanced if the controllability and observability diagonal Grammians of that system are identical A balanced model simplifies the analysis and use of model order reduction Refer to Chapter 10 Model Order Reduction for more information about model order reduction In model order reduction balancing highlights the relative importance of the state to the input output performance of the system Balancing consists of finding a similarity transformation from the original model to generate a state space representation Use the CD Balance State Space Model Diagonal VI and the CD Balance State Space Model Grammians VI to balance a state space system If you use the CD Balance State Space Model Grammians VI the Balanced Model output of this VI has equal and diagonal controllability and observability Grammians To use this VI the system must be stable controllable and observable If you use the CD Balance State Space Model Diagonal VI the balanced state space model has an even eigenvalue spread for the state matrix A or the composite matrix which contains the natural composition of A B and C National Instruments Corporation 9 5 Control Design User Manual Model Orde
220. states This configuration is useful for analyzing and simulating the original and estimated states at the same time System Included with Noise Incorporates noise r into the system included configuration Standalone with Estimator Defines an estimator structure with the controller target This configuration is useful for performing offline simulations and analyses of the controller You can use offline simulations and analyses to test the controller with mismatched models and systems Mismatched models and systems have a calculated estimator and controller gain that applies to the mismatched model or to the model with uncertainties To select this configuration choose a standalone configuration and then wire an estimator with output L to the Estimator Gain L input of the CD State Space Controller VI Standalone without Estimator Bases the control action u on the actual states x instead of using an estimator to reconstruct the states This configuration is useful for analyzing a closed loop system To select this configuration choose a standalone configuration but do not wire anything to the Estimator Gain L input of the CD State Space Controller VI 14 2 ni com Chapter 14 Defining State Space Controller Structures B Note Both the system included and system included with noise configurations automatically include an estimator The following sections show the implementation of all four configurations for all three controller
221. sted in the Related Documentation section of this manual If you execute this example using an Initial State Estimate xhat 0 of 0 1 7 and an input of 0 this function returns the graphs shown in Figure 15 8 sat Actual state x t x2 3 2 5 aay a vu 2 E a oS 0 5 AEn 1 1 1 1 1 1 1 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 Simulation Time s xhatt t Estimated state xhat t xhat2 t Ba 3 a go F Tyla lt Hy j 1 j 1 i j j 1 j 1 1 1 00 0S LO LS 20 2 5 30 35 40 45 50 55 60 6 5 70 Simulation Time s Figure 15 8 Actual Model States vs Estimated Model States National Instruments Corporation 15 11 Control Design User Manual Chapter 15 Estimating Model States In Figure 15 8 notice the continuous observer starts estimating both model states correctly after about one second To confirm this fact you can look at the Error e t graph defined as x t xhat t for each model state Figure 15 9 shows the error graph of this example eltt Bas Error eft ea t AM Amplitude 1 1 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 Simulation Time s Figure 15 9 Estimation Error of a Continuous Observer Figure 15 9 confirms that the observation error for both states converges to zero after about one second This example uses the Runge Kutta 23 ODE solver with an initial time step of 0 01 seconds Refer to the LabVIEW Help for information about this and other ODE
222. stem outputs To calculate the control action based on the estimated states the estimator needs to approach the actual states faster than the controller Therefore you can calculate an estimator gain matrix such that A LC has eigenvalues at 5 5 which is farther to the left of the origin than the poles of the controller located at 1 1 The system included configuration takes both the estimator gain matrix L and the controller gain matrix K and uses them to synthesize a state compensator Figure 14 14 shows the implementation of a state compensator using the system included configuration Observer Gain Current Y Estimator Poles Ho ESN SEE EAS EIEEE CD Ackermann vi controller Poles A Controller Gain _v Figure 14 14 System Included State Compensator Control Design User Manual 14 22 ni com Chapter 14 Defining State Space Controller Structures The CD Initial Response VI uses 0 0 2 1 as the initial conditions As in the Example System Included State Estimator section of Chapter 13 Defining State Estimator Structures these initial conditions mean that the initial conditions of the actual states are 2 1 whereas the initial conditions of the estimated states are 0 0 Figure 14 15 shows the response of the system to those initial conditions State Trajectory Graph xiModel x2Model xiSystem x25ystem 3 i
223. straints With the dual optimization method you cannot specify this priority Similarly if you have two conflicting constraints the controller cannot prioritize one over the other If you want to prioritize the constraints and cost weightings for a controller use the barrier function method instead of the dual optimization method Refer to the Barrier Function Method section of this chapter for more information about the barrier function method Refer to the CDEx MPC with Dual Constraints VI located in the labview examples Control and Simulation Control Design MPC directory for an example of using the dual optimization method to set constraints for a controller Refer to the CDEx MPC Dual vs Barrier Constraints VI in this same directory for a comparison of the dual optimization and barrier function methods Refer to Nonlinear Programming as listed in the Related Documentation section of this manual for more information about the dual optimization method Barrier Function Method Use the Barrier instance of the CD Create MPC Controller VI to set constraints using the barrier function method You can specify these constraints in the MPC Constraints Barrier parameter of the CD Create MPC Controller VI Like the dual optimization method the barrier function method specifies initial and final minimum and maximum value constraints for the control action the rate of change in control action and the plant output However the barrier func
224. t 1 at4 to make the transfer function proper is a small number typically between 0 05 and 0 2 such that the pole has a negligible effect on the system dynamics Control Design User Manual 11 4 ni com Chapter 11 Designing Classical Controllers The Control Design and Simulation Module supports the PID controller in the following four forms PID Academic PID Parallel PID Parallel Discrete and PID Serial Table 11 1 shows the equations for each of these forms Table 11 1 PID Controller Forms in the Control Design and Simulation Module PID Controller Form Equation PID Academic U s K 1 A E s s Ts amp Tys 1 PID Parallel U s _ aa K Kys E s s aK s 1 PID aa 5 K T 2K z K T 2K T 4K z 2K apy E ES A E S Pe 2Tz z 1 PID Series ua a eli EE T s aT js 1 Each PID form produces the same result but incorporates information in a different manner For example you can adjust each term independently using the PID Parallel form The PID form you use depends on the design decisions you make such as how you need to manipulate the output of the controller Use the polymorphic VI selector of the CD Construct PID Model VI to implement a PID controller using one of these four PID forms Note Insome applications you specify the gain in the PID Academic transfer function in terms of a proportional band PB PB x 100 c A proportional band defined by the prev
225. t Delay The Transfer Function Converted Model expresses the additional poles at the origin with two additional zeros in the denominator Representing Delay Information Control Design User Manual To illustrate how the Control Design and Simulation Module represents delay in a system model consider the following MIMO transfer function equation where U is the input transfer function matrix and Y is the output transfer function matrix eae U 6 8 ni com Chapter 6 Working with Delay Information The following equations define this MIMO transfer function Y Ay Ay U Y The following equations define the transport delay matrix T4 the input delay vector I4 and the output delay vector O4 Refer to the Delay Information in Continuous System Models section of this chapter for the definition of the continuous delay factor e Sty Sty e _ e e T Ia 0 sti Stn es Sty e e To incorporate this delay information into H compute the product of the transfer function input and output matrices with their respective delay matrices or vectors H4 shown in the following equation represents H with delay information included Y H id U The following equations show the computation of these transfer functions to incorporate delay st st st st H e Hype H H ti 12 H 11 12 H T 11 12 _ je e sta slz H H st stn H e Hye 21 22 je e U e U sty U St Hs Ue Uy
226. t a dynamic system model 3 Note Refer to the labview examples Control and Simulation Control Design Model Construction directory for example VIs that demonstrate the concepts explained in this chapter National Instruments Corporation 2 1 Control Design User Manual Chapter 2 Constructing Dynamic System Models Constructing Accurate Models Control Design User Manual To create a model of a system think of the system as a black box that continuously accepts inputs and continuously generates outputs Figure 2 1 shows the basic black box model of a dynamic system Input gt H s gt Output Figure 2 1 Black Box Model of a Dynamic System You refer to this model as a black box model because you often do not know the relationship between the inputs and outputs of a dynamic system The model you create therefore has errors that you must account for when designing a controller An accurate model perfectly describes the dynamic system that it represents Real world dynamic systems however are subject to a variety of non deterministic fluctuating conditions and interacting components that prevent you from making a perfect model You must consider many external factors such as random interactions and parameter variations You also must consider internal interacting structures and their fundamental descriptions Because designing a perfectly accurate model is impossible you must design a contro
227. t of the Continuous Extended Kalman Filter function Defining the Continuous Plant Model To use the Continuous Extended Kalman Filter function first define the plant model whose states you want to estimate Use the SIM Continuous Nonlinear Plant Model template VI located in the labview templates Control and Simulation directory to define the plant model For instance consider a plant model of a vehicle moving with constant velocity and whose acceleration is slightly perturbed Also assume a radar measures the range r and the bearing angle 0 of the vehicle both corrupted by additive noise The following equations describe this plant model National Instruments Corporation 16 9 Control Design User Manual Chapter 16 Using Stochastic System Models where x and x are the x and y position in the Cartesian frame system x and x are the x and y velocities and y and y are the range r and bearing angle 0 respectively You define the system model by calculating the vector valued functions f x u t and h x u t for the continuous plant model where 0010 Mea 0 0 0 0l fx 0 0 00 lx 2 2 Xi X h x u t tan EB Xi On the block diagram of the SIM Continuous Nonlinear Plant Model template VI you can use either VIs and functions or text based scripts in the MathScript Node to define this model The following figure defines this continuous model using the SIM Continuous Nonlinear Plant Model template V
228. t time step u k The Discrete Observer function calculates u k at the current time step k and applies this control action at the current time step k Refer to Chapter 15 Estimating Model States for more information about observers Control Design User Manual 17 10 ni com Chapter 17 Deploying a Controller to a Real Time Target Example State Space Controller with Kalman Filter for Stochastic System Code The example in Figure 17 8 shows a block diagram that implements a state space controller that depends on estimated state information Because the controller must take noise into account this example uses a Kalman filter instead of a predictive or current observer Must be the same las the Stochastic i State Space Model crete CD State Feedback ded Filter Controller vi Figure 17 8 Implementing a Kalman Filter with Feedthrough on an RT Target The example in Figure 17 8 implements a Kalman filter with feedthrough that is when D 0 Because this example has feedthrough you cannot use the current state estimate x k k to calculate the control action at the current time step u k Instead you must use the predicted state estimate x k 1 k to calculate the control action at the next time step u k 1 The Discrete Kalman Filter function calculates u k 1 at the current time step k but applies this control action at the next time step k 1 Because this example has feedthrough you can i
229. tate compensator Controller Gain_ Figure 17 3 Implementing a State Compensator on an RT Target The example in Figure 17 3 uses the CD Construct State Space Model VI to construct a model of the system to be controlled The controller consists of the block diagram code inside the Timed Loop The control action is defined as u K xRef x where xRef is the reference state you specify x is the measured state information and K is the controller gain matrix This example assumes you can measure all state information If you cannot measure all state information you can use a predictive or current observer to estimate state information Refer to the Example State Space Controller with Predictive Observer Code and Example State Space Controller with Current Observer Code sections of this chapter for information on implementing predictive and current observers Control Design User Manual 17 6 ni com Chapter 17 Deploying a Controller to a Real Time Target Example SISO Zero Pole Gain Controller with Saturation Code Figure 17 4 shows a block diagram that implements a SISO zero pole gain controller and takes saturation into account Output Node a Discrete Zero Pole Gain Figure 17 4 Implementing a Discrete Zero Pole Gain Controller on an RT Target The example in Figure 17 4 defines a SISO controller model interactively Notice that the model equation appears on the Discrete Zero Pole Gain
230. tdeiescovessseaeoauasiecedieeaces seat EEE ENIE 14 3 System Included Configuration eee ee eseeeseeseeeseeseesseeseeeneees 14 4 System Included with Noise Configuration 0 0 0 0 cee eeeeeeeeereeee 14 5 Standalone with Estimator Configuration eee eeeeseeeeeeeeees 14 6 Standalone without Estimator Configuration eee 14 7 State Resilator sis acetates hii gis E Eaa Ee ite hah ERTER A E ES 14 8 System Included Configuration eee ee eee eseeeeeseeeseeeesseeseeeaeens 14 9 System Included Configuration with Noise eee eeeeeeseeeeeee 14 10 Standalone with Estimator Configuration eee eseeeeeeeeees 14 11 Standalone without Estimator Configuration eee 14 12 State Regulator with Integral Action eee eeeeseeseeeseceeeeeeeeeeaetseeeeees 14 13 System Included Configuration eee eee eseeeeeseeeseeseesseeseeeseees 14 14 System Included with Noise Configuration cece eeeeseeeeeeee 14 16 Standalone with Estimator Configuration eee eeeeeereeeeeees 14 17 Standalone without Estimator Configuration eee 14 19 Example System Configurations 2 0 0 0 cecceeesceescesecseesceeseceeeeseesseeseceseeaeensesaesneesseenaeeaes 14 20 Example System Included State Compensator eee eeeeeeeeeeeeeeeeeeees 14 22 Example System Included with Noise State Compensator eee 14 24 Example Standalone with Estimator State Compensator eee 14 25 Example Standalone without Estimator State Compensator eee 14 27 Chapter 15
231. te After 20 seconds the state estimator still cannot track the actual state Therefore you must study the system and model mismatch to determine the effect of the mismatch on the state estimation Control Design User Manual 13 14 ni com Defining State Space Controller Structures 3 State controllers use state information to calculate the control action To define the structure of a state controller you need a model of the system and a controller gain matrix K You can calculate K using the CD Pole Placement VI the CD Ackermann VI or the CD Linear Quadratic Regulator VI Refer to Chapter 12 Designing State Space Controllers for information about these VIs You use K to define the structure of a controller You can design a controller structure to take various factors such as input noise or input disturbances into consideration The following sections provide information about using the LabVIEW Control Design and Simulation Module to incorporate the gain matrix K into the control system The controllers in the following sections assume that all inputs are known and all outputs are measurable Refer to the Measuring and Adjusting Inputs and Outputs section of Chapter 13 Defining State Estimator Structures for information about measuring inputs and outputs Note Refer to the labview examples Control and Simulation Control Design State Space Synthesis directory for example VIs that demonstrate the concepts explained in
232. te space model can make the model order reduction process easier When you balance the state space model the Grammian matrices are diagonal and you avoid computing the eigenvalues Given a state space model complete the following steps to reduce the model order 1 Balance the state space model 2 Compute the Grammians 3 Remove stable states corresponding to small eigenvalues in proportion to the other eigenvalues of the Grammian matrix 4 Repeat steps 1 through 3 until the model is of the order you want Refer to the CDEx Model Reduction with Grammians VI located in the labview examples Control and Simulation Control Design Model Reduction directory for an example of this procedure Refer to the Analyzing Controllability and Observability Grammians section and the Balancing Systems section of Chapter 9 Analyzing State Space Characteristics for more information about computing controllability and observability Grammians and balancing a model Selecting and Removing an Input Output or State Manipulating the system representation involves ignoring certain inputs and outputs of a model such as those connected by a unit gain Ina state space model manipulating the system representation involves removing unwanted states from the description Use the CD Select IO from Model VI and the CD Remove IO from Model VI to reduce a model by directly removing inputs outputs or states Manipulating a model is useful for building
233. te uncorrelated samples of the Gaussian noise vectors w and v You must specify the mean vectors E w and Efv the auto covariance matrices Q Cov w w and R Cov v v and the cross variance matrix N Cov w v If you choose the External Noise instance of this function you must generate the samples of the noise vectors w and v and wire them to the Process noise w k input and the Measurement noise v k input of the Discrete Nonlinear Noisy Plant function respectively National Instruments Corporation 16 19 Control Design User Manual Chapter 16 Using Stochastic System Models Refer to the Constructing Noise Models section of this chapter for more information about constructing noise models in the Control Design and Simulation Module Implementing the Discrete Extended Kalman Filter Function After you define the plant model and add noise to the model you can use the Discrete Extended Kalman Filter function to estimate the states of the model The following figure illustrates the implementation of the Discrete Extended Kalman Filter function using the External Jacobian instance of the function The Discrete Extended Kalman Filter function takes measurements made on the plant that the Discrete Nonlinear Noisy Plant function represents Control amp Simulation Loop Discrete Nonlinear Noisy Plant T Simulation Time Waveform Simulation Time Waveform xhat O 1
234. tem that these equations describe g y ry y _ gt Controller gt System x Estimator National Instruments Corporation Figure 14 2 System Included with Noise State Compensator 14 5 Control Design User Manual Chapter 14 Defining State Space Controller Structures x r The states inputs and outputs of the state compensator are K and x u h respectively J Standalone with Estimator Configuration In the standalone with estimator configuration the system model detaches from the controller The system outputs y become inputs to the estimator Unlike the system included and system included with noise configurations the standalone with estimator configuration does not account for output error You must wire a value to the Estimator Gain L input of the CD State Space Controller VI to include the estimator in the standalone state compensator The following equations describe the standalone configuration A BK L C DK x BK LDK L K J 7 K ae K Or y C DK DK 0j y This configuration does not include the original system This configuration considers the system output y as another input to the estimator Figure 14 3 represents the dynamic system that these equations describe r u gt Q Controller Y gt x gt Estimator Figure 14 3 Standalone with Estimator State Compensator The
235. tem to locate poles and zeros of a system Using this information you then can design a controller to improve unwanted parts of the frequency response When applied to the system a sinusoidal input with unit amplitude zero phase and frequency produces the following sinusoidal output H iw Aloe A is the magnitude of the response as a function of and is the phase The magnitude and phase of the system output vary depending on the values of the system poles zeros and gain This chapter provides information about using the LabVIEW Control Design and Simulation Module to perform Bode frequency analysis Nichols frequency analysis and Nyquist stability analysis 3 Note Refer to the labview examples Control and Simulation Control Design Frequency Analysis directory for example VIs that demonstrate the concepts explained in this chapter Bode Frequency Analysis Use Bode plots of system frequency responses to assess the relative stability of a closed loop system given the frequency response of the open loop system By analyzing the frequency response you can determine what the open and closed loop frequency responses of a system imply about the system behavior Use the CD Bode VI to create a Bode plot 3 Note Use the CD Evaluate at Frequency VI to determine the frequency at specified values National Instruments Corporation 7 1 Control Design User Manual Chapter 7 Frequency Response Analysis Control Design User
236. the nonadjustable or system disturbances By default matrices A and A are identity matrices whose size equals the number of inputs A is an identity matrix whose size equals the number of outputs Adding a State Estimator to a General System Configuration Use the CD State Estimator VI to define an estimator structure This VI integrates L into a dynamic system so you can analyze and simulate the estimator performance ny Note To simplify the equations in the rest of this chapter assume that all inputs are known and all outputs are measurable This assumption means B B L L and D D Control Design User Manual Consider the following equations that represent a continuous state space system x Ax Bu y Cx Du r Assume that L is based on this system some estimator performance specifications and the output noise r covariance You then can calculate the estimated states x using the following equations for dynamic models x Ax Bu L y y y Cx Du 13 2 ni com Chapter 13 Defining State Estimator Structures The state space system and dynamic model equations share the same system matrices and input u The states x and x are different because the initial conditions of the system might differ from the model and because of the noise input r Without a noise input however the model states track the system states making the difference x x converge asymptotically to zero The following equation shows how
237. this chapter for more information about creating a discrete zero pole gain model SIMO MISO and MIMO Zero Pole Gain Models You create SIMO MISO and MIMO zero pole gain models the same way you create SIMO MISO and MIMO transfer function models Refer to the SIMO MISO and MIMO Transfer Function Models section of this chapter for information about creating these forms of system models Symbolic Zero Pole Gain Models You create symbolic zero pole gain models the same way you create symbolic transfer function models Refer to the Symbolic Transfer Function Models section of this chapter for information about creating a symbolic system model Constructing State Space Models Control Design User Manual Continuous state space models use first order differential equations to describe the system Discrete state space models use difference equations to describe the system You analyze state space models in the time domain 2 14 ni com Chapter 2 Constructing Dynamic System Models B Note State space models can be either deterministic or stochastic Deterministic models do not account for noise whereas stochastic models do This chapter provides information about deterministic state space models Refer to Chapter 16 Using Stochastic System Models for information about stochastic state space models The following equations define a continuous and a discrete state space model Continuous State Space Model x Ax Bu y Cx Du
238. this system is the total current i which is the sum of currents i and i gt R4 and R are resistors and L and L are inductors The following equations describe the individual currents for the circuit system in Figure 4 10 eee ae 0 lat t v Lyg Ri v The following equations give the resulting transfer functions for each circuit loop LCs _ 1 AS Tay oR H s a l In Figure 4 11 H s and H gt s represent the transfer functions defined in the previous equations and J s and J s are the respective outputs of these transfer functions V s is the transfer function of the voltage input v that both circuit loops share Vis gt Hi s m gt h s V s gt H s m gt h s Figure 4 11 Each Circuit Loop in the Circuit System National Instruments Corporation 4 9 Control Design User Manual Chapter 4 Connecting Models Figure 4 12 illustrates the relationship between the voltage input v and total current i by placing both models together in one larger system model When the two models are in parallel both models share the same input V s and provide a total output s as shown in Figure 4 12 Figure 4 12 Entire Circuit System as a Parallel Model The following equations describe the resulting transfer function as a second order system Ks s 1 s V s H s H s H s 5 H s Hy s Control Design User Ma
239. tial State x 0 input This function accepts changes to the stochastic model and the noise model as long as the dimensions of the A B C D G H Q R and N matrices remain the same Because of this functionality you can use the Discrete Stochastic State Space function to simulate the behavior of linear time variant LTV models Refer to the LabVIEW Help for more information about these functions Using Kalman Filters to Estimate Model States In the real world controllers typically receive measurements that are corrupted by noise Also you typically do not or cannot measure all state values If you want to calculate state values the only information you have is these noisy measurements and the known inputs In this situation you can use a Kalman filter to estimate the state values given noisy sensor measurements Use the Discrete Kalman Filter function to implement a Kalman filter for a discrete stochastic state space model This function calculates the filtered state estimate using only known inputs and noisy measurements of the plant The Discrete Kalman Filter function returns the filtered state estimate which is defined as x k k This notation translates as the estimated state vector at time k given all measurements up to and including k Calculating the filtered state estimate involves applying a gain matrix M k to the difference between the measured output and the estimated output The Discrete Kalman Filter function c
240. tion method also associates a penalty and a tolerance with each of these constraints The penalty on a constraint specifies how much the MPC algorithm attempts to avoid reaching the constrained value The tolerance specifies the distance from the constrained value at which the 18 8 ni com Chapter 18 Creating and Implementing a Model Predictive Controller penalty becomes active By specifying penalties on constraints you can prioritize the constraints and cost weightings of a controller Relationship Between Penalty Tolerance and Parameter Values If the distance between a parameter value z and its constrained value z is greater than or equal to the tolerance fol the penalty P is 0 The penalty becomes active when z reaches Zr tol i if Zj is a maximum constraint or z tol if zj is a minimum constraint The penalty then increases quadratically as z approaches z When z equals z that is when the parameter value reaches the constrained value P equals the specified penalty constant pj If z exceeds the constrained value the penalty continues to increase quadratically Figure 18 3 illustrates this behavior for a maximum constraint x oO E A Pmax gt a D A lt H 0 Zmax tOlmax Zmax Parameter Value z Figure 18 3 Penalty Profile for Parameter z with Maximum Constraint Zmax For example consider a plant output y with a maximum constraint y tolerance y and a penalty con
241. tion to the input delays before transferring delay information to the output delays 3 Note Some Control Design VIs internally distribute the delay to preserve as much delay information as possible in the resulting model Refer to the LabVIEW Help to determine which VIs manipulate the transport delay matrix to preserve delay information Control Design User Manual For example consider the system model described in the Accessing Total Delay Information section of this chapter If you apply the CD Distribute Delay VI to this system model you get the following equation loo faal aaka Because 4 is the common factor among the transport delay matrix the CD Distribute Delay VI transferred a delay of 4 to the input delays Figure 6 7 shows the output of the CD Distribute Delay VI Input Delays i JO 44 00 1400 f Transport Delays Output Delays ca LA Jo 0 00 0 00 0 10 00 Jo foo foo 0 00 Figure 6 7 Resulting Delay Distribution The input and output delay vectors are now 4 4 and ol respectively 0 6 12 ni com Chapter 6 Working with Delay Information Figure 6 8 shows how you implement this example using the Control Design and Simulation Module Transfer Function Model In Output Delays a0 IGE CD Distribute Delay vi Output Delays fees Yo ransport Delays Figure 6 8 Totaling and Distributing the Delay Information in a Model Residual Delay Information Resid
242. torials application notes instrument drivers and so on Registered users also receive access to the NI Discussion Forums at ni com forums NI Applications Engineers make sure every question submitted online receives an answer Standard Service Program Membership this program entitles members to direct access to NI Applications Engineers via phone and email for one to one technical support as well as exclusive access to on demand training modules via the Services Resource Center NI offers complementary membership for a full year after purchase after which you may renew to continue your benefits For information about other technical support options in your area visit ni com services or contact your local office at ni com contact Training and Certification Visit ni com training for self paced training eLearning virtual classrooms interactive CDs and Certification program information You also can register for instructor led hands on courses at locations around the world System Integration If you have time constraints limited in house technical resources or other project challenges National Instruments Alliance Partner members can help To learn more call your local NI office or visit ni com alliance A 1 Control Design User Manual Appendix A Technical Support and Professional Services If you searched ni com and could not find the answers you need contact your local office or NI corporate headquarters Phone
243. tputs text boxes in the Model Dimensions section This section is dimmed if you configure a SISO model because SISO models have only one input and one output National Instruments Corporation 17 3 Control Design User Manual Chapter 17 Deploying a Controller to a Real Time Target 5 Enter numerator and denominator coefficients in the Numerator and Denominator text boxes Notice the Preview window updates to display the model equation For MIMO models use the Input Output Model control to select different input output pairs You can enter unique Numerator and Denominator coefficients for each input output pair 6 Click the OK button to save the model definition and return to the block diagram If you defined a SISO model the function icon updates to show the model equation You also can resize the function icon Defining a Controller Model Programmatically Launch the Discrete Transfer Function Configuration dialog box select Transfer Function from the Parameters listbox and select Terminal from the Parameter source pull down menu After you click the OK button the Transfer Function input appears on the function icon You then can use the CD Construct Transfer Function VI or a block diagram constant to define a transfer function model Wire this model definition to the Transfer Function input of the Discrete Transfer Function function Writing Controller Code The examples in this section use a Timed Loop to implement the feedb
244. tseseeeeseesees 9 3 Analyzing Controllability and Observability Grammians cccececeeseseeeseeseeees 9 4 Balancing Systems niasin naii a E E A E a a 9 5 Chapter 10 Model Order Reduction Obtaining the Minimal Realization of Models ssssessssseessseseseseersreerssrsresresesreseseeseeee 10 1 Reducing the Order of Models 00 0 ec imee ai a EE AE 10 2 Selecting and Removing an Input Output or State oo cece ceseeseeeeeeeeeeeaeees 10 3 Chapter 11 Designing Classical Controllers Root Locus Design Technique ccesccessesseeeececsneeesseceaeceaeceneceaeesaeesaeeeeessaeenaeeesaes 11 1 Proportional Integral Derivative Controller Architecture cee eeeeseeeeeseeeeeeeeees 11 4 Designing PID Controllers Analytically 00 0 ceesceeseesseeeceeeeseeeeeseceeseeetseeeaeesees 11 6 Chapter 12 Designing State Space Controllers Calculating Estimator and Controller Gain Matrices 0 ee eeceeeeeeseceseeeeeeseeeeseeeaeees 12 1 Pole Placement Technique iis ccsjsberasstessesesstedadeesastvnds dessins Mavs avid weaaeseteevens 12 2 Linear Quadratic Regulator Technique seceeeeseeeeseceseeeseeeeeeeneeceeeeeseeeease 12 4 Kalman Gain serisini adverse E EE E E A A E ats 12 5 Continuous Models ren e ire eee eirese eee E E AAS pEi Tase EEEE EREHE 12 6 Discrete Models an E EA EE ARRS 12 6 Updated State Estimate sesseseeeeoeeesreseseereserrereeserresesseee 12 6 Predicted State Estimate ces cesceesceceseeeseeeeeeee
245. tural frequency and norm You can use the LabVIEW Control Design and Simulation Module to analyze a system in terms of these characteristics This chapter provides information about using the Control Design and Simulation Module to analyze the stability of a dynamic system This chapter also describes how to use the root locus method to analyze the stability of a system 3 Note Refer to the labview examples Control and Simulation Control Design Dynamic Characteristic Analysis directory for example VIs that demonstrate the concepts explained in this chapter Determining Stability The stability of a system depends on the locations of the poles and zeros within the system To design an effective controller you must take these locations into account A continuous system is stable if all poles are on the left half of the complex plane A discrete system is stable if all poles are within a unit circle centered at the origin of the complex plane Additionally both types of systems are stable if they do not contain any poles A continuous system is unstable if it contains at least one pole in the right half of the complex plane A discrete system is unstable if at least one pole is outside of the unit circle in the complex plane Additionally both types of systems are unstable if they contain more than one pole at the origin In terms of the dynamic response associated with the poles and zeros of a system a pole is stable if the respons
246. u Y x y System Included with Noise Standalone A x A J The following sections discuss each of these configuration types in detail System Included Configuration You can use the system included configuration to analyze and simulate the estimated states and the original states at the same time For example the following equation defines the output estimator error in a system included configuration Control Design User Manual y y C x x ni com Chapter 13 Defining State Estimator Structures By substituting the output estimator error in the general system configuration and removing the sensor noise r you obtain the following equations that describe the system included configuration Aare ara F f de Ee Figure 13 1 represents the dynamic system that these equations describe u System gt y L Estimator y x gt Figure 13 1 System Included State Estimator The states inputs and outputs of the estimator are al u and P 3 respectively x J System Included with Noise Configuration The system included with noise configuration incorporates noise r into the system included configuration The following equation defines the output estimator error y y C x x r National Instruments Corporation 13 5 Control Design User Manual Chapter 13 Defining State Estimator Structures By substituting the output esti
247. u are working based on measurements of the outputs and known states Similar to classical control design the process of designing a controller begins with one or more control objectives Typical objectives include minimizing a cost function and placing the poles and zeros of a system in specific locations You use this process to achieve a specific dynamic response You then select the architecture of the controller such as whether the feedback is based only on outputs or on all the states of the system With this information you can synthesize a controller by selecting an appropriate set of parameters to satisfy the stated objectives This chapter provides information about using the LabVIEW Control Design and Simulation Module to determine estimator and controller gain matrix values This chapter also describes the difference between measured outputs known inputs and adjustable inputs ay Note Refer to the labview examples Control and Simulation Control Design State Space Synthesis directory for example VIs that demonstrate the concepts explained in this chapter Calculating Estimator and Controller Gain Matrices Before you can implement an estimator or a controller you need to calculate their respective gain matrices These gain matrices define the structure of the estimator or the controller The Control Design VIs help you calculate the gain matrix for an estimator or controller National Instruments Corporation 12 1 Cont
248. u have two models in a closed loop configuration the first model is always in the open loop path and the second model is always in the feedback path You have the option to define feedback connections output connections both types of connections or no types of connections Within the CD Feedback VI Feedback Connections defines the connection between the outputs of Model 2 and the inputs of Model 1 Output Connections defines the connection between the outputs of Model 1 and the inputs of Model 2 By default the CD Feedback VI connects the models with negative feedback The resulting model differs depending on the number of connections you define The following sections provide information about the configuration of the models when you define or do not define connections Control Design User Manual 4 14 ni com Chapter 4 Connecting Models Feedback and Output Connections Undefined If you do not define Feedback Connections or Output Connections the CD Feedback VI tries to connect all the outputs of Model 1 to the corresponding inputs of Model 2 The CD Feedback VI also tries to connect all the outputs of Model 2 to the corresponding inputs of Model 1 The Feedback Sign input determines if these outputs are fed back negatively or positively By default the CD Feedback VI connects the models with negative feedback The resulting model shown in Figure 4 17 contains new reference inputs ro and r for each feedback connection io
249. ual delay information is transport delay information that remains when the CD Distribute Delay VI cannot distribute all of the transport delay to the inputs or outputs This situation most often occurs in SIMO MISO and MIMO system models because each input output pair can have different delay information For example consider a system model with the following delay information National Instruments Corporation 6 13 Control Design User Manual Chapter 6 Working with Delay Information Control Design User Manual The CD Distribute Delay VI first distributes the delay in the transport delay matrix to the input delay vector by subtracting the minimum value from each column in the transport delay matrix In this case the minimum value in both columns is 3 This VI then distributes the delay to the output delay vector by subtracting the minimum value from each row in the resulting transport delay matrix In this case only the second row has a minimum value other than 0 lo ol l3 3 3 3 5 3lfo J2ol ol 2 olfo 4 4llol li allo lo olli 3 5llol Jo2Ilol lo2llo Because the CD Distribute Delay VI cannot fully distribute all the delays the transport delay matrix contains the residual delay information 6 14 ni com Frequency Response Analysis The frequency response of a dynamic system is the output of a system given unit amplitude zero phase sinusoidal inputs at varying frequencies You can use the frequency response of a sys
250. uations to calculate Ackermann s formula defined by the following equation K lo 0 1 s AB a e A Combine the controller gain matrix K with the CD State Space Controller VI to define a controller structure for the system Refer to Chapter 14 Defining State Space Controller Structures for more information about defining a controller structure If you use the pole placement technique to calculate the estimator gain matrix L combine L with the CD State National Instruments Corporation 12 3 Control Design User Manual Chapter 12 Designing State Space Controllers Estimator VI to define an estimator structure for the system Refer to Chapter 13 Defining State Estimator Structures for more information about defining an estimator structure Linear Quadratic Regulator Technique Control Design User Manual The linear quadratic regulator LQR technique calculates the controller gain matrix K that minimizes a quadratic cost function Unlike the pole placement technique you cannot use the LQR technique to calculate a estimator gain matrix L The design process for LQR requires specifying matrices Q and R which specify weights on the states and inputs respectively You also can specify a matrix N that penalizes the cross product between the inputs and states Typically the selection of these gain matrices is an iterative process Use the CD Linear Quadratic Regulator VI to apply the LQR technique to a model with any number
251. ul Figure 6 3 shows the effects of polynomial orders on the accuracy of a Pad approximation of H s Pe seesidecdtosttcatectacdt RENEE TENE a ee eE Figure 6 3 Effect of Polynomial Orders for a Pad Approximation Control Design User Manual 6 6 ni com Chapter 6 Working with Delay Information Delay Information in Discrete System Models Mathematically incorporating delay into a discrete system model involves evaluating that model at n units in the past ng equals the delay divided by the sampling time T of the system For example consider the discrete SISO system model y k The equation y kT ngT provides the output of y k at nq units in the past where k represents the current sample Removing the sampling time T from this equation provides the simplified equation y k ng This simplified equation produces the same result as y kT n T This equation shows the delay factor z for a discrete system model where z represents time in the discrete domain You use z to evaluate y k at ng samples in the past The following equation shows this process which also is known as applying the shift operator y k ny y k z In transfer function models and zero pole gain models incorporating delay information means adding poles at the origin By applying z to a transfer function or zero pole gain model you increase the order of the denominator polynomial by adding ng poles at the origin In
252. ure analysis operations and synthesis operations account for the delay 3 Note The CD Convert Delay with Pade Approximation VI converts a state space model to a transfer function model before incorporating the delay information This VI then converts the resulting model back to a state space model As a result the final states of the model might not directly correspond to the original states Refer to Chapter 3 Converting Models for more information about converting between model forms For example consider a continuous SISO system with an input delay of 25 seconds The delay factor in this system is e gt so the following equation represents the system National Instruments Corporation 6 5 Control Design User Manual Chapter 6 Working with Delay Information Figure 6 2 shows the step response of this system Figure 6 2 Step Response with a 25 Second Delay You can see that incorporating e s into the input of H s delays the step response of H s by 25 seconds Refer to the Analyzing a Step Response section of Chapter 5 Time Response Analysis for information about a step response You can use the Polynomial Order input of the CD Convert Delay with Pade Approximation VI to affect the accuracy of the approximation A larger Polynomial Order means a more accurate approximation but results in a higher order system model A large Polynomial Order can have the unintended side effect of making a model too complex to be usef
253. vi DELH Sensor Measurement vi gt Discrete Transfer Function 0 d is e ao i LA Hel 5 2 q F Method TF Y Zero Order Hold_ Sea EEE i top E A Figure 17 2 Implementing a Discrete Transfer Function Controller on an RT Target AA Note In Figure 17 2 and throughout the following sections the Sensor Measurement subVI represents block diagram code that acquires a measurement from a hardware sensor The Controller Output subVI represents block diagram code that sends the controller output to the actuator When you click the Run button in this example LabVIEW downloads the VI to the RT target and executes the following steps 1 Acquires a Sensor Measurement from a hardware sensor that measures the plant output 2 Subtracts the Sensor Measurement from a Reference Input you define 3 Applies the result of step 2 to the controller the Discrete Transfer Function function defines This example uses the CD Construct Lead Lag Controller VI to define the controller model programmatically The Discrete Transfer Function function returns the Controller Output 4 Sends the Controller Output to the hardware actuator Steps 1 through 4 repeat until you stop the VI National Instruments Corporation 17 5 Control Design User Manual Chapter 17 Deploying a Controller to a Real Time Target Example State Compensator Code Figure 17 3 shows a block diagram that implements a s
254. w sensitive the controller is to the system model mismatches You perform these tests before deploying the controller to a real time RT target Using a design method called robust control design you can create model based controllers that take into account possible modeling errors Refer to Essentials of Robust Control as listed in the Related Documentation section of this manual for information about robust control design Example Standalone without Estimator State Compensator This state compensator uses the standalone without estimator configuration which indicates that you do not need a state estimator because the states are directly available for control The following equations describe the compensator model x A BK x BKr y Cx 3 Note The direct transmission matrix D is not part of this expression because D is null in this example The poles or the eigenvalues of A BK of the closed loop system are in the left side of the complex plane If you set the output noise r to zero the controller gain matrix K immediately drives the states to zero Figure 14 20 shows how you use the CD Ackermann VI to calculate the controller gain matrix K which you then use to study the performance of the state compensator National Instruments Corporation 14 27 Control Design User Manual Chapter 14 Defining State Space Controller Structures Standalone Y CD Initial Response vi e Dornen o Contr
255. y 5 Cx 5 Du 5 In these equations the current observer applies the observer gain L to the difference between the measured output y k and the estimated output y k You can use the CD Ackermann VI or the CD Pole Placement VI to calculate Lo After estimating x 5 5 the Discrete Observer function uses u 5 to estimate the model states for the next time step x k 1 k or x 6 5 The following equation shows this estimation x 6 5 Ax 5 5 Bu 5 At the next time step k 6 the state estimate x 6 5 becomes x k k 1 The Discrete Observer function corrects x 6 5 to become x 6 6 The Discrete Observer function then uses x 6 6 information to estimate x 7 6 National Instruments Corporation 15 7 Control Design User Manual Chapter 15 Estimating Model States Figure 15 5 shows a block diagram that implements a current observer for this model While Loop Discrete State Space State x k DB fritial State Current ato ft stimate xhat O 1 f Estimate xhat k k De Poles coe Observer Gain Current Y Figure 15 5 Implementing a Current Observer for the State Space Model Control Design User Manual 15 8 ni com Chapter 15 Estimating Model States Figure 15 6 shows the error graph of a current observer for the same model described in the Predictive Observer section of this chapter Error ek 3 z a 1 Time s Figure 15 6 Estimation Error of
Download Pdf Manuals
Related Search
Related Contents
StarTech.com 30m Multimode 50/125 Duplex Fiber Patch Cable LC - LC 4 - pdf.lowes.com Valueline VLCB62700B20 firewire cable Neu in TOPIX:8 Samsung 40" UHD 4K Smart TV JU7002 sērija 7 Lietotāja rokasgrāmata DR 500 active series User´s Guide LP®650 - InFocus Class 100Q - Dittrich Nähmaschinen Copyright © All rights reserved.
Failed to retrieve file