Campbell Scientific CR200X CR200/CR200X-series Dataloggers - Page 83

Numerical Formats

Page 83 highlights

Section 9. Programming processing instructions that compress many common calculations used in CR200(X) dataloggers. These four elements must be properly placed within the program structure. 9.4 Numerical Formats Four numerical formats are supported by CRBASIC. Most common is the use of base 10 numbers. Scientific notation, binary, and hexadecimal formats may also be used, as shown in TABLE. Formats for Entering Numbers in CRBASIC (p. 71). Only standard base 10 notation is supported by Campbell Scientific hardware and software displays. Table 5. Formats for Entering Numbers in CRBASIC Format Example Base 10 Equivalent Value Standard 6.832 6.832 Scientific notation 5.67E-8 5.67X10-8 Binary &B1101 11 Hexadecimal &HFF 255 Binary format is useful when loading the status (1 = high, 0 = low) of multiple flags or ports into a single variable, e.g., storing the binary number &B11100000 preserves the status of flags 8 through 1. In this case, flags 1 - 5 are low, 6 - 8 are high. CRBASIC EXAMPLE. Load Binary Information into a Variable (p. 71) shows an algorithm that loads binary status of flags into a LONG integer variable. CRBASIC EXAMPLE 2. Public FlagInt Public Flag(8) Public I Load binary information into a single variable DataTable (FlagOut,True,1000) Sample (1,FlagInt) EndTable BeginProg Scan (1,Sec) FlagInt = 0 For I = 1 To 8 Flag (I) = IIF (Flag(I)= 0,0,-1) If Flag(I) = true then FlagInt = FlagInt + 2 ^ (I - 1) EndIf Next I CallTable FlagOut NextScan EndProg 71

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208

Section 9.
Programming
processing instructions that compress many common calculations used in
CR200(X) dataloggers.
These four elements must be properly placed within the program structure.
9.4
Numerical Formats
Four numerical formats are supported by CRBASIC. Most common is the use of
base 10 numbers. Scientific notation, binary, and hexadecimal formats may also
be used, as shown in
TABLE. Formats for Entering Numbers in CRBASIC
(p.
71). Only standard base 10 notation is supported by Campbell Scientific
hardware and software displays.
Table 5.
Formats for Entering Numbers in CRBASIC
Format
Example
Base 10 Equivalent Value
Standard
6.832
6.832
Scientific notation
5.67E-8
5.67X10
-8
Binary
&B1101
11
Hexadecimal
&HFF
255
Binary format is useful when loading the status (1 = high, 0 = low) of multiple
flags or ports into a single variable, e.g., storing the binary number
&B11100000 preserves the status of flags 8 through 1. In this case, flags 1 - 5
are low, 6 - 8 are high.
CRBASIC EXAMPLE. Load Binary Information into a
Variable
(p. 71) shows an algorithm that loads binary status of flags into a
LONG integer variable.
CRBASIC EXAMPLE 2.
Load binary information into a single variable
Public FlagInt
Public Flag(8)
Public I
DataTable (FlagOut,True,1000)
Sample (1,FlagInt)
EndTable
BeginProg
Scan (1,Sec)
FlagInt = 0
For I = 1 To 8
Flag (I) = IIF (Flag(I)= 0,0,-1)
If Flag(I) = true then
FlagInt = FlagInt + 2 ^ (I - 1)
EndIf
Next I
CallTable FlagOut
NextScan
EndProg
71