- Index
- » Programming
- » Modelica Language
- » Problem with clocked when statements...
Problem with clocked when statements and reinit
Problem with clocked when statements and reinit
Hi all,
I use Clock() from the modelica synchronous library to try to create a pulse signal. The period and length should be set with parameters.
The following MWE summarizes my problem
Code:
block RowAddress
Real int1;
equation
der(int1) = 1;
when (Clock(0.1)) then
reinit(int1,0);
end when;
end RowAddress;
When running with openmodelica 1.16.0 I get an error window "The code generation process failed ........." but no error information at all.
When I try "Try with old front-end once" I get the message
[1] 10:39:11 Translation Error
[RowAddress: 8:5-8:19]: Operator reinit may only be used in the body of a when equation.
Note that the reinit operator is in the body of a when equation, so the compiler is confused.
Replacing the condition for the when with (int1>1) makes the model run successfully (but it doesn't do what I want any more).
On the other hand I have the following model which implements a wrapping counter:
Code:
block RowAddress1
discrete Integer Countval(start = 1);
equation
when (Clock(0.1)) then
Countval = if (time <= 0 or previous(Countval)>=10) then 1 else previous(Countval) + 1;
end when;
end RowAddress1;
This model runs fine, which confirms that the clock as the when condition is not the problem for openmodelica.
However both models won't run in dymola, with the following error
Code:
Continuous time parts and discrete parts don't decompose for:
Clock_0.isTicking
Countval
Equations:
equation
when Clock_0 then
Countval = (if time <= 0 or previous(Countval) >= 10 then 1 else previous(Countval)+1);
end when;
Clock_0 = Clock(0.1);
Decomposition in base clocks failed.
See the file dsmodelBaseClockDecomposition0.mof.
ERRORS have been issued.
So my question is
- is my code violating modelica, or is openmodelica messing up, and dymola even more?
Best regards,
Paul van der Hulst
- Index
- » Programming
- » Modelica Language
- » Problem with clocked when statements...