Table 4-1: Data types, ranges and resolutions
Data type
Description
Range
Resolution
Where used
Float
IEEE four byte
floating point
+/–1.8 *10^–38 to
+/–1.7 *10^38
24 bits
(about 7 digits)
variables
Long
four byte
signed integer
–2,147,483,648 to
+2,147,483,647
1 bit
variables, output
Boolean
four byte
signed integer
–1, 0
True (–1) or
False ( 0)
variables,
sample output
String
ASCII String
variables,
sample output
IEEE4
IEEE four byte
floating point
+/–1.8 *10^–38 to
+/–1.7 *10^38
24 bits
(about 7 digits)
internal calculations,
output
FP2
Campbell Scientific
two byte floating point
–7999 to +7999
13 bits
(about 4 digits
output
4.4.1 Variables
In CRBasic, the declaration of variables (via the
DIM
or the
PUBLIC
statement) allows an
optional type descriptor
As
that specifies the data type. The data types are
Float
,
Long
,
Boolean
, and
String
. The default type is
Float
.
Example variables declared with optional data types
Public
PTemp
As Float
, Batt_volt
Public
Counter
As Long
Public
SiteName
As String
* 24
As Float
specifies the default data type. If no data type is explicitly specified with the
As
statement, then
Float
is assumed. Measurement variables are stored and calculations are
performed internally in IEEE 4 byte floating point with some operations calculated in double
precision. A good rule of thumb is that resolution will be better than 1 in the seventh digit.
As Long
specifies the variable as a 32 bit integer. There are two possible reasons a user would
do this: (1) speed, since the CR1000 Operating System can do math on integers faster than with
Float
s, and (2) resolution, since the
Long
has 31 bits compared to the 24 bits in the
Float
. A
good application of the
As Long
declaration is a counter that is expected to get very large.
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, High/Low). 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. When a
4. Data
31
Содержание CR1000X
Страница 1: ...Revision 02 21 2019 Copyright 2000 2019 Campbell Scientific ...
Страница 2: ......
Страница 4: ......
Страница 6: ......
Страница 8: ......
Страница 16: ...Appendix A Glossary 176 Appendix B Index 214 Table of Contents viii ...
Страница 20: ...l Smart sensors o SDI 12 o RS 232 o Modbus o DNP3 o TCP IP o RS 485 1 Data acquisition system components 4 ...
Страница 192: ......
Страница 237: ...wiring panel 5 Appendix B Index 220 ...