QUOTE(wagner @ Jun 6 2006, 09:40 AM)

Hello Meppel,
a parameter variable is like a constant value that can be assigned only before running the simulation. That's why your model doesn't work with period as parameter.
The problem with the "when-condition must be discrete value" is the sample command. The sample command can only take a constant value as its argument. You have to replace the sample command and implement your own functionality.
I've done it in this sample model.
CODE
model FrequencySaw
annotation (uses(Modelica(version="2.2.1")), Icon);
Modelica.Blocks.Interfaces.RealInput n annotation (extent=[-100,-10; -80,10]);
Modelica.Blocks.Interfaces.RealOutput y annotation (extent=[80,-10; 100,10]);
parameter Real amplitude=1 "Amplitude of saw tooth";
parameter Real offset=0 "Offset of output signals";
parameter Modelica.SIunits.Time startTime=0.1 "Output = offset for time < startTime";
Modelica.SIunits.Time T0(final start=startTime) "Start time of current period";
Modelica.SIunits.Time period(final min=Modelica.Constants.small) "Time for one period";
equation
if (abs(1/(n*60/amplitude))>Modelica.Constants.small) then
period=1/(n*60/amplitude);
else
period=Modelica.Constants.small;
end if;
when time>T0 + period then
T0 = time;
end when;
if (time<startTime) then
y=offset;
else
y=offset+semiLinear(amplitude,(time- T0)/period,(time- T0)/period);
end if;
end FrequencySaw;
I hope it does what you wanted to. You just have to be careful that you don't attach a period of zero because then you get a division by zero error.
Regards
Florian
Hello wagner,
many thanks, your version works well... I also found solution during weekend...
Regards Meppel
QUOTE(wagner @ Jun 6 2006, 09:40 AM)

Hello Meppel,
a parameter variable is like a constant value that can be assigned only before running the simulation. That's why your model doesn't work with period as parameter.
The problem with the "when-condition must be discrete value" is the sample command. The sample command can only take a constant value as its argument. You have to replace the sample command and implement your own functionality.
I've done it in this sample model.
CODE
model FrequencySaw
annotation (uses(Modelica(version="2.2.1")), Icon);
Modelica.Blocks.Interfaces.RealInput n annotation (extent=[-100,-10; -80,10]);
Modelica.Blocks.Interfaces.RealOutput y annotation (extent=[80,-10; 100,10]);
parameter Real amplitude=1 "Amplitude of saw tooth";
parameter Real offset=0 "Offset of output signals";
parameter Modelica.SIunits.Time startTime=0.1 "Output = offset for time < startTime";
Modelica.SIunits.Time T0(final start=startTime) "Start time of current period";
Modelica.SIunits.Time period(final min=Modelica.Constants.small) "Time for one period";
equation
if (abs(1/(n*60/amplitude))>Modelica.Constants.small) then
period=1/(n*60/amplitude);
else
period=Modelica.Constants.small;
end if;
when time>T0 + period then
T0 = time;
end when;
if (time<startTime) then
y=offset;
else
y=offset+semiLinear(amplitude,(time- T0)/period,(time- T0)/period);
end if;
end FrequencySaw;
I hope it does what you wanted to. You just have to be careful that you don't attach a period of zero because then you get a division by zero error.
Regards
Florian