Skip to content

Blocks.Sources.{Sine, Cosine} do not behave as described #4729

@AHaumer

Description

@AHaumer

The parameter description says (defined in Blocks.Interfaces.SignalSource):
parameter SI.Time startTime=0 "Output y = offset for time < startTime";

Image

Yes the output is equal to offset for time before starTime,
but this parameter causes an additional phase shift:

Image

The implementation is wrong:

Image

I used a frequency of 10 Hz and a startTime of 0.025 s (i.e. a quarter of the period).
The sine actually is shifted to a minus cosine, and the cosine is shifted to a minus sine.

I know that it is not easy to change that behaviour (an addtional correction by parameter phase is needed - very confusing)
but to correct the misleading parameter description, and offer additional blocks with the correct implementation:
y = offset + (if time < startTime then 0 else amplitude*sin(2*pi*f*time+ phase));
instead of
y = offset + (if time < startTime then 0 else amplitude*sin(2*pi*f*(time - startTime) + phase));

Bear in mind that this effects Electrial.Analog.Sources and Electrical.Polyphase.Sources!

Metadata

Metadata

Assignees

No one assigned

    Labels

    L: BlocksIssue addresses Modelica.BlocksbugCritical/severe issue

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions