EasyManuals Logo

Campbell CR1000 User Manual

Campbell CR1000
678 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #564 background imageLoading...
Page #564 background image
Appendix A. CRBasic Programming Instructions
<=
Less than or equal
to
A.7.3 Bitwise Operations
Bitwise shift operators (<< and >>) allow CRBasic to manipulate the position of
bits within a variable declared As Long (integer). Following are example
expressions and expected results:
&B00000001 << 1 produces &B00000010 (decimal 2)
&B00000010 << 1 produces &B00000100 (decimal 4)
&B11000011 << 1 produces &B10000110 (decimal 134)
&B00000011 << 2 produces &B00001100 (decimal 12)
&B00001100 >> 2 produces &B00000011 (decimal 3)
The result of these operators is the value of the left-hand operand with all of its
bits moved by the specified number of positions. The resulting "holes" are filled
with zeros.
Smart sensors, or a communication protocol, may output data that are compressed
into integers that are composites of "packed" fields. This type of data
compression is a tactic to conserve memory and communication bandwidth.
Following is an example of data compressed into an eight-byte integer:
A packed integer that is stored in variable input_val will be unpacked into
three integers individually stored in value_1, value_2, and value_3. In the
packed integer, the information that is unpacked into value_1 is stored in bits
7 and 6, value_2 is unpacked from bits 5 and 4, and value_3 from bits 3, 2, 1,
and 0. The CRBasic code to do this unpacking routine is shown in CRBasic
example Using Bit-Shift Operators
(p. 564).
With unsigned integers, shifting left is equivalent to multiplying by two. Shifting
right is equivalent to dividing by two.
The operators follow:
<<
Bitwise left shift
Syntax
Variable = Numeric Expression << Amount
>>
Bitwise right shift
Syntax
Variable = Numeric Expression >> Amount
&
Bitwise AND assignment performs a bitwise AND of a variable with an
expression and assigns the result back to the variable.
564

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Campbell CR1000 and is the answer not in the manual?

Campbell CR1000 Specifications

General IconGeneral
Power Requirements9.6 to 16 VDC
Data Logger Operating SystemCRBasic
Memory4 MB
Analog Inputs16 single-ended or 8 differential
Analog Input Resolution13 bits
Analog Input Range+/-2.5V
Digital I/O8
Pulse Counters2
Communication PortsRS-232
Operating Temperature-25°C to +50°C
Pulse Channels4

Related product manuals