Tech Note 529 Detail

calculator functions

Affected Products:

CI-6870 NOT A VALID PART NUMBER
PS-2400 SPARKvue Site License

Problem/Symptom:
calculator functions in DataStudio / SPARK / PASCO Capstone

PASCO Solution:

amplitude(peak%, valley%, time, x) Capstone / SPARKvue / DataStudio
The amplitude(peak [% maximum],valley [% minimum], T [s],x) function reports the maximum of the variable x(t) within a time interval T.

The quantities peak% and valley% set thresholds of the percent of the maximum and minimum that x(t) must exceed in order to find the peak, where T is the time range over which the algorithm reports a peak.

For best results, set the T to approximately twice the period of oscillation and adjust the valleys of peak and valley so that they a few percent larger than 100 times the ratio of the noise level to the signal level.

If your function has an offset, use the peakamp() to evaluate the amplitude of the oscillating signal.

and(A, B) Capstone/ DataStudio
Performs a logical and on the results of the sub-expressions A and B: If A and B are both non-zero, then and(A, B) = 1; otherwise, and(A, B) = 0.

avg(x) Capstone / SPARKvue / DataStudio
Returns the average of the data set x from the beginning of the set until the current value. This is sometimes called a running average. The last value reported will be the average of the entire data set.

avgfilter(n, x) Capstone/ DataStudio
Smooths data by averaging N adjacent values to produce a single value.

chgfilter(changeAmount, x) Capstone / DataStudio

Filters input values for x, reporting only those values which represent a change of at least "changeAmount" from the prior value. If changeAmount is 0, then any change (no matter how small) is reported. This filters out a large number of identical (or nearly identical) data values.

derivative(n, y) DataStudio

The derivative(n, y) function is the first order time derivative of the measurement y with respect to its implicit independent variable, which unless redefined by graphing with respect to another parameter, will be time t. The value is determined as (y(ti+n)- y(ti))/(ti+n- ti). It is the slope of a line segment from the first data point in a sequence to the nth data point in a sequence. 2 is the minimum and default value for n.

derivative(n, y, x) Capstone / SPARKvue

The derivative(n, y, x) function is the first order time derivative of the measurement y with respect to x. The derivative is determined as (y(ti+n)- y(ti))/(ti+n- ti). It is the slope of a line segment from the first data point in a sequence to the nth data point in a sequence. 2 is the minimum and default value for n.

first(x) Capstone / SPARKvue / DataStudio
Returns a set of values that are all equal to the first input value for x. The lenght of the set of values is equal to the lenght of the input source, x. This function is useful for subtracting an initial value of a measurement from each later value (e.g. "x - first(x)").

inrange( minimumValue, maximumValue, x) Capstone / DataStudio
Compares the input value (x) with the specified range and returns the value 1 for values in the range (inclusive) and 0 for values outside of the range. This is a quasi-boolean operator.

integral(y) DataStudio

The integral(y) function uses the trapezoidal method to return the numerical integral of the data set, y(x) versus its implicit independent variable x, which, unless redefined by graphing with respect to another parameter, will be time, t.

integral(y, x) PASCO Capstone / SPARKvue

The integral(y, x) function uses the trapezoidal method to return the numerical integral of the data set, y(x).

max(x) Capstone / SPARKvue / DataStudio

Returns the maximum value of the data set x from the beginning of the set until the current value. This is sometimes called a running maximum. The last value reported will be the maximum of the entire data set.

min(x) Capstone / SPARKvue / DataStudio
Returns the minimum of the data set x from the beginning of the set until the current value. This is sometimes called a running minimum. The last value reported will be the minimum of the entire data set.

mod( numerator, denominator ) Capstone / DataStudio

Returns the remainder (a floating-point number) when the numerator is divided by the denominator an integer number of times. The numerator and denominator can each be a constant or an input variable.

not(A) Capstone/ DataStudio
Logical not of the sub-expression A. If A is a non-zero number, then not(A) = 0. If A is exactly 0, then not(A) = 1.

or(A, B) Capstone/ DataStudio
Performs a logical or of the results of the sub-expressions A and B. If either expression A or B is a non-zero number, then or(A, B) = 1; otherwise, or(A, B) = 0.

outputstate( adapter #, adapter port, state ) DataStudio
Sets the state of a digital output channel on a connected PASPORT Digital Adapter. When configuring the Digital Adapter, the Relay Control option must be selected. adapter # = the number of the connected digital adapter (1 for the first, 2 for the second, etc...) adapter port = the number of the port on the adapter (i.e 1 or 2) state = a variable or sub-expression If the state is a non-zero value, then the relay connected to the digital adapter port will be energized ("on"). If the value of state is exactly zero, then the relay is not energized ("off").

outputswitch( A ) DataStudio
Controls the ON/OFF state of the Signal Generator window when using a ScienceWorkshop interface (SW700 or SW750). If the result of the sub-expression A is non-zero, then the Signal Generator is turned ON. Otherwise, the signal generator is turned off. The waveform, amplitude or voltage settings of the Signal Generator are unaffected by this command.

outputvoltage( A ) DataStudio
Controls the voltage (DC) or amplitude (waveform) of the Signal Generator window when using a ScienceWorkshop interface (SW700 or SW750). The result of the sub-expression A is used to set the output voltage or amplitude. Note: The parameter to outputvoltage will be limited to the range of +/-5V (without a power amplifier), or +/-10V (with a power amplifier).

peakamp(T [s], x ) Capstone / SPARKvue / DataStudio

Looks at the input data (x) every T seconds and reports a single value representing half the distance between the minimum and maximum value. The peakamp function is useful for reducing fast-sampled data of a harmonic phenomenon to a small number of points representing the "average amplitude".

period (time, x) DataStudio
period(peak%, valley%, time, x) SPARKvue / Capstone
The period(peak%,valley%,time,x) function determines the period of the variable "x", assuming that the values of "x" are oscillating (i.e., going through cycles). Period detects peaks in the data and gives you the time between peaks. The period function is constantly looking at data values and keeping track of the total range of the data.

The values peak%, valley%, and time are important constants that you type in. These constants allow you to "tune" the peak detection algorithm to the characteristics of your data. The quantities "peak" and "valley" set the thresholds to finding the peak, and "time" is the time range over which the algorithm is detecting a peak. For example, if you set peak = 10, valley =10, and time =1s then the period function determines the period of oscillation when the value of data goes above the top 10 percent and below the bottom 10 percent of the total data range of the 1 s time interval. Since the algorithm keeps a running tab of the times in which a peak occurred, the period is easily calculated. Once it has determined the period, the value is recorded and the algorithm begins to detect a peak and a valley for the next 1 second time interval. PASCO recommends you set "time" to approximately twice the period of oscillation.

It is important to select the most appropriate values for "peak" and "valley." If the values of "peak" and/or "valley" are too high, the algorithm might not detect some peaks or valleys. If the values of "peak" and/or "valley" are too low, the algorithm might detect extra peaks in your data.

smooth(n, x)
SPARKvue/ DataStudio

The smooth(n,x) function is a trailing average of n consecutive values of xi. For example, if you type "7" for the value of "n", then the average is carried out on data points 1 through 7, 2 through 8, 3 through 9 etc.

Capstone
The smooth function and the graph smoothing tool in Capstone use a center-weighted Savitzky–Golay smoothing algorithm of degree 4, where the value displayed in the smoothing slider n is an odd value representing the total number of values in the original data set that are used in determining each smoothed value.

Coefficient weights are used, such that the values closest to the value being smoothed usually have a greater weight, and thus a greater influence on the determining the resulting smoothed value. These coefficients are symmetric unless there are fewer than (n-1)/2 unsmoothed values to both sides of the smoothed value.

timefilter( timeOffset, x ) Capstone / DataStudio

Filters input values for x, subtracting timeOffset from the time of each point. Useful for time-shifting data on the X axis, especially when the event of interest does not occur at time zero. The Y values are unchanged.

timeof(x) Capstone / DataStudio
The timeof(x) function gives the time or other independent variable that corresponds to the value of the variable x. In DataStudio, this is the only way of referencing the time value of a variable in a calculation.

[These functions are not found in the drop down menu--they must be manually entered into the expression editor window in the DataStudio Calculator]

A > B Capstone / DataStudio
If the value of A is strictly greater than the value of B, then A > B = 1; otherwise, A > B is 0.

A < B Capstone / DataStudio
If the value of A is strictly less than the value of B, then A < B = 1; otherwise, A < B is 0.


Creation Date: 06/1/2005
Last Modified: 06/4/2014
Mod Summary: