-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
79 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
docs/modules/ROOT/pages/reference/misc/schmitt_trigger.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
= Schmitt Trigger | ||
|
||
include::../../common.adoc[] | ||
|
||
== Overview | ||
|
||
The output of a simple comparator is determined by its inputs. The output is `1` if the input signal is greater than the reference signal plus a specified hysteresis. Otherwise, the output is `0` if the input signal is less than the reference signal minus the specified hysteresis. | ||
|
||
== Include | ||
|
||
```c++ | ||
#include <q/fx/schmitt_trigger.hpp> | ||
``` | ||
|
||
== Declaration | ||
|
||
```c++ | ||
struct schmitt_trigger | ||
{ | ||
schmitt_trigger(float hysteresis); | ||
schmitt_trigger(decibel hysteresis); | ||
|
||
bool operator()(float s, float ref); | ||
bool operator()() const; | ||
}; | ||
``` | ||
|
||
== Expressions | ||
|
||
=== Notation | ||
|
||
`st`, `a`, `b` :: Objects of type `schmitt_trigger`. | ||
`h` :: Floating point value representing hysteresis. | ||
`hdb` :: Object of type `decibel` representing the hysteresis in decibels. | ||
`sps` :: Floating point value representing samples per second. | ||
`s` :: Input sample. | ||
`ref` :: A reference signal. | ||
|
||
=== Constructor | ||
|
||
=== Constructors and Assignment | ||
|
||
[cols="1,1"] | ||
|=== | ||
| Expression | Semantics | ||
|
||
| `schmitt_trigger(h)` | Construct a `schmitt_trigger` with specified hysteresis, `h`. | ||
| `schmitt_trigger(hdb)` | Construct a `schmitt_trigger` with specified hysteresis, `h` (in dB). | ||
| `a = b` | Assign `b` to `a`. | ||
| `a = s` | Set the latest result to `s`. | ||
|=== | ||
|
||
NOTE: C++ brace initialization may also be used. | ||
|
||
[cols="1,1,1"] | ||
|=== | ||
| Expression | Semantics | Return Type | ||
|
||
| `st()` | Return the latest result. | `float` | ||
| `st(s, ref)` | Processes the input sample `s`. The | ||
output is `1` if the input signal `s` | ||
is greater than the reference signal | ||
`ref` plus the specified hysteresis. | ||
Otherwise, the output is `0` if the | ||
input signal `s` is less than the | ||
reference signal `ref` minus the | ||
specified hysteresis. | `bool` | ||
|=== | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters