change the speed of the Servos ?

I new in arduino and i'm building a robot arm how do i change the speed of the Servos ?

-max-9 months ago

You change the output angle command over time more slowly. Servo motors are controlled with a pulse that's between 1000uS and 2000uS, which sets the angle of the shaft. Ideally the pulse would cause the shaft of the motor to reach the correct position instantly.

.

So the way you would do it is after importing the servo library (which is really unessesary since you can really just do digitalWrite(sensePin, HIGH); delayMicroseconds(value); digitalWrite(sensePin, LOW);

.

You have the "value" variable increment up and down. This will increment the angle in proportion to how fast the code loops, which may be undesirable. I've not dealt with arduino in a while but there may be a function which creates a busy loop until a timer resets which effectively caps the maximum speed of the void loop() function.

You can use timers and interrupts which causes the increment/decrement code to run at specified time intervals much more precisely, by attaching an interrupt on an unused timer, which itself if configured to count up to a certain 16 bit unsigned integer value with a clock divider set appropriately to create as much or little delay as you want! :) As you can tell this does get a bit technical and advanced, involving ports, registers, flags, timer configurations, etc. But it's the best solution as well as it leaves your code to run independantly.

Downunder35m9 months ago

Small and fast stepper motors with a worm drive might be a better solution unless your arm is too small....

I'm relatively new to Arduino myself so you will no doubt get a better answer from someone else, but I'll try to offer some help if I can.

First of all remember that the speed at which a servo can move is determined by the specific servo (i.e. different servos can have varying specs and speeds), consult the datasheet for your chosen servos to confirm this. Also the physical load on the servo can have an effect on the speed.

To vary the speed from Arduino you could consider using a modified servo library that includes speed control. I've provided a link below, but note that this is a few years old and things may have changed in the current servo library since then, but it's probably worth a shot.

https://forum.arduino.cc/index.php?topic=61586.0