the following problem:
I built up a hobby robot arm with some servos MG996R. Everything works fine (more or less ...).
I wrote a control program where I memorize each position and calculate ramps from position to position to have a - more or less, still in improvement - smooth postioning to avoid to high shocks that lead to damage and unstable movement.
But, during Startup when my program has to send the first positions - typical some default, home position, the program can not control the speed/acceleration with wich the arm goes in its position as the program does not know the actual position in general.
This leads to very high shocks on the system and anyway an uncontrolled movement that is difficult to predict, e.g. to avoid collisions with the environment.
Therefore I would like to have a possibility to read out the potentiometer of the servo at the startup.
Is there any chance, hack for it, or is there a similar servo where this is possible?
Do You want us to search for crystal balls or give pure wild guesses?
For heavens sake, post the code! In code tags! Link to the datasheet of that servo please.
Either put in absolute position encoding or limit the drive until the software gets its act together and then command to find "home" at the lowest speed possible.
Also, standard 5/16 shaft pots that come with most Arduino kits have 300° or so of rotation so an app that only moves, say 180° or 270° doesn't need magic hardware.
If you're clever, you can ramp the speed of the motors down as you near the target position. This will greatly reduce the jerking motions.
Yeah, the speed up and down ramps for a smooth acceleration I already implemented. Nevertheless, at startup the position is not known and so the servo moves rather fast to its initial value ... in the worst case.
If you're ramping already, then just start SLOW instead of on FAST! If your hardware is taking off before the software is ready on a RESET then put an ENABLE relay in so you don't power up the motor's until the speed values have been set.
If you have position feedback then the trick is to command it to where it already IS! Then you can move it around at will. But continuous feedback is the key. A discrete home feedback point requires slow start. You can't have machinery that spazzes out on powerup. In a factory setting that'll KILL someone.
You have to PLAN for control during reset/restart.
I think you will find @mikado322 problem is the action of the servo intially after the servo.attach command is used.
If the servo is at say 90deg, when you first command a position say 0Deg, the servo will jump to 0Deg, as you do not know the initial position you cannot issue slow motion commands.
The jump is due to the servos internal controller seeing it is at 90Deg then all of a sudden told to go to 0Deg.
Which it does a s fast as it can.
The Adafruit feedback servo is the best solution, also it is designed to be forced manually into postitions, so you can physically program its movements.
Yes thanks, I modified all my 6 servos today and I get reasonable values that will allow me to at least improve the startup procedure, avoiding to high jumps. The idea of using the values to program would be great as well ... programming the movements by recording servo values while the power is of.