The Complete 2DoF Hexapod Tutorial

Last modified by Eric Nantel on 2023/01/25 13:50

The Complete 2DOF Hexapod Tutorial. Updated 09/30/2010

Notice: 
  -
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, see text)

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.


Image of Hexapod 2.

 

 
Step 1. Establishing Communication. 
The first thing we need to do is establish a connection between your computer and the SSC-32 so that we can align the servos. This is done by using a program called LynxTerm on the PC with the SSC-32 connected. 

Connect the serial data cable to the PC's serial port. This can be recognized by having 9 pins that stick out. Connect the other end of the serial data cable to the SSC-32's DB9 port. 

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


Figure 1.

Step 2.
Install and run LynxTerm on your PC. Plug the 9vdc battery in and notice the green LED light up on the SSC-32. Choose the COM port for your computer 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 not a power indicator but a status indicator. Its job is to light up on power up showing the SSC-32 is 95% functional. After it receives a serial command it will turn off, and from there on it will blink when it receives data. This will happen even if the data is not formatted correctly. The LED on the Bot Board II is a simple power indicator.


Figure 2.

 
Step 3. Aligning the Servos.
Place the robot on top of a CD spindle or other similar object to support the body and lift the legs off the ground. Make sure your 6v battery is connected to the wiring harness and flip the power switch to the ON position to apply power to the servos. 

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


Figure 3.


Step 4.
Click on the H2 Sequencer button in the lower left corner.  

Since no servo is perfect, you will need to set offsets to center each servo. Use the Offset tool under Servo Quick Test. Click on "Read" to load any previous offset settings. Select the 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 on "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.

 


Figure 4-2.


Figure 4-3.


Schematic.
Double check your connections against the schematic below. Be sure that red wires go to positive (+) and black wires go to negative (-). Also be sure that your jumpers are connected the exact same way as detailed below. Note: Your PS2 cable may not match up with Schematic 1. Refer to Schematic 2 for accurate connection information.


  Schematic 1.



Schematic 2.

Step 5. Programming the Microcontroller.
The following steps refer to several programs that offer complete control of all aspects of the hexapod gait sequence through a wireless PS2 controller. Install and run the BASIC Micro Studio to allow programming the chip.

Refer to this tutorial for assistance on using the BASIC Micro Studio program.
 

Filename Program description
h2prog01.zip Default program. 
h2prog02.zip Tank mode and single joystick mode.
h2prog03.zip Single joystick mode and pan-and-tilt on left joystick.

Table 5


Figure 5.
 
Step 6. PS2 Control.
Controlling the motion of the hexapod is handled using a single joystick. Make sure the controller is in Analog mode. control of the direction of walking with the right joystick, while Left and Right on the D-Pad adjusts speed. Initially, in either mode the joystick positions will allow a max of 100% XS speed. Pressing D-Pad Left lowers the max in 5% increments, and D-Pad Right increases the max in 5% increments up to 200%

Both modes offer additional control of leg trajectory for the alternating tripod gait. This refers to the vertical and horizontal motion that the foot goes through during the walking gait. Pressing /\, O (default), X, or [] changes how the foot is lifted and the stride motion. 

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

You may notice that there are no commands to change the height of the robot's body in the default program. In order to take full advantage of the mechanical advantage legs, they need to remain at their highest point. 


Figure 6.


PS2 Controls 
Right-Joystick Mode
Applies to h2prog01.zip
L Joy U Tilt Servo up R Joy U Forward
L Joy D Tilt Servo down R Joy D Backward
L Joy L Pan Servo left R Joy L Left
L Joy R Pan Servo right R Joy R Right
/\ See Figure 8 [] See Figure 8
X See Figure 8 O See Figure 8
D-Pad L Speed Limit Down D-Pad R Speed Limit Up
Start Disable/Enable Crash Monitor

Table 6-1

PS2 Controls 
Right Joystick Mode
Applies to h2prog0
3.zip
L Joy U Tilt Servo up R Joy U Forward
L Joy D Tilt Servo down R Joy D Backward
L Joy L Pan Servo left R Joy L Left
L Joy R Pan Servo right R Joy R Right
All Other Commands See Table 8-3

Table 6-2

PS2 Controls 
Tank Mode or (Right Joystick Mode)
Applies to h2prog02.zip
L Joy U Left Side Forward (N/A) R Joy U Right Side Forward (Forward)
L Joy D Left Side Backward (N/A) R Joy D Right Side Backward (Backward)
L Joy L N/A R Joy L N/A (Left)
L Joy R N/A R Joy R N/A (Right)
L1 Raise body height R1 Increase leg lift
L2 Lower body height R2 Decrease leg lift
L3 N/A R3 Switch control mode
D-Pad U Raise body height /\ See Figure 8
D-Pad D Lower body height X See Figure 8
D-Pad L Speed Limit Down [] See Figure 8
D-Pad R Speed Limit Up O See Figure 8
Start Disable/Enable Crash Monitor Select N/A

Table 6-3

 
Step 7. Autonomous Control.
The following autonomous-behavior program requires the addition of three Sharp GP2D12 sensors, connected as follows:

A to D channel 0 sensor: on front left side, facing right.
A to D channel 1 sensor: on front right side, facing left.
A to D channel 2 sensor: on rear, facing behind the robot.

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

Filename Program description
h2prog04.zip Autonomous using two Sharp GP2D12 sensors and one on the rear.

Table 7


Figure 7.

Step 8. Additional Information.
The Hexapod Sequencer can be used to test the hexapod without a microcontroller. Simply connect the SSC-32 to the serial port as if you were going to align the servos, then follow along.

The values for the L* and R* textboxes will control the positions the legs are moved to in the sequence. You can fine-tune these values to your mechanical leg arrangement with the same Servo Quick Test. Just adjust the position slider instead of the offset slider. 
 

Tripod Leg Movement Sequence
LF Left Front Horiz RF Right Front Horiz
LH Left High Vertical RH Right High Vertical
LM Left Middle Vertical RM Right Mid Vertical
LL Left Low Vertical RL Right Low Vertical
LR Left Rear Horiz RR Right Rear Horiz

Table 8


Figure 8.
 
Step 9.
Now to make the robot walk forward. Adjust the XL and XR sliders to 100%. Note that HT=1500uS (1.5 seconds). Set the XS slider to ~50% and notice that the stride takes 3 seconds. Adjust the HT slider to 1000 and notice that 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 will cause the robot to turn in place. Reverse values of XL and XR will cause the robot to walk backwards. Moving a slider is the same as typing from the terminal or sending the command from a microcontroller. For example, moving XS to 50% is the same as sending "XS50". Once the commands are sent, the robot will continue to walk until it receives XS = 0. If you are using a host microcontroller to send commands, it will be free to do any timing-intensive tasks without worrying about any of the walking process.


Figure 9.

 
Step 10.
For the do-it-yourselfers, the program to the right 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

Table 10.

Tags:
Created by Eric Nantel on 2023/01/24 14:09
Copyright RobotShop 2018