Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
slref.pdf
Скачиваний:
39
Добавлен:
26.03.2015
Размер:
16.01 Mб
Скачать

2

Blocks — Alphabetical List

Abs

Purpose

Library

Description

Output absolute value of input

Math Operations

The Abs block outputs the absolute value of the input.

For signed-integer data types, the absolute value of the most negative value is not representable by the data type. In this case, the Saturate on integer overflow check box controls the behavior of the block:

 

If you...

The block...

And...

 

 

Select this

Saturates to the

For 8-bit signed integers,

 

 

check box

most positive value

-128 maps to 127.

 

 

 

of the integer data

For 16-bit signed integers,

 

 

 

type

-32768 maps to 32767.

 

 

 

 

 

 

 

 

For 32-bit signed integers,

 

 

 

 

-2147483648 maps to

 

 

 

 

2147483647.

 

 

Do not select

Wraps to the most

For 8-bit signed integers,

 

 

this check box

negative value of

-128 remains -128.

 

 

 

the integer data

For 16-bit signed integers,

 

 

 

type

 

 

 

-32768 remains -32768.

 

 

 

 

 

 

 

 

For 32-bit signed integers,

 

 

 

 

-2147483648 remains

 

 

 

 

-2147483648.

 

The Abs block supports zero-crossing detection. However, when you select Enable zero-crossing detection on the dialog box, the block does not report the simulation minimum or maximum in the Fixed-Point Tool. If you want to use the Fixed-Point Tool to analyze a model, disable zero-crossing detection for all Abs blocks in the model first.

2-2

Abs

Data Type The Abs block accepts real signals of the following data types:

Support

Floating point

Built-in integer

Fixed point

The block also accepts complex floating-point inputs. For more information, see “Data Types Supported by Simulink” in the Simulink documentation.

Parameters The Main pane of the Abs block dialog box appears as follows:

and Dialog Box

2-3

Abs

Enable zero-crossing detection

Select to enable zero-crossing detection. For more information, see “Zero-Crossing Detection” in the Simulink documentation.

Sample time (-1 for inherited)

Enter the time interval between sample time hits or specify another appropriate sample time such as continuous. By default, the block inherits its sample time based upon its context within the model. For more information, see “Sample Time”.

The Signal Attributes pane of the Abs block dialog box appears as follows:

2-4

Abs

Output minimum

Specify the minimum value that the block should output. The default value is [] (unspecified). Simulink software uses this value to perform:

Simulation range checking (see “Signal Ranges”)

Automatic scaling of fixed-point data types

2-5

Abs

Output maximum

Specify the maximum value that the block should output. The default value is [] (unspecified). Simulink software uses this value to perform:

Simulation range checking (see “Signal Ranges”)

Automatic scaling of fixed-point data types

Output data type

Specify the output data type. You can set it to:

A rule that inherits a data type, for example, Inherit: Inherit via back propagation

The name of a built-in data type, for example, single

The name of a data type object, for example, a

Simulink.NumericType object

An expression that evaluates to a data type, for example, fixdt(1,16,0)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the

Output data type parameter.

See “Specify Block Output Data Types” in Simulink User’s Guide for more information.

Lock output data type setting against changes by the fixed-point tools

Select to lock the output data type setting of this block against changes by the Fixed-Point Tool and the Fixed-Point Advisor. For more information, see “Use Lock Output Data Type Setting”.

Integer rounding mode

Specify the rounding mode for fixed-point operations. For more information, see “Rounding”. in the Simulink Fixed Point™ documentation.

2-6

Abs

Saturate on integer overflow

Action

Reason for Taking

What Happens

Example

 

This Action

 

 

Select this

Your model has

Overflows saturate to

The number 130 does

check box.

possible overflow and

the maximum value

not fit in a signed 8-bit

 

you want explicit

that the data type can

integer and saturates

 

saturation protection

represent.

to 127.

 

in the generated code.

 

 

Do not select

You want to optimize

Overflows wrap to the

The number 130 does

this check

efficiency of your

appropriate value that

not fit in a signed 8-bit

box.

generated code.

is representable by the

integer and wraps to

 

 

data type.

-126.

When you select this check box, saturation applies to every internal operation on the block, not just the output or result. In general, the code generation process can detect when overflow is not possible. In this case, the code generator does not produce saturation code.

Examples Usage as an Input to a MinMax Block

The sldemo_hardstop model shows how you can use the Abs block as an input to the MinMax block.

2-7

Abs

In the sldemo_hardstop model, the Abs block is in the Friction Model subsystem.

2-8

Abs

Usage as an Input to a Switch Block

The sldemo_zeroxing model shows how you can use the Abs block as an input to the Switch block.

Characteristics

Direct Feedthrough

Yes

 

Sample Time

Specified in the Sample time parameter

 

Dimensionalized

Yes

 

Multidimensionalized

Yes

 

Zero-Crossing Detection

Yes, if enabled

 

 

 

2-9

Action Port

Purpose

Implement Action subsystems used in if and switch control flow

 

statements

Library

Ports & Subsystems

Description

Action Port blocks implement Action subsystems used in if and switch

 

control flow statements. The Action Port block is available in the If

 

Action Subsystem and the Switch Case Action Subsystem.

 

Use Action Port blocks to create Action subsystems as follows:

1Place a subsystem in the system containing the If or Switch Case block.

You can use an ordinary subsystem or an atomic subsystem. In either case, the resulting Action subsystem is atomic.

2Add an Action Port to the new subsystem.

This block adds an input port named Action to the subsystem, which is now an Action subsystem.

Action subsystems execute their programming in response to the conditional outputs of an If or Switch Case block. Use Action subsystems as follows:

1Create an Action subsystem for each output port configured for an If or Switch Case block.

2Connect each output port to the Action port on an Action subsystem.

if, else, or elseif ports for the If block

case or default ports for the Switch Case block

When you make a connection, the icon changes for the subsystem and the Action Port block it contains to the name of the output port for the If or Switch Case block (for example, if{ }, else{ }, elseif{ },

case{ }, or default{ }).

2-10

Action Port

Data Type

Support

Parameters and Dialog Box

3Open the new subsystem and add the diagram that you want to execute in response to the condition this subsystem covers.

Note All blocks in an Action subsystem driven by an If or Switch Case block must run at the same rate as the driving block.

Action Port blocks do not have data inputs or outputs.

“States when execution is resumed” on page 2-11

“Propagate sizes of variable-size signals” on page 2-14

States when execution is resumed

Specify how to handle internal states when a subsystem with an Action Port block reenables.

Settings

Default: held

2-11

Action Port

held

When the subsystem reenables, retains the states of the Action subsystem with their previous values. Retains the previous values of states between calls even if calling other member Action subsystems of an if-else or switch control flow statement.

reset

Reinitializes the states of the Action subsystem to initial values when the subsystem reenables.

Reenablement of a subsystem occurs when called and the condition of the call is true after having been previously false. In the following example, the Action Port blocks for both Action subsystems A and B have the States when execution is resumed parameter set to reset.

If case[1] is true, call Action subsystem A. This result implies that the default condition is false. When later calling B for the default condition, its states are reset. In the same way, Action subsystem A states are reset when calling A right after calling Action subsystem B.

Repeated calls to the Action subsystem of a case does not reset its states. If calling A again right after a previous call to A, this action does not reset the states of A. This behavior is because the

2-12

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]