Unit 03 Section 02 Lesson 09

Robotic Gripper Arm

Assigned activities

In this activity you will develop a robotic gripper arm and a visual basic interface to control the device

Activity 1
Part 1

Required Resources

  • Phidget 8 motor advanced servo controller
  • 2 Servo motors with small control wheel
  • Large C bracket
  • Servo motor rotary base with utility bracket and motor
  • 2 Aluminum Hubs
  • 3" Aluminium tube
  • Gripper
  • Gripper Plate
  • Plastic push rivets / pins
  • Hardware kit (screws, nuts, washers)

Pan and Tilt Assembly Fabrication

The first part of this assembly is the same as for the pan and tilt camera mount. You need to replace the C bracket with the camera mount with the second C bracket.

Check your kits for the parts. The hardware (nuts & bolts) are in the small plastic containers.

Locate a small bolt (hex head) with 2 plastic washers and a plastic cap nut (see below)

Push the bolt through the hole in the servo motor bracket (the one mounted on the rotary base.

Next position a servo motor in the bracket. The shaft of the motor must be in-line with the screw you just placed.

Fasten the motor with at least 2 push pins.

Attach the white control wheel to the servo motor bracket as shown in the next sequence. Use 2 small self tapping screws (or if the holes in the wheel have been drilled out use 2 small bolts and nuts). Make sure the wheel is centered on the bracket hole.


Next locate and attach an aluminum hub to the c bracket using 4 small nuts and bolts (black)

Next locate the gripper and mount 4 hex bolts and nuts. Tighten the nuts on the gripper.

Locate the gripper plate and mount the second aluminum hub using 4 small nuts and bolts (black)

Mount the gripper plate to the gripper using 4 cap nuts. These are locking nuts and you will need to use a pliers to tighten them.

Connect the gripper and the C bracket hubs using the 3" aluminum tube and 2 hex bolts.

Next press a servo motor into the underside of the gripper. You will need to avoid the gripper plate screws but it does fit!

Do not insert the screw into the motor shaft as you will need to adjust the gripper opening later.

Finally, mount the C bracket on the servo motor shaft and on the screw you previously placed in the bracket. The washers and cap nut must be placed exactly as shown in the next illustration. You may have to bend the C bracket out slightly to get it to fit over the servo shaft.

Finally, turn the C bracket. If it does not turn equal angles from the vertical position, slip the wheel off the motor shaft, turn the C bracket and reattach. When the C bracket is centered, replace the servo shaft screw to secure the control wheel.

Circuit Configuration

Connect the bottom (pan) motor to connector 0 (first) of the Phidget servo controller. Connect the upper (tilt) motor to connect 1 (second). Make sure the yellow or white wire on the servo line up with the W on the connector. Connect the gripper motor to connect 2 (third).

Attach a 12 volt power supply to the controller. Finally, connect the USB cable to the computer.

Create the Graphical User Interface

Note: Save your project at frequent intervals!

Run Visual Basic 6.  Select a Standard Exe.

  • Draw a Frame on the form.
  • Draw the following controls on the frame. A suggested layout follows.
    • A vertical scroll bar
    • 2 horizontal scroll bar
    • 3 text boxes, place Text1 by the lower horizontal scroll bar, and Text2 by the vertical scroll bar, and Text3 by the upper horizontal scroll bar.

Change the properties for the following:

  • Frame1
    • Caption - Robot Arm Control
    • Font - Arial, 14pt, bold
    • Backcolor - something appropriate
  • Text1, Text 2 & Text 3 box:
    • Text - Delete the default text (Text1....)
    • Font - Arial, Bold, 14
  • Hscroll1
    • Min - 0
    • Max - 180
    • Value - 90
  • Vscroll1
    • Min - 0
    • Max - 180
    • Value - 90
  • Hscroll2
    • Min - 0
    • Max - 180
    • Value - 90


Code the Interface

  • You will be using the PhidgetAdvancedServo therefore the Phidget library must be referenced. Open the Project menu and select References.

    Scroll down and check Phidget Library 2.1 (or whatever version you have loaded). Click OK.
  • Open the code window. Start by selecting General...Declarations in the small windows. Enter the following code:

 Dim WithEvents Servo As PhidgetAdvancedServo

  • Code the Form_Load procedure:

Set Servo = New PhidgetAdvancedServo
Call Servo.Open

  • Code the HScroll1_Change procedure with the following:

Servo.Position(0) = Hscroll1.Value
Text1 = Hscroll1.Value

  • Code the HScroll1_Scroll procedure with the same code:

    Servo.Position(0) = Hscroll1.Value
    Text1 = Hscroll1.Value

  • Code the VScroll1_Change procedure with the following:

Servo.Position(1) = Vscroll1.Value
Text2 = Vscroll1.Value

  • Code the VScroll1_Scroll procedure with the same code:

    Servo.Position(1) = Vscroll1.Value
    Text2 = Vscroll1.Value

  • Code the HScroll2_Change procedure with the following:

Servo.Position(2) = Hscroll2.Value
Text3 = Hscroll2.Value

  • Code the HScroll2_Scroll procedure with the same code:

    Servo.Position(2) = Hscroll2.Value
    Text3 = Hscroll2.Value

  • Finally select servo....OnAttach from the small windows at the top of the code form and code the following:

For i = 0 To servo.MotorCount - 1
   servo.ServoType(i) = PHIDGETCOM_SERVO_HITEC_HS322HD
   servo.Engaged(i) = True
   servo.VelocityLimit(i) = 40
   servo.Position(i) = 90

Test the System

Save the project. Run the program and make sure the gripper moves to the "home" position when the program starts (middle position for all motors).

You may have to adjust the white control wheel on the tilt C bracket and motor to make sure the arm is straight up. Also you may have to remove the motor from the gripper, rotate it and re-insert into the gripper. You need to have the gripper half open when you start the program.

Check to see that the vertical and horizontal scroll bars actually control the motors. Make note of the numbers that indicate the maximum opening and closing of the gripper. You will need these later.

Joystick Control - Part 1

A joystick can be used to make control of the arm and gripper easier. It is assumed that the global majic custom controls are installed on your computer. Start by adding the joystick control to the toolbar.

  • Open the Project menu and select Components.
  • Scroll down to and select GMS Joystick check the box). Click OK
  • Draw the joystick control on the frame. Change the Joystick1 properties:
    • Display Style: Graphical
    • XMax:  90
    • XMin:  -90
    • YMax:  90
    • YMin:  -90
    • ZMax:  90
    • ZMin:  -90
  • Next add a Timer to the frame. In the properties box, set the Interval to 200.

Code the Timer1_Timer procedure with the following:

Servo.Position(0) = Cint(Joystick1.XPos + 90)
Servo.Position(1) = Cint(-Joystick1.YPos + 90)
Servo.Position(2) = Cint(Joystick1.ZPos + 90)

Text1 = Servo.Position(0)
Text2 = Servo.Position(1)
Text3 = Servo.Position(2)

Save and run the program again. Move the joystick by clicking and dragging with the mouse.

The Gripper is opened and closed by using the joystick "throttle". That's the vertical slider you see to the left of the joystick "stick"

If you have a USB joystick, stop the program, attach to a USB port and wait until it is recognized by the computer. Start the program and try the joystick!

Note1: The speed of the motors can be changed by changing the following line in the servo....OnAttach sub procedure:

servo.VelocityLimit(i) = 40

Try changing the 40 to 100 and see what happens. Careful :)

Note2: When you stop the program running, the motors stay engaged (powered). You can stop shut down the power to the motors and end the program by adding a command button (command1) to the frame.

Code the command1 button with the following:

For i = 0 To servo.MotorCount - 1
  servo.Position(i) = 0
  servo.Engaged(i) = False
Next i

Joystick Control - Part 2

There is a way to make the joystick smoother. Follow these steps:

  • Replace the code in Timer1_Timer with the following:

If (Servo.Position(0) < 180) and (Joystick1.XPos > 20) Then
     Servo.Position(0) = Servo.Position(0) + 1
Elseif (Servo.Position(0) > 0) and (Joystick1.XPos < -20) Then
     Servo.Position(0) = Servo.Position(0) - 1
End If
Text1 =

If (Servo.Position(1) < 180) and (Joystick1.YPos > 20) Then
     Servo.Position(1) = Servo.Position(1) + 1
Elseif (Servo.Position(1) > 0) and (Joystick1.YPos < -20) Then
     Servo.Position(1) = Servo.Position(1) - 1
End If
Text2 = Servo.Position(1)

 Servo.Position(2) = Joystick1.ZPos + 90
Text3 = Servo.Position(2)

Save and run the program. Again see what effect the Timer1 Interval has. Also you can experiment with the increment/decrement value. That is try .5 instead of 1, etc.

2004 CDLI