Adjust gripper closing angle or pressure

Greetings all and happy Thanksgiving!

Please, I am trying to write a code to control the gripper closing force or angle according to a reading from a sensor ( I am not sure if only one sensor needed or two)
so the gripper servo will respond and go to the best closing angle which is enough to:

]Hold tight the object /:m]
]Lift the object for two seconds or so/:m]
]put back the object/:m]
]Release object/:m]
The serial monitor will display Force applied and adjusted **gripper Angle **continuously while dealing with each object

The gripper will expect another object ( I am trying to use three different sizes or weights) to gripp, hold and lift and put back so in this case the gripper will adjust to new angle or pressure. My gripper works between ~ 45 degrees (full open) to ~ **110 **degrees (full close)

Please i need help with such a code. I could get a reading from sensors every time i press on them but i could not so far able to code the gripper adjustment around each object

Electronics:

I have one sensor attached to each gripper finger.

]One servo for gripper/:m]
]One servo to lift arm /:m]
]Arduino Mega 2560 microcontroller/:m]
][font=arial][size=2][highlight=#ffffff]Interlink Electronics 0.5" Circular FSR[/highlight][/size][/font]/:m]
][highlight=#ffffff][font=arial][size=2]Interlink Electronics 1.5" Square FSR[/size][/font][/highlight]/:m]
Thank you so much. Your help will make much difference!

Hi,

To read the sensors, you could do something like this:

[code]
int FSR = A0; //the FSR is connected to analog pin 0 (A0)
void setup(){
Serial.begin(9600);
}

void loop(){
int FSRValue = analogRead(FSR);//this takes a reading of the analog value of the FSR

// Do Other Tasks here

}[/code]

I think you should read the code regularly and store the value. Once you have the value, you can do whatever you want, calculate means, move you gripper according to sensor value …

I hope this helps you getting started !

Best reagrds,

Thank you Mr. Latour for your time reading my post.

Here is my test code

[code]#include <Servo.h>

Servo s1;
Servo s2;
int pos;
int fsr = 15; // pin for sensor and 10k resistor
int force; // analog reading

void setup()
{
Serial.begin(9600);
s1.attach(8);
s2.attach(9);
}

void loop()
{
s2.write(45); //start gripper open
delay(1000);
s2.write(100);
force = analogRead(fsr); // FSR reading
Serial.print("FSR reading = ");
Serial.println(force); // display fsr value when gripper close
pos = map(force, 0, 1023, 45, 100); // relates force reading to degrees of gripper servo position
Serial.print("Gripper Angle = ");
Serial.println(pos); // gripper angle reading from pos
delay(300);
if(force < 1 ){
s2.write (90);

if(force = 10){
s2.write(85);

if(force >18){
s2.write(75);
}
}
}
s2.write(pos); // go to pos
delay(250); // Delay 250 milliseconds

s1.write(25); //the object will be lifted
delay (3000);
s1.write(0); // put down object
delay (1000);
}[/code]

I can already have a reading when i press firmly on the FSR sensor. I could get like 0 ~ 1000

The scenario that i wasn’t able yet to have is that like mentioned in the post is to make the gripper adjust it self to gripp the object firmly then lift it up. and during that, it should display the pressure applied and the corrected closing angle. I don’t know if i am looking for **if or case **statement.

Thank you and everybody else for any input on this code.

Hi,

I think you could start using timers callback to do multiple tasks at the same time.
Look here: playground.arduino.cc/Code/ArduinoTimerObject

you could do something like this:

gripperTask called by 20/50/… ms timer ( change frequency to you need, only as example)
Her you do everything related to the grasping / adjustements of the gripper

ArmTrajectoryTask called by a 100/200 ms timer
This is you main trajectory

Have fun !

Hi,

I am thankful for your care and assistance. I will go over the information you provided and search more about it. I had no idea about it before.

I will try my best to work it out. I will update the post for any further assistance if you don’t mind. I appreciate your time!

Thank you! :slight_smile: