Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

When with multiple clocks

When with multiple clocks

Hi,
I try to set and reset a variable on different (alternating) clocks. The first clock should set the variable, the second clock should reset it again. The shift between the clocks determines the pulse duration.

Code:

block RowAddress


  Clock clk1=Clock(10);
  Clock clk2=shiftSample(clk1,10,100);
  Boolean active(start=false);

initial equation
equation
  when clk1 then
   active = true;
   elsewhen clk2 then
   active=false;
   end when;

end RowAddress;

Openmodelica says: "Clocked when equation can not contain elsewhen part."
(In Dymola this gives an "Unknown internal error in Dymola")

When I split the when into two independent sections

Code:

block RowAddress


  Clock clk1=Clock(10);
  Clock clk2=shiftSample(clk1,10,100);
  Boolean active(start=false);

initial equation
equation
  when clk1 then
   active = true;
   end when;
   when clk2 then
   active=false;
   end when;

end RowAddress;

I get from openmodelica: "Too many equations, over-determined system. The model has 6 equation(s) and 5 variable(s)."
(From dymola I get: the model is structurally singular  ("The Boolean part has 4 unknowns and 5 equations." seems to be the problem, although I don't understand what these 4 booleans are),)

Now I assume the second option must be wrong because modelica cannot assume that the events will not occur simultaneously (although they are definitely in this case).

Is this solvable, and how?

Best regards,
Paul

Edited by: paulvdh - Nov-05-20 12:57:23
There are 0 guests and 0 other users also viewing this topic
You are here: