[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [damos-dev] Dynamic modification of parameters
|
Hi Sebastian,
By design, parameters are always static since they are replaced by
constants in the generated code. If you need a block where some
"parameters" are variable, you have to create your own block type and
use inputs instead of parameters. You can use an existing block from the
block library as a template and change it accordingly.
For instance, let's say we need a discrete derivative with a variable
gain. The block type from the block library looks as follows:
-------------------------------------------------------------
package damos.blocks
synchronous blockType DiscreteDerivative {
input u
output y
parameter gain = 1(s) // normalize
parameter initialCondition = 0
behavior {
check(real) -> real
static assert u is real(?) :
error "Input value must be numeric"
static assert initialCondition is real(?) :
error "Initial condition must be numeric"
static assert initialCondition is real(?) && u is real(?) =>
unit(initialCondition) == unit(u) :
error "Initial condition and input value must have same unit"
static assert gain is real(?) :
error "Gain value must be numeric"
eq u{-1} = initialCondition
eq y{n} = fs * gain * (u{n} - u{n-1})
}
}
-------------------------------------------------------------
We change the gain parameter to an input so that the new block looks as
follows:
-------------------------------------------------------------
package example.blocks
synchronous blockType DiscreteDerivativeWithVariableGain {
input u
input gain // <-- Gain input instead of parameter
output y
// No gain parameter here
parameter initialCondition = 0
behavior {
// Adjust the check, everything else stays the same
check(real, real) -> real
static assert u is real(?) :
error "Input value must be numeric"
static assert initialCondition is real(?) :
error "Initial condition must be numeric"
static assert initialCondition is real(?) && u is real(?) =>
unit(initialCondition) == unit(u) :
error "Initial condition and input value must have same unit"
static assert gain is real(?) :
error "Gain value must be numeric"
eq u{-1} = initialCondition
eq y{n} = fs * gain * (u{n} - u{n-1})
}
}
-------------------------------------------------------------
I didn't test it but the idea should be clear. You could even combine
both methods and make it configurable, but it's a bit more complex (we
may do this for certain block parameters in the future).
Best regards,
Andreas
On 06/04/2014 07:21 AM, Sebastian Stickel wrote:
> Hi all,
>
> is there a way to make the block parameters dynamic? We need to to
> modify our control parameters at runtime as the system characteristics
> are not fix.
>
>
>
> Regards,
> Sebastian Stickel
>
>
> _______________________________________________
> damos-dev mailing list
> damos-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/damos-dev
>