diff --git a/implementation/library/Motor/stepper_103H5208.emx b/implementation/library/Motor/stepper_103H5208.emx
index e5a20c5..ed4ba62 100644
--- a/implementation/library/Motor/stepper_103H5208.emx
+++ b/implementation/library/Motor/stepper_103H5208.emx
@@ -8,31 +8,42 @@
0
False
Motor\stepper_103H5208.emx
- 2020-7-21 18:09:21
+ 2020-7-22 15:08:02
-
- parameters
- real I_phase = 3.4 {mH};
- real R_phase = 2.9 {ohm};
- real RotorInertia = 5.6e-6 {kg.m2};
- real StepperMass = 0.29 {kg};
- real angle_step = 1.8 {deg};
- real n_phase = 2 {none};
- real fluxLinkage = 15.0e-4 {Wb};
- real detentTorque = 0.01 {N.m};
-variables
- real omega;
- real p; // rotor division
-initialequations
- p = 2 * pi / (2 * n_phase * angle_step);
- omega = 200;
-
';
type Mainmodel
end;
implementation bg
submodels
- Cycloid 352 216
+ C 976 392
+ description '
+
+ 4.2
+1
+ False
+ Bond Graph\C.emx
+ 2011-11-29 15:58:35
+
+';
+ type C
+ ports
+ power in p;
+ signal out state;
+ restrictions
+ causality preferred out p;
+ end;
+ icon bg bottom
+ figures
+ text 'C' 976 392 color 0 18 bold;
+ end;
+ implementation eq
+parameters
+ real c = 0.00001;
+equations
+ state = int(p.f);
+ p.e = state / c;
+implementation_end;
+ Cycloid 184 224
description '4.01False
Signal\Sources\SignalGenerator-Cycloid.emx
2007-9-27 16:0:53
@@ -43,17 +54,17 @@ initialequations
end;
icon bg bottom
figures
- rectangle 336 200 368 232 color 0 fill 15132390;
- line 338.9 224 365.1 224 color 0;
- line 341.1 208 341.1 226.2 color 0;
- spline 341 224 345.8 222.1 352.2 212.8 364.3 210.7 color 16711680 fill 15132390;
- line 361.8 224 361.8 210.7 color 0 fill 15132390 dotted;
+ rectangle 168 208 200 240 color 0 fill 15132390;
+ line 170.9 232 197.1 232 color 0;
+ line 173.1 216 173.1 234.2 color 0;
+ spline 173 232 177.8 230.1 184.2 220.8 196.3 218.7 color 16711680 fill 15132390;
+ line 193.8 232 193.8 218.7 color 0 fill 15132390 dotted;
end;
implementation eq
parameters
- real amplitude = 25 {none};
- real start_time = 0.0 {s};
- real stop_time = 2.0 {s};
+ real amplitude = 3.1415 {none};
+ real start_time = 1.0 {s};
+ real stop_time = 1.3{s};
variables
real hidden tDelta, cycl;
boolean hidden change;
@@ -74,63 +85,7 @@ equations
end
end;
implementation_end;
- I 560 104
- description '
-
- 4.2
-1
- False
- Bond Graph\I.emx
- 2011-11-29 15:55:55
-
-';
- type I
- ports
- power in p;
- signal out state;
- restrictions
- causality preferred in p;
- end;
- icon bg bottom
- figures
- text 'I' 560 104 color 0 18 bold;
- end;
- implementation eq
-parameters
- real global I_phase;
-equations
- state = int(p.e);
- p.f = state / I_phase;
-implementation_end;
- I1 608 328
- description '
-
- 4.2
-1
- False
- Bond Graph\I.emx
- 2011-11-29 15:55:55
-
-';
- type I
- ports
- power in p;
- signal out state;
- restrictions
- causality preferred in p;
- end;
- icon bg bottom
- figures
- text 'I' 608 328 color 0 18 bold;
- end;
- implementation eq
-parameters
- real global I_phase;
-equations
- state = int(p.e);
- p.f = state / I_phase;
-implementation_end;
- I2 752 160
+ I2 1024 272
description '
4.2
@@ -149,17 +104,16 @@ implementation_end;
end;
icon bg bottom
figures
- text 'I' 752 160 color 0 18 bold;
+ text 'I' 1024 272 color 0 18 bold;
end;
implementation eq
parameters
real i = 8e-5 {kg.m2};
- real global RotorInertia;
equations
state = int(p.e);
- p.f = state / (i+RotorInertia);
+ p.f = state / i;
implementation_end;
- Integrate 424 216
+ Integrate 656 336
description '
4.3
@@ -176,8 +130,8 @@ implementation_end;
end;
icon bg bottom
figures
- rectangle 408 200 440 232 color 0 fill 15132390;
- text '∫' 424 216.3 color 16711680 'Lucida Sans' 21 italic;
+ rectangle 640 320 672 352 color 0 fill 15132390;
+ text '∫' 656 336.3 color 16711680 'Lucida Sans' 21 italic;
end;
implementation eq
parameters
@@ -185,117 +139,33 @@ parameters
equations
output = int (input, initial);
implementation_end;
- MGY_a 656 160
- description '
-
- 4.2
-1
- False
- Bond Graph\MGY.emx
- 2011-11-29 16:03:53
-
-';
- type MGY
- ports
- power in p1;
- power out p2;
- signal in r;
- restrictions
- causality constraint equal p1 p2;
- end;
- icon bg bottom
- figures
- text 'MGY' 656 160 color 0 18 bold;
- end;
- implementation eq
-equations
- p1.e = r * p2.f;
- p2.e = r * p1.f;
-implementation_end;
- MGY_b 656 272
- description '
-
- 4.2
-1
- False
- Bond Graph\MGY.emx
- 2011-11-29 16:03:53
-
-';
- type MGY
- ports
- power in p1;
- power out p2;
- signal in r;
- restrictions
- causality constraint equal p1 p2;
- end;
- icon bg bottom
- figures
- text 'MGY' 656 272 color 0 18 bold;
- end;
- implementation eq
-equations
- p1.e = r * p2.f;
- p2.e = r * p1.f;
-implementation_end;
- MSe_a 512 160
- description '
-
- 4.2
-1
- False
- Bond Graph\MSe.emx
- 2011-11-29 16:12:33
-
-';
- type MSe
- ports
- electric out p;
- signal in effort;
- restrictions
- causality fixed out p;
- end;
- icon bg bottom
- figures
- text 'MSe' 512 160 color 0 18 bold;
- end;
- implementation eq
-variables
- real flow;
-equations
- p.e = effort;
- flow = p.f;
-implementation_end;
- MSe_b 512 272
+ Integrate1 720 336
description '
- 4.2
+ 4.3
1
False
- Bond Graph\MSe.emx
- 2011-11-29 16:12:33
+ Signal\Block Diagram\Integrate.emx
+ 2013-3-8 14:47:42
';
- type MSe
+ type Integrate
ports
- electric out p;
- signal in effort;
- restrictions
- causality fixed out p;
+ signal in input;
+ signal out output;
end;
icon bg bottom
figures
- text 'MSe' 512 272 color 0 18 bold;
+ rectangle 704 320 736 352 color 0 fill 15132390;
+ text '∫' 720 336.3 color 16711680 'Lucida Sans' 21 italic;
end;
implementation eq
-variables
- real flow;
+parameters
+ real initial = 0; // initial value
equations
- p.e = effort;
- flow = p.f;
-implementation_end;
- OneJunction 896 216
+ output = int (input, initial);
+ implementation_end;
+ OneJunction 1024 336
description '
4.2
@@ -314,7 +184,7 @@ implementation_end;
end;
icon bg
figures
- text '1' 896 216 color 0 18 bold;
+ text '1' 1024 336 color 0 18 bold;
end;
implementation eq
equations
@@ -322,7 +192,7 @@ equations
equal (collect (p.f));
flow = first (p.f);
implementation_end;
- OneJunction1 584 160
+ OneJunction1 936 392
description '
4.2
@@ -334,14 +204,14 @@ implementation_end;
';
knot OneJunction
ports
- electric knot duplicatable none p [1];
+ rotation knot duplicatable none p [1];
signal knot out flow [1];
restrictions
causality constraint one_out p;
end;
icon bg
figures
- text '1' 584 160 color 0 18 bold;
+ text '1' 936 392 color 0 18 bold;
end;
implementation eq
equations
@@ -349,61 +219,69 @@ equations
equal (collect (p.f));
flow = first (p.f);
implementation_end;
- OneJunction2 584 272
- description '
-
- 4.2
-1
- False
- Bond Graph\OneJunction.emx
- 2011-11-29 16:17:51
-
-';
- knot OneJunction
+ PD 568 336
+ description '
+ 4.0
+ 1
+ False
+ Signal\Control\PID Control\Continuous\PD.emx
+ 2008-1-17 10:49:7
+';
+ type PD
ports
- electric knot duplicatable none p [1];
- signal knot out flow [1];
- restrictions
- causality constraint one_out p;
+ signal in error;
+ signal out output;
end;
- icon bg
+ icon bg bottom
figures
- text '1' 584 272 color 0 18 bold;
+ rectangle 552 320 584 352 color 0 fill 15132390;
+ text 'PD' 568.5 336.1 color 16711680 18 bold;
end;
implementation eq
+parameters
+ real kp = 6 {}; // Proportional gain
+ real tauD = 7.5 {s}; // Derivative time constant: tauD > 0
+ real beta = 0.4 {}; // Tameness constant: 0 < beta << 1
+ real maximum = 100;
+variables
+ real state, rate;
equations
- sum (direct (p.e)) = 0;
- equal (collect (p.f));
- flow = first (p.f);
-implementation_end;
- OneJunction3 752 216
- description '
-
- 4.2
-1
- False
- Bond Graph\OneJunction.emx
- 2011-11-29 16:17:51
-
-';
- knot OneJunction
+ rate = (kp * error - output) / (beta * tauD);
+ state = int (rate);
+ output = state + kp * error / beta;
+ implementation_end;
+ PD1 432 336
+ description '
+ 4.0
+ 1
+ False
+ Signal\Control\PID Control\Continuous\PD.emx
+ 2008-1-17 10:49:7
+';
+ type PD
ports
- rotation knot duplicatable none p [1];
- signal knot out flow [1];
- restrictions
- causality constraint one_out p;
+ signal in error;
+ signal out output;
end;
- icon bg
+ icon bg bottom
figures
- text '1' 752 216 color 0 18 bold;
+ rectangle 416 320 448 352 color 0 fill 15132390;
+ text 'PD' 432.5 336.1 color 16711680 18 bold;
end;
implementation eq
+parameters
+ real kp = 3 {}; // Proportional gain
+ real tauD = 50 {s}; // Derivative time constant: tauD > 0
+ real beta = 0.4 {}; // Tameness constant: 0 < beta << 1
+ real maximum = 25;
+variables
+ real state, rate;
equations
- sum (direct (p.e)) = 0;
- equal (collect (p.f));
- flow = first (p.f);
-implementation_end;
- PlusMinus1 448 160
+ rate = (kp * error - output) / (beta * tauD);
+ state = int (rate);
+ output = state + kp * error / beta;
+ implementation_end;
+ PlusMinus1 392 336
description '4.01False
Signal\Block Diagram\PlusMinus.emx
2007-9-27 10:15:13
@@ -416,13 +294,13 @@ implementation_end;
end;
icon bg ellipse
figures
- ellipse 440 152 456 168 color 0 fill 16777215;
+ ellipse 384 328 400 344 color 0 fill 16777215;
end;
implementation eq
equations
output = sum (collect (plus)) - sum (collect (minus));
implementation_end;
- PlusMinus2 448 272
+ PlusMinus2 528 336
description '4.01False
Signal\Block Diagram\PlusMinus.emx
2007-9-27 10:15:13
@@ -435,13 +313,13 @@ equations
end;
icon bg ellipse
figures
- ellipse 440 264 456 280 color 0 fill 16777215;
+ ellipse 520 328 536 344 color 0 fill 16777215;
end;
implementation eq
equations
output = sum (collect (plus)) - sum (collect (minus));
implementation_end;
- R 608 104
+ R 896 392
description '
4.2
@@ -457,101 +335,117 @@ equations
end;
icon bg bottom
figures
- text 'R' 608 104 color 0 18 bold;
+ text 'R' 896 392 color 0 18 bold;
end;
implementation eq
parameters
- real global R_phase;
+ real r = 100;
equations
- p.e = R_phase * p.f;
+ p.e = r * p.f;
implementation_end;
- R1 560 328
- description '
-
- 4.2
-1
- False
- Bond Graph\R.emx
- 2011-11-29 16:35:37
-
-';
- type R
+ SignalLimiter1 480 336
+ description '4.01False
+ Signal\Block Diagram Non-Linear\SignalLimiter-Limit.emx
+ 2007-9-26 12:47:40
+';
+ type 'SignalLimiter-Limit'
ports
- power in p;
+ signal in input;
+ signal out output;
end;
icon bg bottom
figures
- text 'R' 560 328 color 0 18 bold;
+ group
+ rectangle 464 320 496 352 color 0 fill 15132390;
+ line 479.9 324.5 479.9 349 color 0 fill 15132390;
+ line 467 336.2 492.7 336.2 color 0 fill 15132390;
+ spline 473.9 343.1 485.9 329.4 color 16711680 fill 15132390 width 2;
+ spline 485.3 330.2 493.9 329.8 color 16711680 fill 15132390 width 2;
+ spline 467 343.6 473.9 343.1 color 16711680 fill 15132390 width 2;
+ end;
end;
implementation eq
parameters
- real global R_phase;
+ real maximum = 25;
+ real minimum = -25;
equations
- p.e = R_phase * p.f;
-implementation_end;
- RotorAngle 656 216
- description '4.0
- Template\Submodel-Equation.emx
-1
- False
- 2007-11-1 22:32:1
- False
+ output = limit (input, minimum, maximum);
+ implementation_end;
+ SignalLimiter2 616 336
+ description '4.01False
+ Signal\Block Diagram Non-Linear\SignalLimiter-Limit.emx
+ 2007-9-26 12:47:40
';
- type Submodel
+ type 'SignalLimiter-Limit'
ports
- signal out output_b;
- signal out output_a;
- signal in omega {rad/s} ;
- signal out output_d;
+ signal in input;
+ signal out output;
end;
- icon bg
+ icon bg bottom
figures
- rectangle 616 200 696 232 color 0 fill 15132390;
- text 'name' 656 216 color 0 'Clear Sans' 16;
+ group
+ rectangle 600 320 632 352 color 0 fill 15132390;
+ line 615.9 324.5 615.9 349 color 0 fill 15132390;
+ line 603 336.2 628.7 336.2 color 0 fill 15132390;
+ spline 609.9 343.1 621.9 329.4 color 16711680 fill 15132390 width 2;
+ spline 621.3 330.2 629.9 329.8 color 16711680 fill 15132390 width 2;
+ spline 603 343.6 609.9 343.1 color 16711680 fill 15132390 width 2;
+ end;
end;
implementation eq
parameters
- real global fluxLinkage;
- real global detentTorque;
-variables
- real global p;
- real angle {rad};
+ real maximum = 100;
+ real minimum = -100;
equations
- angle = int(omega);
- output_a = -p * fluxLinkage * sin(p * angle);
- output_b = p * fluxLinkage * sin(p * angle - pi / 2);
- output_d = detentTorque * sin(2 * p * angle);
- implementation_end;
- Se 752 272
- description '
-
- 4.2
+ output = limit (input, minimum, maximum);
+ implementation_end;
+ Splitter2 304 336
+ description '4.0
+ Signal\Block Diagram\Splitter.emx
+ 2008-01-17 11:28:29
1
- False
- Bond Graph\MSe.emx
- 2011-11-29 16:12:33
-
-';
- type MSe
+ False
+';
+ knot Splitter
ports
- power out p;
- signal in effort;
- restrictions
- causality fixed out p;
+ signal knot duplicatable out output [1];
+ signal knot in input [1];
end;
- icon bg bottom
+ icon bg ellipse
figures
- text 'MSe' 752 272 color 0 18 bold;
+ ellipse 300.8 332.8 307.2 339.2 color -1 fill 0;
+ ellipse 299.7 331.7 308.3 340.3 color -1;
+ terminals
+ input 304 336 fixed;
end;
implementation eq
-
-variables
- real flow;
equations
- p.e = effort;
- flow = p.f;
+ collect (output) = input;
+implementation_end;
+ Splitter3 688 336
+ description '4.0
+ Signal\Block Diagram\Splitter.emx
+ 2008-01-17 11:28:29
+1
+ False
+';
+ knot Splitter
+ ports
+ signal knot duplicatable out output [1];
+ signal knot in input [1];
+ end;
+ icon bg ellipse
+ figures
+ ellipse 684.8 332.8 691.2 339.2 color -1 fill 0;
+ ellipse 683.7 331.7 692.3 340.3 color -1;
+ terminals
+ input 688 336 fixed;
+ end;
+ implementation eq
+equations
+ collect (output) = input;
implementation_end;
- Splitter1 720 216
+ Splitter4 752 336
description '4.0
Signal\Block Diagram\Splitter.emx
2008-01-17 11:28:29
@@ -565,16 +459,16 @@ implementation_end;
end;
icon bg ellipse
figures
- ellipse 716.8 212.8 723.2 219.2 color -1 fill 0;
- ellipse 715.7 211.7 724.3 220.3 color -1;
+ ellipse 748.8 332.8 755.2 339.2 color -1 fill 0;
+ ellipse 747.7 331.7 756.3 340.3 color -1;
terminals
- input 720 216 fixed;
+ input 752 336 fixed;
end;
implementation eq
equations
collect (output) = input;
implementation_end;
- Square 448 96
+ Square 216 336
description '
4.0
1
@@ -582,27 +476,27 @@ implementation_end;
Signal\Sources\WaveGenerator-Square.emx
2009-3-5 16:05:33
';
- type WaveGenerator
+ type 'WaveGenerator-Square'
ports
signal out output;
end;
icon bg bottom
figures
- rectangle 432.1 80 463.9 112 color 0 fill 15132390;
- line 436.1 83.9 435.9 110.2 color 0 fill 0;
- line 433.9 108.1 459.9 108.1 color 0 fill 0;
- line 436.1 108.1 440 108.1 440 96 color 16711680 fill 0;
- line 448 96 440 96 448 96 color 16711680 fill 0;
- line 448 108.1 448 96 448 108.1 color 16711680 fill 0;
- line 456 96 456 108.1 456 96 color 16711680 fill 0;
- line 459.9 96.1 455.7 96.1 color 16711680 fill 0;
- line 448 108.1 456 108.1 color 16711680 fill 0;
+ rectangle 200.1 320 231.9 352 color 0 fill 15132390;
+ line 204.1 323.9 203.9 350.2 color 0 fill 0;
+ line 201.9 348.1 227.9 348.1 color 0 fill 0;
+ line 204.1 348.1 208 348.1 208 336 color 16711680 fill 0;
+ line 216 336 208 336 216 336 color 16711680 fill 0;
+ line 216 348.1 216 336 216 348.1 color 16711680 fill 0;
+ line 224 336 224 348.1 224 336 color 16711680 fill 0;
+ line 227.9 336.1 223.7 336.1 color 16711680 fill 0;
+ line 216 348.1 224 348.1 color 16711680 fill 0;
end;
implementation eq
parameters
- real amplitude = 3.4; // amplitude of the wave
+ real amplitude = 1.0; // amplitude of the wave
+ real omega = 0.1 {rad/s}; // angular frequency of the wave
variables
- real global omega; // angular frequency of the wave
real hidden s, half;
boolean hidden change;
equations
@@ -619,156 +513,566 @@ equations
(amplitude / 2) * (s + 1)
end;
implementation_end;
- Square1 384 272
- description '
- 4.0
-1
- False
- Signal\Sources\WaveGenerator-Square.emx
- 2009-3-5 16:05:33
+ Step 528 472
+ description '4.01False
+ Signal\Sources\SignalGenerator-Step.emx
+ 2007-9-27 16:2:44
';
- type WaveGenerator
+ type 'SignalGenerator-Step'
ports
signal out output;
end;
icon bg bottom
figures
- rectangle 368.1 256 399.9 288 color 0 fill 15132390;
- line 372.1 259.9 371.9 286.2 color 0 fill 0;
- line 369.9 284.1 395.9 284.1 color 0 fill 0;
- line 372.1 284.1 376 284.1 376 272 color 16711680 fill 0;
- line 384 272 376 272 384 272 color 16711680 fill 0;
- line 384 284.1 384 272 384 284.1 color 16711680 fill 0;
- line 392 272 392 284.1 392 272 color 16711680 fill 0;
- line 395.9 272.1 391.7 272.1 color 16711680 fill 0;
- line 384 284.1 392 284.1 color 16711680 fill 0;
+ group
+ rectangle 512 456 544 488 color 0 fill 15132390;
+ line 521.6 468.8 538.6 468.8 color 16711680 width 2;
+ line 514.9 480 541.1 480 color 0;
+ line 517.1 480.1 521.7 480.1 521.7 468.7 color 16711680 width 2;
+ line 517.1 464 517.1 482.2 color 0;
+ end;
end;
implementation eq
parameters
- real amplitude = -3.4; // amplitude of the wave
-variables
- real global omega; // angular frequency of the wave
- real hidden s, half;
+ real amplitude = 25;
+ real start_time = 1.0 {s};
+variables
boolean hidden change;
equations
- "calculate at least 2 points per period
- (just after the change in sign)"
- half = pi / omega;
- change = frequencyevent (half, 1e-14);
-
- "calculate the square wave"
- s = sign (sin (omega * time + pi/2));
- output = if( s == 0 ) then
- amplitude
- else
- (amplitude / 2) * (s + 1)
- end;
+ "calculate at least at the start time"
+ change = timeevent (start_time);
+
+ "calculate the step signal"
+ output = amplitude * step (start_time); implementation_end;
+ Submodel1 304 200
+ description '4.0
+ Template\Submodel-Equation.emx
+1
+ False
+ 2007-11-1 22:32:1
+ False
+';
+ type 'Submodel-Equation'
+ ports
+ signal in input;
+ signal out output;
+ end;
+ implementation eq
+parameters
+ real angleStep = 1.8 {deg};
+ real C = 5 {none};
+ real D = 3 {none};
+ real omega_max = 27.5 {rad/s};
+variables
+ real a_max {rad/s2};
+ real currentAngle {rad};
+ real omega {rad/s};
+ real acc {rad/s2};
+initialequations
+ currentAngle = 0;
+ omega = 0;
+equations
+ a_max = C * exp(D * abs(omega));
+ acc = limit(input - currentAngle, -a_max, a_max);
+ omega = limint(acc, -omega_max, omega_max);
+ currentAngle = int(omega);
+ output = currentAngle;
+/*
+parameters
+ real kp = 0.1 {}; // Proportional gain
+ real tauD = 2.0 {s}; // Derivative time constant: tauD > 0
+ real beta = 0.1 {}; // Tameness constant: 0 < beta << 1
+variables
+ real state, rate;
+equations
+ rate = (kp * error - output) / (beta * tauD);
+ state = int (rate);
+ output = state + kp * error / beta;*/
+
+ implementation_end;
+ Submodel3 832 336
+ description '4.81parameters
+ real I_phase = 3.4 {mH};
+ real R_phase = 2.9 {ohm};
+ real u_max = 3.4 {V};
+ real RotorInertia = 5.6e-6 {kg.m2};
+ real StepperMass = 0.29 {kg};
+ real angle_step = 1.8 {deg};
+ real n_phase = 2 {none};
+ real fluxLinkage = 0.0022 {Wb};
+ real detentTorque = 0.01 {N.m};
+variables
+ real omega;
+ real p; // rotor division
+initialequations
+ p = 2 * pi / (2 * n_phase * angle_step);
+ omega = 200;';
+ type Submodel
+ ports
+ signal in angle;
+ rotation out p;
+ end;
+ implementation bg
+ submodels
+ I 560 104
+ description '
+
+ 4.2
+1
+ False
+ Bond Graph\I.emx
+ 2011-11-29 15:55:55
+
+';
+ type I
+ ports
+ power in p;
+ signal out state;
+ restrictions
+ causality preferred in p;
+ end;
+ icon bg bottom
+ figures
+ text 'I' 560 104 color 0 18 bold;
+ end;
+ implementation eq
+parameters
+ real global I_phase;
+equations
+ state = int(p.e);
+ p.f = state / I_phase;
+implementation_end;
+ I1 608 328
+ description '
+
+ 4.2
+1
+ False
+ Bond Graph\I.emx
+ 2011-11-29 15:55:55
+
+';
+ type I
+ ports
+ power in p;
+ signal out state;
+ restrictions
+ causality preferred in p;
+ end;
+ icon bg bottom
+ figures
+ text 'I' 608 328 color 0 18 bold;
+ end;
+ implementation eq
+parameters
+ real global I_phase;
+equations
+ state = int(p.e);
+ p.f = state / I_phase;
+implementation_end;
+ I2 752 160
+ description '
+
+ 4.2
+1
+ False
+ Bond Graph\I.emx
+ 2011-11-29 15:55:55
+
+';
+ type I
+ ports
+ power in p;
+ signal out state;
+ restrictions
+ causality preferred in p;
+ end;
+ icon bg bottom
+ figures
+ text 'I' 752 160 color 0 18 bold;
+ end;
+ implementation eq
+parameters
+ real i = 8e-5 {kg.m2};
+ real global RotorInertia;
+equations
+ state = int(p.e);
+ p.f = state / (RotorInertia);
+implementation_end;
+ MGY_a 656 160
+ description '
+
+ 4.2
+1
+ False
+ Bond Graph\MGY.emx
+ 2011-11-29 16:03:53
+
+';
+ type MGY
+ ports
+ power in p1;
+ power out p2;
+ signal in r;
+ restrictions
+ causality constraint equal p1 p2;
+ end;
+ icon bg bottom
+ figures
+ text 'MGY' 656 160 color 0 18 bold;
+ end;
+ implementation eq
+equations
+ p1.e = r * p2.f;
+ p2.e = r * p1.f;
+implementation_end;
+ MGY_b 656 272
+ description '
+
+ 4.2
+1
+ False
+ Bond Graph\MGY.emx
+ 2011-11-29 16:03:53
+
+';
+ type MGY
+ ports
+ power in p1;
+ power out p2;
+ signal in r;
+ restrictions
+ causality constraint equal p1 p2;
+ end;
+ icon bg bottom
+ figures
+ text 'MGY' 656 272 color 0 18 bold;
+ end;
+ implementation eq
+equations
+ p1.e = r * p2.f;
+ p2.e = r * p1.f;
+implementation_end;
+ MSe_a 512 160
+ description '
+
+ 4.2
+1
+ False
+ Bond Graph\MSe.emx
+ 2011-11-29 16:12:33
+
+';
+ type MSe
+ ports
+ electric out p;
+ signal in effort;
+ restrictions
+ causality fixed out p;
+ end;
+ icon bg bottom
+ figures
+ text 'MSe' 512 160 color 0 18 bold;
+ end;
+ implementation eq
+variables
+ real flow;
+equations
+ p.e = effort;
+ flow = p.f;
+implementation_end;
+ MSe_b 512 272
+ description '
+
+ 4.2
+1
+ False
+ Bond Graph\MSe.emx
+ 2011-11-29 16:12:33
+
+';
+ type MSe
+ ports
+ electric out p;
+ signal in effort;
+ restrictions
+ causality fixed out p;
+ end;
+ icon bg bottom
+ figures
+ text 'MSe' 512 272 color 0 18 bold;
+ end;
+ implementation eq
+variables
+ real flow;
+equations
+ p.e = effort;
+ flow = p.f;
+implementation_end;
+ plug angle 200 216;
+ plug p 1472 216;
+ OneJunction1 840 216
+ description '
+
+ 4.2
+1
+ False
+ Bond Graph\OneJunction.emx
+ 2011-11-29 16:17:51
+
+';
+ knot OneJunction
+ ports
+ rotation knot duplicatable none p [1];
+ signal knot out flow [1];
+ restrictions
+ causality constraint one_out p;
+ end;
+ icon bg
+ figures
+ text '1' 840 216 color 0 18 bold;
+ end;
+ implementation eq
+equations
+ sum (direct (p.e)) = 0;
+ equal (collect (p.f));
+ flow = first (p.f);
+implementation_end;
+ OneJunction2 584 160
+ description '
+
+ 4.2
+1
+ False
+ Bond Graph\OneJunction.emx
+ 2011-11-29 16:17:51
+
+';
+ knot OneJunction
+ ports
+ electric knot duplicatable none p [1];
+ signal knot out flow [1];
+ restrictions
+ causality constraint one_out p;
+ end;
+ icon bg
+ figures
+ text '1' 584 160 color 0 18 bold;
+ end;
+ implementation eq
+equations
+ sum (direct (p.e)) = 0;
+ equal (collect (p.f));
+ flow = first (p.f);
+implementation_end;
+ OneJunction3 584 272
+ description '
+
+ 4.2
+1
+ False
+ Bond Graph\OneJunction.emx
+ 2011-11-29 16:17:51
+
+';
+ knot OneJunction
+ ports
+ electric knot duplicatable none p [1];
+ signal knot out flow [1];
+ restrictions
+ causality constraint one_out p;
+ end;
+ icon bg
+ figures
+ text '1' 584 272 color 0 18 bold;
+ end;
+ implementation eq
+equations
+ sum (direct (p.e)) = 0;
+ equal (collect (p.f));
+ flow = first (p.f);
+implementation_end;
+ OneJunction4 752 216
+ description '
+
+ 4.2
+1
+ False
+ Bond Graph\OneJunction.emx
+ 2011-11-29 16:17:51
+
+';
+ knot OneJunction
+ ports
+ rotation knot duplicatable none p [1];
+ signal knot out flow [1];
+ restrictions
+ causality constraint one_out p;
+ end;
+ icon bg
+ figures
+ text '1' 752 216 color 0 18 bold;
+ end;
+ implementation eq
+equations
+ sum (direct (p.e)) = 0;
+ equal (collect (p.f));
+ flow = first (p.f);
+implementation_end;
+ R 608 104
+ description '
+
+ 4.2
+1
+ False
+ Bond Graph\R.emx
+ 2011-11-29 16:35:37
+
+';
+ type R
+ ports
+ power in p;
+ end;
+ icon bg bottom
+ figures
+ text 'R' 608 104 color 0 18 bold;
+ end;
+ implementation eq
+parameters
+ real global R_phase;
+equations
+ p.e = R_phase * p.f;
+implementation_end;
+ R1 560 328
+ description '
+
+ 4.2
+1
+ False
+ Bond Graph\R.emx
+ 2011-11-29 16:35:37
+
+';
+ type R
+ ports
+ power in p;
+ end;
+ icon bg bottom
+ figures
+ text 'R' 560 328 color 0 18 bold;
+ end;
+ implementation eq
+parameters
+ real global R_phase;
+equations
+ p.e = R_phase * p.f;
implementation_end;
- Square2 384 160
- description '
- 4.0
+ R2 824 264
+ description '
+
+ 4.2
1
- False
- Signal\Sources\WaveGenerator-Square.emx
- 2009-3-5 16:05:33
-';
- type WaveGenerator
- ports
- signal out output;
- end;
- icon bg bottom
- figures
- rectangle 368.1 144 399.9 176 color 0 fill 15132390;
- line 372.1 147.9 371.9 174.2 color 0 fill 0;
- line 369.9 172.1 395.9 172.1 color 0 fill 0;
- line 372.1 172.1 376 172.1 376 160 color 16711680 fill 0;
- line 384 160 376 160 384 160 color 16711680 fill 0;
- line 384 172.1 384 160 384 172.1 color 16711680 fill 0;
- line 392 160 392 172.1 392 160 color 16711680 fill 0;
- line 395.9 160.1 391.7 160.1 color 16711680 fill 0;
- line 384 172.1 392 172.1 color 16711680 fill 0;
- end;
- implementation eq
+ False
+ Bond Graph\R.emx
+ 2011-11-29 16:35:37
+
+';
+ type R
+ ports
+ power in p;
+ end;
+ icon bg bottom
+ figures
+ text 'R' 824 264 color 0 18 bold;
+ end;
+ implementation eq
parameters
- real amplitude = -3.4; // amplitude of the wave
-variables
- real global omega; // angular frequency of the wave
- real hidden s, half;
- boolean hidden change;
+ real r = 1.0e-3;
equations
- "calculate at least 2 points per period
- (just after the change in sign)"
- half = pi / omega;
- change = frequencyevent (half, 1e-14);
-
- "calculate the square wave"
- s = sign (sin (omega * time + pi));
- output = if( s == 0 ) then
- amplitude
- else
- (amplitude / 2) * (s + 1)
- end;
+ p.e = r * p.f;
implementation_end;
- Square3 448 336
- description '
- 4.0
+ RotorAngle 656 216
+ description '4.0
+ Template\Submodel-Equation.emx
1
False
- Signal\Sources\WaveGenerator-Square.emx
- 2009-3-5 16:05:33
+ 2007-11-1 22:32:1
+ False
';
- type WaveGenerator
- ports
- signal out output;
- end;
- icon bg bottom
- figures
- rectangle 432.1 320 463.9 352 color 0 fill 15132390;
- line 436.1 323.9 435.9 350.2 color 0 fill 0;
- line 433.9 348.1 459.9 348.1 color 0 fill 0;
- line 436.1 348.1 440 348.1 440 336 color 16711680 fill 0;
- line 448 336 440 336 448 336 color 16711680 fill 0;
- line 448 348.1 448 336 448 348.1 color 16711680 fill 0;
- line 456 336 456 348.1 456 336 color 16711680 fill 0;
- line 459.9 336.1 455.7 336.1 color 16711680 fill 0;
- line 448 348.1 456 348.1 color 16711680 fill 0;
- end;
- implementation eq
+ type Submodel
+ ports
+ signal out output_b;
+ signal out output_a;
+ signal in omega {rad/s} ;
+ signal out output_d;
+ end;
+ icon bg
+ figures
+ rectangle 616 200 696 232 color 0 fill 15132390;
+ text 'name' 656 216 color 0 'Clear Sans' 16;
+ end;
+ implementation eq
parameters
- real amplitude = 3.4; // amplitude of the wave
-variables
- real global omega; // angular frequency of the wave
- real hidden s, half;
- boolean hidden change;
+ real global fluxLinkage;
+ real global detentTorque;
+variables
+ real global p;
+ real angle {rad};
equations
- "calculate at least 2 points per period
- (just after the change in sign)"
- half = pi / omega;
- change = frequencyevent (half, 1e-14);
+ angle = int(omega);
+ output_a = -p * fluxLinkage * sin(p * angle);
+ output_b = p * fluxLinkage * sin(p * angle - pi / 2);
+ output_d = detentTorque * sin(2 * p * angle);
+ implementation_end;
+ Se 752 272
+ description '
+
+ 4.2
+1
+ False
+ Bond Graph\MSe.emx
+ 2011-11-29 16:12:33
+
+';
+ type MSe
+ ports
+ power out p;
+ signal in effort;
+ restrictions
+ causality fixed out p;
+ end;
+ icon bg bottom
+ figures
+ text 'MSe' 752 272 color 0 18 bold;
+ end;
+ implementation eq
- "calculate the square wave"
- s = sign (sin (omega * time - pi/2));
- output = if( s == 0 ) then
- amplitude
- else
- (amplitude / 2) * (s + 1)
- end;
+variables
+ real flow;
+equations
+ p.e = effort;
+ flow = p.f;
implementation_end;
- Submodel2 512 216
- description '4.0
+ Submodel2 512 216
+ description '4.0
Template\Submodel-Equation.emx
1
False
2007-11-1 22:32:1
False
';
- type 'Submodel-Equation'
- ports
- signal in angle;
- signal out a;
- signal out b;
- end;
- implementation eq
+ type Submodel
+ ports
+ signal in angle;
+ signal out a;
+ signal out b;
+ end;
+ icon bg
+ figures
+ rectangle 472 200 552 232 color 0 fill 15132390;
+ text 'name' 512 216 color 0 'Clear Sans' 16;
+ end;
+ implementation eq
parameters
real global u_max {V};
real global angle_step;
@@ -779,43 +1083,90 @@ variables
real global p;
boolean hidden eventa, eventb;
equations
- a = -sign (cos (p*angle));
+ a = u_max * (cos (p*angle));
eventa = event(a);
- b = sign (sin (p*angle));
+ b = u_max * -(sin (p*angle));
eventb = event(b);
+ current_angle = angle;
-
implementation_end;
+ end;
+ connections
+ angle -> Submodel2\angle;
+ I2\p <= OneJunction4\p;
+ MGY_a\p2 => OneJunction4\p;
+ MGY_b\p2 => OneJunction4\p;
+ MSe_b\p => OneJunction3\p;
+ OneJunction1\p => p;
+ OneJunction2\p <= MSe_a\p;
+ OneJunction2\p => I\p;
+ OneJunction2\p => MGY_a\p1;
+ OneJunction2\p => R\p;
+ OneJunction3\p => I1\p;
+ OneJunction3\p => MGY_b\p1;
+ OneJunction3\p => R1\p;
+ OneJunction4\flow -> RotorAngle\omega;
+ OneJunction4\p => OneJunction1\p;
+ OneJunction4\p => R2\p;
+ RotorAngle\output_a -> MGY_a\r;
+ RotorAngle\output_b -> MGY_b\r;
+ RotorAngle\output_d -> Se\effort;
+ Se\p => OneJunction4\p;
+ Submodel2\a -> MSe_a\effort;
+ Submodel2\b -> MSe_b\effort;
+ end;
+ implementation_end;
+ ZeroJunction1 936 336
+ description '
+
+ 4.2
+1
+ False
+ Bond Graph\ZeroJunction.emx
+ 2011-11-29 16:45:16
+
+';
+ knot ZeroJunction
+ ports
+ rotation knot duplicatable none p [1];
+ signal knot out effort [1];
+ restrictions
+ causality constraint one_in p;
+ end;
+ icon bg
+ figures
+ text '0' 936 336 color 0 18 bold;
+ end;
+ implementation eq
+equations
+ sum (direct (p.f)) = 0;
+ equal (collect (p.e));
+ effort = first (p.e);
+implementation_end;
end;
connections
- Cycloid\output -> Integrate\input;
- I2\p <= OneJunction3\p;
- Integrate\output -> Submodel2\angle;
- MGY_a\p2 => OneJunction3\p;
- MGY_b\p2 => OneJunction3\p;
- MSe_a\p => OneJunction1\p;
- MSe_b\p => OneJunction2\p;
- OneJunction1\p => I\p;
- OneJunction1\p => MGY_a\p1;
+ C\p <= OneJunction1\p;
+ Integrate\output -> Splitter3\input;
+ Integrate1\output -> Splitter4\input;
+ OneJunction\p => I2\p;
OneJunction1\p => R\p;
- OneJunction2\p => I1\p;
- OneJunction2\p => MGY_b\p1;
- OneJunction2\p => R1\p;
- OneJunction3\flow -> Splitter1\input;
- OneJunction3\p => OneJunction\p;
- RotorAngle\output_a -> MGY_a\r;
- RotorAngle\output_b -> MGY_b\r;
- RotorAngle\output_d -> Se\effort;
- Se\p => OneJunction3\p;
- Splitter1\output -> RotorAngle\omega;
- Square\output -> PlusMinus1\plus;
- Square1\output -> PlusMinus2\plus;
- Square2\output -> PlusMinus1\plus;
- Square3\output -> PlusMinus2\plus;
- Submodel2\a -> MSe_a\effort;
- Submodel2\b -> MSe_b\effort;
+ PD\output -> SignalLimiter2\input;
+ PD1\output -> SignalLimiter1\input;
+ PlusMinus1\output -> PD1\error;
+ PlusMinus2\output -> PD\error;
+ SignalLimiter1\output -> PlusMinus2\plus;
+ SignalLimiter2\output -> Integrate\input;
+ Splitter2\output -> PlusMinus1\plus;
+ Splitter2\output -> Submodel1\input;
+ Splitter3\output -> Integrate1\input;
+ Splitter3\output -> PlusMinus2\minus 688 288 528 288;
+ Splitter4\output -> PlusMinus1\minus 752 384 392 384;
+ Splitter4\output -> Submodel3\angle;
+ Square\output -> Splitter2\input;
+ Submodel3\p => ZeroJunction1\p;
+ ZeroJunction1\p => OneJunction\p;
end;
implementation_end;
]]>
@@ -837,19 +1188,14 @@ equations
- Submodel2\max_a
+ Submodel3\Submodel2\max_a
m/s2
0
-
- u_max
- V
- 0
-
- I1\state_initial
+ C\state_initial
0
@@ -857,11 +1203,32 @@ equations
0
- I\state_initial
+ PD1\state_initial
+ 0
+
+
+ PD\state_initial
+ 0
+
+
+ Submodel1\currentAngle_initial
+ rad
+ 0
+
+
+ Submodel1\omega_initial
0
- RotorAngle\angle_initial
+ Submodel3\I1\state_initial
+ 0
+
+
+ Submodel3\I\state_initial
+ 0
+
+
+ Submodel3\RotorAngle\angle_initial
rad
0
@@ -870,14 +1237,19 @@ equations
time
- I2\p.e
- I2\p.f
- RotorAngle\angle
- omega
- Submodel2\c
- MSe_a\effort
- MSe_b\effort
- Submodel2\s
+ Submodel3\I2\p.e
+ Submodel3\I2\p.f
+ Submodel3\RotorAngle\angle
+ Submodel3\MSe_a\effort
+ Submodel3\MSe_b\effort
+ Submodel3\Submodel2\a
+ Submodel3\Submodel2\b
+ Integrate\input
+ Integrate\output
+ Integrate1\output
+ Square\output
+ PD\error
+ PD1\error
@@ -946,12 +1318,12 @@ equations
true
- true
+ false
false
0.0
- 5.207213548315313
+ 1.8
true
3
@@ -959,15 +1331,15 @@ equations
- -10.0
- 10.0
+ -0.005
+ 0.005
true
2
- -0.05
- 0.05
+ -2.0
+ 8.0
true
2
@@ -992,7 +1364,7 @@ equations
true
- I2\p.e
+ Submodel3\I2\p.e
@@ -1011,7 +1383,7 @@ equations
true
- I2\p.f
+ Submodel3\I2\p.f
@@ -1092,7 +1464,7 @@ equations
0.0
- 5.207213548315313
+ 1.8
true
3
@@ -1100,12 +1472,19 @@ equations
- -0.19999999999999993
- 0.8
+ -0.39999999999999986
+ 1.6
true
2
+
+ -1.5
+ 3.5
+ true
+ 2
+
+
@@ -1126,7 +1505,26 @@ equations
true
- RotorAngle\angle
+ Submodel3\RotorAngle\angle
+
+
+
+ 6076255
+ 1
+ 6076255
+ 0
+ true
+ 1
+ 1
+ 1
+ true
+
+ true
+ time
+
+
+ true
+ Square\output
@@ -1207,7 +1605,7 @@ equations
0.0
- 5.207213548315313
+ 1.8
true
3
@@ -1215,11 +1613,39 @@ equations
- -50.0
- 450.0
+ -60.0
+ 140.0
+ true
+ 1
+
+
+
+ -400.0
+ 600.0
+ true
+ 1
+
+
+
+ -400.0
+ 600.0
+ true
+ 1
+
+
+
+ -400.0
+ 600.0
+ true
+ 1
+
+
+
+ -400.0
+ 600.0
true
1
-
+
@@ -1241,7 +1667,83 @@ equations
true
- omega
+ Integrate\input
+
+
+
+ 6076255
+ 1
+ 6076255
+ 0
+ true
+ 1
+ 1
+ 1
+ true
+
+ true
+ time
+
+
+ true
+ Integrate\output
+
+
+
+ 12553035
+ 1
+ 12553035
+ 0
+ true
+ 1
+ 1
+ 1
+ true
+
+ true
+ time
+
+
+ true
+ Integrate1\output
+
+
+
+ 15086320
+ 1
+ 15086320
+ 0
+ true
+ 1
+ 1
+ 1
+ true
+
+ true
+ time
+
+
+ true
+ PD\error
+
+
+
+ 15790150
+ 1
+ 15790150
+ 0
+ true
+ 1
+ 1
+ 1
+ true
+
+ true
+ time
+
+
+ true
+ PD1\error
@@ -1272,7 +1774,7 @@ equations
16777215
true
1
- Plot
+ Window 2
true
@@ -1322,7 +1824,7 @@ equations
0.0
- 5.207213548315313
+ 1.8
true
3
@@ -1330,32 +1832,32 @@ equations
- -2.5
- 2.5
+ -5.0
+ 5.0
true
2
-
+
- 0.0
- 10.0
+ -5.0
+ 5.0
true
2
- 0.0
- 10.0
+ -5.0
+ 5.0
true
2
- 0.0
- 10.0
+ -5.0
+ 5.0
true
2
-
+
@@ -1377,7 +1879,7 @@ equations
true
- Submodel2\c
+ Submodel3\Submodel2\a
@@ -1396,7 +1898,7 @@ equations
true
- MSe_a\effort
+ Submodel3\MSe_a\effort
@@ -1415,7 +1917,7 @@ equations
true
- MSe_b\effort
+ Submodel3\MSe_b\effort
@@ -1434,7 +1936,7 @@ equations
true
- Submodel2\s
+ Submodel3\Submodel2\b
@@ -1460,28 +1962,28 @@ equations
2
- true
+ false
Window 2
2
4
- StripChart
+ Base
-0.130729 0.114815 0.9375 0.896296
+0.0260417 0.025 0.908854 0.872222
-0 0.0259259 1 1
+0.172917 0.158333 0.841667 0.919444
0.0
- 20.0
+ 1.8
false
false
false
@@ -1585,22 +2087,45 @@ equations
- 10
+ 20
false
- true
+ false
true
false
- true
- 0
+ false
+ 1
0.0
- true
- MultipleRun
+ false
+ Optimization
true
-
- UseEndValue
+ Submodel3\RotorAngle\angle
+ Square\output
+ UseIntegralAbsolute
0.001
BroydonFletcherGoldfarbShanno
+
+ PD1\kp
+ 1.0
+ 50.0
+ Linear
+ Uniform
+ 15.0
+ 3.75
+ 1.0
+ 10.0
+
+
+ PD1\tauD
+ 1.0
+ 50.0
+ Linear
+ Uniform
+ 6.0
+ 1.5
+ 1.0
+ 10.0
+
diff --git a/implementation/library/Motor/stepper_control.emx b/implementation/library/Motor/stepper_control.emx
new file mode 100644
index 0000000..f912944
--- /dev/null
+++ b/implementation/library/Motor/stepper_control.emx
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ 4.8
+1
+ Motor\stepper_control.emx
+ 2020-7-22 15:25:26
+
+';
type Submodel
ports
signal in setpoint {rad} ;
signal out output {rad} ;
end;
implementation bg
submodels
Acceleration_int 648 336
description '
4.3
1
False
Signal\Block Diagram\Integrate.emx
2013-3-8 14:47:42
';
type Integrate
ports
signal in input;
signal out output;
end;
icon bg bottom
figures
rectangle 632 320 664 352 color 0 fill 15132390;
text '∫' 648 336.3 color 16711680 'Lucida Sans' 21 italic;
end;
implementation eq
parameters
real initial = 0; // initial value
equations
output = int (input, initial);
implementation_end;
Acceleration_limit 568 336
description '4.01False
Signal\Block Diagram Non-Linear\SignalLimiter-Limit.emx
2007-9-26 12:47:40
';
type 'SignalLimiter-Limit'
ports
signal in input;
signal out output;
end;
icon bg bottom
figures
group
rectangle 552 320 584 352 color 0 fill 15132390;
line 567.9 324.5 567.9 349 color 0 fill 15132390;
line 555 336.2 580.7 336.2 color 0 fill 15132390;
spline 561.9 343.1 573.9 329.4 color 16711680 fill 15132390 width 2;
spline 573.3 330.2 581.9 329.8 color 16711680 fill 15132390 width 2;
spline 555 343.6 561.9 343.1 color 16711680 fill 15132390 width 2;
end;
end;
implementation eq
parameters
real maximum = 200;
real minimum = -200;
equations
output = limit (input, minimum, maximum);
implementation_end;
plug setpoint 136 336;
plug output 791 336;
PlusMinus1 240 336
description '4.01False
Signal\Block Diagram\PlusMinus.emx
2007-9-27 10:15:13
';
knot PlusMinus
ports
signal knot duplicatable in plus [1];
signal knot duplicatable in minus [1];
signal knot out output [1];
end;
icon bg ellipse
figures
ellipse 232 328 248 344 color 0 fill 16777215;
end;
implementation eq
equations
output = sum (collect (plus)) - sum (collect (minus));
implementation_end;
PlusMinus2 432 336
description '4.01False
Signal\Block Diagram\PlusMinus.emx
2007-9-27 10:15:13
';
knot PlusMinus
ports
signal knot duplicatable in plus [1];
signal knot duplicatable in minus [1];
signal knot out output [1];
end;
icon bg ellipse
figures
ellipse 424 328 440 344 color 0 fill 16777215;
end;
implementation eq
equations
output = sum (collect (plus)) - sum (collect (minus));
implementation_end;
Position_control 296 336
description '
4.0
1
False
Signal\Control\PID Control\Continuous\PD.emx
2008-1-17 10:49:7
';
type PD
ports
signal in error;
signal out output;
end;
icon bg bottom
figures
rectangle 280 320 312 352 color 0 fill 15132390;
text 'PD' 296.5 336.1 color 16711680 18 bold;
end;
implementation eq
parameters
real kp = 4 {}; // Proportional gain
real tauD = 100 {s}; // Derivative time constant: tauD > 0
real beta = 0.4 {}; // Tameness constant: 0 < beta << 1
real maximum = 25;
variables
real state, rate;
equations
rate = (kp * error - output) / (beta * tauD);
state = int (rate);
output = state + kp * error / beta;
implementation_end;
Splitter3 688 336
description '4.0
Signal\Block Diagram\Splitter.emx
2008-01-17 11:28:29
1
False
';
knot Splitter
ports
signal knot duplicatable out output [1];
signal knot in input [1];
end;
icon bg ellipse
figures
ellipse 684.8 332.8 691.2 339.2 color -1 fill 0;
ellipse 683.7 331.7 692.3 340.3 color -1;
terminals
input 688 336 fixed;
end;
implementation eq
equations
collect (output) = input;
implementation_end;
Splitter4 752 336
description '4.0
Signal\Block Diagram\Splitter.emx
2008-01-17 11:28:29
1
False
';
knot Splitter
ports
signal knot duplicatable out output [1];
signal knot in input [1];
end;
icon bg ellipse
figures
ellipse 748.8 332.8 755.2 339.2 color -1 fill 0;
ellipse 747.7 331.7 756.3 340.3 color -1;
terminals
input 752 336 fixed;
end;
implementation eq
equations
collect (output) = input;
implementation_end;
Velocity_control 480 336
description '
4.0
1
False
Signal\Control\PID Control\Continuous\PD.emx
2008-1-17 10:49:7
';
type PD
ports
signal in error;
signal out output;
end;
icon bg bottom
figures
rectangle 464 320 496 352 color 0 fill 15132390;
text 'PD' 480.5 336.1 color 16711680 18 bold;
end;
implementation eq
parameters
real kp = 12 {}; // Proportional gain
real tauD = 10 {s}; // Derivative time constant: tauD > 0
real beta = 0.4 {}; // Tameness constant: 0 < beta << 1
real maximum = 100;
variables
real state, rate;
equations
rate = (kp * error - output) / (beta * tauD);
state = int (rate);
output = state + kp * error / beta;
implementation_end;
Velocity_int 720 336
description '
4.3
1
False
Signal\Block Diagram\Integrate.emx
2013-3-8 14:47:42
';
type Integrate
ports
signal in input;
signal out output;
end;
icon bg bottom
figures
rectangle 704 320 736 352 color 0 fill 15132390;
text '∫' 720 336.3 color 16711680 'Lucida Sans' 21 italic;
end;
implementation eq
parameters
real initial = 0; // initial value
equations
output = int (input, initial);
implementation_end;
Velocity_limit 376 336
description '4.01False
Signal\Block Diagram Non-Linear\SignalLimiter-Limit.emx
2007-9-26 12:47:40
';
type 'SignalLimiter-Limit'
ports
signal in input;
signal out output;
end;
icon bg bottom
figures
group
rectangle 360 320 392 352 color 0 fill 15132390;
line 375.9 324.5 375.9 349 color 0 fill 15132390;
line 363 336.2 388.7 336.2 color 0 fill 15132390;
spline 369.9 343.1 381.9 329.4 color 16711680 fill 15132390 width 2;
spline 381.3 330.2 389.9 329.8 color 16711680 fill 15132390 width 2;
spline 363 343.6 369.9 343.1 color 16711680 fill 15132390 width 2;
end;
end;
implementation eq
parameters
real maximum = 25;
real minimum = -25;
equations
output = limit (input, minimum, maximum);
implementation_end;
end;
connections
Acceleration_int\output -> Splitter3\input;
Acceleration_limit\output -> Acceleration_int\input;
PlusMinus1\output -> Position_control\error;
PlusMinus2\output -> Velocity_control\error;
Position_control\output -> Velocity_limit\input;
setpoint -> PlusMinus1\plus;
Splitter3\output -> PlusMinus2\minus 688 288 432 288;
Splitter3\output -> Velocity_int\input;
Splitter4\output -> output;
Splitter4\output -> PlusMinus1\minus 752 400 240 400;
Velocity_control\output -> Acceleration_limit\input;
Velocity_int\output -> Splitter4\input;
Velocity_limit\output -> PlusMinus2\plus;
end;
implementation_end;
]]>
+
+
+
diff --git a/implementation/library/Motor/stepper_model.emx b/implementation/library/Motor/stepper_model.emx
new file mode 100644
index 0000000..8be3bf6
--- /dev/null
+++ b/implementation/library/Motor/stepper_model.emx
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+ 4.8
+1
+ Motor\stepper_model.emx
+ 2020-7-22 15:25:37
+
+
+ parameters
+ real I_phase = 3.4 {mH};
+ real R_phase = 2.9 {ohm};
+ real u_max = 3.4 {V};
+ real RotorInertia = 5.6e-6 {kg.m2};
+ real StepperMass = 0.29 {kg};
+ real angle_step = 1.8 {deg};
+ real n_phase = 2 {none};
+ real fluxLinkage = 0.0022 {Wb};
+ real detentTorque = 0.01 {N.m};
+variables
+ real omega;
+ real p; // rotor division
+initialequations
+ p = 2 * pi / (2 * n_phase * angle_step);
+ omega = 200;
+
+';
type Submodel
ports
signal in angle;
rotation out p;
end;
implementation bg
submodels
I 560 104
description '
4.2
1
False
Bond Graph\I.emx
2011-11-29 15:55:55
';
type I
ports
power in p;
signal out state;
restrictions
causality preferred in p;
end;
icon bg bottom
figures
text 'I' 560 104 color 0 18 bold;
end;
implementation eq
parameters
real global I_phase;
equations
state = int(p.e);
p.f = state / I_phase;
implementation_end;
I1 608 328
description '
4.2
1
False
Bond Graph\I.emx
2011-11-29 15:55:55
';
type I
ports
power in p;
signal out state;
restrictions
causality preferred in p;
end;
icon bg bottom
figures
text 'I' 608 328 color 0 18 bold;
end;
implementation eq
parameters
real global I_phase;
equations
state = int(p.e);
p.f = state / I_phase;
implementation_end;
I2 752 160
description '
4.2
1
False
Bond Graph\I.emx
2011-11-29 15:55:55
';
type I
ports
power in p;
signal out state;
restrictions
causality preferred in p;
end;
icon bg bottom
figures
text 'I' 752 160 color 0 18 bold;
end;
implementation eq
parameters
real i = 8e-5 {kg.m2};
real global RotorInertia;
equations
state = int(p.e);
p.f = state / (RotorInertia);
implementation_end;
MGY_a 656 160
description '
4.2
1
False
Bond Graph\MGY.emx
2011-11-29 16:03:53
';
type MGY
ports
power in p1;
power out p2;
signal in r;
restrictions
causality constraint equal p1 p2;
end;
icon bg bottom
figures
text 'MGY' 656 160 color 0 18 bold;
end;
implementation eq
equations
p1.e = r * p2.f;
p2.e = r * p1.f;
implementation_end;
MGY_b 656 272
description '
4.2
1
False
Bond Graph\MGY.emx
2011-11-29 16:03:53
';
type MGY
ports
power in p1;
power out p2;
signal in r;
restrictions
causality constraint equal p1 p2;
end;
icon bg bottom
figures
text 'MGY' 656 272 color 0 18 bold;
end;
implementation eq
equations
p1.e = r * p2.f;
p2.e = r * p1.f;
implementation_end;
MSe_a 512 160
description '
4.2
1
False
Bond Graph\MSe.emx
2011-11-29 16:12:33
';
type MSe
ports
electric out p;
signal in effort;
restrictions
causality fixed out p;
end;
icon bg bottom
figures
text 'MSe' 512 160 color 0 18 bold;
end;
implementation eq
variables
real flow;
equations
p.e = effort;
flow = p.f;
implementation_end;
MSe_b 512 272
description '
4.2
1
False
Bond Graph\MSe.emx
2011-11-29 16:12:33
';
type MSe
ports
electric out p;
signal in effort;
restrictions
causality fixed out p;
end;
icon bg bottom
figures
text 'MSe' 512 272 color 0 18 bold;
end;
implementation eq
variables
real flow;
equations
p.e = effort;
flow = p.f;
implementation_end;
plug angle 200 216;
plug p 1472 216;
OneJunction1 840 216
description '
4.2
1
False
Bond Graph\OneJunction.emx
2011-11-29 16:17:51
';
knot OneJunction
ports
rotation knot duplicatable none p [1];
signal knot out flow [1];
restrictions
causality constraint one_out p;
end;
icon bg
figures
text '1' 840 216 color 0 18 bold;
end;
implementation eq
equations
sum (direct (p.e)) = 0;
equal (collect (p.f));
flow = first (p.f);
implementation_end;
OneJunction2 584 160
description '
4.2
1
False
Bond Graph\OneJunction.emx
2011-11-29 16:17:51
';
knot OneJunction
ports
electric knot duplicatable none p [1];
signal knot out flow [1];
restrictions
causality constraint one_out p;
end;
icon bg
figures
text '1' 584 160 color 0 18 bold;
end;
implementation eq
equations
sum (direct (p.e)) = 0;
equal (collect (p.f));
flow = first (p.f);
implementation_end;
OneJunction3 584 272
description '
4.2
1
False
Bond Graph\OneJunction.emx
2011-11-29 16:17:51
';
knot OneJunction
ports
electric knot duplicatable none p [1];
signal knot out flow [1];
restrictions
causality constraint one_out p;
end;
icon bg
figures
text '1' 584 272 color 0 18 bold;
end;
implementation eq
equations
sum (direct (p.e)) = 0;
equal (collect (p.f));
flow = first (p.f);
implementation_end;
OneJunction4 752 216
description '
4.2
1
False
Bond Graph\OneJunction.emx
2011-11-29 16:17:51
';
knot OneJunction
ports
rotation knot duplicatable none p [1];
signal knot out flow [1];
restrictions
causality constraint one_out p;
end;
icon bg
figures
text '1' 752 216 color 0 18 bold;
end;
implementation eq
equations
sum (direct (p.e)) = 0;
equal (collect (p.f));
flow = first (p.f);
implementation_end;
phase_control 512 216
description '4.0
Template\Submodel-Equation.emx
1
False
2007-11-1 22:32:1
False
';
type Submodel
ports
signal in angle;
signal out a;
signal out b;
end;
icon bg
figures
rectangle 472 200 552 232 color 0 fill 15132390;
text 'name' 512 216 color 0 'Clear Sans' 16;
end;
implementation eq
parameters
real global u_max {V};
real global angle_step;
real max_a {m/s2};
variables
real current_angle;
real c,s;
real global p;
boolean hidden eventa, eventb;
equations
a = u_max * (cos (p*angle));
eventa = event(a);
b = u_max * -(sin (p*angle));
eventb = event(b);
current_angle = angle;
implementation_end;
R 608 104
description '
4.2
1
False
Bond Graph\R.emx
2011-11-29 16:35:37
';
type R
ports
power in p;
end;
icon bg bottom
figures
text 'R' 608 104 color 0 18 bold;
end;
implementation eq
parameters
real global R_phase;
equations
p.e = R_phase * p.f;
implementation_end;
R1 560 328
description '
4.2
1
False
Bond Graph\R.emx
2011-11-29 16:35:37
';
type R
ports
power in p;
end;
icon bg bottom
figures
text 'R' 560 328 color 0 18 bold;
end;
implementation eq
parameters
real global R_phase;
equations
p.e = R_phase * p.f;
implementation_end;
R2 824 264
description '
4.2
1
False
Bond Graph\R.emx
2011-11-29 16:35:37
';
type R
ports
power in p;
end;
icon bg bottom
figures
text 'R' 824 264 color 0 18 bold;
end;
implementation eq
parameters
real r = 1.0e-3;
equations
p.e = r * p.f;
implementation_end;
RotorAngle 656 216
description '4.0
Template\Submodel-Equation.emx
1
False
2007-11-1 22:32:1
False
';
type Submodel
ports
signal out output_b;
signal out output_a;
signal in omega {rad/s} ;
signal out output_d;
end;
icon bg
figures
rectangle 616 200 696 232 color 0 fill 15132390;
text 'name' 656 216 color 0 'Clear Sans' 16;
end;
implementation eq
parameters
real global fluxLinkage;
real global detentTorque;
variables
real global p;
real angle {rad};
equations
angle = int(omega);
output_a = -p * fluxLinkage * sin(p * angle);
output_b = p * fluxLinkage * sin(p * angle - pi / 2);
output_d = detentTorque * sin(2 * p * angle);
implementation_end;
Se 752 272
description '
4.2
1
False
Bond Graph\MSe.emx
2011-11-29 16:12:33
';
type MSe
ports
power out p;
signal in effort;
restrictions
causality fixed out p;
end;
icon bg bottom
figures
text 'MSe' 752 272 color 0 18 bold;
end;
implementation eq
variables
real flow;
equations
p.e = effort;
flow = p.f;
implementation_end;
end;
connections
angle -> phase_control\angle;
I2\p <= OneJunction4\p;
MGY_a\p2 => OneJunction4\p;
MGY_b\p2 => OneJunction4\p;
MSe_b\p => OneJunction3\p;
OneJunction1\p => p;
OneJunction2\p <= MSe_a\p;
OneJunction2\p => I\p;
OneJunction2\p => MGY_a\p1;
OneJunction2\p => R\p;
OneJunction3\p => I1\p;
OneJunction3\p => MGY_b\p1;
OneJunction3\p => R1\p;
OneJunction4\flow -> RotorAngle\omega;
OneJunction4\p => OneJunction1\p;
OneJunction4\p => R2\p;
phase_control\a -> MSe_a\effort;
phase_control\b -> MSe_b\effort;
RotorAngle\output_a -> MGY_a\r;
RotorAngle\output_b -> MGY_b\r;
RotorAngle\output_d -> Se\effort;
Se\p => OneJunction4\p;
end;
implementation_end;
]]>
+
+
+