Student of group 214-19 Olimov Jaloliddin Working with sum product and gain blocks in simulnik package. Independent work I



Yüklə 304,26 Kb.
səhifə1/2
tarix15.04.2023
ölçüsü304,26 Kb.
#98511
  1   2
comp1independent work


Student of group 214-19
Olimov Jaloliddin
Working with sum product and gain blocks in simulnik package.
Independent work I
The Sum block performs addition or subtraction on its inputs. The Add, Subtract, Sum of Elements, and Sum blocks are identical blocks. This block can add or subtract scalar, vector, or matrix inputs. It can also collapse the elements of a signal and perform a summation.
You specify the operations of the block with the List of signs parameter with plus (+), minus (-), and spacer (|).

  • The number of + and - characters equals the number of inputs. For example, +-+ requires three inputs. The block subtracts the second (middle) input from the first (top) input, and then adds the third (bottom) input.

  • A spacer character creates extra space between ports on the block icon.

  • If performing only addition, you can use a numerical value equal to the number of inputs.

  • If only there is only one input port, a single + or - adds or subtracts the elements over all dimensions or in the specified dimension.

The Sum block first converts the input data type to its accumulator data type, then performs the specified operations. The block converts the result to its output data type using the specified rounding and overflow modes.
Calculation of Block Output
Output calculation for the Sum block depends on the number of block inputs and the sign of input ports:


The Sum block is an implementation of the Add block which is described in Subsection 8.1.2, Chapter 8. This block performs addition or subtraction on its inputs. This block can add or subtract scalar, vector, or matrix inputs. From the parameters dialog box we can choose the icon shape of the block, rectangular or round. We specify the operations of the block with the List of Signs parameter. Plus (+), minus (-), and spacer () characters indicate the operations to be performed on the inputs. If there are two or more inputs, then the number of characters must equal the number of inputs. For example, "+ - +" requires three inputs and configures the block to subtract the second (middle) input from the first (top) input, and then add the third (bottom) input.

The Gain block multiplies the input by a constant value (gain). The input and the gain can each be a scalar, vector, or matrix. We specify the value of the gain in the Gain parameter. The Multiplication parameter lets us specify element-wise or matrix multiplication. For matrix multiplication, this parameter also lets us indicate the order of the multiplicands.
Example 2.10




The model shown in Figure 2.20 performs the matrix multiplication A B where A = [1 _1 2]' and B = [2 3 4].

We double-click on the Constant block and we enter[1 -1 2]' The apostrophe is required to indicate that this is a column vector. Next, we double click on the Gain block, we enter the row vector [2 3 4] , and for Multiplication we choose Matrix (u*K). Initially, the Display block may show just one value with two small black triangles. This tells us that we must resize the Display block in both directions to see all the elements of the resultant 3 3 matrix.
Mathematically, this loop implies that the output of the Sum block is an
algebraic state z constrained to equal the first input u minus z (i.e. z = u – z).
The solution of this simple loop is z = u/2, but most algebraic loops cannot be
solved by inspection.

Subsystem For conditionally executed subsystems: one for the enable


port if present, and one for the trigger port, if present.
Switch One: to detect when the switch condition occurs.
It is easy to create vector algebraic loops with multiple algebraic state variables
z1, z2, etc., as shown in this model.
The Algebraic Constraint block is a convenient way to model algebraic
equations and specify initial guesses. The Algebraic Constraint block
constrains its input signal F(z) to zero and outputs an algebraic state z. This
block outputs the value necessary to produce a zero at the input. The output
must affect the input through some feedback path. You can provide an initial
guess of the algebraic state value in the block’s dialog box to improve algebraic
loop solver efficiency.
A scalar algebraic loop represents a scalar algebraic equation or constraint of
the form F(z) = 0, where z is the output of one of the blocks in the loop and the
function F consists of the feedback path through the other blocks in the loop to
the input of the block. In the simple one-block example shown on the previous
page, F(z) = z – (u – z). In the vector loop example shown above, the equations
are
z2 + z1 – 1 = 0
z2 – z1 – 1 = 0
Algebraic loops arise when a model includes an algebraic constraint F(z) = 0.
This constraint might arise as a consequence of the physical interconnectivity
of the system you are modeling, or it might arise because you are specifically
trying to model a differential/algebraic system (DAE).
When a model contains an algebraic loop, Simulink calls a loop solving routine
at each time step. The loop solver performs iterations to determine the solution
to the problem (if it can). As a result, models with algebraic loops run slower
than models without them.
To solve F(z) = 0, the Simulink loop solver uses Newton's method with weak
line search and rank-one updates to a Jacobian matrix of partial derivatives.
Although the method is robust, it is possible to create loops for which the loop
solver will not converge without a good initial guess for the algebraic states z.
You can specify an initial guess for a line in an algebraic loop by placing an IC
block (which is normally used to specify an initial condition for a signal) on that
line. As shown above, another way to specify an initial guess for a line in an
algebraic loop is to use an Algebraic Constraint block.
Whenever possible, use an IC block or an Algebraic Constraint block to specify

In this case, the input at the u2 port of the adder subsystem is equal to the
subsystem’s output at the current time step for every time step. The
mathematical representation of this system
z = z + 1
reveals that it has no mathematically valid solution.
Highlighting Algebraic Loops
You can cause Simulink to highlight algebraic loops when you update,
simulate, or debug a model. Use the ashow command to highlight algebraic
loops when debugging a model.
To cause Simulink to highlight algebraic loops that it detects when updating or
simulating a model, set the Algebraic loop diagnostic on the Diagnostics
pane of the Configuration Parameters dialog box to Error (see “The
Configuration Parameters Dialog Box” on page 10-30 for more information).
This causes Simulink to display an error dialog (the Diagnostics Viewer) and
recolor portions of the diagram that represent the algebraic loops that it
detects. Simulink uses red to color the blocks and lines that constitute the
loops. Closing the error dialog restores the diagram to its original colors.
For example, the following figure shows the block diagram of the hydcyl demo
model in its original colors.

The following figure shows the diagram after updating when the Algebraic
loop diagnostic is set to Error.

In this example, Simulink has colored the algebraic loop red, making it stand


out from the rest of the diagram.
Eliminating Algebraic Loops
Simulink can eliminate some algebraic loops that include any of following types
of blocks:
• Atomic Subsystem
• Enabled Subsystem
• Model
To enable automatic algebraic loop elimination for a loop involving a particular
instance of an Atomic Subsystem or Enabled Subsystem block, select the
Minimize algebraic loop occurrences parameter on the block’s parameters
dialog box. To enable algebraic loop elimination for a loop involving a Model
block, check the Minimize algebraic loop occurrences parameter on the
Model Referencing configuration parameters dialog (see “Model Referencing
Pane” on page 10-67) of the model referenced by the Model block. If a loop
includes more than one instance of these blocks, you should enable algebraic
loop elimination for all of them, including nested blocks.
The Simulink Minimize algebraic loop solver diagnostic allows you to specify
the action Simulink should take, for example, display a warning message, if it
is unable to eliminate an algebraic loop involving a block for which algebraic
loop elimination is enabled. See “The Diagnostics Pane” on page 10-48 for more
information.
Algebraic loop minimization is off by default because it is incompatible with
conditional input branch optimization in Simulink (see “The Optimization
Pane” on page 10-43) and with single output/update function optimization in
Real-Time Workshop®. If you need these optimizations for an atomic or
enabled subsystem or referenced model involved in an algebraic loop, you must
eliminate the algebraic loop yourself.
As an example of the ability of Simulink to eliminate algebraic loops, consider
the following model.

The Product block detected a singular matrix


while inverting one of its inputs in matrix multiplication mode.
A branch line is a line that starts from an existing line and carries its signal to
the input port of a block. Both the existing line and the branch line carry the
same signal. Using branch lines enables you to cause one signal to be carried
to more than one block.

In this example, the output of the Product block goes to both the Scope block
and the To Workspace block.

To add a branch line, follow these steps:


1 Position the pointer on the line where you want the branch line to start.
2 While holding down the Ctrl key, press and hold down the left mouse button.
3 Drag the pointer to the input port of the target block, then release the mouse
button and the Ctrl key.
You can also use the right mouse button instead of holding down the left mouse
button and the Ctrl key.
Drawing a Line Segment
You might want to draw a line with segments exactly where you want them
instead of where Simulink draws them. Or you might want to draw a line
before you copy the block to which the line is connected. You can do either by
drawing line segments.
Connecting Blocks
To draw a line segment, you draw a line that ends in an unoccupied area of the
diagram. An arrow appears on the unconnected end of the line. To add another
line segment, position the cursor over the end of the segment and draw another
segment. Simulink draws the segments as horizontal and vertical lines. To
draw diagonal line segments, hold down the Shift key while you draw the lines.
Moving a Line Segment
To move a line segment, follow these steps:
1 Position the pointer on the segment you want to move.
2 Press and hold down the left mouse button.
3 Drag the pointer to the desired location.
4 Release the mouse button.
To move the segment connected to an input port, position the pointer over the
port and drag the end of the segment to the new location. You cannot move the
segment connected to an output port.
Block methods perform the same types of operations in different ways for
different types of blocks. The Simulink user interface and documentation uses
dot notation to indicate the specific function performed by a block method:
BlockType.MethodType
For example, Simulink refers to the method that computes the outputs of a
Gain block as
Gain.Outputs
The Simulink debugger takes the naming convention one step further and uses
the instance name of a block to specify both the method type and the block
instance on which the method is being invoked during simulation, e.g.,
g1.Outputs
Model Methods
In addition to block methods, Simulink also provides a set of methods that
compute the model’s properties and its outputs. Simulink similarly invokes
these methods during simulation to determine a model’s properties and its
outputs. The model methods generally perform their tasks by invoking block
methods of the same type. For example, the model Outputs method invokes the
Outputs methods of the blocks that it contains in the order specified by the
model to compute its outputs. The model Derivatives method similarly invokes
the Derivatives methods of the blocks that it contains to determine the
derivatives of its states.
Simulating Dynamic Systems
Simulating a dynamic system refers to the process of computing a system’s
states and outputs over a span of time, using information provided by the
system’s model. Simulink simulates a system when you choose Start from the
model editor’s Simulation menu, with the system’s model open.
A Simulink component called the Simulink Engine responds to a Start
command, performing the following steps.
Model Compilation
First, the Simulink engine invokes the model compiler. The model compiler
converts the model to an executable form, a process called compilation. In
Yüklə 304,26 Kb.

Dostları ilə paylaş:
  1   2




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin