Specifications

Section 8. Processing and Math Instructions
8-23
OR Operator Example
The example sets Msg that depends on the value of variables A, B, and C,
assuming that no variable is a Null. If A = 10, B = 8, and C = 11, the left
expression is True and the right expression is False. Because at least one
comparison expression is True, the OR expression evaluates True
Dim A, B, C 'Declare variables.
A = 10: B = 8: C = 11 'Assign values.
If A > B OR B > C Then 'Evaluate expressions.
Msg = True
Else
Msg = False.
End If
PeakValley (DestPV, DestChange, Reps, Source, Hysteresis)
Used to detect peaks and valleys (local maxima and minima) in a signal.
When a new peak or valley is detected, the new peak or valley and the change
from the previous peak or valley are stored in variables.
Parameter
& Data Type
Enter
DestPV
Variable or
array
Variable or array in which to store the new peak or valley. When a new
peak or valley is detected, the value of the peak or valley is loaded in the
destination. PeakValley will continue to load the previous peak or valley
until the next peak or valley is detected.
DestChange
Variable or
array
Variable or array in which to store the change from the previous peak or
valley. When a new peak or valley is detected, the change from the
previous peak or valley is loaded in the destination. When a new peak or
valley has not yet been reached, 0 is stored in the destination. When Reps
are greater than 1, the array must be dimensioned to Reps+1. The additional
element is used to flag when a new peak or valley is detected in any of the
source inputs. The flag element is stored after the changes [e.g.,
changevar(Reps+1)] and is set to -1 (true) when a new peak or valley is
detected and set to 0 (false) when none are detected.
Reps
Constant
The number of inputs for which to track the peaks and valleys. Each input
is tracked independently. When reps are greater than 1 the source and
DestPV arrays must be dimensioned to at least the number of repetitions;
DestChange must be dimensioned to Reps+1.
Source
Variable or
Array
The variable or array containing the inputs to check for peaks and valleys.
Hysteresis
Constant
Variable or
expression
The minimum amount the input has to change to be considered a new peak
or valley. This would usually be entered as a constant.
The following example uses sine and cosine signal inputs to illustrate the use
of PeakValley with two repetitions. Data Table PV1 stores the peaks and
valleys from the cosine wave. PV2 stores the peaks and valleys from the sine
wave. PV3 stores the peaks and valleys from both.