Controlling servo via digitalWrite - weird phenomenon on board startup

Dears @ community,

After 15 years for not hobbying microcontrollers I'm back with Arduino UNO and some Chinese 270 degree 5-7v "normal size" Servo which I'm trying to play around.

There is a tons of examples to control Servo via the library and tried them as well. Control seems to be "ok" but for some reason the servo looked slow on it's movement to my eye compared to the micro servo and seemed that during the movement there was some really awkward jams on it's movement path. None of these was noted with the micro servo driven by the power directly from arduino board 5V line. For the "normal size" servo I use external laboratory power supply with 5v and current draw seems to be around 100-300mA during the no-load movement.

As I was troubled more about the strange movement behavior I created just a simple few line code to feed the pulse(s) with digitalWrite on arduino pin 5.

void setup() {
  // put your setup code here, to run once:
pinMode (5, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(5, HIGH);
delayMicroseconds(800);
digitalWrite(5, LOW);
delay(3000);
digitalWrite(5, HIGH);
delayMicroseconds(1200);
digitalWrite(5, LOW);
delay(3000);

}

It did really help, the movement of the servo is solid without any weird behavior but still it's somehow slow compared to micro servo I'm referring earlier with quite similar specs. And with slow I mean something like +300ms/60 degrees measured from complete 270 movement range and using stopwatch (so not so scientific). I guess it's just servo cannot do any better? power supply has set current limitation to 4 amps so it should not restrict the current even not seen on the supply meter.

But the main problem now comes here:

When I power up the arduino uno board (throughout PC and for servo throughout power supply) seems that with above code servo seems not to start movement. Well sometimes it will, I'm pretty sure I witnessed this at least once, but 99/100 it will not. But the strange parts comes out while I was doing wiring check; I noticed that the movement only kicks in when I physically remove servo control signal wire from arduino board and put it back. Then the movement continues as planned in first place. Board reset button will not help while pushed while circuit and servo powered.

I have no oscilloscope to check the signal levels or what's going on in the line. Any suggestion what might be wrong? Tried also put small 4.7k pulldown resistor to output secure the zero but apparently no help.

And now I'm here to ask you guys for a help, thanks in advance.

try the servo library to see if the strange behavior follows.

I’m quite surprised that the servo does anything useful at all when you send a single pulse then nothing. Servos generally don’t like having the control signal just stop for several seconds. Have you tried doing it more normally i.e. one pulse roughly every 20ms continually?

Steve

I'm quite surprised that the servo does anything useful at all when you send a single pulse then nothing. Servos generally don't like having the control signal just stop for several seconds. Have you tried doing it more normally i.e. one pulse roughly every 20ms continually?

Steve

Idahowalker:
try the servo library to see if the strange behavior follows.

With servo library, servo will have glitches at some point of the movement where the power consumpion will increase and seems that it starts to oscillate. It usually recover from situation and continue the movement but seems not to be very reliable way of controlling at least this servo. And actually I ordered two of these servos same time and same phenomenon happens on both of them. Thats why I tried it old fashion way of controlling it with just single pulses.
Type of servo is TD-8120MG.
http://wiki.sunfounder.cc/images/9/9a/TD-8120MG_Digital_Servo.pdf

slipstick:
I'm quite surprised that the servo does anything useful at all when you send a single pulse then nothing. Servos generally don't like having the control signal just stop for several seconds. Have you tried doing it more normally i.e. one pulse roughly every 20ms continually?

Steve

Thanks for reply. Why dont they like that? I mean of course we will lose the "force and hold still" functionality but I'm not after that on my project, it's kind of an gate with no load to the servo axel.

And you are powering the servos through a breadboard?

Post a pic of your setup and a schematic.

I've not had any issues with the servo library.

And for this venture could you stick with the servo library as the issue is worked out? The servo library is a known good quantity.

Post the servo library code you used, in code tags.

Just be aware that 95% of issues people have here with servos turn out to be due to an inadequate power supply. Servos need lots of current, in very bursty peaks (which most multimeters are entirely unable to
see).

You shouldn't even be thinking of powering any servo or motor from the 5V logic supply from an Arduino
or other logic board. Motors can put all sorts of spikes and dropouts on their supply, keep this separate from
logic supplies which need to be spike and drop-out free.

Idahowalker:
And you are powering the servos through a breadboard?

Post a pic of your setup and a schematic.

I’ve not had any issues with the servo library.

And for this venture could you stick with the servo library as the issue is worked out? The servo library is a known good quantity.

Post the servo library code you used, in code tags.

Have to work out a bit with schematic, but there is nothing special. If you have time, I took small video with servo connected and another where the micro servo is connected. Both now with same code:

#include <Servo.h>
Servo myservo;

void setup() {
  // put your setup code here, to run once:
myservo.attach(3);
}

void loop() {
  // put your main code here, to run repeatedly:

myservo.write(50);
delay(3000);
myservo.write(150);
delay(3000);
}

Link for video 1:

Link for video 2:

MarkT:
Just be aware that 95% of issues people have here with servos turn out to be due to an inadequate power supply. Servos need lots of current, in very bursty peaks (which most multimeters are entirely unable to
see).

You shouldn’t even be thinking of powering any servo or motor from the 5V logic supply from an Arduino
or other logic board. Motors can put all sorts of spikes and dropouts on their supply, keep this separate from
logic supplies which need to be spike and drop-out free.

If you have time and interest, please check the previous comment, I added small videos of two servos and behavior . I know the setup is now throughout breadboard which obviously is not good for high current transfer but I have also tested without breadboard and there is no change.

Yes, most hookup wiring sold for breadboard use is not suitable for high currents (some
is hopeless in fact - just cut the wire and see how little copper (or even aluminium)
they use)

I use 0.6mm diameter solid-core wire for breadboarding as it will handle high currents,
but breadboard connections have enough resistance to cause issues at these current
levels, its much better to have solid wiring and solid connections when the current's
significant.

You PSU shows current peakiness fairly well, but the instantaneous currents could be
double or more what the display can handle - a current probe and an oscilloscope will
show the true max current demand.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.