Hexadecimal, Binary, Bytes, Words - Arrick Rbotics Mobile Robot User Manual

Mobile robot for hobbyist, research and education
Table of Contents

Advertisement

Hexadecimal, Binary, Bytes, Words, etc.
Most commands require parameters in the form of hexadecimal values and many commands return
hexadecimal values. Sometimes the bits in these values will represent certain things. We'll use the term
"hex" to refer to hexadecimal.
Hexadecimal
Hex numbers are easy for computers to work with because each hex digit can represent 4 bits, 2 hex dig-
its can represent a byte, and 4 hex digits can represent a word. Sometimes hex digits are referred to as
nibbles. Hex numbers are base 16 instead of base 10 like our decimal numbering system. Hex digits
are: 0 1 2 3 4 5 6 7 8 9 A B C D E F (16 total).
Bits
A bit is a single binary (base 2) digit which can be a "1" or a "0". Digital computers such as the Basic
Stamp, use binary values for processing. A "1" is ON or HIGH, a "0" is OFF or LOW.
Bytes
A byte consists of 8 bits. A byte can be represented as a hex value such as "00" or "FF". The range of
values that a byte can represent is 0-255 decimal (00-FF hex).
Words
A word consists of 2 bytes (16 bits). A word can be represented as a hex value such as "0000" or
"FFFF". The range of values that a word can represent is 0-65535 decimal (0000-FFFF hex).
The following table shows the binary equivalent for each hex digit:
Hex digit Binary value (bits) Decimal
0
0000
1
0001
2
0010
3
0011
4
0100
5
0101
6
0110
7
0111
Basic Stamp Commands
The Basic Stamp II's PBasic language has special commands used to convert numbers to hexadecimal
as needed by the coprocessor. See the SERIN and SEROUT commands in the Basic Stamp Program-
ming manual for details (available at the Parallax web site http://www.parallaxinc.com). Examples:
serout net,baud,["!1R1", hex2 position]
serin net,baud,[hex4, ec]
0
1
2
3
4
5
6
7
'Get encoder as 4-hex characters into ec.
35
Hex digit Binary value (bits) Decimal
8
1000
9
1001
A
1010
B
1011
C
1100
D
1101
E
1110
F
1111
'Move RC Servo Motor.
8
9
10
11
12
13
14
15

Advertisement

Table of Contents
loading

This manual is also suitable for:

Arobot

Table of Contents