SPECIAL OFFER - Buy (1) Apeiros Robot & Get (1) 8x2 Character LCD Free!

Lesson 7

Lesson 7: Commanding Apeiros Servo Gripper

In this lesson you will learn how to control an optional servo gripper mechanism by using the ApeirosGripper class library. The ApeirosGripper library makes use of the Servo library. More specifically, we use the writeMicroseconds() function in order to command the Apeiros servo gripper to a valid position.

Prerequisites

Before starting this lesson be sure to follow the Initial Setup & Configuration. Also, we strongly recommend that you take some time to read "Getting Started with Arduino and Genuino products". This lesson assumes that you have purchased and installed an optional Apeiros Servo Gripper Kit.

Introduction

Apeiros is built upon a custom-designed injection molded ABS body that provides mounting features for an optional servo gripper mechanism. The custom servo gripper mechanism provides Apeiros with the ability to manipulate and move small objects within its environment. The gripper fingers are spring loaded in an attempt to reduce stress on the actuating HS-81 hobby servo. NOTE: You can replace the standard plastic gears with a set of metal gears.

WARNING: Attempting to fully close the gripper on an object can damage the plastic gears within the HS-81 servo! Always ensure that the gripper is not controlled to a position that can not be reached due to being blocked by an object. A blocking object can also damage the internal plastic gears!

Apeiros Class Library Functions

The ApeirosGripper class library contains (4) functions for controlling an optional servo gripper.

void openGripper();
void closeGripper();
uint16_t getGripperPosition();
void setGripperPosition(uint16_t positionInMicroseconds);

Recall that we first need to declare an instance of the ApeirosGripper class library. However, we do NOT need to add anything to the setup() function.

// Declare Apeiros class instances.//
/***********************************/
ApeirosGripper myGripper;
/***********************************/

void setup() {
  // put your setup code here, to run once:
  
}

Once we have declared an instance, myGripper, of the ApeirosGripper library, then we can access the servo gripper functions. If we want to open the gripper to its fully open position, then we call the openGripper() function. Always make sure that the gripper is not blocked and can move freely. Otherwise you risk damaging the servo's internal plastic gears.

void loop() {
  // put your main code here, to run repeatedly:
 
  // Command servo gripper to fully open position.
  myGripper.openGripper();
  
  delay(100);  // Delay for a specified amount of time in milliseconds
}

Now suppose we want to fully close the servo gripper. We can call the closeGripper() function.

void loop() {
  // put your main code here, to run repeatedly:
 
  // Command servo gripper to fully closed position.
  myGripper.closeGripper();
  
  delay(100);  // Delay for a specified amount of time in milliseconds
}

The servo gripper can be commanded to any position in-between the fully open and fully closed position. The servo gripper position is determined by setting a value in microseconds. A valid servo position is from 1000 to 2200 microseconds. A value of 1000 corresponds to fully closed and 2200 commands the gripper to fully open. You can specify any integer value that falls within this range and call the setGripperPosition() function. Let's command the gripper to a position of 1500 microseconds.

void loop() {
  // put your main code here, to run repeatedly:
 
  // Command servo gripper to a position of 1500 microseconds.
  myGripper.setGripperPosition(1500);
  
  delay(100);  // Delay for a specified amount of time in milliseconds
}

We have access to one last function, getGripperPosition(). This function returns the current position of the servo gripper in microseconds as an unsigned 16-bit value. This particular function can be useful when commanding the servo gripper to multiple positions within your sketch.

void loop() {
  // put your main code here, to run repeatedly:
 
  // Declare a gripper position variable.
  int gripperPosition;

  // Declare a gripper position variable.
  gripperPosition = myGripper.getGripperPosition()
  
  delay(100);  // Delay for a specified amount of time in milliseconds
}

EXPERIMENT


 

Can you create a sketch that opens and closes the gripper a total of (3) times whenever the front center IR sensor is blocked? HINT: Be sure to add a sufficient delay in-between opening and closing the gripper. Otherwise the gripper may not have time to complete the previous command.