I'm working on a little project using 3 servos. They're powered with a bench power supply and I'm just going to make a program that runs once and then stops.
One of the servos is an mg996r that I converted to continuous rotation to function as a winch.
Ideally I'd like the whole routine to start when I press a button or flip a switch and to work using Millis but for now I'm just trying to get it working with delays.
This is the basic routine.
Begin
Delay
Servo1 rotates 45 degrees.
Delay
Servo2 Winch turns 360 for 3 or 4 revolutions.
Delay
Servo3 rotates 45 degrees
Delay
Servo1 rotates back and forth for a period of time.
Delay
Servo3 rotates back 45 degrees.
One problem I'm having is that I can't figure out how to rotate the winch and then stop it. If I get it spinning with:
myservo.write(85);
It will spin but it won't stop. If I write myservo.write(90); and upload it will stop.
I want it to spin for a set time or a specific number of rotations (doesn't matter which) and then stop but I nodded it by glueing the potentiometer so its never finished spinning.
How do I write this? Can I make it spin for a set number of milliseconds only?
Most people just disconnect the potentiometer from the shaft. You should be able to command the three basic operations (Fwd, Rev, Stop) with correct choice of the write() command argument, but fine speed control is usually not possible.
Can I make it spin for a set number of milliseconds only?
You may have to determine the setting that will stop the "servo". 90 (degrees) may not be right for that particular "servo". The writeMicroseconds function will give you finer control.
Read the forum guidelines. Post the code that you have so far.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.
Hi @tbone23 .
I have a "servo" still similar to the Futaba s3003 provided by Paralax.
As it is a continuous "servo", it is not possible to define how many degrees it rotates.
It has an external access potentiometer for adjusting the center point at which it changes the direction of rotation.
I did a test here with it, sending it to rotate -90 and then +90 and a delay of 2000 mSec between each step.
The only solution to stop it was to use the myServo.detach(X) method,
and to rotate it again, the myServo.attach() method.
I don't think I have any control over position with this one because the potentiometer is set to about halfway and glued. I also snipped the end off so it doesn't reach the gear so my understanding is that it will rotate either clockwise or counterclockwise to try and reach the position but it just keeps going forever because it gets no positional feedback.
If I set it to 90 degrees it doesn't move. I'm not sure if that's normal with a modded servo or if I just got lucky and glued it in the perfect position.
I don't know if I'm understanding this correctly but doesn't it need to complete the task before it will move on to another command like detach?
Is the "Command Fwd, delay(), Stop" bit code for a regular DC motor that tells it to move forward for a period of time and stop?
I finally started trying to code with the actual servos connected.
Suprisingly I think the wiring is all working but I'm having trouble implementing some of the commands.
I have 2 high torque servos and a modified mg996r that serves as a winch.
I'm probably making some stupid mistakes but the code is below.
I don't understand what the "int angle" variable is. I keep seeing it in tutorials but I'm not comprehending the explanation. I thought they were saying it was to store a particular angle to reference later but I guess not. Is it just setting the initial state of the servo? If so then how do I write more then one for the different servos?
Another unexpected result, why does the "Larm" raise pretty much immediately and then fall after a few seconds like it lost power? I'm not using Millis yet so I thought the commands would all run in order and the delays would keep things from happening too fast.
Does it read the code for the "Rarm" and start executing it and then immediately read and execute the "Larm" code while the "Rarm" is just starting it's task?
And finally, what can I add to these commands to get the servos to run at a slower speed when I need it.
For instance if I want the Rarm servo to go to 110 degrees slowely and then pause and move to 175 fast? I've found several methods I can't make sense of them.
If you want to control the speed at which the (normal not continuous) servos move try using VarSpeedServo.h instead of Servo.h. VarSpeedServo has a useful "speed" parameter in its write() command.
Ok thanks. That looks promising.
I don't have a lot of experience with servos but I'm noticing that my 60 kg servo doesn't have near as much power as I thought it would.
I'm trying to make a machine for archery target shooting.
I made a couple wood gears to speed things up. The servo arm is attached to the big gear (about 7 inches in diameter) and spins a smaller one ( about 3 inches). The smaller one has two bolts coming off the side to attach a carbon arrow shaft I'm using as an arm. At the end of the 40 inch long arm is a rubber pad to fasten a target to.
The whole arm weighs about 12 ounces with nearly all the weight being at the end. The servo does not want to lift it.
I thought I'd be ok with a 60 kg servo even with the length and weight of the arm and gears etc.
It might be because the gears aren't secure enough and compress when I put the arm on but should I also be counterbalancing the arm?
The servo has a voltage range of around 6-8v and I'm using 6.8. would that cause it to lose a lot of torque?