|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
how do you code a servo to run continuously
We are using a servo to move an arm and want to command the servo to turn until triggered to stop. We're not sure how to do this using either set() or setAngle. Those commands will move the motor a fractional rotation, but not spin continuosly. Can someone provide a little insight as to command a servo from a pwm output to turn continuously, at different rates of speed and in different directions?
Thanks in advance... |
|
#2
|
||||
|
||||
|
Re: how do you code a servo to run continuously
There are 2 types of servo's,
Standard ones, and Continuous rotation servos. Standard servos can only do ~180 degrees of motion.(some have more range some have less) so each PWM value corresponds to a position of the servo horn. Continuous rotation servos, as the name implies, can rotate continuously. Each PWM servo corresponds to a rotation speed. There is no way of making a regular servo rotate continuously. |
|
#3
|
||||
|
||||
|
Re: how do you code a servo to run continuously
well there are actually ways to modify the servo to rotate continuously.
Unfortunately due to <R47>, you may not legally modify a servo. however, you may infact be able to find a continuous rotation servo on servocity.com or other sites that meets the 4W power requirements. Good luck |
|
#4
|
|||
|
|||
|
Re: how do you code a servo to run continuously
http://www.wbrobotics.com/javadoc/ed...ilibj/PWM.html
My team was having a similar issue. We decided to replace the continuous servo with a motor, but we had an untested idea to program a continuous rotation servo. I believe that there is a setSpeed(double speed) method in the PWM class, which the Servo class extends. If there isn't one, you'll have to play around with setRaw(int value). This is the code I found in the library itself: Code:
final void setSpeed(double speed) {
// clamp speed to be in the range 1.0 >= speed >= -1.0
if (speed < -1.0) {
speed = -1.0;
} else if (speed > 1.0) {
speed = 1.0;
}
// calculate the desired output pwm value by scaling the speed appropriately
int rawValue;
if (speed == 0.0) {
rawValue = getCenterPwm();
} else if (speed > 0.0) {
rawValue = (int) (speed * (getPositiveScaleFactor()) +
(getMinPositivePwm()) + 0.5);
} else {
rawValue = (int) (speed * (getNegativeScaleFactor()) +
(getMaxNegativePwm()) + 0.5);
}
// send the computed pwm value to the FPGA
setRaw(rawValue);
}
Good luck! |
|
#5
|
|||
|
|||
|
Re: how do you code a servo to run continuously
Thanks for the insight. We have been able to usine the HiTech motor on a application that only move 120 degrees.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|