# Position control of a stepper motor based on force feedback

I designed a simple two-finger robotic gripper using a stepper motor. Now I want to attach a three-axial force sensor on one gripper finger, and control the position of the stepper motor so that grip force can be controlled when an object is grasped. The analog output from the force sensor is voltage signal, which can be transferred to Newtons using the given relationship. I am considering using PID control. The Arduino continuously reads the force signal and calculates the target force based on tangential force and coefficient of friction. However, as I am new to all the stuff, especially programming, I do need help on how to write the code. I have learned a bit from some example codes, and written a (wrong) script myself. Can someone help me? Thanks a lot.

Stepper_Force_Control.ino (1.57 KB)

There is not much point setting the speed when using code like this. The speed will be determined by how often the second line is called.

``````myStepper.setSpeed(120);
myStepper.step(1);
delay(5);
``````

And I don't see any attempt to use the stepper motor to manage the force.

In any case I don't understand how you propose to vary the force using a stepper motor. How many steps are there between the minimum and maximum force?

I think a better explanation of what you are trying to do would help.

What stepper motor and stepper motor driver are you using?

Thanks for your reply. The stepper motor I use is a 6-wire hybrid stepper motor, and I use a L298N to drive it (only 4 wires are connected). I planned to vary the force by controlling the position of gripper finger (moving close to increase grip force). And you are right, I need to figure out the relationship between steps and magnitude of force. I guess the force change due to one-step movement will depend on the grip force itself. For example, when grip force is 1N, a step forward might increase grip force by 0.1N; while that might increase force by 0.2N when grip force is 3N.

The process of the controller in my mind is:

1. The gripper closes until the sensed grip force reaches 1N.
2. PID control starts, which maintains the grip force at desired value.

I have to say that based on the information so far I am doubtful that a stepper motor can be used in the way that you want.

If the gripping finger is touching a solid object then the stepper motor cannot move any additional steps. If you command it to move it will just miss steps and stay where it is. In the course of missing steps it may apply a damaging force to the solid object.

A diagram of your proposed mechanism would be a big help. See this Simple Image Guide

...R

Thanks for the feedback. I also have such doubt, and just started using a DC motor instead of a stepper, which you may see in Grip force control of a robotic gripper driven by a DC motor - Motors, Mechanics, Power and CNC - Arduino Forum