Powering Arduino + Servo with same battery problem

Hi, I have problem with powering servo controlled by Arduino nano and hc-06 BT module.

I’ve used a Li-Po Battery with step-up dc-dc converter(max current is 2A). Also I was trying to power it using ATX power supply.

On this configuration servo and Arduino are getting crazy. The TX diode on arduino blinks much faster than normally, and the servo is not spinning, only making weird noises and making little moves.

But if I power Arduino from usb port and servo from external power supply it’s working fine.
Edit:
i’m sending code and schematic(the converter in schematic is diffrent than I have, i used that to show where it is)

#include <Servo.h>
#include <SoftwareSerial.h>
int btRX = 10;
int btTX = 11;
SoftwareSerial btSerial(btRX, btTX);
Servo myServo;
int i;
int speedVal;
int angleVal;
char cmd[100];
byte cmdIndex;
int sButton1 = 2;
int sButton2 = 3;

void setup() {
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
myServo.attach(9);
btSerial.begin(9600);
Serial.begin(9600);
speedVal = 1;
angleVal = 40;
}
void btAngle(){
  if (cmd[0] == 's'){
    angleVal =  atof(cmd + 2);
  }
}
void btSpeed() {
  if(cmd[0] == '1') {
    speedVal = 1;
  }
  if(cmd[0] == '2') { 
    speedVal = 2;  
  }
} 
void valuesCheck(){
    if (btSerial.available() > 0) {
    char c = (char)btSerial.read();
    if (c == '\n'){
      cmd[cmdIndex] = 0;
      btAngle();
      btSpeed();
      cmdIndex = 0;
    }
      else{
        cmd[cmdIndex] = c;
        if (cmdIndex < 99){
          cmdIndex++;
        }
      }      
    }
    if (isButtonPressed(sButton1)){
      speedVal = 1;
    }
    if(isButtonPressed(sButton2)){
      speedVal = 2;
    }
}
bool isButtonPressed(int button){
  if (digitalRead(button) == LOW){
    delay(20);
    if(digitalRead(button) == LOW){
      return true;
    }
  }
  return false;
}
void loop() { 
    valuesCheck();
    Serial.println(speedVal);
    Serial.println(angleVal);
    for (i = angleVal; i <= 180 - angleVal; i = i + speedVal){  
    myServo.write(i); 
    delay(5); 
   } 
   valuesCheck();  
   for (i = 180 - angleVal; i >= angleVal; i  = i - speedVal){  
    myServo.write(i);
    delay(5);  
}

  valuesCheck();
}

There is something wrong with the schematic you didn’t post.

When you say "DC-DC converter", do you mean a buck/boost converter or just a voltage regulator?

If it's buck/boost, how clean is the output?

If there's high-frequency noise there, that might be throwing your arduino and your servo.

What voltage LiPo are you using that you need a DC-DC converter?

:slight_smile:

I mean buck/boost converter. But I also tried to power it with atx power supply and the problem still exists. So, probably that's not a buck/boost converter fault.
The voltage of battery is 3.7v. I'm using this because my project have to be small :wink:

Which Arduino board are you using? What is the clock rate of the mystery Arduino board? Post the code and schematic of the project.

You will get better and faster help if you follow the guidelines in the how to use this forum-please read stickies.

What Voltage is your converter boosting it up to?

If you’re using an Uno and the onboard Voltage regulator, maybe the V-drop there is making the supply Voltage marginal?

Definitely not an earthing problem when the battery’s connected?

Like everybody else keeps saying, a schematic and the sketch would be helpful to see :slight_smile:

I expect you're doing something wrong that we would easily have worked out by now if you'd provided a circuit diagram and more details.

E.g. boost converter from 3.7V to what voltage? ATX power supply but which of the many voltages are you using. What pins/connectors on the Arduino are you connecting the power to?

Oh and "getting crazy" isn't a very useful problem description. Exactly what symptoms does an Arduino demonstrate to convince you that it is "crazy"?

Steve

I'm using the Vin pin on the clone of Arduino nano, and I was trying with 5 6 and 7v. I used also 5v voltage on atx power supply.

I added schematic and code.


How to post images.

Vin must be 7V minimum for the 5V regulator to function properly. If you have 5V, just connect to the 5V pin, not Vin.

I'd be tempted to put a scope on the dc-dc output and see what happens when the servo starts to move - as the problem only turns up when you're running off the battery, it's gotta be a power-supply problem of some sort...

What sort of servo? Servos take fairly high currents (some more than 2A) so if you're really connecting it via a breadboard it no surprise if it does not work reliably.

Steve

slipstick:
What sort of servo? Servos take fairly high currents (some more than 2A) so if you're really connecting it via a breadboard it no surprise if it does not work reliably.

Steve

It's a standard size servo feetech fs510b and I checked in datasheet that's maximum current is less than 1A. It was working on breadboard using Arduino Uno powered from usb but now i trying to make it on universal pcb board(I want to close it in small box)

0x10c:
I'd be tempted to put a scope on the dc-dc output and see what happens when the servo starts to move - as the problem only turns up when you're running off the battery, it's gotta be a power-supply problem of some sort...

Probably you're right because when I connected my atx to the 5v pin the servo runs correct. So, the problem is in converter.
Can you guys give me advice how to power it? I thought about use dwo serial connected batteries and 7805 module but I really want to have possibility to charge it using tp4056

Detmot:
It's a standard size servo feetech fs510b and I checked in datasheet that's maximum current is less than 1A.

There's no such thing as an FS510B. Perhaps you mean the 5103B or maybe the 5106B which are both standard size servos.

Have you tried your boost converter set to 5V output connected to the Arduino 5V pin? That setup works for many of us.

Steve

Diagram shows a hc-05 module and the boost converter number cannot find module anywhere(LM2621)

Chip itself is 1A.

http://www.ti.com/product/LM2621

slipstick:
There's no such thing as an FS510B. Perhaps you mean the 5103B or maybe the 5106B which are both standard size servos.

Have you tried your boost converter set to 5V output connected to the Arduino 5V pin? That setup works for many of us.

Steve

sorry, i mean ft5106b

bluejets:
Diagram shows a hc-05 module and the boost converter number cannot find module anywhere(LM2621)

Chip itself is 1A.

http://www.ti.com/product/LM2621

I have different converter which current is 2A, but i wasn't find it in fritzing. The same thing is with bt module (I'm using hc06)