Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out intrinsics for hysteresis #2

Open
Keno opened this issue Aug 1, 2024 · 2 comments
Open

Figure out intrinsics for hysteresis #2

Keno opened this issue Aug 1, 2024 · 2 comments

Comments

@Keno
Copy link
Contributor

Keno commented Aug 1, 2024

The following was proposed:

p = finite_state(Bool)
p[]::Bool
event!(cond, dir=:both) do
     transition!(p, !p[])
end
@Keno
Copy link
Contributor Author

Keno commented Aug 2, 2024

Thinking about this some more, I don't think I like the callback versions, so maybe:

p = discvar(Bool)
transition!(cond, :both, p, !p)

@Keno
Copy link
Contributor Author

Keno commented Oct 30, 2024

Final design. Keep discvar (renamed discrete) and add:

"""
	ett!(on_change, assign, val)

Declare an edge-triggered transision. When `on_change` (in the discrete domain)
changes value (under egality), the discrete variable `assign` is set to `val`.
The change to `assign` may trigger further edge-triggered transitions. It is
an error for multiple transitions to trigger simultaneously, unless one such
transition strictly dominates the other.

Note: `assign` must be a bare discrete variable (unlike ordinary continuous equations
where the assignment is inferred or non-linearly solved).
"""
ett!

"""
	pre(x)

When evalutated in the continuous domain, this intrinsic is equivalent to
the identity function. When evaluated at event triggers, this function returns
the value of `x` using the left-limit of all discrete and continuous algebraic
variables.
"""
pre

"""
	threshold(x)

Detects zero-crossing of the continuous-domain expression `x`. Returns `true`
when `x` is about to be `> 0` and false otherwise, generating an edge-trigger
event at the crossing. Note that the actual value of `x` at the event-trigger
may have a small difference from `0` (in either direction) according to the
solver tolerance.
"""
threshold

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant