Skip to content

Commit

Permalink
test an integer clock with sample time < 1s
Browse files Browse the repository at this point in the history
  • Loading branch information
rfranke committed Mar 4, 2016
1 parent e89ea24 commit 6739ebe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions openmodelica/cppruntime/clockedTest.mos
Expand Up @@ -7,7 +7,8 @@ setCommandLineOptions("+simCodeTarget=Cpp");

loadString("
model DID \"Double Integrator Discrete-time\"
parameter Real dt = 0.1 \"sample time\";
parameter Integer intervalCounter = 1 \"sample interval\";
parameter Integer resolution = 10 \"resolution of sample interval\";
parameter Real p = 1 \"gain for input\";
parameter Real y1_start = 1 \"start value for first state\";
parameter Real y2_start = 0 \"start value for second state\";
Expand All @@ -17,7 +18,7 @@ model DID \"Double Integrator Discrete-time\"
Real xd2(start = y2_start);
output Real y1, y2;
equation
ud = sample(u, Clock(dt));
ud = sample(u, Clock(intervalCounter, resolution));
xd1 = previous(xd1) + p * ud * interval(ud);
xd2 = previous(xd2) + previous(xd1) * interval(xd1) + 0.5 * ud * interval()^2;
y1 = hold(previous(xd1));
Expand Down

0 comments on commit 6739ebe

Please sign in to comment.