Campbell Scientific CR9000X Measurement and Control System User Manual

Page 143

Advertising
background image

Section 4. CRBasic – Native Language Programming

FP2

Used for data storage only. While IEEE 4 byte floating point is used for
variables and internal calculations, FP2 is adequate for most stored data. FP2
provides 3 or 4 significant digits of resolution, and requires half the data
storage memory of the IEEE 4 numeric format (2 bytes verses 4 bytes).

TABLE 4.2.4-2. Resolution and Range Limits of FP2 Data

Zero

Minimum Magnitude

Maximum Magnitude

0.000

±0.001

±7999.

The resolution of FP2 is reduced to 3 significant digits when the first (left
most) digit is 8 or greater (Table 4.2.4-3). Thus, it may be necessary to use
IEEE4 format or an offset to maintain the desired resolution of a measurement.
For example, if water level is to be measured and stored to the nearest 0.01
foot, the level must be less than 80 feet for low-resolution format to display the
0.01-foot increment. If the water level is expected to range from 50 to 90 feet
the data can be formatted as IEEE4.

TABLE 4.2.4-3. FP2 Decimal Location

Absolute Value

Decimal Location

0 to 7.999

X.XXX

8 to 79.99

XX.XX

80 to 799.9

XXX.X

800 to 7999.

XXXX.

FLOAT

“AS FLOAT” specifies the default IEEE4 Standard 754 data type. If no data
type is explicitly specified with the AS statement, then FLOAT is assumed.
IEEE4 has 24 bits of resolution. Less processing is required when storing data
in IEEE4, because the logger does not have to convert the value (internal
operations are done in IEEE4).

Public Z, RefTemp, TCTemp(3)
Public X AS FLOAT

LONG

“AS LONG” specifies the variable as a 32 bit long integer, ranging from –
2,147,483,648 to +2,147,483,647 (31 bits plus the sign bit). There are two
possible reasons a user would do this: (1) speed, since the OS can do math on
integers faster that with floats, and (2) resolution, since the LONG has 31 bits
compared to the 24 bits in the IEEE4. It is not always suitable for data storage
as the fractional portion of the value is lost.
Examples:

Dim I AS LONG
Public LongCounter AS LONG

NSEC

NSEC data type consists of 8 bytes divided up as 4 bytes of seconds since 1990
and 4 bytes of nanoseconds into the second. NSEC is used when a LONG
variable being sampled is the result of the RealTime () instruction, or when the
sampled variable is a LONG storing time since 1990, such as results when time-
of-maximum or time-of-minimum is requested. Used for data storage only.

4-15

Advertising