The Complete Hexapod 2 Tutorial

Last modified by Eric Nantel on 2026/04/02 16:10

The Complete Hexapod 2 Tutorial

Updated January 26, 2007

Hardware

SSC-32, Bot Board / BASIC Atom 28, PS2 Cable, PS2 Wireless Controller (not included), Extreme Hexapod 2, L5/L6 Arm (optional), Sharp GP2D12 Sensor (optional)

Software

LynxTerm | Basic Micro Atom IDE ver 2.2.1.1
Note: if your Basic Atom chip has a "Rev-D" label on the bottom, you must use IDE v5.3.1.3.

Hexapod Programs: h2prog1.zip | h2prog2.zip | h2prog3.zip | h2prog4.zip | h2l56p5.zip | h2prog6.zip | h2prog7.zip Autonomous

Resources

Wiring Schematic (wd001.gif) | Wiring Schematic (h2l56wd.gif)

Goal

Install, program, and test the electronics to operate a Hexapod 2 with optional L5/L6 arm from a Lynxmotion, MadCatz, Pelican, or Hiteck wireless controller.

Hexapod 2 Tutorial — Install Electronics
Step 1 / 15

Install the Bot Board and SSC-32 onto the top of the robot as shown.

Figure 1.
Hexapod 2 Tutorial — Connect Power Wires
Step 2 / 15

Connect power wires for the servos as illustrated. Install VS1=VS2, VL=VS1, TX and RX, and both Baud jumpers for these tests. This will set the Baud rate to 115.2k and allow DB9 communications. Consult the SSC-32 user manual for more detailed information.

Figure 2. (click for printable version)
Hexapod 2 Tutorial — Connect Servos
Step 3 / 15

Connect the servos to their appropriate I/O channels. See Table 3 and consult the SSC-32 user manual. Double check your work — the header pins are close and numerous.

SSC-32 I/OServo
00Right Rear Vertical
01Right Rear Horizontal
02Right Middle Vertical
03Right Middle Horizontal
04Right Front Vertical
05Right Front Horizontal
16Left Rear Vertical
17Left Rear Horizontal
18Left Middle Vertical
19Left Middle Horizontal
20Left Front Vertical
21Left Front Horizontal
Figure 3.
Hexapod 2 Tutorial — Connect Serial Cable
Step 4 / 15

Step 4a. Connect the serial data cable to the PC's serial port (recognized by 9 pins that stick out).

Step 4b. Connect the other end of the serial data cable to the SSC-32's DB9 port. Turn on the power.

Note: you can also use an IOGear USB-to-Serial adaptor.

Figure 4.
Hexapod 2 Tutorial — Install & Test LynxTerm
Step 5 / 15

Install and run LynxTerm on your PC. Choose the COM port from the drop down menu in the upper left corner.

Click in the black text box and type "ver". If everything is working correctly, you should receive a response such as "SSC32-1.03XE".

Note: if text goes below the bottom of the box, it may be necessary to change font settings and/or the number of rows under Terminal Setup.

Figure 5. (click to enlarge)
Hexapod 2 Tutorial — Aligning the Servos
Step 6 / 15

Click on the Sequencer button in the lower left corner. Click "All = 1500" and notice the hexapod legs hold position. If the robot was constructed properly, the legs will be horizontal and perpendicular to the body.

If your robot does not have mechanical alignment, use the Offset tool under Servo Quick Test. Select each servo on the Hexapod diagram and adjust the offset slider. Do this for all twelve servos. When completed, click Config to display configuration data. The lines starting with "#0PO" can be cut and pasted into the serout command in the included programs — search for "Servo Offset" in the supplied programs and follow the instructions.

Figure 6. (click to enlarge)
Hexapod 2 Tutorial — Hexapod Sequencer
Step 7 / 15

The L* and R* textboxes control the positions the legs move to in the sequence. Fine-tune these values using the Servo Quick Test position slider.

Tripod Leg Movement Sequence
LFLeft Front HorizRFRight Front Horiz
LHLeft High VerticalRHRight High Vertical
LMLeft Middle VerticalRMRight Mid Vertical
LLLeft Low VerticalRLRight Low Vertical
LRLeft Rear HorizRRRight Rear Horiz
Figure 7. (click to enlarge)
Hexapod 2 Tutorial — Walking the Robot
Step 8 / 15

Adjust the XL and XR sliders to 100%. Set the XS slider to ~50% and notice the stride takes 3 seconds. Adjust HT to 1000 and the stride now takes 2 seconds.

You have complete control over all aspects of the tripod gait. Adjust XL or XR lower to do gradual turns. Setting them to opposite directions causes the robot to turn in place. Reverse values cause backward walking.

Figure 8. (click to enlarge)
Hexapod 2 Tutorial — Sample Walking Code
Step 9 / 15

Remove the TX and RX jumpers, install the data cable to the Bot Board, and configure the Baud rate jumpers for 38.4k. To change speed and direction, alter the XL, XR, XS values.

XL var sbyte XR var sbyte XS var byte XL = 100 XR = 100 XS = 100 start: serout p15,i38400,["LF1700 RF1300 LR1300",13] serout p15,i38400,["RR1700 LH1000 LM1700",13] serout p15,i38400,["LL1800 RH2000 RM1300",13] serout p15,i38400,["RL1200 VS3000 HT1500",13] serout p15,i38400,["XL",SDEC XL,"XR",SDEC XR,13] serout p15,i38400,["XS",DEC XS,13] loop: goto loop
Hexapod 2 Tutorial — PS2 Programs
Step 10 / 15

Install and run the BASIC Atom IDE to allow programming the chip. The following programs offer complete control through a wireless PS2 controller.

FilenameDescription
h2prog1.zipDifferential tank-steer mode
h2prog2.zipAbove, and single joystick mode
h2prog3.zipAbove, and leg high-position adjustable
h2prog4.zipAbove, leg low-pos. adjustable and obstacle detection
h2l56p5.zipAbove, and L5/L6 arm control
h2prog6.zipSame as h2prog4, single joystick mode and pan-and-tilt on left joystick
Figure 10.
Hexapod 2 Tutorial — Wiring the Robot
Step 11 / 15

Wire your robot as illustrated in the wiring diagram. The Sharp GP2D12 is not required, but offers crash protection if installed.

You can use a 7.2VDC battery for best performance, however if installing an L5 or L6 arm, 6.0VDC is recommended due to the micro servo on the gripper. For increased runtime, you can power the logic of the Bot Board and SSC-32 from a 9V battery — remember to remove the VS=VL jumpers on both boards.

Install the speaker enable jumper for audible feedback. Install the PS2 receiver module and put fresh batteries in your controller. When you run the program, you should hear beeps until the game controller is recognized. Press the Analog button and the legs should hold position.

Figure 11. (click for printable version)
Hexapod 2 Tutorial — Install PS2 Cable
Step 12 / 15

Install the Playstation 2 cable as illustrated in Figures 12-1 and 12-2.

Figure 12-1.

Figure 12-2.
Hexapod 2 Tutorial — PS2 Control Modes
Step 13 / 15

Make sure the controller is in Analog mode. Mode 1 (default) uses differential/tank mode — the right joystick controls the right legs, and the left joystick controls the left legs. Mode 2 controls walking direction with the right joystick. Pressing R3 swaps between modes.

Both modes offer control of leg trajectory. Pressing △, O (default), X, or □ changes how the foot is lifted. Control max vertical height with R1/R2. Control max low position with L1/L2 or D-Pad Up/Down.

If the robot is driven toward an obstacle, the forward joystick position is ignored after a threshold is reached. The controller will vibrate proportionally to obstacle distance. The Sharp sensor can be enabled/disabled with the Start button.

Figure 13. (click to enlarge)
Hexapod 2 Tutorial — PS2 Control Reference
Step 14 / 15

The Select button switches between Hexapod and Arm control modes.

Arm control: Move X and Y with the Left joystick, move Z (Base Rotate) and Wrist Angle with the Right joystick, close/open gripper with L1/L2, turn Wrist (L6 only) with R1/R2, invert X axis with L3, initialize Arm position with X, disable/enable Arm servos with △.

PS2 Controls — Default Tank Mode:

L Joy ULeft Side ForwardR Joy URight Side Forward
L Joy DLeft Side BackwardR Joy DRight Side Backward
L1Raise body heightR1Increase leg lift
L2Lower body heightR2Decrease leg lift
L3N/AR3Switch control mode
D-Pad URaise body heightFigure 12
D-Pad DLower body heightXFigure 12
D-Pad LSpeed Limit DownFigure 12
D-Pad RSpeed Limit UpOFigure 12
StartDis/En Crash MonitorSelectSwitch to Arm mode

PS2 Controls — Right-Joystick Mode:

L Joy U/D/L/RN/AR Joy UForward
R Joy DBackward
R Joy LLeft
R Joy RRight

PS2 Controls — Arm Control:

L JoyMove X and YR JoyMove Z and Wrist
L1Close GripperR1Turn Wrist Right
L2Open GripperR2Turn Wrist Left
L3Invert X AxisR3Switch control mode
XHome PositionDisable/Enable Servos
Figure 14.
Hexapod 2 Tutorial — Autonomous Control
Step 15 / 15

The autonomous program requires three Sharp GP2D12 sensors connected as follows:

  • A to D channel 0: front left side, facing right
  • A to D channel 1: front right side, facing left
  • A to D channel 2: rear, facing behind the robot
FilenameDescription
h2prog7.zipAutonomous using two Sharp GP2D12 sensors and one on the rear
Figure 15.
Tags:
Created by Eric Nantel on 2024/07/03 09:20
Copyright RobotShop 2018