Campbell Scientific CR5000 Measurement and Control Module User Manual

Page 192

Advertising
background image

Section 8. Processing and Math Instructions

8-20

If bit in

And bit in

The result

expr1 is

expr2 is

is

0

0

0

0

1

1

1

0

1

1

1

1

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)

PeakValley is 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 inputs to track the peaks and valleys for. 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.

Advertising