Radio Shack Mobile Robot manual Hexadecimal, Binary, Bytes, Words, etc

Page 38

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

0

1

0001

1

2

0010

2

3

0011

3

4

0100

4

5

0101

5

6

0110

6

7

0111

7

Hex digit

Binary value (bits)

Decimal

8

1000

8

9

1001

9

A

1010

10

B

1011

11

C

1100

12

D

1101

13

E

1110

14

F

1111

15

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] 'Move RC Servo Motor.

serin net,baud,[hex4, ec]

'Get encoder as 4-hex characters into ec.

35

Image 38
Contents Assembly and User Guide ARobot Mobile Robot Connectors Basic Stamp II Control Computer IntroductionAbout ARobot Feature List What You’ll NeedTechnical Specifications Precautions Component Locator ControllerGlossary of Terms Glossary of Terms Glossary of Terms Assembly Overview About Screw, nut, and washer sizes PartsQuantity Description Used For Parts Motor Brackets Paint Primer PaintingSanding Finish CoatHow it Works WhiskersSummary Whisker Detail Full Scale Whisker Wire Pattern Drive Motor and Brackets Encoder Sensor Front Wheel Assembly Steering Motor and Rear Wheels Steering Motor Mounting Wheel and Axle Steering System Controller Board Summary Don’t install batteries yet Battery PackDon’t install batteries yet Body Cable Finishing Up Programming Basic Stamp II InstallationAbout the Controller Board USB Port Cable to your PCPC Editor/Downloader Software Programming NoteTest Program TEST.BS2 Steering Adjustment Program STRAIGHT.BS2Programs Wander Program WANDER.BS2About the Controller Board Batteries Power On/Off SwitchReset Button LED indicators SpeakerPush Buttons and Jumpers switches Drive Motor and EncoderSteering Motor Coprocessor Command Summary Example !1M11200E7RC Servo Motor and Steering Motor Control Coprocessor Communication RulesHexadecimal, Binary, Bytes, Words, etc Serial Port J12 Battery Connector J9Body Connector J8 PinoutPowerful Connector J11 RC Servo Motor Connectors J2-J5Drive Motor Connector J10 Voltage 12 volts Maximum Current 500ma PinoutExpansion Connector J1 Expansion Port RC Servo Motor SignalsExpansion Port Circuit Examples Digital Inputs Switch Input ExampleDigital/Power Output Sensor Input ExampleAnalog Inputs Basic Stamp II light sensor example codeCoprocessor Network Expansion CommunicationsCabling between ARobot’s controller and another controller Using Other ControllersUsing ARobot’s controller as a coprocessor Suggested Reading Component Suppliers Stock Drive Products Sava IndustriesSmall Parts SuperCircuitsInternet Robot Resources Web SitesInternet News Groups Newsgroup NameDescriptionTroubleshooting Warranty Information Arrick RoboticsRobotics.com