dataTaker - Data Loggers, Powerful and Flexible Data Acquisition & Data Logging Systems

Channel Variables and Calculations

The dataTaker data loggers have a powerful calculations facility to evaluate expressions in real time. The results of calculations can be returned to the host computer, logged to the internal memory or memory card, displayed, used in Alarms, used to set the initial count of counters, used to set the range of System Timers, etc.

dataTaker expressions comprise Channel Variables, constants and intrinsic functions only. While input channels cannot be specified directly in expressions, the data from input channels is first read and assigned to Channel Variables which in turn are used in an expression.

Calculations provide many opportunities in dataTaker applications, including

computation of parameters from single input channel data which involves fixed expressions

support for sensors with calibrations which cannot be evaluated by Polynomials or Spans

allow parameters which involve a number of different real time data to be evaluated in real time

the volume of stored data can be reduced by combining the readings from a number of input channels in real time

allow alarms to be used for parameters which involve a number of different real time data

allow alarm setpoints, counter ranges, System Timer ranges, etc. to be dynamically altered in real time

dynamically changing the High Speed Counter 1 output channel frequency in real time

manage digital output channels by Boolean logic

Calculations can be used in applications for an infinite number of purposes. Some examples of categories for the use of calculations in applications are listed below as a guide

calculate the statistical data for a parameter from a number of distributed sensors, for example spatial average and range of temperature

calculate corrected data for parameters by adjusting for variations in influencing factors, for example correcting fluid flow by Boyles Law

calculate derived parameters from fundamental data, for example wind sigma from wind speed and direction

calculate integrals involving multiple input channel data, for example spatial heat sum

calculate elapsed times, down times, up times, etc.

calculate theoretical time profiles for a parameter for comparison with measured time profiles, for example temperature rise profile for a furnace

All calculations are performed in the Data Schedules, in the same way as the scanning of input channels.

When calculations are performed in Data Schedules, data can be sequentially collected from the input channels and then used in subsequent calculations in each pass. This procedure will occur each time the Schedule triggers.

Calculations can also be performed in the Immediate Schedule, in which case the calculation is only performed once when the schedule is entered. This operation is similar to performing calculations at the command level, and is the basis of using calculations to initialise Channel Variables, to run calculations from Alarms and to run calculations directly entered by the host.

All calculations involve the use of Channel Variables, to pass real time input channel data to the expression, and/or to receive results of the expression evaluation.

Channel Variables

The dataTaker has 100 internal Channel Variables which are used for temporary storage of data. The Channel Variables are floating point registers within the dataTaker memory, and are cleared when the dataTaker is initially powered up, is hardware reset or executes the RESET command.

Channel Variables are used for a number of purposes including

to receive the data from input channels by assignment at the time of scanning of the channels

to pass input channel data to expressions

to receive the results of expression evaluations

to pass input channel data and results of expressions to the host computer, the internal memory and memory cards, and the display.

to pass input channel data and results of expressions to alarms, counters, System Timers, etc.

The Channel Variables are treated in the same manner as physical input channels, and are included in Immediate Schedules and Triggered Schedules to return the Channel Variable data to the host, to log the Channel Variable data, and to display the Channel Variable data.

The data formatting functions of the channel options, the Switch commands and the Parameter commands can also be applied to the Channel Variables to specify the format of returned real time and stored data.

There are 100 Channel Variables available in the dataTaker, which are numbered 1 to 100.

The general formats for the Channel Variables are as follows

nCV(options)
n..mCV(options)

where

CV               is the Channel Variable identifier
n                 is a single Channel Variable number
n..m             is a sequence of Channel Variables numbers
(options)        are optional channel options to be applied

The channel options apply to situations where the Channel Variable is used to return, log or display data previously assigned either from input channel scans or expression evaluation.

Units Text for Channel Variables

Channel Variables do not have directly definable units text, because of the infinite range of engineering units which can be appropriate to the results of calculations.

However defined units text can be applied to Channel Variables using ëdummyí Polynomials, as illustrated in the following example

Y1=0,1"KWh"
BEGIN
 RA5M
  5CV(Y1,"Power Consumption",FF2)
END

where in this case the Polynomial does not change the actual value of the Channel Variable, but adds the units text. The data returned from the Channel Variable will be similar to

Power Consumption  57.32 KWh

The advantage of this approach is that the Polynomial can also be used to re-scale the value of the Channel Variable if required.

Note also that Channel Options can also be used to name the Channel Variable and format the returned data.

Assigning Input Channel Data to Channel Variables

Input channels cannot be directly included in expressions. The input channel data must first be assigned to Channel Variables, which are then used in expressions. The Channel Variables effectively pass the data to the expression evaluator.

The assignment of input channel data to Channel Variables is performed by including the Channel Variable, with an assignment operator, as a Channel Option to the input channel to be read.

The input channel specification complete with the Channel Variable assignment is included in Schedules, which control the periodic scanning of the input channel and the assignment of the data to the Channel Variable.

The data from input channels is assigned to Channel Variables in a number of ways.

Direct Assignment

               =nCV     assign the input channel reading to the Channel Variable, overwriting any previous value.

Addition Assignment

               +=nCV   add the input channel reading to the value stored in the Channel Variable.

Subtraction Assignment

               ñ=nCV   subtract the input channel reading from the value stored in the Channel Variable.

Multiplication Assignment

                    S=nCV   multiply the value stored in the Channel Variable by the input channel reading.

Division Assignment

               /=nCV   divide the value stored in the Channel Variable by the input channel reading.

Using DeTransfer, input channel data is transferred to Channel Variables by commands for example

1TK(=3CV)

instructs the dataTaker to return the temperature read for a type K thermocouple connected to analog input channel 1, and assign the reading to Channel Variable 3 replacing any previous value.

2C(R,+=9CV)

instructs the dataTaker to read low speed counter channel 2, reset the counter when it is read, and add the count to the value which is stored in Channel Variable 9 (this procedure overcomes the problem of the 16 bit low speed counter registers overflowing at 65535 counts).

2F(/=23CV)

instructs the dataTaker to read the frequency on analog channel 2, and divide the value stored in Channel Variable 23 by the value of the new reading.

The assignment of input channel data to Channel Variables is made when the embracing Schedule (RA, RB, RC, RD, RX) executes. For example

BEGIN
 RA10S
  1TT(+=1CV)
END

in this case the temperature sum will accumulate every 10 seconds.

Using DeLogger, input channel data can be assigned to Channel Variables by the following program in the Program Builder. Firstly define the input channel , then right click on the channel icon and select Channel Options:Assign to CVÖ This opens the Channel Properties dialog with the CV tab in view. Enter the number of the Channel Variable to receive the reading, and select the modifier (operator) to use. The ëNoneí modifier means direct assignment.

 

 

 

 

 

If the input channel specification contains other data manipulation Channel Options such as Polynomials, Spans, Intrinsic Functions, differences and integrals, these have precedence over assignment to Channel Variables. The Channel Variable receives the result of all data manipulations of the input channel data.

This is illustrated by the following program example

BEGIN
 RA5M
  3V(Y1,DF,=12CV)
END

where the Channel Variable is assigned the difference between this and the previous channel reading which have been converted by the polynomial.

The order of application of the various data manipulation functions is maintained irrespective of the order of their listing in the channel options list. The assignment of channel data to Channel Variables always follows processing of the data manipulation, such that the Channel Variable receives the final result.

Assigning Statistical Data to Channel Variables

The various statistical data that is produced by the Statistical Sub Schedule can also be assigned to Channel Variables. When a Channel Variable is included as a Channel Option for input channels that are statistically scanned, then the statistical result is assigned to the Channel Variable rather than the individual data readings. This is illustrated by the following example

BEGIN
 RS5S
 RA10M
  3V(AV,=1CV)(MX,=2CV)(MN,=3CV)
END

in which the voltage connected to analog input channel 3 is sampled every 5 seconds (RS5S). Every 10 minutes (RA10M) the average, the minimum and the maximum values are calculated and assigned to the Channel Variables 1CV, 2CV, and 3CV respectively.

Assigning Results of Expressions to Channel Variables

Results of expressions are generally assigned to Channel Variables. The Channel Variable is entered as the component to the left of the assignment operator of the equation, and the expression is entered as the component to the right of the assignment operator

Using DeTransfer, the result of expressions is assigned to the Channel Variables for example

3CV=(1+COS(2CV))*1.141

where the expression is evaluated and assigned to 3CV.

Using DeLogger, the result of expressions is assigned to the Channel Variables in the Program Builder. Firstly define the Channel Variable to receive the result of the expression

 

 

Right click on the Expression icon, and enter the expression and Channel Variable number

 

 

The use of Channel Variables with expressions is discussed in detail in the Calculations section below.

Assigning Channel Variables to Channel Variables

Channel Variables can be assigned to other Channel Variables for various purposes including to temporarily store data, to carry the data to different calculations, to reverse the sign of the data, etc.

Channel Variables can be assigned to other Channel Variables by either of two methods.

ï one Channel Variable can be assigned to another Channel Variable by an expression, as illustrated by the following examples

1CV=2CV
15CV=-23CV

ï one Channel Variable can be assigned to another Channel Variable by specifying the second Channel Variable as a channel option of the first Channel Variable, as illustrated by the following examples

9CV(=3CV)
15CV(+=12CV)

where in each case the value of the Channel Variable specified as the 'channel' is assigned the value of the Channel Variable specified as the channel option.

The second example illustrates the use of the assignment operators which are available for assignment via channel options, and is equivalent to the expression

12CV=12CV+15CV

Channel Options for Channel Variables

Channel Options can be used with Channel Variables to perform data manipulation, scaling, statistical, data destination and data formatting functions that are available for the input channels. The Channel Options that are appropriate to Channel Variables are listed below

reset (R) the Channel Variable to zero. For example

12CV(R)

ï scale the value stored in Channel Variables by a scale factor (f.f), Polynomials (Yn), Spans (Sn) or Intrinsic Functions (Fn). For example

52CV(Y3)

18CV(10.5,F3)

ï return the difference (DF), rate of change (RC and RS) or integral (IB) between successive assignments to Channel Variables. For example

5CV(DF)

15CV(IB)

ï return the average (AV), standard deviation (SD), minimum (MN), maximum (MX), date of minimum and maximum (DMN and DMX), the time of minimum (TMN and TMX) and histogram (Hx:y:n..mCV) for Channel Variables. For example

16CV(AV)(SD)(MN)(MX)

7CV(H:-100:100:20..30CV)

ï assign unique names to Channel Variables. For example

33CV("Corrected Fuel Flow")

set the numeric format of Channel Variable data to Floating Point (FFn), Exponential (FEn) or Mixed (FMn). For example

52CV(FF2)

set destinations for the data from Channel Variables for not returned (NR), not logged (NL), not displayed (ND). For example

27CV(NL,ND)

set Channel Variables as working or intermediate variables (W) for which data is to be retained internally for further calculation, use in alarms, etc. For example

BEGIN
 R1M
  1CV(W)=(5CV+6CV)/2
 ALARM3(1CV>125)"Oven overheating"
END

ï define a bar graph (BGx:y) for displaying Channel Variable data. For example

8CV(BG0:100,"Slow    %    Fast")

Using the Channel Variables

Channel Variables are used in the same manner as input channels in Data Schedules, the Statistical Sub Schedules and Alarms. Assignment to Channel Variables, returning of Channel Variable data, logging of Channel Variable data and displaying of Channel Variable data is carried out when the associated Schedule triggers and executes.

Channel Variables do not have user definable units text, however the polynomials can be used to append units text to returned, logged and displayed data (See Units Text for Channel Variables above).

Using Channel Variables in Schedules

Channel Variables are only processed whenever the embracing Data Schedule or Alarm Schedule runs. When Channel Variables are included in Schedules then data can be sequentially assigned to the Channel Variables from the input channels, and used in subsequent calculations in each pass. This procedure will occur each time that the Schedule runs.

When Channel Variables are included in Immediate Schedules, the Channel Variable is processed once when the schedule is entered. This is similar to performing calculations at the command level, and is the basis of initialising Channel Variables, assigning values to Channel Variables from Alarm, and assigning values to Channel Variables directly from the host.

Using DeTransfer, a program using Channel Variables in a Schedule is illustrated below

Y1=0,1"Deg C"
BEGIN
 RA2M
  1TT(=6CV,W)
  2TT(=7CV,W)
  5CV("Mean Temp",Y1,FF1)=(6CV+7CV)/2
END

which measures two temperatures and temporarily saves the data in 6CV and 7CV, calculates the average temperature and assigns this to 5CV, and returns 5CV. This sequence repeats every 2 minutes, and returns data each time the Schedule runs that is similar to

Mean Temp  23.5 Deg C
Mean Temp  24.6 Deg C
Mean Temp  27.1 Deg C

Note :  The Working (W) Channel Option is used to define working steps where the temperatures are measured and assigned to Channel Variables for use in the later calculation. If the Wchannel option is omitted from these steps, then the raw temperature data will also be returned to the host. A dummy Polynomial is used to append units text to the average temperature data.

Using DeLogger, this same program is entered into the Program Builder as follows

 

 

DeLogger does not provide a way to name or label a Channel Variable channel.

Using Channel Variables as the Test Data in Alarms

Channel Variables can be used in the Alarms as the test data that is tested for alarm state (See Section III - Alarms). The use of Channel Variables as the test data for Alarms allows the results of calculations to be tested in alarms for range, etc.

The following DeTransfer program for example measures two temperatures and calculates the average temperature, which is then tested in an alarm.

BEGIN
 RA5S
  1TT(=6CV,W)
  2TT(=7CV,W)
  5CV(W)=(6CV+7CV)/2
 RZ5S
  ALARM1(5CV>105)"Over Temperature"
END

Note that in this type of program the Schedule (RA5S) in which the raw data is collected and the calculation performed must execute at the same interval as the Alarm Schedule (RZ5S).

The Alarm Schedule is executed after the Data Schedule in each scan, and so data passed forward in this way is appropriate to the current test for the alarm.

Using DeLogger, this alarm step can be added to the program above in the Program Builder as follows

 

 

Channel Variables can also be used in Alarms to test data from the same input channel in several alarms. This increases the speed of alarm processing, because the input channel only needs to be read once rather than for each alarm.

This use of Channel Variables in this way is illustrated in the following DeTransfer example

BEGIN
  ALARM1(1V(=1CV)>0.5)"Over 0.5 Volts"
  ALARM2(1CV>0.6)"Over 0.6 Volts"
  ALARM3(1CV>0.7)"Over 0.7 Volts"
END

This approach can also be used to test input channel data which is continuously varying.

Using Channel Variables as Setpoints in Alarms

Channel Variables can also be used within the Alarms as setpoints, against which the test data is tested for alarm state (See Section III ñ Alarms). This allows the results of calculations to be used as range limits that can be dynamically changed as the program runs, for the testing the test data.

The following program for example measures two temperatures and tests one against the other in an alarm.

BEGIN
 RA5S
  1TT(=6CV,W)
  2TT(=7CV,W)
 RZ5S
  ALARM1(6CV>7CV)"Uneven Temperature"
END

Note that in this type of program the Data Schedule (RA5S) in which the raw data is collected must execute at the same interval as the Alarms Schedule (RZ5S).

Using Channel Variables to Transfer Statistical Data to Alarms

Statistical data (AV, MN, MX, SD, etc) cannot be tested in an Alarm directly (See Section III ñ Alarms). To test statistical data, the data must first be obtained in a Data Schedule/Statistical Sub Schedule, and assigned to a Channel Variable which is then tested in an Alarm.

This same approach must be used when testing difference, rate and integral data in Alarms.

The following program example demonstrates this approach

BEGIN
 RS5S
 RA1M
  3PT385(SD,=1CV,W)(AV,=2CV,W)
 RZ1M
  ALARM1(1CV>1.0)"Excess Variability"
  ALARM2(2CV>125)"High Temperature"
END

The raw data is collected every 5 seconds (RS5S), and the statistical data is calculated every 1 minute (RA1M). Note that in this type of program the Data Schedule (RA1M) in which the statistical data is calculated must execute at the same interval as the Alarms Schedule (RZ1M).

Using Channel Variables with Date and Time

Date, Time and System Timers of the real time clock can be assigned to Channel Variables for temporary storage of time points, and for use in calculations based on time such as elapsed time, down time, up time, rates, etc.

Date is stored in Channel Variables as the number of days elapsed since 01/01/1989. This format is irrespective of the Date format defined by the Parameter31 command.

Time of day is stored in Channel Variables as the number of seconds elapsed since the last midnight, or as the number of seconds for the current day. This format is irrespective of the Time format defined by the Parameter39 command.

Data for each of the System Timers is stored in Channel Variables as the number of counts registered in the particular timer, in the units of time for the particular timer.

Assigning Date, Time and System Timers to Channel Variables is illustrated in the following examples

D(=1CV)
T(=2CV)
2ST(=3CV)

The following program illustrates the use of Channel Variables to calculate the on time and the off time for a switch monitored by a Schedule Triggered by Digital Event

1CV(W)=0              'Clear ON time
2CV(W)=0              'Clear OFF time
T(=6CV,W)             'Program start time
BEGIN
 R1+E                 'Switch turned ON
  T(=5CV,W)
  2CV=2CV+(5CV-6CV)   'Total OFF time
 R1-E                 'Switch turned OFF
  T(=6CV,W)
  1CV=1CV+(6CV-5CV)   'Total ON time
END

This example program is only suitable for use over a single day. If the program runs longer than one day, then calculation of elapsed times will have to account for the Time resetting to zero at midnight.

 

The dataTaker can evaluates expressions in real time. The results of these calculations can be returned to the host computer, logged into memory, displayed, used in Alarms, used to set initial count of counters, used to set the range of System Timers, etc.

The dataTaker calculations are based on expressions which can contain channel variables, numeric constants and mathematical functions.

Input channels cannot be specified directly in expressions. The data from input channels must first be sampled and assigned to Channel Variables, which in turn can be used in the expressions (see Channel Variables above).

The use of calculations provides many opportunities in applications, including

computation of parameters from single input channel data which involves fixed expressions

support for sensors with calibrations which cannot be evaluated by polynomials or spans

allow parameters which involve a number of different real time data to be evaluated in real time

the volume of stored data can be reduced by combining the readings from a number of input channels in real time

allow alarms to be used for parameters which involve a number of different real time data being calculated to a single value

allow alarm setpoints, counter ranges, System Timer ranges, etc. to be dynamically altered in real time

dynamically changing the High Speed Counter 1 output channel frequency in real time

manage digital output channels by Boolean logic

Some examples of categories for use of calculations in applications are listed below as a guide

calculate the statistical data for a parameter from distributed sensors, for example spatial average and range of temperature variation in a room

calculate corrected data for parameters by adjusting for influencing factors, for example correcting flow for temperature and pressure according to Boyles Law

calculate derived parameters from fundamental data, for example wind sigma from wind speed and direction

calculate elapsed times, down times, up times, rates, etc.

calculate theoretical profiles for a parameter for comparison with measured profiles, for example temperature rise profile of furnaces

All calculations are performed in Data Schedules, in the same way as the scanning of input channels.

Expressions Operators

The dataTaker expression evaluator supports the standard range of arithmetic, relational and logical operators, and supports a number of mathematical functions. The expression operators supported by the dataTaker are listed below

 

Arithmetic                         Addition                                    +
                                     Subtraction                                ñ
                                     Multiply                                    *
                                     Divide                                       /
                                     Modulus                                    %
                                     Exponent                                   ^

Relational                        Less than                                   <
    (1 is true)                     Less than or equal to                    <=
    (0 is false)                    Equal to                                    =
                              Not equal to                        !=
                                     Greater than or equal to               >=
                                     Greater than                              >

Logical                                                                           AND
    (≠¹0 is true)                                                                  OR
    (=0 is false)                                                                 XOR
                                                                                    NOT

Functions                         Absolute                                    ABS()
                                     Logarithm base 10                      LOG()
                                     Natural logarithm                        LN()
                                     Sine                                         SIN()
                                     Cosine                                      COS()
                                     Tangent                                     TAN()
                                     ArcSine                                     ASIN()
                                     ArcCosine                                 ACOS()
                                     ArcTangent                                ATAN()
                                     Square Root                               SQRT()

Precedence                       Parentheses                                ( )

 

The SIN(), COS() and TAN() functions require arguments in radians, where 1 radian = 57.296 degrees. The ASIN(), ACOS() and ATAN() functions return data in radians.

Polynomials, spans and intrinsic functions cannot be used directly in expressions, but can be applied as channel options to the Channel Variable associated with expressions to further process the result of an expression.

Operator Precedence

The order of evaluation of the components of an expression follows an operator precedence as follows

( )
NOT        ñ  (unary)
S             /             ^             %
+            ñ
>            >=           <             <=           =       !=
AND        OR          XOR
= (assignment)

The order of precedence is in descending order down the list.

When more than one operator has the same level of precedence, then evaluation follows the order left to right in the list above.

The parentheses ( ) operator can be used to define a particular order of evaluation, with expressions in the parentheses being executed first.

 

 

For example the two expressions below will evaluate as follows

1CV=2+3*10

1CV=(2+3)*10

the first expression will evaluate as 32, while the second expression will evaluate as 50.

Parentheses can be nested to further define the order of evaluation, as illustrated in the following example

5CV=((1CV+(2CV-0.0231))/COS(3CV*4CV))/3.3

Expressions can be entered directly into the logger from DeTransfer, and can be included in programs developed in the Program Builder of DeLogger.

Execution of Calculations

All calculations are evaluated in Schedules, in the same way as the scanning of input channels.

When calculations are included in Schedules, the input channels to be scanned and calculations to be evaluated can be mixed in any order within the Schedule. When the schedule runs, the input channels are scanned and the calculations are evaluated in that same order as the order of entry.

Therefore data can be sequentially collected from the input channels and used in subsequent calculations in each pass. This sequence will repeat each time the Schedule runs. Several of the examples given in this chapter employ this sequencing.

The individual Schedules are executed in the order RA, RB, RC, RD then RX when the triggers for two or more of the Schedules coincide. Therefore with careful planning, the data collected in one Schedule can also be synchronously used in calculations within another Schedule .

Calculations can also be performed in the Immediate Schedule, in which the calculation is performed once when the schedule is entered into the logger. This has the effect that the calculations are performed at command level. This feature is the basis of using calculations to initialise Channel Variables, to run calculations from Alarms, and to execute calculations that are directly entered by the host.

Maximum Number of Calculations

All calculations are evaluated in Schedules, and Channel Variables receiving the results of calculations are entered into the internal channel table with the input channels for data acquisition and Alarms.

The Channel Variables which receive the results of calculations share that part of the channel table which is allocated to the data acquisition Schedules.

Therefore the number of calculations which can be performed in an application is governed by the proportion of the internal channel table that is allocated to the Data Schedules (defined by Parameter30), and the number of input channels being scanned.

For example, if Parameter30=40, then there is space for 40 Alarms and space for up to 70 channel accesses (input or output) and calculations. This could be distributed as 20 channel accesses and 50 calculations, or 35 channel accesses and 35 calculations, etc.

The expressions for calculations are collectively stored in a separate area of memory, and are limited to a total of 3848 characters.

Conditional Calculations

The dataTaker has no formal commands for conditional evaluation of expressions. However conditional evaluation can be performed by using Relational or Boolean expressions, or Alarms.

 

Boolean expressions employing Boolean logic can be used to return results that are dependent on a condition being true or false. Boolean expressions return a value of 0 if the result of the relational test is false, and return a value of 1 if the result of the relational test is true.

The following expressions will evaluate

(2CV>=100)

(15CV=25.5)

The first Boolean expression will return 1 if the value of 2CV is greater than or equal to 100, and will return 0 if the value of 2CV is less than 100.

The second Boolean expression will return 1 if the value of 15CV is equal to 25.5, and will return 0 if the value of 15CV is greater than or less than 25.5.

The value returned by Boolean expressions can be used to control evaluation of conditional expressions, that are arranged to add the results of two sub-expressions of which one will evaluate as false and one will evaluate as true.

The following example illustrates the use of Boolean expressions for conditional evaluation.

2CV=(1CV*2*(1CV<100))+(1CV*4*(1CV>=100))

If 1CV is less than 100, then the first Boolean expression will return a value of 1, and the second Boolean expression will return a value of 0. The conditional expression will therefore reduce to

2CV=(1CV*2*(1))+(1CV*4*(0))
or
2CV=(1CV*2*(1))+0

and 2CV will be assigned the value of 1CV*2.

If however 1CV is greater than or equal to 100, then the first Boolean expression will return a value of 0, and the second Boolean expression will return a value of 1. The conditional expression will therefore reduce to

2CV=(1CV*2*(0))+(1CV*4*(1))
or
2CV=0+(1CV*4*(1))

and 2CV will be assigned the value of 1CV*4.

The BASIC language equivalent of this conditional expression is

IF 1CV<100 THEN 2CV=1CV*2 ELSE 2CV=1CV*4

The same conditional evaluation can also be performed by 2 Alarms as follows

ALARM1(1CV<1000)"[2CV=1CV*2]"
ALARM2(1CV>1000)"[2CV=1CV*4]"

Alarms must be used with care in conditional calculations

the Alarm Schedule (RZ) must trigger at the same intervals as any Schedules which use the result

the Alarms are executed after the Schedule, and so the result of the conditional calculation will not be available until the next iteration of the Schedule

the Alarms execute the action commands each time that the alarm state becomes true and not while the alarm state remains true (unless the repeating Alarms ALARMR are used)

Standard Conditional Calculations

Several standard conditional calculations are listed below that can be used as a guide for dataTaker programs. This list is not exhaustive, however it provides a number of models for further development.

maintain a maximum value

2CV(W)=-99999     ëInitial maximum
BEGIN
 RA10S
  1V(=1CV,W)
  2CV=2CV*(1CV<=2CV)+1CV*(1CV>2CV)  ëKeep largest value
END

maintain a minimum value

2CV(W)=999999      ëInitial minimum
BEGIN
 RA10S
  1V(=1CV,W)
  2CV=2CV*(1CV>=2CV)+1CV*(1CV<2CV)  ëKeep smallest value
END

count the number of readings outside of a range

2CV(W)=0      ëInitial count
BEGIN
 RA10S
  1V(=1CV,W)
  2CV=2CV+((1CV<100)OR(1CV>500))  ëAdd 1 if value<100 or value>500
END

count the number of readings within a range

2CV(W)=0      ëInitial count
BEGIN
 RA10S
  1V(=1CV,W)
  2CV=2CV+((1CV>100)AND(1CV<200))  ëAdd 1 if 100>value<200
END

correct sensor readings for errors according to range

BEGIN
 RA1M
  1V(=1CV,W)
  1CV=1CV-0.5*((1CV>=25)AND(1CV<35))ëSubtract 0.5 if 25<value<34.99
  1CV=1CV-1.5*((1CV>=35)AND(1CV<45))ëSubtract 1.5 if 35<value<44.99
  1CV=1CV-2.5*((1CV>=45)AND(1CV<55))ëSubtract 2.5 if 45<value<54.99
END

count elapsed ON time and elapsed OFF time for a digital input

2CV(W)=0    ëClear elapsed ON time
3CV(W)=0    ëClear elapsed OFF time
BEGIN
 RA1S
  1DS(=1CV,W)
  2CV=2CV+(1CV>0.5) ëON time
  3CV=3CV+(1CV<0.5) ëOFF time
END

Combining Calculations

The different scaling and calculation functions of the dataTaker can be used together as illustrated in the following programs.

This program calculates the cross channel average of 10 temperatures

BEGIN
 RA10S
  1CV(W)=0  'Clear 1CV
  1..10TT(+=1CV,W) 'Sum the 10 temps into 1CV
  1CV=1CV/10 'Divide by 10 for average
END

This program calculates the mean and standard deviation of wind direction, and the mean and standard deviation of wind speed. The inputs are wind speed and direction.

'Program to calculate the
'    - mean wind speed
'    - mean wind direction
'    - std devn of wind speed
'    - std devn of wind direction

'Define the wind sensor calibrations
Y1=0,0.050"m/s"                'Wind speed 0-1000mV = 0-50 m/s
Y2=0,0.360"Deg"                'Wind dirn  0-1000mV = 0-360 deg

'Define units text for calculations
Y3=0,1"m/s"
Y4=0,1"Deg"

'Clear accumulators
10..16CV(W)=0

BEGIN
 'Scan wind set every 5 secs
 RA5S
  1V(Y1,=1CV,W)                 'Read wind speed and save
  2V(Y2,=2CV,W)                 'Read wind dirn and save
  2CV(W)=2CV/57.29              'Convert wind dirn to radians
  10CV(W)=10CV+COS(2CV)         'Sum of COS(wd)
  11CV(W)=11CV+SIN(2CV)         'Sum of SIN(wd)
  12CV(W)=12CV+1CV              'Sum of ws
  13CV(W)=13CV+(1CV*1CV)        'Sum of ws * ws
  14CV(W)=14CV+(1CV*COS(2CV))   'Sum of ws * COS(wd)
  15CV(W)=15CV+(1CV*SIN(2CV))   'Sum of ws * SIN(wd)
  16CV(W)=16CV+1.0              'Number of scans

 'Calculate wind data every minute
 RB1M
  D                             'Calculation date
  T                             'Calculation time
  20CV(W)=14CV/16CV             'Mean ws * COS(wd)
  21CV(W)=15CV/16CV             'Mean ws * SIN(wd)

  'Calculate mean wind speed
  22CV(W)=SQRT((20CV*20CV)+(21CV*21CV))
  22CV("Mean Wind Speed",Y3,FF2)

  'Calculate mean wind direction
  23CV(W)=ATAN(21CV/20CV)*57.29

  'Find quadrant for mean wind direction
  23CV(W)=23CV+((20CV>0)AND(21CV<0))*360      '4th quadrant
  23CV(W)=23CV+((20CV<0)AND(21CV<0))*180      '3rd quadrant
  23CV(W)=23CV+((20CV<0)AND(21CV>0))*180      '2nd quadrant
  23CV(W)=23CV+((20CV>0)AND(21CV>0))*0        '1st quadrant
  23CV(W)=23CV-(12CV=0)*(23CV+1)              'No wind, return -1
  23CV("Mean Wind Dirn",Y4,FF2)

  'Calculate std devn of wind speed
  24CV(W)=13CV-((12CV*12CV)/16CV)
  24CV(W)=SQRT(24CV/16CV)
  24CV("SD Wind Speed",Y3,FF2)

  'Calculate std devn of wind dirn
  25CV(W)=10CV/16CV
  26CV(W)=11CV/16CV
  27CV(W)=SQRT((25CV*25CV)+(26CV*26CV))
  27CV(W)=SQRT(-2.0*LN(27CV))*57.29
  27CV("SD Wind Dirn",Y4,FF2)

  'Clear accumulators
  10..16CV(W)=0
END
LOGON

Calculation Errors

When data from input channels is used in calculations, then any measurement errors which result in the input channel returning the universal error value of 99999.9 will also force the result of the calculation using that data to 99999.9.

Forcing of the result of the calculation to 99999.9 can be disabled, and the value 99999.9 is used in the calculation which will return a result based on this value.

The method for handling over-range channel data in calculations is determined by the Over Range Error Carry Switch as follows

/J      Carry error through to result of calculations (Default)
/j       Substitute error with 99999.9 and perform calculation

The Over Range Error Carry Switch defaults to /J when dataTaker is powered up, is hardware reset or executes a RESET command.

The following examples demonstrate the function of the Over Range Error Carry Switch

/J
1V(=1CV)
2CV=1CV/2

any over-range errors are carried through, and the expression returns 99999.9

/j
1V(=1CV)
2CV=1CV/2

any over-ranged data is substituted with 99999.9, and the expression returns 49999.95.

 


The histogram is based on the statistical standard, the Normal Distribution, and is a method of reducing large volumes of data into a statistical description of the variability of that data set.

The histogram is defined to have an overall range of values, and a number of classes of equal interval value within the overall range. For example a histogram may have a range of 0 to 100 units, and have 10 classes each of 10 units where class 1 is 0 ñ 9.99 units, class 2 is 10 ñ 19.99 units, class 3 is
20 ñ 29.99 units, etc

Each of the values in the data set is inspected for range, and is counted in the class interval in which its value fits. The result is a count or frequency or values from the data set which fall into each of the class intervals. Hence the alternate name for histogram ñ frequency distribution.

A Histogram or Frequency Distribution is illustrated in Figure 131 below.

 

 

Figure 131 ñ The Histogram or Frequency Distribution

 

The dataTaker Histogram is implemented as a Channel Option, and can be used with any channel type to progressively build up a histogram of a data set as the data set is collected. The class frequencies are counted into a sequential group of Channel Variables.

The histogram is specified as a Channel Option in the format

Hx:y:n..mCV

where

x              is the lowest data value of interest
y              is the highest data value of interest
n              is the first Channel Variable to store counts (nCV)
m             is the last Channel Variable to store counts (mCV)

The overall range of the histogram classes is set by x and y, and the number of classes is set by the number of Channel Variables between n..m.

The dataTaker allocates all but 3 of the Channel Variables for classes, and class intervals are calculated by the dataTaker for this number of Channel Variables over the range.

The dataTaker also stores 3 other counts into Channel Variables as follows

the number of readings under the range specified (<x)

the number of readings over the range specified (>y)

the total number of readings, including those outside of the range

Programming the Histogram

Using DeTransfer, a histogram of a measured temperature over 5 classes is programmed in the example below. It is necessary to allocate 8 Channel Variables, 5 for the classes, 1 for under range frequency, 1 for over range frequency, and 1 for total number of readings

1TT(H25:35:1..8CV)

In this example a histogram will be generated with 5 temperature classes with intervals of 2oC as follows

1CV                       counts for first class (25 - 27oC interval)
2CV                       counts for second class (27 - 29oC interval)
3CV                       counts for third class (29 - 31oC interval)
4CV                       counts for fourth class (31 - 33oC interval)
5CV                       counts for fifth class (33 - 35oC interval)
6CV                       number of samples under range (<24oC)
7CV                       number of samples over range (>35oC)
8CV                       total counts or the sum of 1..7CV

The complete program requires two basic activities. The input channel is sampled over a period, and the resulting data is stored into the appropriate classes. At some longer interval the Channel Variables are returned or logger, to recover the Histogram data. For example

BEGIN
 RA30S
  1TK(H0:100:1..13CV,W)   ëCollect primary data
 RB1H
  1..13CV(R)              ëReturn the class frequencies
 END

The Channel Variables can be cleared each time Schedule B returns the frequencies, or not cleared and left to continue to accumulate frequencies, depending on requirements.

The frequency counts that are generated can be normalised using the total number of values as follows

1CV=1CV/8CV
2CV=2CV/8CV
3CV=3CV/8CV
etc.

DeLogger does not support the Histogram function.

Page Content


Home

Title and Waranty

Go to: Section 2 | Section 3

Section 1


Construction of the dataTaker 50

Construction of the dataTaker 500 600

Construction of the CEM

Getting Started

 

Section 2


Interfacing

Powering the dataTaker

Powering Sensors from the dataTaker

The Serial Interfaces

The RS232 COMMS Serial Interface

The NETWORK Interface

Analog Process

Connect Analog

Analog Chns

Measuring Low Level Voltages

Measuring High Level Voltages

Measuring Currents

Measuring 4-20mA Current Loops

Measuring Resistance

Measuring Frequency and Period

Measuring Analog Logic State

Measuring Temperature

Measuring Temperature with Thermocouples

Measuring Temperature with RTDs

Measuring Temperature with IC Temperature Sensors

Measuring Temperature with Thermistors

Measuring Bridges and Strain Gauges

Measuring Vibrating Wire Strain Gauges

The Digital Input Channels

Monitoring Digital State

The Low Speed Counters

The Phase Encoder Counter

The High Speed Counters

The Digital Output Channels

The Channel Expansion Module

Installing The Panel Mount Display

 

Section 3


Programming the dataTaker

Communication Protocols and Commands

Entering Commands and Programs

Format of Returned Data

Specifying Channels

The Analog Input Channels

The Digital Input Channels

The Counter Channels

The Digital Output Channels

The Real Time Clock

The Internal Channels

Channel Options

Schedules

Alarms

Scaling Data - Polynomials, Spans and Functions

CVs Calcs and Histogram

Logging Data to Memory

Programming from Memory Cards

STATUS RESET TEST

Switches and Parameters

Networking

Writing Programs

Keypad and Display

Error Mess Text

Appendix A - ASCII

Appendix B - ADC Timing