FIGURE 9. Partial listing of the Real_Puppet.BAS
program for controlling the puppet.
FIGURE 6. The body is hinged at the
hips and moved with a servo. The
Parallax servo controller simplifies
the controlling program.
FIGURE 7. The complete puppet looks
very lifelike when being manipulated
with the joystick.
universal joints on an automobile
driveshaft) while ensuring a secure
connection. The body is hinged to the
hips allowing a small side-to-side tilt.
Figure 6 shows how the servo is
mounted to control this movement.
The connecting rod passes through a
hole in the bottom of the body and
connects to an eye-bolt in the hip
surface. Figure 6 also shows a Parallax
USB servo controller that will be discussed later. The arms aren’t functional
in a true robotic sense, but the pull of
a string creates just enough movement
to add to the illusion of life.
Figure 7 shows the fully clothed
and painted puppet. Fake fur from a
cloth store was used for hair. The USB
cable for the servo controller, as well
as a power cable are run down the
puppet’s leg and extend from the bottom of the pants to make connections
38 SERVO 11.2008
//——Constants
COMMS_PORT = 1
JOYSTICK_PORT = 1
//====================================================================
MainProgram:
GoSub Instructions
GoSub SetUp
GoSub Initialize
GoSub Start_Control
GoSub FinishUp
Exit
//====================================================================
Read_Joystick:
GetButton btn
if btn == Buttons[0] then n=MsgBox(I_M)
if btn == Buttons[1] then Quit = true
joystickE JOYSTICK_PORT,jvalue
jx = jvalue[0,0]/(jvalue[0,2]-jvalue[0,1])
jy = jvalue[1,0]/(jvalue[1,2]-jvalue[1,1])
jz = jvalue[2,0]/(jvalue[2,2]-jvalue[2,1])
jr = jvalue[3,0]/(jvalue[3,2]-jvalue[3,1])
jb = jvalue[6,0]
jhat = jvalue[7,0]
Return
//====================================================================
Start_Control:
while !Quit
GoSub Read_Joystick
//—-check buttons first (special movement combinations
if jb == B_Yes then GoSub Yes_Combo \ continue
if jb == B_No then GoSub No_Combo \ continue
if jb == B_Combo1 then GoSub Combo1 \ continue
if jb == B_Combo2 then GoSub Combo2 \ continue
//—-then move all motors based on joystick’s position
GoSub HeadR_Movements
GoSub HeadT_Movements
GoSub Arms_Movements
GoSub Brows_Movements
GoSub Eyes_Movements
GoSub Mouth_Movements
GoSub Torso_Movements
wend
Return
//====================================================================
Yes_Combo:
//—-Yes comination movement
m = “Yes”
xyText 0,100,m+spaces(20),””,20,fs_Bold
ramping = HeadTRamping
channel = HeadTChannel
for i = 1 to 3
nn = 750
a = char(channel)+char(ramping)+char(nn&255)+char((nn >> 8)&255)
SerOut “!SC”,a,char(13)
delay 500
nn = 950
a = char(channel)+char(ramping)+char(nn&255)+char((nn >> 8)&255)
SerOut “!SC”,a,char(13)
delay 500
next
Return
//====================================================================
HeadR_Movements:
//—-rotate the head
ramping = HeadRRamping
channel = HeadRChannel
if HeadRTime < Timer()
rHeadR =random(HeadRRandomness)-HeadRRandomness/2
HeadRTime = Timer()+1000 // random movement every 1000 mseconds
endif
nn = HeadRLowLimit+round(jr*(HeadRHighLimit-HeadRLowLimit))+rHeadR
a = char(channel)+char(ramping)+char(nn&255)+char((nn >> 8)&255)
SerOut “!SC”,a,char(13)
Return
//====================================================================