Puppy Instruction Manual
Puppy Instruction Manual
Playful Puppy
Instruction Manual
Manufacturer:
DAGU Hi-Tech Electronic Co.,LTD
WWW.AREXX.COM.CN
Address:NO.4-107/108 HengXing Street, HengHai Rd, South District, ZhongShan City of GuangDong China
TEL:0760-88811951
http://www.arexx.com.cn
E-mail:info@arexx.com.cn 1
Contents
Product description 3
Warnings 3
Required tools 3
Parts list 4
Assembly instructions 5
Wiring Instructions 9
Trouble Shooting 25
Controller specifications 26
2
Product Description
Thank you for selecting the Playful Puppy for your next do-it-your-self project. This kit
allows you to build and program a small quadruped robot that can track moving objects
and respond to your hand movements.
Product Features
1. Arduino compatible robot controller with USB interface.
2. Laser cut, transparent acrylic base plate.
3. 10x 9g miniature servos.
4. 1x pan tilt assembly with magnetic servo clutches.
! Warnings:
Opened packages can not be returned. Please check package contents before opening.
Read the instructions carefully before assembly.
Use all tools carefully.
Small parts are a choking hazard. Keep this kit away from young children and babies
during construction and operation.
Not for children under 8 years. Not to be used by children except under adult
supervision.
Observe the correct polarity of the battery.
Keep the battery dry at all times.
Do not mix old and new batteries. Do not mix alkaline, standard (carbon-zinc), or
rechargeable (nickel-cadmium) batteries.
Remove the battery if the kit is not used for a long period of time.
Necessary
Tools:
Please read this manual thoroughly before you start assembling the kit. Please follow the
assembling instructions exactly to avoid problems. If you work accurately and follow the
instructions in this manual exactly, you will quickly assemble your Playful Puppy robot.
Before you start you must prepare the following tools:
3
Parts List:
1 2 3 4 5
9g servo clutchplate
Base plate 1pc 9g geared motor 10pcs Round servo horn 4pcs Servo horn-2 4pcs 2pcs
6 7 8 9 10
Servo mounting
Clutch-drop shape 1pc Leg segment 8pcs 5x3mm magnet 16pcs EVA feet 4pcs bracket 1pc
11 12 13 14 15
16 17 18 19 20
M2*6 self-tapping M2*6 self-tapping M2*8 self-tapping M2.3*12 self-tapping M2.6*8 self-tapping
screw with flange 16pcs screw 12pcs screw with flange 4pcs screw 2pcs screw 2pcs
21 22 23 24 25
M3*6 screw 10pcs M3*8 screw 2pcs M3 nut 10pcs M3 Nyloc nut 1pc Washer 5pcs
26 27 28 29 30
31 32 33 34 35
36
Spiral wrap tail 1pc 4
Assembly Instructions:
Before you begin assembly Step 1:
set all your servos to center Servo
position as shown. output 14
shaft
x4
Step 2:
17
7 18
4 attach legs so
knee bent at 90°.
x4
Step 3: Please note that servo
14 mounts differently for
14
left and right legs.
2
2
x2 x2
5 0 inch 1 inch 2 inch
Step 4: 16 Step 5:
17
Step 6: 20
Note position
of hip servos
and mount legs
at 90° to body.
Step 7:
21
10
2
12 15
34 19
25
30 x2
30 x2 23
5
5
Install 8x Magnets in both clutch
34
pieces so the
poles alternate
as shown.
Pay careful attention to
which bracket you use.
The hole patterns are
different to suit various
sensors.
22 25(2pcs)
19 15
30 x2
Step 10: 23
21 31 26
32
33 27
28
23
Step 13:
36
29
22
8
Wiring the robot:
Start by plugging the rainbow cable into the eye. Pay careful attention to the colours to ensure correct function of the
eye. Thread the cable under the tilt servo an use a cable tie to hold it in place. Leave this cable tie very loose so that
the cable can move a bit if necessary.
Red wire
Please note that connects
the brown wire to Vcc
has been swapped
to the other side
Loose
cable tie
The Mini Driver includes a dual motor driver that is not used for this robot. By disconnecting the jumpers we can
access the control pins. Disconnect the Jumper for D8 and connect the violet wire. This wire controls the IR LEDs on
the compound eye. Now connect the blue, green, yellow and orange wires to A2, A3, A4 and A5 as shown. These are
your analog signals from the compound eye.
D8
When servos are not being used this jumper can be set
to 5V allowing digital sensors to be powered from the 5V
regulator instead.
9
In this robot, A0 and A1 are being used as digital outputs instead of analog inputs to drive the pan and tilt servos.
These servos are getting power through the 5V regulator so they cannot be heavily loaded.
Connect the "tilt" servo to A1 as shown in the first photo. Make sure the brown ground wire is closest to the outer
edge of the PCB. Next connect the "pan" servo to A0 as shown in the second photo.
Tilt servo
Pan servo
Loosely cable tie the front knee and hip servos as shown. Make sure the knee and hip can both move freely over their
entire range before tightening the cable tie. Repeat the process for the rear legs. Feed these cables through the
holes in the base plate as shown.
Cable ties
Make sure
the cable is
long enough
10
Installing the software:
The CD includes a copy of all third party software required for those without internet access. It is recommended that you check the
internet for the latest versions. To install the sample code you must first have the Arduino IDE version 1.03 or later running on your
computer. The Arduino IDE can be downloaded for free from here: http://arduino.cc/en/Main/Software. The Arduino IDE is available
for Windows, Mac and Linux platforms.
The robot controller uses the CP2102 USB interface IC. Depending on your OS you may need to install drivers. These are included
on the CD or you can download the latest from here:
http://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx.
Once you have the Arduino IDE running you can goto the PlayfulPuppy folder and open the "PlayfulPuppy.ino" file on your CD. If
your CD is lost or damaged you can download the software from the DAGU product support site here:
https://sites.google.com/site/daguproducts/
The Playful Puppy robot uses the Mini Driver robot controller from DAGU. Before we can upload the sample code we must select
the correct board type and serial port. This is done in the Tools menu. Select "Arduino NG or older w/ATmega8" as your board type.
11
Installing the software ( cont.):
Before you plug the robot into the computer make sure you have 4x freshly charged AAA NiMh batteries installed and the power
connector plugged in the correct way. Turn off the robot while uploading the new program to stop the robot from trying to move. The
processor and head servos will be powered from the USB port but the leg servos will not have power.
If you are using a small laptop or your USB ports are heavily loaded then your computer may not be able to power the robot through
the USB. In this case, leave the robot turned on and put it on it's back so it cannot try to run away.
Before you upload the code it is always good practice to verify it first. This will compile the code and check for any errors before
attempting to upload the code. When you click on the upload button a progress bar will appear at the bottom. The message "Done
compiling." and the size of the compiled code will appear when the process is complete.
Once the code has been verified you can upload the code to the robot. The progress bar will appear again and the D13 LED on the
controller will flash a few times. Once the message "Done uploading." appears you can disconnect the robot and turn it on. The
robot will not start immediately. This gives you time to put it on the ground.
12
Controlling the robot:
Using the sample code provided, the puppy responds to movement. When your hand or any object is in range (within
15cm - 20cm) of the puppy's compound eye the puppy will track the movement of your hand with it's head.
When standing the puppy will follow your hand and if necessary, will turn to try and keep your hand in front of it. If
your hand gets too close the robot will back up. If your hand is too far away (but still in range) then the robot will walk
forward.
If you do not play with the puppy it will get bored and sit down. While the robot is sitting, if you slowly move your hand
down and then towards one of the front legs it will lift that leg to "Shake Hands". If you move your hand between the
legs the robot will lie down.
To get the robot back up on it's feet you need to make it look straight up. Making the puppy look straight up will get it
to jump up on it's back legs.
13
Understanding the Code:
Although you can play with the robot using just the sample code provided, the real fun is in teaching it new tricks!
This section explains some of the basic features of the code and how they can be changed. Do not be afraid to
experiment, you can always restore the original code if you make a mistake.
Below is a flowchart of the sample code. A flow chart is not actual code, it is more like a map showing blocks of code
and the different paths the processor can follow within your code. Lines linking the blocks have an arrow head
showing the direction that the processor must follow along the path.
As you can see, once the processor enters the loop(), no matter which path it takes, they all return back to the loop
and the process is repeated. The only way to break out of the loop is to switch the power off or reset the processor.
Depending on the inputs from the sensors and the values of the timers, different paths are taken
as the code repeats the loop over and over again. If you write additional code to teach the puppy
new tricks then additional pathways will be added to the map.
On / Reset
Include
Servo library
Constants
IOpins
define
global variables
and servos
setup()
Initialize servos
configure pins
loop()
IReye()
IRtrack()
Is puppy
bored?
Yes No
SitShake
Liedown()
Follow()
Puppy
sitting?
Yes
Get No
up
Shake Shake
Left Right Play()
Lie
down Take Look
Sitting step? up?
Motion() Do
Walking nothing
Jump()
Motion()
14
Understanding the code (cont.)
If you are new to Arduino then a guide to all the main commands and functions can be found by going to help and
selecting reference.
The first tab is the main program. In the beginning the <Servo.h> library and definitions are added. Then global
variables and servos are defined.
The setup() function runs only once when the program first runs. This is where the servos are attached to their digital
pins and initialized to their center positions. By default, all digital pins are configured as inputs on startup as a safety
precaution. The pinMode() command is used here to reconfigure the IRleds pin to become a digital output so it can
control the IR LEDs on the compound eye.
The loop() function is the main section of code. As the name suggest, this code is run repeatedly until the processor
is reset or turned off.
15
Understanding the code (cont.)
The second tab is [Constants.h]. This tab contains definitions for constant values that do not change when the
program is running. In this tab we can set the center position of each servo and experiment with some other values
that affect the way the robot walks and tracks movement.
Normally the servos should be centered at 1500. If they need a big adjustment you should re-seat the servo horn. For
fine adjustment (+/- 200) you can change the center values in this tab.
The Boredom constant determines how long the robot will wait for you to play with it before it gets bored and sits
down. 3000 milliseconds = 3 seconds.
The speed and stepsize constants can be used to change the gait of the robot. Bigger steps need more time for the
servo to move but cover more ground. Smaller steps can be completed quicker and might offer smoother movement.
Making the speed value smaller will make the robot faster but if it is too small then the servos will not keep up and the
robot will not walk properly.
The constant bestdistance is the average distance the robot tries to maintain between itself and the object it is
tracking. Bigger values = smaller distance. Closer distances make it easier to maintain a lock on the object.
The constant distancemax is the maximum distance an object can be before the robot ignores it. If this value is too
small then the robot will confuse ambient light for an object. The smaller the value, the greater the distance.
LRscalefactor and UDscalefactor are used to adjust how quickly the head moves in response to an object. In most
cases you do not need to adjust these values. If the head moves too quickly it can overshoot and the head will tend to
vibrate or constantly shake. Too slow and the robot will loose it's lock on a moving object. If you make changes to the
code that affect how quickly the main loop repeats then these values may need adjustment to compensate.
IRdelay is the time in microseconds needed for the photo transistors in the compound eye to respond to changes in
the IR light when the IR LEDs turn on or off. Increasing this value may improve the robot's sensitivity a bit but it will
also make the robot slower and less responsive.
16
Understanding the code (cont.)
The [IOpins.h] tab is your programs wiring diagram. If you want to change which pins are used for a servo or sensor
then that change must be reflected here. If you need to replace a servo or even if you are wiring up the robot for the
first time then this tab is your guide as to what device connects to which pin.
The [IReye] tab is where the data from the eye is generated. This code first takes a reading of all sensors
with the IR LEDs turned ON. This reading is a combination of the ambient IR light plus the IR light from the
LEDs being reflected from any nearby objects.
Then the LEDs are turned OFF and the sensors are read again. This reading is only the ambient IR light.
These values are subtracted from the previous sensor readings to give a value equal to just the IR light
from the IR LEDs being reflected by any nearby objects.
This value depends a lot on the size and colour of the object being tracked. If there is a lot of ambient IR
light such as bright sunlight then the sensor can be blinded. The eye works best indoors or at night.
17
Understanding the code (cont.)
The tab [IRtrack] is where the data from the compound eye is used to control the pan and tilt servos. If there are no
objects nearby then the head will slowly return to center position.
Basically the code adjust the pan servo to keep the left and right IR values equal. The tilt servo is adjusted to keep
the upper and lower IR values equal. This keeps the sensor facing directly at any nearby object.
The variables panscale and tiltscale are used to try and compensate for distance and the speed at which the
program runs. The constants, LRscalefactor and UDscalefactor can be changed in the [Constants.h] tab to
compensate for changes in the code that affect the speed of the code.
The code in the [Follow] tab is where the speed and direction of the legs are controlled. If the head has to
turn too far to track an object, the LShift and RShift walking speeds are adjusted to turn the body towards
the object being tracked. These speeds are then adjusted forward or backward to try and maintain
bestdistance from the object being tracked.
18
Understanding the code (cont.)
This robot uses some timers in the code to control certain functions. This is done using the millis() function which
counts the number of milliseconds since the robot was turned on. We will briefly look at how the unsigned long
variable sit is used to measure boredom in the robot.
In the [Play] tab, sit is set to equal the value reported by the millis() function whenever the robot takes a step. This
resets the boredom timer because the difference between millis() and sit is reset to 0.
In the loop() section of the code, the difference between millis() and sit are compared to the constant Boredom.
The result is that if the robot does not take a step for Boredom milliseconds then the robot will become bored and sit
down. Once this happens, the timer cannot be reset unless you make the robot look up at which point the variable sit
is set to equal the new value of millis() in the [SitShakeLiedown] part of the code and the difference is now 0 again.
In the loop() function, the program constantly reads the sensors in the eye, tracks movement with the head. If the
puppy is not bored then it will follow your hand and walk / jump in play mode. If the puppy becomes bored then it will
sit down. In this mode it will shake hands or lie down.
19
Understanding the software (cont.)
If the robot is not bored then the code in the [Play] tab determines if the puppy walks or jumps. Normally the puppy
will walk unless the size of the steps, determined by the distance is too small. If the head tilts far enough upward to
track the object then the robot will jump.
The code for the puppy's walking motion (gait) is in the [WalkingMotion] tab. The gait consist of 10 steps with
nothing happening in steps 2,4,7 & 9 to allow more time for the legs to move forward / backward. Essentially, two
diagonally opposite legs lift simultaneously, move forward or backward by the values LShift, RShift then lower
again. Then the other two legs raise, move and lower.
Negative values of LShift and RShift make the legs go backward instead of forward. The Speed constant
determines the number of milliseconds between steps in the gait. Stepsize set the limit for the size of the steps.
20
Understanding the software (cont.)
When the puppy first becomes bored, the code in the [SittingMotion] tab is called. So that the robot does not just
suddenly drop down, the same timer used to measure boredom is used to control the robots sitting speed with the
rear legs slowly straightening at the knee and moving forward at the hips.
Once the robot is sitting the code in the [SitShakeLiedown] tab determines the behavior of the puppy. While in the
sitting position the robot will still track movement with it's head. If the head tracks movement towards either front leg
then that leg will lift so that the puppy can shake hands. If the head tracks movement down and between the legs then
both front legs will lift causing the puppy to lie down.
To break out of the sit, shake, lie down mode the robot must track movement upward causing it's head to tilt straight
up. This will reset the boredom timer and put the puppy back into play mode.
21
Uploading via the ISP socket:
Since version 1.0 of the Arduino IDE it has been possible upload your programs directly to the processor using the
ISP socket. This will overwrite the bootloader making more memory available and cause your program to start
immediately on power up or reset.
To do this we need a programmer. If you have a programmer, please refer to it's instruction manual. These
instructions will explain how to use an Arduino or compatible board as the programmer.
Using the example code supplied with the Arduino IDE you can use another Arduino or Arduino compatible board as
a programmer. Go to the File menu, Examples and select ArduinoISP.
Upload this program into another Arduino or an Arduino compatible controller. This will then become your
programmer. Use jumper wires to connect your programmer to the puppy robot's ISP socket as instructed in the
programmer code.
22
Uploading via the ISP socket (cont.)
You can connect the wires directly from the ISP socket of the programmer to the ISP socket of the puppy or you can
use the digital pins. Note that D10 or D53 of the programmer is connected to the reset pin of the puppy.
Configuration for D12 / MISO Vcc
1 2
boards using:
D13 / SCK D11 / MOSI
ATmega 328 3 4 Vcc MISO MISO
2 1 1 2
ATmega168 D10 or RESET Gnd
5 6 MOSI SCK SCK MOSI
ATmega8 4 3 3 4
Gnd RESET Gnd
6 5 5 6
Programmer Puppy Robot
ISP header ISP header
D50 / MISO Vcc
Configuration for 1 2
boards using:
D52 / SCK D51 / MOSI
3 4
ATmega 2560 Programmer
ATmega1280 D53 or RESET Gnd D10 or D53
5 6
The programmer can be any Arduino compatible controller using an ATmega 8, 168, 328, 1280 or 2560 processor
with a 5V logic supply. No matter what board you use for the programmer, leave the board type as Arduino NG or
older w/ ATmega8 as this is the configuration of the puppy robot.
Go to the Tools menu, select programmer and choose your programmer type Arduino as ISP. Then select Upload
Using Programmer from the file menu.
23
Uploading via the ISP socket (cont.)
For no apparent reason you may get an error message. If you try and upload a second time then the program should
upload ok. If you continue to get this message then check your robot is turned on and that the batteries are fully
charged. Check the wiring and make sure your board type and programmer type are set correctly. The serial port
must be set to the programmer.
The procedure is very similar to uploading code via the ISP socket. If you have not done so already, configure an
Arduino or compatible board as your programmer as explained on page 21.
Once your programmer is prepared, go to the Tools menu and select your serial port to suit your programmer. Select
the board type to Arduino NG or older w/ ATmega8. Now select Burn Bootloader.
As with programming via the ISP socket you may get an error message the first time. Select Burn Bootloader a
second time and it should work fine.
More detailed information on uploading code and burning the bootloader via the ISP socket can be found here:
http://letsmakerobots.com/node/35649
Letsmakerobots.com is a site dedicated to the hobby of robot making. membership is free. You can ask questions
on this site and get help from myself and other robot enthusiasts.
24
Trouble Shooting:
Please note that this robot is designed to work only with good quality, AAA NiMh batteries. Alkaline batteries will not
be able to deliver the current necessary and should not be used. Do not use a 2S LiPo battery as the voltage is too
high and may damage the servos.
Q. The robot tries to stand up or move but then stops, waits a while and tries again.
A. The batteries are getting flat or the servo power selection jumper is in the wrong position. See page 9.
The pan / tilt assembly is too tight causing the pan /tilt servos to overload the regulator.
Q. I have been experimenting with the code and now the head tracks objects too slowly.
A. As you add more code the speed at which the program loops may slow down.
Try increasing values of LRscalefactor and UDscalefactor in the [Constants.h] tab. See page 15.
25
Robot Controller:
Specifications:
Ø
Input voltage 4.5V - 9V with reverse polarity protection rated at 4A.
Ø
LDO 5V regulator rated at 1A.
Ø
USB interface and ISP socket, can be programmed with USB cable or ISP programmer.
Ø
ATmega8A processor @ 16MHz with 8K FLASH, 1K SRAM and 512 Bytes EEPROM memory.
Ø
8x digital I/O pins with servos compatible 3 pin male headers and selectable power (+5V / +Battery).
Ø
6x analog inputs with regulated 5V and Gnd for powering analog sensors.
Ø
Built in battery monitor on analog input A7.
Ø
Dual FET "H" bridge rated at 2.5A per channel can drive 2x DC motor or 1x Stepper motor.
Ø
Serial port for optional Bluetooth transceiver.
26