0 evaluări0% au considerat acest document util (0 voturi)
47 vizualizări7 pagini
A linear Digital Model of a continuous-time system can be extracted into MATLAB. The Conversion to a discrete-time system is done with Zero-Order Hold blocks. These blocks act as both D / a (sample-and-hold) and a / D devices. The extraction of a model makes use of In and Out Connection blocks and dlinmod.
A linear Digital Model of a continuous-time system can be extracted into MATLAB. The Conversion to a discrete-time system is done with Zero-Order Hold blocks. These blocks act as both D / a (sample-and-hold) and a / D devices. The extraction of a model makes use of In and Out Connection blocks and dlinmod.
A linear Digital Model of a continuous-time system can be extracted into MATLAB. The Conversion to a discrete-time system is done with Zero-Order Hold blocks. These blocks act as both D / a (sample-and-hold) and a / D devices. The extraction of a model makes use of In and Out Connection blocks and dlinmod.
A linear digital model of this continuous-time system (in state space or transfer function form) can be extracted from a Simulink model into MATLAB. Conversion to a discrete-time (digital) system is done with Zero-Order Hold blocks on both the inputs and outputs of the system, which act as both D/A (sample-and-hold) and A/D devices. The extraction of a model makes use of In and Out Connection blocks and the MATLAB function dlinmod. We will start with the model which we just build. You can download a complete version here. We will first group all of the system components (except for the Step and Scope which aren't really part of the system) into a Subsystem block. Drag the mouse from one corner of your model window to the other to highlight all of the components. If possible, avoid highlighting the Step and Scope blocks, but if you do, hold the shift key and single click on either of the Step and Scope blocks to un-highlight them. Your model window should appear as shown below.
Select Create Subsystem on the Edit menu (or hit Ctrl-G). This will group all of the selected blocks into a single block. Your window should appear as shown below.
2
Change the label of the Subsystem block to "Continuous Plant". If you like, you can resize this block so the words "In1" and "Out1" inside of it don't overlap. To resize a block, highlight it by single clicking it and drag the corners to the desired size. Replace the Step Block and Scope Block with Zero Order Hold blocks (from the Discrete block library). One Zero Order Hold block is used to convert a discrete-time signal to a stepwise- constant continuous signal. The other Zero Order Hold block is used to take discrete samples of the output from the plant. Edit the Zero Order Hold blocks and set the Sample Time fields to 0.001 (this is fast compared to the desired step response in the MATLAB tutorial.) Connect an In Connection Block to the input of the first Zero Order Hold block, and an Out Connection Block to the output of the second Zero Order Hold block. (these blocks can be found in the Connections block library). This defines the input and output of the system for the extraction process. Drag each block in your model so that they are arranged in a line.
3
Save your file as "motorpos.mdl" (select Save As from the File menu). MATLAB will extract the linear model from the saved model file, not from the open model window. At the MATLAB prompt, enter the following commands: [A,B,C,D]=dlinmod('motorposmodel',.001) [num,den]=ss2tf(A,B,C,D) The extra parameter in dlinmod provides the sample time for the discrete conversion. You should see the following output, providing discrete time models of the system both in state-space and transfer function form. A =
1.0000 -1.9425 0.9425 0 As noticed in above results, both numerator and denominator of the discrete transfer function have one extra root at z = 0. These cancel each other, and the discrete-time transfer function to the motor position output from the voltage input is:
To verify the model extraction, we will generate an open-loop step response of the extracted transfer function in MATLAB. Enter the following commands in MATLAB.
4
[x1] = dstep(num,den,201); t=0:0.001:0.2; stairs(t,x1) You should see the following plot which is equivalent to the Scope's output.
Implementing Digital Control In the motor speed control digital example a digital controller was designed with the following transfer function.
Bring up the model window containing the digital system which was just extracted into MATLAB. (You can download our version here) Delete the "In" and "Out" blocks.
5
We will first feed back the plant output. Insert a Sum block and assign "+-" to it's inputs. Tap a line of the output line of the output Zero Order Hold line and draw it to the negative input of the Sum block.
The output of the Sum block will provide the error signal. We will feed this into the digital controller. Insert a Discrete Transfer Function Block (from the Discrete block library) after the summer and connect them with a line. Edit this block and change the Numerator field to "450*conv([1 -.85],[1 -.85])", the Denominator field to "conv([1 .98],[1 -.7])", and the Sample Time to ".001". Label this block "Controller" and resize it to view the entire contents.
6
Finally, we will apply a step input and view the output on a scope. Attach a Step block to the free input of the feedback Sum block and attach a Scope block to the plant output. Double-click the Step block and set the Step Time to "0".
You can download our version of the closed-loop system here. Closed-loop response To simulate this system, first, an appropriate simulation time must be set. Select Parameters from the Simulation menu and enter "0.05" in the Stop Time field. The design requirements included a settling time of less than 0.04 sec, so we simulate for 0.05 sec to view the output. The physical parameters must now be set. Run the following commands at the MATLAB prompt:
Run the simulation (Ctrl-t or Start on the Simulation menu). When the simulation is finished, double- click on the scope and hit its autoscale button. You should see the following output.