Campbell Scientific CR1000KD CR1000 Measurement and Control System - Page 227
Bool8 Data Type
View all Campbell Scientific CR1000KD manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 227 highlights
Section 7. Installation '3) sample time to three string forms using the TableName.FieldName notation. 'Form 1: "mm/dd/yyyy hr:mm:ss UTTime(1) = TimeTable.TimeLong(1,1) 'Form 2: "dd/mm/yyyy hr:mm:ss UTTime(2) = TimeTable.TimeLong(3,1) 'Form 3: "ccyy-mm-dd hr:mm:ss (ISO 8601 Int'l Date) UTTime(3) = TimeTable.TimeLong(4,1) NextScan EndProg 7.8.11 Bool8 Data Type Boolean variables are used to represent conditions that have only two states -- true or false -- such as program-control flags and hardware-control ports. A BOOLEAN data-type variable uses the same four-byte integer format as a LONG data type, but it can be set to only one of two values. To save data-storage space and data transmission bandwidth, consider using BOOL8 format to store data in final-storage data tables. BOOL8 is a one-byte variable that holds eight bits of information (8 states * 1 bit per state). To store the same information using the 32-bit BOOLEAN data type, 256 bits are required (8 states * 32 bits per state). When programming with BOOL8, repetitions in the output processing DataTable() instruction must be divisible by two, since an odd number of bytes cannot be stored. Also note that when the CR1000 converts a LONG or FLOAT data type to BOOL8, only the least significant eight bits of the binary equivalent are used, i.e., only the binary representation of the decimal integer modulo divide (p. 458) 256 is used. Example: Given: LONG integer 5435 Find: BOOL8 representation of 5435 Solution: 5435 / 256 = 21.2304687 0.2304687 * 256 = 59 Binary representation of 59 = 00111011 (CR1000 stores these bits in reverse order) When datalogger support software (p. 77) retrieves the BOOL8 data type, it splits it apart into eight fields of -1 or 0 when storing to an ASCII file. Consequently, more memory is required for the ASCII file, but CR1000 memory is conserved. The compact BOOL8 data type also results in less use of telecommunications band width when data are collected. CRBasic example Bool8 and Bit-Shift Operators (p. 229) programs the CR1000 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 as shown in figure Alarms Toggled in Bit-Shift Example (p. 228) . Samples of the four public variables FlagsBool(1), FlagsBool(2), FlagsBool(3), and FlagsBool(4) are stored in data table "Bool8Data" as four onebyte values. However, as shown in figure Bool8 Data from Bit-Shift Example (Numeric Monitor) (p. 228) , when viewing the data table in a numeric monitor , data are conveniently translated into 32 values of True or False. In addition, as shown in figure Bool8 Data from Bit-Shift Example (PC Data File) (p. 229) , when datalogger support software (p. 77) stores the data in an ASCII file, it is stored as 32 columns of either 0 or -1, each column representing the state of an alarm. 227