The Complete 2DoF Hexapod Tutorial

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

The Complete 2DOF Hexapod Tutorial

Updated September 30, 2010

This tutorial follows the 2DOF Hexapod assembly guide. Make sure all servos and other connections are set up as detailed there.

Required Hardware

Any Lynxmotion 2 DOF Hexapod, SSC-32, Bot Board / BASIC Atom Pro 28, PS2 Cable, PS2 Wireless Controller (not included in combo kit), Sharp GP2D12 Sensor (optional)

Required Software

LynxTerm (free download) | Basic Micro Studio ver 2.0.0.0
Basic Atom Pro Hexapod Programs: h2prog01.zip PS2 | h2prog02.zip PS2 | h2prog03.zip PS2 | h2prog04.zip Autonomous

Resources

Wiring Schematic (2dofsch2.gif)

Goal

Install, program, and test the electronics to operate a Hexapod 2 remotely from a Lynxmotion wireless controller or autonomously using sensors.

2DOF Hexapod Tutorial — Establishing Communication
Step 1 / 10

Connect the serial data cable to the PC's serial port (recognized by 9 pins that stick out). Connect the other end to the SSC-32's DB9 port.

Note: if your computer does not have a native serial port, you can use a high quality USB to Serial adapter such as one made by FTDI. If using an FTDI adapter, install the VCP (Virtual Com Port) driver and change the "latency" property to its minimum.

Figure 1.
2DOF Hexapod Tutorial — Install & Test LynxTerm
Step 2 / 10

Install and run LynxTerm on your PC. Plug in the 9VDC battery and notice the green LED light up on the SSC-32. Choose the COM port from the drop down menu in the upper left corner.

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

Note: the LED on the SSC-32 is a status indicator, not a power indicator. It lights up on power up, turns off after receiving a serial command, then blinks when it receives data. The LED on the Bot Board II is a simple power indicator.

Figure 2. (click to enlarge)
2DOF Hexapod Tutorial — Aligning the Servos
Step 3 / 10

Place the robot on top of a CD spindle or similar object to support the body and lift the legs off the ground. Make sure the 6V battery is connected to the wiring harness and flip the power switch to ON.

Click the "All=1500" button at the bottom of the program and the legs should move to a centered position. If the robot was constructed properly, the legs will be horizontal and perpendicular to the body. If the legs are more than 15° off, remove the output horn, rotate it, and reinstall it. The next step is to align the servos in software.

Figure 3.
2DOF Hexapod Tutorial — Fine-Tuning Servo Alignment
Step 4 / 10

Click on the H2 Sequencer button in the lower left corner. Use the Offset tool under Servo Quick Test. Click "Read" to load any previous offset settings. Select each servo on the Hexapod diagram and adjust the offset slider to fine-tune the leg alignment. Do this for all twelve servos. When completed, click "Write" to save your offsets to the SSC-32 EEPROM.

Refer to Figures 4-2 and 4-3 for how each servo should be aligned.

Figure 4-1. (click to enlarge)
Figure 4-2.
Figure 4-3.

Schematic. Double check your connections. Red wires to positive (+), black wires to negative (−). Note: your PS2 cable may not match Schematic 1 — refer to Schematic 2 for accurate connection information.

Schematic 1.

Schematic 2.

2DOF Hexapod Tutorial — Programming the Microcontroller
Step 5 / 10

Install and run the BASIC Micro Studio to allow programming the chip. Refer to this tutorial for assistance using the BASIC Micro Studio program.

Available Programs
h2prog01.zipDefault program
h2prog02.zipTank mode and single joystick mode
h2prog03.zipSingle joystick mode and pan-and-tilt on left joystick
Figure 5.
2DOF Hexapod Tutorial — PS2 Control
Step 6 / 10

Control the direction of walking with the right joystick. Left and Right on the D-Pad adjusts speed in 5% increments (up to 200%). The joystick positions will allow a max of 100% XS speed initially.

Both modes offer additional control of leg trajectory. Pressing △, O (default), X, or □ changes how the foot is lifted during the walking gait.

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

Figure 6.

PS2 Controls — Right-Joystick Mode (h2prog01.zip)

L Joy UTilt Servo upR Joy UForward
L Joy DTilt Servo downR Joy DBackward
L Joy LPan Servo leftR Joy LLeft
L Joy RPan Servo rightR Joy RRight
See Figure 8See Figure 8
XSee Figure 8OSee Figure 8
D-Pad LSpeed Limit DownD-Pad RSpeed Limit Up
StartDisable/Enable Crash Monitor

PS2 Controls — Right Joystick Mode (h2prog03.zip)

L Joy UTilt Servo upR Joy UForward
L Joy DTilt Servo downR Joy DBackward
L Joy LPan Servo leftR Joy LLeft
L Joy RPan Servo rightR Joy RRight
All other commandsSee Tank Mode table below

PS2 Controls — Tank Mode or Right Joystick Mode (h2prog02.zip)

L Joy ULeft Side Forward (N/A)R Joy URight Side Forward (Forward)
L Joy DLeft Side Backward (N/A)R Joy DRight Side Backward (Backward)
L Joy L/RN/AR Joy L/RN/A (Left/Right)
L1Raise body heightR1Increase leg lift
L2Lower body heightR2Decrease leg lift
L3N/AR3Switch control mode
D-Pad URaise body heightSee Figure 8
D-Pad DLower body heightXSee Figure 8
D-Pad LSpeed Limit DownSee Figure 8
D-Pad RSpeed Limit UpOSee Figure 8
StartDisable/Enable Crash MonitorSelectN/A
2DOF Hexapod Tutorial — Autonomous Control
Step 7 / 10

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

The exact angle of the sensors isn't critical, but will affect the robot's behavior. Experimentation is encouraged.

Autonomous Program
h2prog04.zipAutonomous using two Sharp GP2D12 sensors and one on the rear
Figure 7.
2DOF Hexapod Tutorial — Hexapod Sequencer
Step 8 / 10

The Hexapod Sequencer can be used to test the hexapod without a microcontroller. Connect the SSC-32 to the serial port as if aligning the servos, then follow along.

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 8. (click to enlarge)
2DOF Hexapod Tutorial — Walking the Robot
Step 9 / 10

Adjust the XL and XR sliders to 100%. Note that HT=1500uS (1.5 seconds). 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 either XL or XR lower to do gradual turns. Setting XL and XR to opposite directions causes the robot to turn in place. Reverse values cause the robot to walk backwards.

Moving a slider is the same as sending the command from a microcontroller — for example, moving XS to 50% is the same as sending "XS50". The robot will continue to walk until it receives XS = 0.

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

The following program will set up and initiate walking on the robot. To change speed and direction, just alter the XL, XR, XS values. The robot will immediately begin walking in the speed and direction commanded.

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
Tags:
Created by Eric Nantel on 2024/07/03 09:20
Copyright RobotShop 2018