Simple Servo Control Issue

First time poster so please be gentle...

I'm a software designer just getting into the arduino scene for fun with a little side project in mind.

At any rate, I have an Uno and various components, but the one thing that's confusing me at the moment is the control of a servo. I've done the obvious and uploaded the example sweep sketch and that works fine, however when I then want to write to a particular angle, rather than sweep, I get no noticeable response out of the servo. Something IS happening as I can hear a pulsing from the servo itself

As mentioned, if I just take the default sweep sketch and run it, it sweeps through the degrees no problem. If I then take that same sketch and just change the write lines from .

  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }

to

  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(10);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(170);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }

I would expect that it should write to first 10 degrees, then to 170 degrees. Yes, I realize that's not the best approach, I'm just trying to minimize the differences between what works and what doesn't. If I create a simple sketch that just writes various angles and delays in between again I get nothing.

The only thing I've been able to find is the caution against providing a proper ground, and I do have that (proof is that the sweep example works). Other examples, I've seen just write the angle to the servo and it (apparently) just works.

The only other thing I can think of is that it depends on the servo itself. I'm using a MS24 20kg Miuzei Digital Servo (Google that on Amazon and you'll see it).

Any thoughts/suggestions? Or am I missing some basic understanding on how the servo control works?

Thanks.

Well there was one thing that I left off of my list of things to check, and that was power.

I made the mistake of assuming that since the external power supply that I was using worked for the sweep example, it was sufficient for the servo in general. Lesson learned.

I first started by changing the pos increment on the example from 1 degree to 10 and it didn't work, so then I changed it to 5 degrees and what do you know it started to move...
I guess the battery supply was sufficient to provide the current draw on a small step, but not a prolonged period of the motor being energized to move from one angle to another. As soon as I connected the servo to my bench power supply it worked right away (something I should have done from the start but I already had a battery supply handy for a separate purpose and got lazy ::slight_smile: ).

Anyway, thanks for reading, hopefully it helps someone else out.

I guess that's exactly what loads of us were about to tell you. So congratulations on continuing your investigations and getting there first. And thanks for reporting back.

Steve

qn42:
Lesson learned.

I have to believe that this is part of the intent of the authors.
It quickly and thoroughly teaches the new user the limits of the arduino power supply, often before that user gets in to more complex experiments.

Also, thanks for reporting back. Karma++

vinceherman:
I have to believe that this is part of the intent of the authors.
It quickly and thoroughly teaches the new user the limits of the arduino power supply, often before that user gets in to more complex experiments.

Also, thanks for reporting back. Karma++

No problem. And just so it's clear to anyone else reading, I wasn't actually using the arduino itself to power the servo. (I've read enough on forums and videos not to try to drive any motors with the arduino itself.)

I was actually using the small separate power supply that you get with those kits, the ones that then in turn run off of a 9V. Although convenient, the 9V itself doesn't provide enough current to drive a larger motor, or in this case a larger load on that motor.

I'm sure to have more issues down the road....until then.