modelExpression
User defined real function
Extends from IndustrialControlSystems.MathOperations.RealType.Interfaces.RealNinOperation (Real comparison interface).
Information
Description
Model of a generic function of n real numbers.
The output ( y ) is the result of the generic function f(.) of the
inputs ( u(:) ) signals.
y = f(u[:])
Fixed Point numbers
When using fixed point real numbers, Nbit is the number of bits that can be represented. The range is
Xfp in [-2Nbit - 1 + 1 ,..., 2Nbit - 1]Then it is possible to define a scaleFactor
X = Xfp/scaleFactorWhen the Fixed Point representation is selected (through the selection of the boolean flag FixedPoint), each input number u is converted into an integer Ufp
Ufp = u*scaleFactorthen the result of the math operation Yfp is computed and converted into the output value y. The output conversion depends on the math operation performed.
Saturation
To note that the Fixed Point numbers have a maximum and minimum value. In order to avoid saturation when performing the computations, the number of bit as well the scale factor have to be choosen carefully.
Parameters
| Type | Name | Default | Description |
|---|---|---|---|
| Modelica.Units.SI.Time | Ts (from RealNinOperation) | 0.1 | sampling time |
| Integer | nInput (from RealNinOperation) | 1 | number of inputs |
| Boolean | useInputs (from RealNinOperation) | true | =true, if inputs are enabled |
| String | fname | "F name" | String that represent the name of the implemented function |
| Fixed Point | |||
| Boolean | FixedPoint (from RealNinOperation) | false | Use fixed point real numbers |
| Integer | Nbit (from RealNinOperation) | 16 | Number of bits for representing the real numbers |
| Real | scaleFactor (from RealNinOperation) | 1 | Scale factor for Fixed Point numbers |
| Integer | MAX (from RealNinOperation) | integer(2^(Nbit - 1)) | maximum number that can be represented with Fixed Point notation |
| Integer | MIN (from RealNinOperation) | -integer(2^(Nbit - 1)) + 1 | minimum number that can be represented with Fixed Point notation |
Connectors
| Type | Name | Default | Description |
|---|---|---|---|
| Modelica.Blocks.Interfaces.RealInput[nInput] | u (from RealNinOperation) | input vector | |
| Modelica.Blocks.Interfaces.RealOutput | y (from RealNinOperation) | output |
Components
| Type | Name | Default | Description |
|---|---|---|---|
| Integer[nInput] | Ufp (from RealNinOperation) | floating point converted input | |
| Integer | Yfp (from RealNinOperation) | floating point converted output |
Contents
| Name | Description |
|---|---|
| f | generic real function |
| g | Output re-scaling function |
Revisions
- Industrial Control Systems (v 1.0.0) : April-May 2012
- List of revisions:
- 11 May 2012 (author: Marco Bonvini)
- Main Authors:
- Marco Bonvini; <bonvini@elet.polimi.it>
- Alberto Leva <leva@elet.polimi.it>
- Politecnico di Milano
- Dipartimento di Elettronica e Informazione
- Via Ponzio 34/5
- 20133 Milano - ITALIA -
- Copyright:
- Copyright © 2010-2012, Marco Bonvini and Alberto Leva.
- The IndustrialControlSystems package is free software; it can be redistributed and/or modified under the terms of the Modelica license.