Web Site: www.parallax.com
Forums: forums.parallax.com
Sales: sales@parallax.com
Technical: support@parallax.com
Office: (916) 624-8333
Fax: (916) 624-8003
Sales: (888) 512-1024
Tech Support: (888) 997-8267
Penguin Robot Kit
(Red #27313)
(Blue #27314)
(Clear #27315)
(Black #27316)
The Penguin Robot is a precision-machined 4” tall biped. The Penguin walks forward with a tilt-stride
action and turns by sweeping both feet on the ground in opposite directions. Individual movement
segments are linked together for this robot to walk. This basic biped design functions best in the
Penguin’s small scale. The Penguin mechanics have a close-tolerance fit and are designed to provide
precise electronic control.
The Penguin’s microcontroller is an embedded BASIC Stamp2px24 module, the fastest and most powerful
BASIC Stamp microcontroller model in the Parallax lineup. The Penguin requires three hours to assemble,
after which it is a PBASIC programming challenge to exploit all of the robot’s capabilities.
Note: This document is for Penguin Robots Rev A or Rev B.
If your robot has a "REV B" label near the 7-segment display on the
PCB, please look out for assembly instruction differences specific to
Rev B.
(Note that Penguin Robots Rev A are not labeled.)
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 1 of 23
Table of Contents
1.0 Introduction................................................................................................................................. 2
1.1. Audience ............................................................................................................................................................2
1.2. Features .............................................................................................................................................................2
1.3. System and Software Requirements:................................................................................................................3
1.4. Bill of Materials ...................................................................................................................................................3
1.5. Body Kit Mechanical Drawings ..........................................................................................................................4
2.0 Assembly..................................................................................................................................... 5
2.1. Tools Required...................................................................................................................................................5
2.2. Assembly Instructions ........................................................................................................................................5
2.3. Mechanical Troubleshooting Guide.................................................................................................................17
3.0 Programming the Penguin ...................................................................................................... 18
3.1. Programming Concept.....................................................................................................................................18
3.2. Servo Calibration..............................................................................................................................................18
3.3. Penguin’s BASIC Stamp 2px24 Pinout ...........................................................................................................18
3.4. Example Programs ..........................................................................................................................................19
3.5. Optional Compass Calibration.........................................................................................................................19
3.6. Other Helpful Documentation ..........................................................................................................................19
3.7. Test Code Listings ...........................................................................................................................................20
4.0 Electronics ................................................................................................................................ 23
4.1. CR123 Batteries...............................................................................................................................................23
4.2. Schematic.........................................................................................................................................................23
1.0 INTRODUCTION
1.1. AUDIENCE
The Penguin isn’t a beginner’s robot. The Penguin is a small desktop robot, not intended for long-distance
adventuring. The Penguin’s electronics are fully assembled and wired to an assortment of I/O devices.
Additionally, it has a fairly complex programming process which is more difficult to understand than a
two-wheeled robot. For example, Penguin’s walking steps must be linked and the compass sensor must
be calibrated. For these reasons we recommend this robot for the hobby robotics enthusiast or collector
who has an extended interest in PBASIC programming.
1.2. FEATURES
y
y
y
y
y
y
y
y
y
y
y
y
y
BS2px24 module chipset
CNC-machined 6061 aluminum parts available in four color schemes
(2) micro servos
Hitachi HM55B Digital Compass sensor
Blue seven-segment LED for feedback
(2) photoresistors
(2) infrared emitters and one detector
Piezospeaker in body, underneath battery pack
3-position power switch located adjacent to battery pack
FTDI 232RL mini USB programming port
(2) CR123 batteries for 6V power supply
Orange power indicator LED
(2) expansion I/O ports, with Vss and Vdd header for Ping))) distance sensor or RF modules
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 2 of 23
1.3. SYSTEM AND SOFTWARE REQUIREMENTS:
y PC running Windows XP/Vista, with an available USB port
y BASIC Stamp Editor Software v 2.3 or higher - download from www.parallax.com/downloads.
y USB VCP Drivers - these can be installed automatically via the BASIC Stamp Editor v2.3 installer,
or you may download the latest version separately from link on www.parallax.com home page.
y Penguin Test and Sample Programs - test programs are included in this document; all programs
listed may be downloaded as .bpx files from Penguin product page at www.parallax.com.
1.4. BILL OF MATERIALS
Part #
Description
Quantity
Penguin Body Kit
720-27313
Red Anodized Penguin
720-27314
Blue Anodized Penguin
720-27315
Clear Anodized Penguin
720-27316
Black Anodized Penguin
Each of the above includes:
-Body panels
-Leg pairs attached to ankle
-Feet
-4-40 5/8” long standoffs, with machined flat space
Penguin Hardware Package
720-00013
Stride linkage
720-00015
2-56 threaded rod 2.5" long
710-00013
4-40 1/8" long, 0.149" diameter stainless steel shoulder screw
710-00010
4-40 1/8" long, 1/8" diameter stainless steel shoulder screw
710-00011
4-40 1/4" button socket cap stainless steel screw
710-00012
2-56 1/4" button socket cap stainless steel screw
710-00014
2-56 1/4" flathead stainless steel screws
725-00016
2-56 ball links for 2-56 threaded rod
725-00062
1/16" hex key
725-00063
0.05" hex key
725-00064
5/64" hex key
725-00067
1.5 mm hex key
725-00018
1/16" ball links for 2-56 threaded rod
Electronics
555-27313
Penguin BS2px printed circuit board
Each of the above includes:
-BS2px24 circuit board
-Flat white ribbon cable to connect the boards
-Power pack board
Miscellaneous
700-00064
Parallax dual-head screwdriver
752-00003
CR123 Batteries
805-00010
USB A to Mini B programming cable
900-00014
Grand Wing Naro standard servo
700-00063
Drill bit, #55
1
1
1
1
2
2
2
4
1
2
4
4
12
2
4
2
1
1
1
1
2
1
1
1
1
1
2
1
2
1
Missing parts? Your Penguin experience should be nothing short of complete success and
satisfaction. If you encounter a missing part contact us immediately and we’ll put it in the mail for you.
The best way to do this is by e-mail to sales@parallax.com, or you can call us at (888) 512-1024.
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 3 of 23
1.5. BODY KIT MECHANICAL DRAWINGS
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 4 of 23
2.0 ASSEMBLY
2.1. TOOLS REQUIRED
The Penguin kit includes a portion of the tools required to build the robot (the hex keys, drill bit, and
screwdriver). You will need to provide these additional tools to finish assembly, which are not included in
the kit:
y
y
y
y
y
Small pliers
Ruler or calipers
Handheld drill, small drill press, or a vise
Small adjustable crescent wrench (or 3/16” socket)
Safety glasses
Safety first! Taking basic safety precautions is absolutely necessary when building a Penguin. The
assembly process includes several steps where you will be exposed to danger. You will be using a
sharp drill bit to enlarge a tiny hole, and tiny pieces may fly. You will be pressing ball joints together,
where a small slip can puncture your skin. These dangers are minimized by wearing safety glasses
and using the right tools for the job.
2.2. ASSEMBLY INSTRUCTIONS
Step 1: Attach standoffs to servos
Connect (4) of the 4-40 1/4" button socket cap stainless steel screws to the middle of the 5/8” 4-40
standoffs. The standoffs have a machined flat space in the middle against which the servo tab will be
seated when the screw is tightened. Press the standoffs against the servo body when tightening the
screws. This will ensure proper spacing when the servos are mounted in the Penguin body panels.
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 5 of 23
Step 2: Center the servos using the BASIC Stamp Editor
This step centers the servos, so that further mechanical tuning will be minimized once the Penguin is
assembled. It also ensures that you won’t need to take the Penguin apart once you start programming it.
The servos need to be centered with a 1.5 ms pulse, following the directions below:
a. Connect the Penguin boards together using the flat ribbon cable, as pictured. For boards with a
"REV B" label near the 7-segment display, the blue-tipped side of the cable faces toward the
Parallax logo. Otherwise, the blue-tipped side of the cable faces away from the Parallax logo.
b. Insert two (2) CR123 batteries into the power pack. A line drawing on the inside of the battery
holder shows how the batteries are oriented. (Orientation may differ from picture shown.)
c. Plug two servos into the bottom of the power pack, being careful to orient them correctly. From
the perspective of this photo, the servo’s white leads are on the bottom, or the right side of each
servo connector as viewed behind the Penguin.
d. Download and install the BASIC Stamp Editor and FTDI USB VCP drivers software if you have not
done so already.
e. Plug the mini USB cable into the power pack.
f. Plug the other end of the USB cable into your PC.
g. Turn on power to the board (slide the switch toward the ribbon cable).
h. Open the BASIC Stamp Windows Editor and run the Penguin-CenterServos.bpx program.
i. The servos are now centered. Disconnect the servos first, and then remove the batteries and USB
cable from the power pack board.
'
'
'
'
Parallax Penguin Robot
Penguin-CenterServos.bpx
{$STAMP BS2px}
{$PBASIC 2.5}
Center
StrideServo
TiltServo
CON
PIN
PIN
1875
6
7
DO
PULSOUT StrideServo, Center
PULSOUT TiltServo,
Center
PAUSE 15
LOOP
Copyright © Parallax Inc.
' Centered servo pulse
' Center stride servo (J1)
' Center tilt servo (J2)
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 6 of 23
Step 3: Assemble the Penguin body
Install the servos into the Penguin body using (8) 4-40 1/4" long button socket cap stainless steel screws
and the 1/16” hex key. The picture shows how the servo splines are oriented: the stride (bottom) servo
spline is near the rear of the Penguin; the tilt (top) servo spline is near the top of the Penguin. Tighten
the screws.
Step 4: Install stride linkage on the stride servo
Locate the small black plastic stride linkage with two ball-shaped ends. (This part has changed: the style
shown on the left is included in your kit. The previous style is shown in all the photographs.) The stride
linkage has a recess in the reverse shape of the servo spline. Press it onto the servo so that it is as close
to cross-wise to the Penguin body as possible; it may not be perfectly perpendicular because the spline is
toothed. For fine-tuning, this can be corrected with calibration-in-software using sample code available
for free download from the Penguin product page. Secure the stride linkage to the spline with the servo
screw.
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 7 of 23
Step 5: Attach legs and ankles to body
The Penguin’s legs and ankles come pre-assembled since they required a specialized tool to properly
insert small dowel pins through the round ankle. Each Penguin has a pair of left and right legs. Also
notice that there’s a round machined recess with a diameter slightly larger than the shoulder screw head
on each pair of legs. The recess faces out towards the shoulder screw, and the shortest part of the ankle
faces forward. Shoulder screws have a 1/8” diameter smooth stainless steel surface upon which the legs
will rock back and forth.
To install the leg assemblies on the Penguin, use the (4) 4-40 1/8" long shoulder screws and the 5/64”
hex key. The ball-shaped ends of the stride linkage fit within the matching oval cutout in the rear legs.
The legs should move freely when assembled, and you will hear the stride servo’s gears moving at the
same time. If it takes force to move the legs you have one of two problems: either the metal parts have
bound, or the screws are too tight into the body panels. Tighten everything enough to remove “slop” but
not so tight that parts are unable to move freely.
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 8 of 23
Step 6: Mount Penguin feet to the ankles
The Penguin kit has (4) 4-40 1/4" long, 0.149" diameter stainless shoulder screws which are used to
attach the feet to the ankles. The head of these screws provides a bearing surface for the ankle so it may
rotate freely within the foot when Penguin leans from side to side.
Each foot has an additional 2-56 threaded hole where the Penguin’s ball joints mount for the threaded
rod which connects to the tilt servo (the ski poles). These threaded holes denote the front of the foot.
Carefully drop the ankles into the foot. This is a close-tolerance fit; the ankle will only fit into the foot if it
is inserted squarely. Next, use the 1.5 mm hex key to tighten the 4-40 long 0.149” diameter stainless
steel shoulder screws into the ankle.
The Penguin will now stand up without assistance.
Four (4) 4-40 ¼” long 0.149” diameter
stainless shoulder screws hold the ankle
to the feet.
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 9 of 23
Step 7: Screw 2-56 ball links into feet
The Penguin kit contains two different sizes of ball links. The 2-56 threaded ball links are used in this step
(the 1/16” ball links are used in a subsequent step). Open the package and thread the 2-56 ball link post
into the front of each foot. You can tighten them using a 3/16” socket or small wrench. Be careful not to
scratch the feet as you tighten the ball links. The threaded portion of the ball link will not screw all the
way into the foot because it has a small non-threaded portion between the threads and the hex-shaped
post. Don’t force it beyond the point at which the ball link is easily screwed into the foot.
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 10 of 23
Step 8:
Attach plastic ball sockets to 2-56 threaded rod
Now you’re ready to thread the four (4) plastic ball sockets onto each end of the 2-56 threaded rod.
Twist both ends on evenly until the rod length is about 3.4” long. If this is too difficult to do with your
hands, consider carefully holding the threaded rod with pliers. Use a small rag to prevent it from being
scratched.
Step 9: Drill a 1/16” hole in the servo horn
Each servo package includes an assortment of servo horns. We’ll use the widest servo horn in this step. If
you make a mistake it’s okay because there’s a second one in the other servo package.
Put on your safety goggles. Place the #55 drill bit in your handheld drill, drill press, or vise. Very carefully
enlarge the two outermost holes on the servo horn. If you are using a drill, run it very slowly to prevent it
from feeding into the hole too quickly. If you run it too fast the drill will plunge into the plastic and you’ll
crack the servo horn. Take your time and use a low drill speed. If you have secured the drill bit in a vise,
gently twist the servo horn onto the bit to enlarge the hole. Do not press down, and be careful not to
injure your hands.
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 11 of 23
Step 10: Connect the 1/16” ball links to the servo horn
Install the two 1/16” ball links on the servo horn. Tighten carefully but don’t deform the plastic.
Step 11: Attach the servo horn to the tilt servo
Press the assembled servo horn onto the tilt servo, positioning it cross-wise to the Penguin body. Do not
over-tighten the screw; you may need to take off the horn and re-center the servo if it gets moved
during the next step.
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 12 of 23
Step 12: Connect the tilt servo horn and feet with the threaded rods
Now you’re ready to snap the two threaded rods onto the front of the Penguin. The ball joints can be
snapped onto the feet by hand. Attaching them to the servo horn ball joints is a bit more difficult. For this
you can use a small pair of pliers. Place one jaw of the pliers behind the ball link’s post, and the other on
the outside of the plastic ball socket. Future adjustments can be made quite easily by disconnecting the
ball link socket from the feet only. To disconnect them, use a small screwdriver as a lever against the
foot. Cover the foot with a cloth to prevent scratching.
Bad Penguin Posture? You may have rotated the tilt servo off-center while attaching the linkages. If
the servos are centered, the Penguin will have its feet close together and will be standing straight up,
and the tilt servo horn will be horizontal. If the tilt servo is not horizontal, remove the screw and very
gently pull the horn off of the spline. Re-run Penguin-CenterServos.bpx, which should bring the feet
together. Replace the horn on the spline, and replace the screw.
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 13 of 23
Step 13: Attach BASIC Stamp 2px24 board to the Penguin body
The Penguin’s top board contains the BASIC Stamp 2px24 circuitry. It is mounted on the top of the
Penguin using (2) 2-56 1/4" button socket cap stainless steel screws and the 0.050” hex key. You’ll need
to fold the tilt servo’s wire over to tighten the board against the top of the Penguin.
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 14 of 23
Step 14: Attach Power Pack board to the Penguin body
The Penguin’s power pack board is installed using (4) 2-56 ¼” long flathead screws and the 0.050” hex
key. When you mount this board be sure that the servo wires are not preventing it from properly seating
into position.
Plug the servos back in. Connect the stride servo to J1 and the tilt servo to J2; make sure the white
leads are on the right, as shown in the photo.
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 15 of 23
Step 15: Install batteries and tidy servo wires
Install (2) CR123 batteries into the Penguin’s power pack. The batteries will be oriented in the same
direction; refer to the pictorial molded into the bottom of the battery holder’s plastic surface. Coil up the
servo wires behind the robot. It’s also possible to hide them in the Penguin’s body, but that requires
substantial attention to detail considering the lack of free space.
Step 16: Penguin is finished
Congratulations. Your Penguin is complete and ready for programming!
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 16 of 23
2.3. MECHANICAL TROUBLESHOOTING GUIDE
The Penguin is made from CNC-machined aluminum, molded plastic, screw-machine shoulder bolts, and
a variety of electronic components from different factories. There’s always the possibility that something
will go wrong and parts will bind or move with limited freedom – it’s nearly impossible to test every single
sub-assembly. For example, tolerances on the shoulder screws and plastic sockets can vary from batch to
batch or a shoulder screw bolt could have a slightly larger diameter shaft. It is imperative that your
Penguin operate smoothly and without friction to be an effective walker. Contact us if you have any
problems. Below are examples of common Penguin assembly difficulties and solutions to them.
Problem
Explanation
Ball link sockets
are tight or
binding.
The ball link sockets are molded parts and they
may vary in tolerance, though we’ve chosen a
supplier that offers a consistent product. The
socket and ball should move freely without any
friction when assembled. If you need to loosen
up tight-fitting ball links:
Legs move too
much from left
to right.
Ankles are too
tight within the
feet.
Legs are too
tight against the
body.
Picture
(a) Use an X-Acto knife to remove any plastic
burrs inside the plastic socket.
(b) Add a drop of oil into the socket.
(c) Reassemble the ball links and check for
friction.
Pressing the left and right legs together should
create no more than 1/8” to ¼” of movement (or
“slop” as it is called by a machinist). If a
particular leg seems to have too much side-toside play, you can fix this by tightening the
shoulder screw down another ¼ turn. If the
problem persists, you can gently chamfer the
threaded body panel with a drill to sink the
shoulder screw further into the body. Be careful
if you choose this option because you can
remove too much metal and the leg will tighten
against the body!
The ankles are the 1¼” long by ¼” diameter
round standoffs with two channels machined
between. The legs are pinned in these
channels. If the round ankle binds inside the
foot, slightly shorten the ankle by rubbing the
end of it on a piece of sandpaper. Insert the leg
assembly back into the foot and check the fit.
The correct adjustment for the legs depends on
the shoulder screws being tightened gently. If
the leg is binding against the body, back off the
shoulder screws so it can move. Use a dab of
Loc-Tite on the threads of the shoulder screw
so it stays screwed into position in the body
panel.
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 17 of 23
3.0 PROGRAMMING THE PENGUIN
3.1. PROGRAMMING CONCEPT
Programming the Penguin to walk is a matter of shifting its center of gravity from side to side with the tilt
servo, coordinated with moving the legs forward and backward with the stride servo. The BS2px24’s high
speed and expanded memory and RAM are useful for storing motion sequences and for performing the
computations needed in sensor-based autonomous navigation.
Close the Debug Terminal before downloading a new program, disconnecting the USB cable,
or switching off the power to your tethered Penguin! If you fail to close the Debug Terminal
before any of these actions, the port may hang up and the BASIC Stamp Editor may freeze when you
next try to program your Penguin. If this happens, close the Editor with the Task Manager. Be sure to
download the latest version of the BASIC Stamp Editor from www.parallax.com.
3.2. SERVO CALIBRATION
The Penguins servos must be calibrated before the Penguin can walk. This is a crucial step and the
Penguin will not walk without it.
1)
2)
3)
4)
5)
6)
7)
8)
Run Penguin-ServoCalibration.bpx.
Click in the white Transmit area at the top of the Debug Terminal.
Press Enter to enable the servos.
Press + and − to adjust the tilt servo until the Penguin can stand level.
Press the space bar to switch to the stride servo.
Press + and − to adjust the stride servo until the Penguin’s feet are in line with each other.
Press S to save the new settings.
Listen for the long beep to ensure that the settings were saved.
Tip: Pressing 1 through 5 changes the coarseness of the adjustments
3.3. PENGUIN’S BASIC STAMP 2PX24 PINOUT
I/O Pin
Description
Direction
P0
Photoresistor – right
Output
P1
Photoresistor – left
Output
P2
Infrared emitter – right
Output
P3
Infrared emitter – left
Output
P4
Infrared receiver
Input
P5
Front I/O expansion port
Input/Output
P6
Servo stride
Output
P7
Servo tilt
Output
P8
7-segment LED clock
Output
P9
7-segment LED data
Output
P10
7-segment LED latch
Output
P11
Rear I/O expansion port
Input/Output
P12
Speaker
Output
P13
Hitachi HM55B Compass – CLK (clock)
Output
P14
Hitachi HM55B Compass – CS (chip select)
Output
P15
Hitachi HM55B Compass – DIN/DOUT (data in/out)
Input/Output
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 18 of 23
3.4. EXAMPLE PROGRAMS
Download the following test programs from the Penguin product page at www.parallax.com and test that
each Penguin subsystem is working properly. Complete code listings are also included in this document.
y
y
y
y
y
y
Penguin-CenterServos.bpx, page 6
Penguin-SpeakerTest.bpx, page 20
Penguin-IRTest.bpx, page 21
Penguin-7SegmentLEDTest-v1.3.bpx, page 21
Penguin-PhotoresistorTest.bpx, page 20
Penguin-CompassTest.bpx, page 22
Once you are familiar with the I/O capabilities of the Penguin, the following programs can be used to
demonstrate all of the Penguin’s abilities. Download from the Penguin product page at www.parallax.com.
y Penguin-AutonomousNavigation.bpx
y Penguin-MigrateNorth.bpx
3.5. OPTIONAL COMPASS CALIBRATION
To improve the accuracy of the compass, the calibration routines for the Hitachi HM55B Compass Module
have been ported to the Penguin. With the calibrated compass routines added to the Penguin's control
code, extra RAM and code space is required. Separate versions of the following programs have been
created to allow for either more available resources or a more accurate compass.
Original Code
Code Incorporating a Calibrated Compass
Penguin-CompassTest.bpx
Penguin-CalibratedCompassTest.bpx
Penguin-AutonomousNavigation.bpx
Penguin-AutonomousNavigation-CalibratedCompass.bpx
Penguin-MigrateNorth.bpx
Penguin-MigrateNorth-CalibratedCompass.bpx
Before the calibrated compass routines can be used, Penguin-CompassCalibration.bpx must be run to
record the compass calibration data. For more information about compass calibration, please read the
product documentation and the associated code available from the #29123 product page at
www.parallax.com.
3.6. OTHER HELPFUL DOCUMENTATION
The following materials are helpful documents for programming the Penguin; each can be downloaded
from its associated product page:
y BASIC Stamp PBASIC Syntax Guide (on-line version of help file installed with the BASIC Stamp
y
y
y
y
y
Windows Editor)
HM55B Compass Documentation (#29123)
HM55B Graphical Viewer for the HM55B (#29123)
Smart Sensors and Applications (a Stamps in Class Text) (#28029)
IR Remote for the Boe-Bot Text (a Stamps in Class Text) (#70016)
Ping))) Ultrasonic Sensor Documentation (#28014)
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 19 of 23
3.7. TEST CODE LISTINGS
' Parallax Penguin Robot
' Penguin-SpeakerTest.bpx
' {$STAMP BS2px}
' {$PBASIC 2.5}
Speaker
PIN
12
i
Freq
VAR
VAR
Byte
Word
'Inverse of 12th root of 2 multiplied by 65536
'Used to divide by one semitone in a 12 note octave
Scale
CON
61858
Freq = 659
FOR i = 1 TO 12
FREQOUT Speaker, 600, Freq
Freq = Freq ** Scale
NEXT
'
'
'
'
Frequency of an E5
12 semitones = 1 octave
Play the frequency
lower frequency by 1 octave
' Parallax Penguin Robot
' Penguin-PhotoresistorTest.bpx
' {$STAMP BS2px}
' {$PBASIC 2.5}
RLDRPin
LLDRPin
PIN
PIN
0
1
LeftLDR
RightLDR
VAR
VAR
Word
Word
DEBUG CLS
DEBUG "Photoresistor sensor status:", CR,
"Left:", CRSRXY, 15, 1,"Right:"
DO
GOSUB
DEBUG
DEBUG
PAUSE
LOOP
READLDR
CRSRXY, 6, 1, DEC LeftLDR, " "
CRSRXY, 22, 1, DEC RightLDR, " "
150
ReadLDR:
RCTIME LLDRPin, 1, LeftLDR
HIGH RLDRPin
' Prepare debug screen
' Update debug screen with
' status of photoresistors
' Read R/C time for each
' photoresitor then recharge
' their capacitors
RCTIME RLDRPin, 1, RightLDR
HIGH LLDRPin
RETURN
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 20 of 23
' Parallax Penguin Robot
' Penguin-IRTest.bpx
' {$STAMP BS2px}
' {$PBASIC 2.5}
REmitter
LEmitter
IrInput
LeftIr
RightIr
CON
CON
VAR
VAR
VAR
2
3
IN4
Bit
Bit
DEBUG CLS
DEBUG "Infrared sensor status:", CR,
"Left:", CRSRXY, 15, 1,"Right:"
DO
GOSUB ReadIr
DEBUG CRSRXY, 6, 1, DEC LeftIr
DEBUG CRSRXY, 22, 1, DEC RightIr
PAUSE 150
LOOP
ReadIr:
FREQOUT LEmitter,1,6300
LeftIr = ~IrInput
FREQOUT REmitter,1,6300
RightIr = ~IrInput
RETURN
' Prepare debug screen
' Update debug screen with
' status of IR sensors
' Modulate emitters at 38KHz
' and check for reflections
' Parallax Penguin Robot
' Penguin-7SegmentLEDTest-v1.3.bpx
' {$STAMP BS2px}
' {$PBASIC 2.5}
' Rev A. boards use the OUTC port to control a 74LS47 BCD to 7-segment decoder
LEDDisplay
VAR
OUTC
' The LED display mirrors OUTC
' Rev. B boards use a 74HC595 shift register to individually set and clear LEDs
LED_CLK
PIN
8
' LED's shift register clock pin
LED_DATA
PIN
9
' LED's shift register data pin
LED_LATCH
PIN
10
' LED's shift register latch pin
ShiftData
Index
VAR
VAR
DIRC = %1111
Byte
Nib
' Set all used I/O pins as outputs
DO
FOR Index = 0 TO 9
' Loop numbers 0-9 on the display
' For Rev. B PCBs, send data to the shift register
READ Index, ShiftData
SHIFTOUT LED_DATA, LED_CLK, LSBFIRST, [ShiftData]
LED_LATCH = 0
' Then create a falling edge
LED_LATCH = 1
' To latch the data to the LEDs
' For Rev. A PCBs, set the 74LS47 in parallel through OUTC
LEDDisplay = Index
PAUSE 750
' Wait 3/4 of a second
NEXT
LOOP
' Font for the Rev. B display
DATA $06, $CF, $A2, $C2, $4B, $52, $13 ,$CE, $02, $42
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 21 of 23
' Parallax Penguin Robot
' Penguin-CompassTest.bpx
' {$STAMP BS2px}
' {$PBASIC 2.5}
Compass
Clock
Enable
PIN
PIN
PIN
15
13
14
' Transceives to/from Din/Dout
' Sends pulses to HM55B's Clock
' Controls HM55B's /Enable
Reset
Measure
Report
Ready
NegMask
CON
CON
CON
CON
CON
%0000
%1000
%1100
%1100
%1111100000000000
'
'
'
'
'
Reset command for HM55B
Start measurement command
Get status/axis values command
11 -> Done, 00 -> no errors
For 11-bit negative to 16-bits
x
y
Heading
status
VAR
VAR
VAR
VAR
Word
Word
x
x
'
'
'
'
x-axis data
y-axis data
Store Heading measurement
Status flags
DEBUG CLS, "Heading:"
DO
GOSUB ReadCompass
DEBUG CRSRXY, 9, 0, DEC Heading, "°
PAUSE 150
LOOP
"
ReadCompass:
' Compass module subroutine
HIGH Enable
' Send reset command to HM55B
LOW Enable
SHIFTOUT Compass, Clock, MSBFIRST, [Reset\4]
HIGH Enable
' HM55B start measurement command
LOW Enable
SHIFTOUT Compass, Clock, MSBFIRST, [Measure\4]
status = 0
' Clear previous status flags
DO
' Status flag checking loop
HIGH Enable: LOW Enable
' Measurement status command
SHIFTOUT Compass, Clock, MSBFIRST, [Report\4]
SHIFTIN Compass, Clock, MSBPOST, [Status\4]' Get Status
LOOP UNTIL status = Ready
' Exit loop when status is ready
SHIFTIN Compass,Clock,MSBPOST,[x\11,y\11] ' Get x & y axis values
HIGH Enable
' Disable module
IF (y.BIT10 = 1) THEN y = y | NegMask
IF (x.BIT10 = 1) THEN x = x | NegMask
Heading = x ATN -y
Heading = Heading */ 360
RETURN
Copyright © Parallax Inc.
' Store 11-bits as signed word
' Repeat for other axis
' Convert x and y to brads
' Convert brads to degrees
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 22 of 23
4.0 ELECTRONICS
4.1. CR123 BATTERIES
The Penguin uses CR123 batteries (sometimes also referred to as size “N”). Quality CR123 batteries
provide up to one amp-hour of power. CR123 batteries are truly overpriced from readily available sources
(drug stores, grocery stores). For example the Energizer and Duracell CR123s are priced around $12.00
per pair.
Parallax has tested all major brands of CR123 batteries (summarized below) and we buy them in bulk. In
our tests, we used a fixed current draw of 200 mA at 6V. We measured the time required for the battery
voltage to drop below 2.75V. Surprisingly, the tests showed almost no correlation between cost and
performance! The batteries we are selling (Rayovac and Panasonic) have approximately the same
capacity as the more expensive ones and they’re sold by Parallax at less than half the price of retail
outlets! Don’t be fooled into paying high prices for CR123 batteries. If you don’t buy your CR123 batteries
from Parallax then check eBay for the same brand we are selling (usually Rayovac or Panasonic). Pay no
more than $2-3 each. The Penguin’s current draw during full operation is around about 150 mA. With two
Rayovac CR123 batteries it should run for at least six to eight hours.
CR123 Manufacturer
Discharge time
Energizer
270 mins / 4.5 hours
Rayovac
240 mins / 4.0 hours
Duracell
225 mins / 3.8 hours
Panasonic
210 mins / 3.5 hours
Sanyo
150 mins / 2.5 hours
Chinese-label
5 mins / 0.1 hours
CR123 Battery Test with 200 mA Current Draw
Conducted by Tigerbotics and Parallax June 2007
3
2.95
2.9
Voltage
2.85
Energizer
Rayovac
Duracell
Panasonic
Sanyo
WWTach
2.8
2.75
2.7
2.65
2.6
2.55
2.5
0
1
2
3
4
5
6
Time (hours)
4.2. SCHEMATIC
(Schematic PDF is appended, next page)
Copyright © Parallax Inc.
Penguin Robot (#27313-27316)
v1.4 2/16/2010 Page 23 of 23