Skip to content

Add sampletime() and clock() operators #2687

@baggepinnen

Description

@baggepinnen

To implement generic discrete-time components, we need operators that return the sample time and the clock associated with an equation, without these being explicitly specified in the component. As an example, consider the component below, where the clock is unspecified. MTK already has the capability of inferring the clock for the z = ShiftIndex() and the equation y(z) ~ k*(u(z) - u(z-1)) / sampletime(), this feature request is to add support for inferring the value of the sampletime() to be sampletime(inferred_clock).

@mtkmodel DiscreteDerivative begin
    @extend u, y = siso = SISO()
    @parameters begin
        k = 1, [description = "Gain"]
    end
    begin
        z = ShiftIndex()
    end
    @equations begin
        y(z) ~ k*(u(z) - u(z-1)) / sampletime()
    end
end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions