Open nl78 opened 1 year ago
Can you share the model and some code to reproduce the problem?
Steps to reproduce:
buggy model: pulse_timebased.slx
ts=5ms
, compile it as FMU5ms
: output signal period is 2 secs (as expected)10ms
: output signal period is 4 secs ! (2 secs is expected)working model: pulse_externaltime.slx
ts=5ms
, compile it as FMU5ms
: period is 2secs (as expected)10ms
: period is still 2 secs (as expected).Matlab version: 2020b update 8
NOTE: setting outport sample time of pluse_timebased.slx to 0
(instead of default -1
) seems to fix the issue !?
After investigations: the first pusle generator model is 'discrete'. At compilation time, rtmGetT
is not available. In fmi2function.c
this case is handled by calling only once DoFixedStep(s_instance->S);
which may be insufficient.
I suggest a patch like:
#ifdef rtmGetT
time_T tNext = currentCommunicationPoint + communicationStepSize;
double epsilon = (1.0 + fabs(rtmGetT(s_instance->S))) * 2 * DBL_EPSILON;
while (rtmGetT(s_instance->S) < tNext + epsilon)
#else
const int steps = ceil(communicationStepSize / FUNDAMENTAL_STEP_SIZE);
for(int i=0; i<steps; i+=1)
#endif
And add FUNDAMENTAL_STEP_SIZE
definition via fmiwrapper.inc
. It works well when communication step size is greater or equal to internal fmu step size. Otherwise, this patch does not help.
Hello, I face a tricky issue with a very simple model:
This simple pulse is configured with 2secs period. Matlab solver is Fixed Discrete with ts=0.005s :
Using FMIKit-3.1, the pulse period depends on communication step time managed by FMPy. Note that the paramaters exposed by FMU are:
To workaround this issue, I introduced Clock block:
With this model, pulse period is always 2secs whatever the communication step time. Note that the parameters exposed by FMU are slightly different:
Is it a FMIKit issue? a Simulink issue?
kind regards