[SOLVED] - Issues powering servo with a step down converter

I can't get my SG90 working. I'm powering my uno with a barrel jack, which is in parallel with a step down converter (LM2596) that converts 12v to 5v for the servo. The power supply is rated at 2A and the converter should do 3A from what I've seen on the internet.

I've probed all the output voltages and they look fine. There is continuuity between arduino's, servo's and power supply's ground. Still I can't get the servo to do anything. I've tried adding another connection between converter's out- and arduino ground - no luck. Any tips would be greatly appreciated. Code and a crude diagram below.

#include <Servo.h>

Servo myServo; // Create a servo object to control a servo motor

int servoPin = 7; // Define the pin to which the servo is connected

void setup() {
  Serial.begin(9600);
  myServo.attach(servoPin); // Attaches the servo on pin 9 to the servo object
    for (int angle = 0; angle <= 180; angle++) {
    myServo.write(angle); // Set the servo position
    Serial.println(angle);
    delay(15); // Wait for servo to reach the position
  }
  delay(2000);
  // Sweep the servo from 180 to 0 degrees in steps of 1 degree
  for (int angle = 180; angle >= 0; angle--) {
    myServo.write(angle); // Set the servo position
    delay(15); // Wait for servo to reach the position
  }
}

void loop() {
}

You still need a ground wire between the Arduino and the servo.

Like I mentioned - I've tried that and it doesn't change anything

What arduino board you have?

Your diagram doesn't show that you have.

Uno clone

Hi, @thefandorn
Welcome to the forum.

Can you please post some images of your project?
So we can see your component layout.

Do you get the sweep angle values on the IDE monitor?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Since you don't have serial monitor output on this setup, try with onboard LED pin 13 so you have at least some visual indicator confirming arduino is sending pulses.
Control that your wiring has solid connections.

void setup() {
  Serial.begin(9600);
  myServo.attach(servoPin); // Attaches the servo on pin 9 to the servo object
    for (int angle = 0; angle <= 180; angle++) {
    myServo.write(angle); // Set the servo position
    Serial.println(angle);     <==========================================
    delay(15); // Wait for servo to reach the position
  }
  delay(2000);
  // Sweep the servo from 180 to 0 degrees in steps of 1 degree
  for (int angle = 180; angle >= 0; angle--) {
    myServo.write(angle); // Set the servo position
    delay(15); // Wait for servo to reach the position
  }
}

Tom... :smiley: :+1: :coffee: :australia:

I saw it but the wiring scheme indicates battery powered arduino without usb connection.

Inspecting OP's first post,
-Uno clone
-Serial usage present in code, usage typical

  • The lm2596 converters have no isolation, gnd passes straight through

@thefandorn Did you compile and upload, or just compile? Add "hello" print right after serial begin, to be sure, and tell us what you see in monitor.

Thanks all. I compile and upload. Serial prints work as expected (prints hello, angles etc - I can read it in the serial monitor). To simplify and narrow down the issue I switched to an external 5v power supply. See the diagram below.

Code:

#include <Servo.h>

Servo myServo; // Create a servo object to control a servo motor


int servoPin = 7; // Define the pin to which the servo is connected

void setup() {
  Serial.begin(9600);
  myServo.attach(servoPin); // Attaches the servo on pin 9 to the servo object
    for (int angle = 0; angle <= 180; angle++) {
    myServo.write(angle); // Set the servo position
    Serial.println(angle);  
    delay(15); // Wait for servo to reach the position
  }
  delay(2000);
  // Sweep the servo from 180 to 0 degrees in steps of 1 degree
  for (int angle = 180; angle >= 0; angle--) {
    myServo.write(angle); // Set the servo position
    delay(15); // Wait for servo to reach the position
  }
}

void loop() {
  
}

unfortunately it still doesn't work. Don't know why. Tried with two separate servos. One randomly switches a little bit (without any code, just power)??

Orange wire intermittent?
5V to servo, or gnd of servo, intermittent? Symptom is classic of an intermittent position, gnd, or 5v to servo.

Don't remember what I did, but the twitching subsided. I rechecked all the wires for continuity and they look good

Why do you have wires stuck in the board holes, green, red and black wires?

They're soldered for other, unrelated stuff. They're currently unplugged

Are you using a solderless breadboard for connections to the 5V PSU?

Hi,

Change the delay from
delay(15);
to
delay(200);

Put your DMM on Volts DC and measure the voltage between gnd and the signal wire as the code executes.

Tom.. :smiley: :+1: :coffee: :australia:

pulse width from ~800 us to ~2200 us, rep rate 50 hz, means at best 10% of 5V. So yes, the OP might see something, or not.
I'm suspecting that if all jumpers are intact, pin 7 has been fried somehow, so the OP should switch to another pin for testing.

Jim - connectors to the psu are soldered.

@TomGeorge - the voltage is 0 when measured to the psu gnd and around 0.5v when measured to the uno directly. So I would assume that my issues are ground connected after all. However I don't understand why it is this way... I measure 5v when probing the + and either of - on the psu leads

@camsysca checked multiple pins