6 V peak to peak PWM output

Hello,

I’m trying to control a servo (HS-7980th) that goes from 0 to 180 using the Mega 2560 R3. The specs on the servo recommend a pulse of 4.8-7.4 square wave for control w/ a frequency of around 50Hz. Unfortunately, my current code won’t move the servo automatically (I have to manually move the servo arm, and once it reaches the desired position, it maintains it). I used an oscilloscope to observe my PWM signal, and my peak-peak is only 560mV! which I fear is the cause of my problems. Is there a way to increase the peak-peak output to be around 6V? I’m including a simple testing code I’ve been using. Thanks in advance

#include <Servo.h>

Servo myServo;
int angle;

void setup()
{
myServo.attach(9, 1050, 1950);
}

void loop()
{

angle = 180;

myServo.write(angle);
delay(20);
}

Is the servo driven from the Arduino's power or does it have its own?- it really ought to have its own, with the grounds joined.

A 12 V power source is being regulated to 6.5V to power up the servo. The grounds for the microcontroller and Servo are tied together.

myServo.attach(9, 1050, 1950);

I've never used those min and max parameters in the attach, only ever let them default- wonder if it can have anything to do with those?

myServo.attach(9);

Jimbo, Unfortunately, I tried w/o mins and max, and it is still acting the same way. The only reason I placed those boundaries was to choose 180 deg angle displacement as per datasheet specs

I suspect there might be something wrong with your power source/regulator set up if the servo cannot move on it’s own if you change values. Of course your sketch is only sending a single command value out over and over, so I don’t see how your are evaluating the servo performance or if you even have a problem.

Why don’t you run the IDE example sketch Sweep and see how your servo responds and measure the voltage at the servo’s power input pin while it’s running and see what it measures and report back.

// Sweep
// by BARRAGAN <http://barraganstudio.com> 
// This example code is in the public domain.


#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
                // a maximum of eight servo objects can be created 
 
int pos = 0;    // variable to store the servo position 
 
void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
} 
 
 
void loop() 
{ 
  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>=1; 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 
  } 
}

Lefty

The power supply was the problem! I was limiting the current to a level that wouldn't move the servo. Thanks everyone.