Newton gripper controlled via arduino and buttons for open/close

Good Afternoon All,

I am aiming to get a better understanding of the coding in relation to the Newton Gripper, I am aiming to use it with an Arduino and have some custom coding for it but im at a dead end.

I have been wanting the gripper to open with a button and when release to stop in place not keep going to open fully and then with a second button to close and then again when release to stop in place not to keep on closing.

Any help would be great and here is a copy of the code I have been using so far.

Blockquote

#include "Servo.h"

#define GRIPPER_PWM_PIN   9    // Gripper PWM output pin
#define LEFT 12 // PIN 2 IS CONNECTED TO LEFT BUTTON      
#define RIGHT 2 // PIN 2 IS CONNECTED TO RIGHT BUTTON        

#define OPEN_PWM_US       1100  // Gripper open PWM output (us)
#define CLOSE_PWM_US      1900  // Gripper close PWM output (us)

int servoPos = 1500; //starts in the middle
byte servoIncrement = 50; // how much to change each time thru loop, may need to be more or less

//const int buttonPin = 2; //this is redundant
//const int ledPin = 9; //this is redundant

int buttonState = 0;
int buttonState2 = 0;

Servo gripper;

void setup() {
  Serial.begin(9600);
  //pinMode(ledPin, OUTPUT); //this is redundant
  // Attach gripper to proper pin
  gripper.attach(GRIPPER_PWM_PIN);
  pinMode(LEFT, INPUT_PULLUP); // assign pin 12 ass input for Left button
  pinMode(RIGHT, INPUT_PULLUP); // assing pin 2 as input for right button
}

void loop()
{
  buttonState = digitalRead(RIGHT);
  buttonState2 = digitalRead(LEFT);

  // Open the gripper
  if (buttonState == LOW)
  {
    // open gripper:
    Serial.println("opening");
    servoPos = servoPos - servoIncrement;
    if (servoPos <= OPEN_PWM_US) servoPos = OPEN_PWM_US; //it's already open
    gripper.writeMicroseconds(servoPos);
  }

  if (buttonState2 == LOW)
  {
    // close gripper:
    Serial.println("  closing");
    servoPos = servoPos + servoIncrement;
    if (servoPos >= CLOSE_PWM_US) servoPos = CLOSE_PWM_US; //it's already open
    gripper.writeMicroseconds(servoPos);
  }
  delay(100); //make longer or shorter or remove it
}//loop

Hi @Fortheng1234

Is any part of your code working or is is just a matter of getting the gripper to stop when you let go of the button? If it’s just getting the gripper to stop then you need to provide a stop signal, PWM 1500, when none of the buttons are pushed. I made some changes to your code and it’s more or less working as expected:

#include <Servo.h>

#define GRIPPER_PWM_PIN 9
#define LEFT 12 // PIN 2 IS CONNECTED TO LEFT BUTTON      
#define RIGHT 2 // PIN 2 IS CONNECTED TO RIGHT BUTTON        

#define OPEN_PWM_US       1100  // Gripper open PWM output (us)
#define CLOSE_PWM_US      1900  // Gripper close PWM output (us)
#define STOP_PWM_US       1500 // Gripper stop PWM output (us)

int buttonState = 0;
int buttonState2 = 0;

Servo gripper;

void setup() {
  Serial.begin(9600);
  gripper.attach(GRIPPER_PWM_PIN);
  pinMode(LEFT, INPUT_PULLUP); // assign pin 12 ass input for Left button
  pinMode(RIGHT, INPUT_PULLUP); // assing pin 2 as input for right button
}

void loop()
{
  buttonState = digitalRead(RIGHT);
  buttonState2 = digitalRead(LEFT);

  if (buttonState == LOW)
  {
    Serial.println("opening");
    gripper.writeMicroseconds(OPEN_PWM_US);
  }
  else if (buttonState2 == LOW)
  {
    Serial.println("closing");
    gripper.writeMicroseconds(CLOSE_PWM_US);
  }
  else
  {
    gripper.writeMicroseconds(STOP_PWM_US); 
  } 
}

I wasn’t entirely sure what the goal was for your code that increments and decrements the servo position but if it is only to stop at the endpoints then it isn’t necessary. The firmware on the gripper already has logic to sense a stall condition–that is, when the gripper is full open, full closed, or gripped onto something–and automatically stop. You only need to provide a PWM signal in the correct range to either open or close (>1530 µs -1900 µs to open, <1470 µs -1100 µs to close).

I hope this helps!

1 Like

Hello, I have a gripper that I want to control with an arduino.

i have the code running on my arduino and but I have questions as to how to wire it all up.

my gripper has 3 leads. (red, black, yellow)

[breadboard and aurduino connections] (https://photos.app.goo.gl/Cf9wNjEsCioTKJap6)

ALL Black Wires are connected to GND, [for some reason it looks like the black lead is connected to AREF, but its not ]

Button With Blue lead turns on Builtin LED and hopefully open the Gripper
Button with Green Lead turns on the white LED on the BreadBoard and hopefully close the Gripper

The yellow wire is connected to Pin 9 and would send the corresping signal to open/close

I assume i can just connect the red/black to a power supply, but no idea what to do with the yellow wire (does it require a ground or level shifter?)

/ / / / / / /. / / / / / / / / / / / / / / / / 


#include <Servo.h>

#define GRIPPER_PWM_PIN 9
#define LEFT 12 // PIN 2 IS CONNECTED TO LEFT BUTTON      
#define RIGHT 2 // PIN 2 IS CONNECTED TO RIGHT BUTTON  
#define MY_LED 6 // Pin 6 is connected to white LED


#define OPEN_PWM_US       1100  // Gripper open PWM output (us)
#define CLOSE_PWM_US      1900  // Gripper close PWM output (us)
#define STOP_PWM_US       1500 // Gripper stop PWM output (us)

int buttonState1 = 0;
int buttonState2 = 0;

Servo gripper;

void setup() {
  Serial.begin(9600);
  gripper.attach(GRIPPER_PWM_PIN);
  pinMode(LEFT, INPUT_PULLUP); // assign pin 12 ass input for Left button
  pinMode(RIGHT, INPUT_PULLUP); // assing pin 2 as input for right button
}


void loop()
{
  buttonState1 = digitalRead(RIGHT);
  buttonState2 = digitalRead(LEFT);

  if (buttonState1 == LOW)
  {
    digitalWrite(LED_BUILTIN, HIGH);
    Serial.println("bottom button - opening");
    gripper.writeMicroseconds(OPEN_PWM_US);
  }
  else if (buttonState2 == LOW)
  {
    digitalWrite(MY_LED, HIGH);
    Serial.println("top button - closing");
    gripper.writeMicroseconds(CLOSE_PWM_US);
  }
  else
  {
    // turn both LED's OFF
    digitalWrite(LED_BUILTIN, LOW);
    digitalWrite(MY_LED, LOW);
    gripper.writeMicroseconds(STOP_PWM_US); 
  } 
}

Hi,

The gripper needs a power supply between 9 and 18 volts, and remember that the ground should be common between arduino and the gripper power supply.

It would help to share a circuit diagram or a complete picture of your setup, you can also try to minimize your code and create a simple open and close code for the gripper to test the basic functionality with minimal connections.

Hello,

we have tested the gripper with arduino recently and it works great. We want to use the gripper servo to constrain its rotation 10degrees up and 20 degrees down via arduino.

is there a way i can control the gripper to go to an exact position, by maybe flashing the firmware or something? any help on how to go about this would be appreciated, thankyou.

Hi @axppxsky,

The Newton Gripper uses a brushed DC motor[1], and has no included sensor to estimate its position / rotation angle. It’s only possible for it to detect when it’s fully opened (or closed against something) because the driving current spikes at those points, which the firmware takes note of and stops trying to push further.

There’s no reliable way to do this with software alone, unless your application has a highly consistent load on the motor, in which case you could command movement in the desired direction for a set amount of time, but even then the control may not be very precise.

To achieve reliable and precise movement limits your options are:

  1. Make physical end-stops that prevent the motor/linear actuator from moving beyond the desired region
    • in this case the existing firmware will detect that the motor has reached a stopping point and will avoid trying to push beyond it
    • you could potentially design some custom jaws that would achieve such an effect, or add some parts to the existing jaws so they push against something at your desired limits
  2. Add a positioning sensor to the motor, and feed its signal back to whatever you’re using to control the motor
    • this would be significantly more complicated, especially if you’re trying to put the sensor inside the existing gripper housing.

  1. Not a servo motor - we just set the motor controller up to take PWM signals with pulse durations in the standard servo range, for ease of integration with hardware that is normally set up to control servo-style motors or ESCs. ↩︎

thankyou for letting me know. i do have imu mounted on the gripper servo that could give me gyroscope data to know the angles. 2 questions:

1.i was wondering if there is a way to control the speed of opening and closing the gripper so that when i have to go to a specific angle, i could control how fast the gripper moves?
2. is there a way to control the torque via the firmware?