Radio Shack Mobile Robot manual Push Buttons and Jumpers switches, Drive Motor and Encoder

Page 34

Push Buttons and Jumpers (switches)

Two general purpose buttons and jumpers (also called switches) are provided on the controller card which can be read by the Basic Stamp II. Buttons are momentary – after you press them they return to the off state. Jumpers can be left in the on or off position using the jumper plug or wired to external switches. Buttons and Jumpers can be use in your program to set certain parameters or modes as needed. They may be ignored and not used at all. Here is a piece of PBasic example code that reads them: Notice they are active LOW (LOW=on).

if in12=0 then jmp1on if in13=0 then jmp2on if in14=0 then button1 if in15=0 then button2

'If jumper 1 on then jmp1on. 'If jumper 2 on then jmp2on. 'If button 1 on then but1on. 'If button 2 on then but2on.

Drive Motor and Encoder

The drive motor moves the motor forward and backward using the H-Bridge driver circuit (see the con- troller drawing for location). The H-Bridge is controlled by the coprocessor which receives commands from the Basic Stamp II using serial I/O commands over the coprocessor network pin – P8. This frees the Basic Stamp II for other tasks.

An encoder wheel and encoder sensor are used to measure rotation of the drive wheel resulting in dis- tance measurement. There are 20 encoder slots (counts) per revolution. As it rotates, the slots are de- tected by the encoder sensor. The drive wheel is about 3-1/2” in diameter, so each count represents about 1/2” of robot travel – (3.25 x 3.141) / 20. Reading of the encoder is also handled by the coproces- sor to free up the Basic Stamp II. The count (distance) can be read from the coprocessor by the Basic Stamp II when needed.

The following PBasic subroutine will show how to control the drive motor through the coprocessor. We suggest you also study the WANDER and TEST program.

'Drive Motor Control Subroutine. speed var byte

distance var word direction var byte net con 8

baud con 396

'Speed variable. '0'-'9', 'A'. 'Motor distance variable 0-65535. 'Direction. 1=fwd, 0=rev. 'Coprocessor network pin. 'Coprocessor baud rate.

'Subroutine to start drive motor.

'

drivemotor:

serout net,baud,["!1M1", dec1 direction, speed, hex4 distance]

serin net,baud,[char] 'Get "A" back. return

31

Image 34
Contents Assembly and User Guide ARobot Mobile Robot Connectors About ARobot IntroductionBasic Stamp II Control Computer Feature List What You’ll NeedTechnical Specifications Precautions Component Locator ControllerGlossary of Terms Glossary of Terms Glossary of Terms Assembly Overview Quantity Description Used For PartsAbout Screw, nut, and washer sizes Parts Motor Brackets Paint Primer PaintingSanding Finish CoatSummary WhiskersHow it Works 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 Don’t install batteries yet Battery PackSummary Don’t install batteries yet Body Cable Finishing Up About the Controller Board Basic Stamp II InstallationProgramming 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 Reset Button Power On/Off SwitchBatteries 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 CommunicationsUsing ARobot’s controller as a coprocessor Using Other ControllersCabling between ARobot’s controller and another controller Suggested Reading Component Suppliers Stock Drive Products Sava IndustriesSmall Parts SuperCircuitsInternet Robot Resources Web SitesInternet News Groups Newsgroup NameDescriptionTroubleshooting Warranty Information Arrick RoboticsRobotics.com