1
$\begingroup$

I'm using processing to send strings to Arduino, using functions like

else {
    int u=90;
    port.write(u+"z");
}

on the processing side and in the Arduino side I'm using calls like

  case 'z':
    z.write(v);
    v = 0;
    break;
  case 'L':
    z.write(0);
    //v = 0;
    break;
}

yet I can't get the servo to stop at all. How do I make it shut off?

If it was a regular servo I wouldn't even ask because that's easy but I write 0 or 90 or LOW and nothing, it just keeps spinning in one direction but when it meets one of the conditions in my statements it switches polarity/direction and that's good - I want that but I made this function to make it stop and it is not doing so, does anyone have any ideas ?

I am using a Parallax Continuous Rotation Servo.

$\endgroup$
4
  • 2
    $\begingroup$ If you mention the make and model of the specific Continuous servo, we can look up the data sheet and suggest a specific solution to your problem. $\endgroup$
    – Mark Booth
    Apr 15, 2016 at 9:58
  • $\begingroup$ @MarkBooth it is a Parallax continuous servo $\endgroup$
    – jai
    Apr 15, 2016 at 18:52
  • $\begingroup$ On stack exchange, it is better to edit your question to add information requested in comments, rather than adding more comments. Comments are for helping to improve questions and answers, and are distracting, so we try to keep them to a minimum. If all of the information needed to answer the question is contained within it, the comments can be tidied up (deleted). $\endgroup$
    – Mark Booth
    Apr 17, 2016 at 9:23
  • $\begingroup$ This is wrong on many levels: port.write(u+"z"); $\endgroup$
    – Shahbaz
    Apr 19, 2016 at 13:47

2 Answers 2

1
$\begingroup$

There should be some intermediate value of degrees or microseconds that minimizes rotation speed. You can run calibration tests to find the best value, for example by sweeping the angle or time through a range of values, while writing the current value to LCD or Serial; or by setting an initial value then using two buttons or an analog control voltage to tell the sketch to raise or lower the value, jogging up or down until the servo stops or runs at very slow speed.

Note, you will get finer control (hence, closer to the proper value) using Servo.writeMicroseconds() rather than Servo.write(). In some Servo library versions, Servo.writeMicroseconds() resolution is half-microsecond, vs about 10 μs/degree Servo.write() resolution.

Also note, in some Servo library versions, Servo.write() accepts microsecond values as well as degree values, distinguishing the former from the latter by number size; ie, numbers less than 544 are clipped to the range 0 to 180 and treated as degrees, while numbers in the range 544 to 2400 are treated as microsecond values. [See example code in related answer at arduino.stackexchange.]

$\endgroup$
2
  • $\begingroup$ Comments are not for extended discussion; this conversation has been moved to chat. $\endgroup$
    – Mark Booth
    Apr 15, 2016 at 9:44
  • $\begingroup$ On stack exchange, comments are not intended for extended discussions, for that use Robotics Chat. Comments are for helping to improve questions and answers, and are distracting, so we try to keep them to a minimum. Comments should be considered ephemeral, any comment which no longer actively helps to improve a question or answer may be deleted at any time to tidy up a post. $\endgroup$
    – Mark Booth
    Apr 15, 2016 at 9:45
1
$\begingroup$

According to the data sheet and example code, this continuous rotation servo takes an input of 1.3ms full speed clockwise to 1.7ms full speed counter-clockwise, with 1.5ms in the middle being stopped.

As jwpat suggests you are better off using Servo.writeMicroseconds(1500) to stop your servo, since this guarantees that you are sending the correct value, even if you accidentally get the min and max calibration values wrong in your Servo object.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.