beautypg.com

5 data type operational detail – Campbell Scientific CR9000X Measurement and Control System User Manual

Page 141

background image

Section 4. CRBasic – Native Language Programming

TABLE 4.2.4-1. Data Types

Code

Data Format

Where Used

Word
Size

Range Resolution

FP2 CSI

Floating

Point

Output Data Storage

2 bytes

±7999

13 bits
(about 4 digits)

IEEE4 or
FLOAT

IEEE 4 Byte
Floating Point

Output Data Storage,
Variable Declaration

4 bytes

±1.4 x 10

-45

to

±3.4 x 10

38

24 bits
(about 7 digits)

LONG

4 Byte Signed
Integer

Output Data Storage,
Variable Declaration

4 bytes

-2,147,483,648
to
+2,147,483,647

1 bit (1)

UINT2

2 Byte Unsigned
Integer

Output Data Storage

2 bytes

0 to 65535

1 bit (1)

BOOLEAN 4 byte Signed

Integer

Output Data Storage,
Variable Declaration

4 bytes

0, -1

True or False
(-1 or 0)

BOOL8

1 byte Boolean

Output Data Storage

1 byte

0, -1

True or False
(-1 or 0)

NSEC

Time Stamp

Output Data Storage

8 byte

seconds since
1990

1 nanoseconds

STRING ASCII

String Output Data Storage,

Variable Declaration

Set by
program

4.2.4.5 Data Type Operational Detail

BOOLEAN “AS BOOLEAN” specifies the variable as a 4 byte Boolean. Boolean variables

are typically used for flags and to represent conditions or hardware that have
only 2 states (e.g., On/Off, Ports). A Boolean variable uses the same 32 bit
long integer format as a LONG but can set to only one of two values: True,
which is represented as –1, and false, which is represented with 0. To save
memory space, consider using BOOL8 format instead.software to display it as
an ON/OFF, TRUE/FALSE , RED/BLUE, etc.

Public Switches(8) AS Boolean, FLAGS(16) AS Boolean

BOOL8

Used for data storage only. A one byte variable that hold 8 bits (0 or 1) of

information. BOOL8 uses less space than 32-bit BOOLEAN data type, since
32 bits of information are stored in four 8-bit Boolean bytes. Repetitions in
output processing data table instructions must be integrally divisible by two,
since an odd number of bytes cannot be stored in a data table. When
converting from a LONG or a FLOAT to a BOOL8, only the least significant 8
bits are used, i.e., only the modulo 256 is used. When LoggerNet retrieves a
BOOL8 data type, it splits it apart into 8 fields of true or false when storing or
displaying. BOOL8 conserves CR9000X memory which results in less band
width being used when data are collected via telecommunications.

EXAMPLE 4.2.4-3 programs the CR9000X to monitor the state of 32 ‘alarms’
as a tutorial exercise. The alarms are toggled by manually entering zero or
non-zero (e.g., 0 or 1) in each public variable representing an alarm. Samples
of the four FlagsBool variables are stored in data table “Bool8Data” as four 1-
byte values. When programming, remember that aliasing can be employed to
make the program and data more understandable for a particular application.

4-13