## Channel Variables and CalculationsThe
Calculations provide many opportunities in 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 VariablesThe 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 The general formats for the Channel Variables are as follows nCV(options) where CV is the Channel Variable identifier 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 VariablesChannel 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" 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 VariablesInput 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 2C(R,+=9CV) instructs the 2F(/=23CV) instructs the The assignment of input channel data to Channel Variables is made when the embracing Schedule (RA, RB, RC, RD, RX) executes. For example BEGIN 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 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 VariablesThe 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 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 VariablesResults 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 VariablesChannel 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 ï 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) 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 VariablesChannel 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( ï scale the value stored in Channel Variables by a scale factor (f.f), Polynomials (Yn), Spans (Sn) or Intrinsic Functions (Fn). For example 52CV( ï return the difference (DF), rate of change (RC and RS) or integral (IB) between successive assignments to Channel Variables. For example 5CV( ï 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) ï 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 ï define a bar graph (BGx:y) for displaying Channel Variable data. For example 8CV(BG0:100,"Slow % Fast") ## Using the Channel VariablesChannel 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 SchedulesChannel 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" 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
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 AlarmsChannel 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 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 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 This approach can also be used to test input channel data which is continuously varying. ## Using Channel Variables as Setpoints in AlarmsChannel 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 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 AlarmsStatistical 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 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 TimeDate, 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) 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 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 The 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 OperatorsThe
Arithmetic Addition +
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 PrecedenceThe order of evaluation of the components of an expression follows an operator precedence as follows ( ) 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 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 CalculationsAll 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 CalculationsAll 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 CalculationsThe
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) 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)) 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)) 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]" 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 CalculationsSeveral standard conditional calculations are listed below that can be used as a guide for maintain a maximum value 2CV(W)=-99999 ëInitial maximum maintain a minimum value 2CV(W)=999999 ëInitial minimum count the number of readings outside of a range 2CV(W)=0 ëInitial count count the number of readings within a range 2CV(W)=0 ëInitial count correct sensor readings for errors according to range BEGIN count elapsed ON time and elapsed OFF time for a digital input 2CV(W)=0 ëClear elapsed ON time ## Combining CalculationsThe different scaling and calculation functions of the This program calculates the cross channel average of 10 temperatures BEGIN 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 'Find quadrant for mean wind direction ## Calculation ErrorsWhen 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) The Over Range Error Carry Switch defaults to /J when The following examples demonstrate the function of the Over Range Error Carry Switch /J any over-range errors are carried through, and the expression returns 99999.9 /j 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 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 The histogram is specified as a Channel Option in the format Hx:y:n..mCV where x is the lowest data value of interest 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 The 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 HistogramUsing 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 2 1CV counts for first class (25 - 27 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 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 DeLogger does not support the Histogram function. |
## Page Content## Section 1Construction of the dataTaker 50 Construction of the dataTaker 500 600
## Section 2Powering Sensors from the dataTaker The RS232 COMMS Serial Interface Measuring 4-20mA Current Loops Measuring Frequency and Period 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 Installing The Panel Mount Display
## Section 3Communication Protocols and Commands Entering Commands and Programs |