Push Buttons And Jumpers; Drive Motor And Encoder - Arrick Rbotics Mobile Robot User Manual

Mobile robot for hobbyist, research and education
Table of Contents

Advertisement

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

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
'Subroutine to start drive motor.
'
drivemotor:
serout net,baud,["!1M1", dec1 direction, speed, hex4 distance]
serin net,baud,[char]
return
'If jumper 1 on then jmp1on.
'If jumper 2 on then jmp2on.
'If button 1 on then but1on.
'If button 2 on then but2on.
'Speed variable. '0'-'9', 'A'.
'Motor distance variable 0-65535.
'Direction. 1=fwd, 0=rev.
'Coprocessor network pin.
'Coprocessor baud rate.
'Get "A" back.
31

Advertisement

Table of Contents
loading

This manual is also suitable for:

Arobot

Table of Contents