The Comparator Block
Parameters:
vU |
upper output value |
vL |
lower output value |
Description:
This block compares two input signals and produces an output event carrying a value that depends on the result of the comparison.
The user is invited to specify an "upper" and a "lower" output value (vU and vL). Then, if the first input signal is bigger than the second one, the output takes the value of vU, and vL otherwise.
It is the only component that in case of concurrent transitions (cf. the ModelicaDEVS Theory section) executes the external transition before the internal one. This has the following reason: at each event instant, the comparator estimates the moment when the two input signals will cross the next time (the estimation makes use of the linear and quadratic terms of the Taylor series expansion). The chronological distance between the current and the next event is represented by the variable sigma. Suppose now the time instant when the two signals are supposed to cross has arrived. If simultaneously, one of the signals updates its value, it is of course more advantageous to use this new, true value instead of relying on the estimated one. Therefore, in case of concurrent internal and external transitions, the external transition is more important to process, because the values on which the scheduling of the internal transition has been calculated may have become outdated.
Note that because of the reversed priority order of the internal and the external transition, the Comparator block may not be connected in a cycle with itself, unless there is another component in between that breaks the algebraic loop (again, see the Theory section for details on algebraic loops).
The picture below shows the output of a Comparator (red) that compares a sine signal (blue) and the output of a Ramp block (green) run in QSS1-mode, such that there are output events during the ramp. vU and vL have been set to 2 and 1.5 respectively.
Generated at 2024-12-21T19:25:56Z
by OpenModelicaOpenModelica 1.24.3 using GenerateDoc.mos