DC Converters powering 3 Servos, an Ultrasonic Sensor, and a Voice Recognition

Hi all,
I am trying to find a power source for as listed above, 3 motors, a sensor, and a voice recognition module (Geeetech High Sensitivity). I am using a 4 cell 18650 Li-Ion battery with a step down dc to dc converter. When I test the separate parts, such as the Voice Recognition Module, it seems like it powers too little. The light on the Voice Recognition is very thin and no action whatsoever. If I replace the Li-Ion with 4 AAA batteries in a series, it works completely fine, for each part. What is the problem?
One Radioshack Micro servo and two Parallax continuous rotation servos
An Ultrasonic HC-SR04 Sensor
A Geeetech High Sensitivity Voice Recognition Module

I also have this code which is supposed to follow 3 commands and do separate actions for those commands. Does this code work?
There is a Stop command, Wander command, and Look Around command.

//Voice Recognition Code
#include <Servo.h>                                                                                                                                                      
const int RForward = 1000; 
const int RBackward = 2000; 
const int LForward = 1000; 
const int LBackward = 2000; 
const int RNeutral = 1500; 
const int LNeutral = 1500; //constants for motor speed 
const int trigpin = 7; 
const int echopin = 3; 
const int dangerThresh = 10; //threshold for obstacles (in cm) 
int leftDistance, rightDistance; //distances on either side 
Servo panMotor; 
Servo leftMotor; 
Servo rightMotor; //declare motors 
long duration; //time it takes to recieve PING))) signal 
byte com = 0;

void setup (){
  Serial.begin(9600);
  delay(2000);
  Serial.write(0xAA);
  Serial.write(0x37);
  delay(1000);
  Serial.write(0xAA);
  Serial.write(0x21);
  delay(2000);
  rightMotor.attach(11);
  rightMotor.writeMicroseconds(1500);
  leftMotor.writeMicroseconds(1500);
  leftMotor.attach(10);
  panMotor.attach(9);
  delay(1000);
  panMotor.write(90);
}

void loop ()
{
  while(Serial.available())
{
  com = Serial.read();
  switch(com)
{
  case 0x11:
  {
    loop();
    {
      int distanceFwd = ping(); 
      if (distanceFwd>dangerThresh) //if path is clear 
      { 
        leftMotor.writeMicroseconds(LForward); 
        rightMotor.writeMicroseconds(RForward); //move forward 
      } 
      else //if path is blocked 
      { 
        leftMotor.writeMicroseconds(LNeutral); 
        rightMotor.writeMicroseconds(RNeutral); 
        panMotor.writeMicroseconds(1000); 
        delay(500); 
        rightDistance = ping(); //scan to the right 
        delay(500); 
        panMotor.writeMicroseconds(2000); 
        delay(700); 
        leftDistance = ping(); //scan to the left 
        delay(500); 
        panMotor.writeMicroseconds(1500); //return to center 
        delay(100); 
        compareDistance(); 
      }
    }
  } 
  break;
  case 0x12:
  {
    panMotor.writeMicroseconds(2000);              
    delay(1000);                                               
    panMotor.writeMicroseconds(1000);              
    delay(1000);                        
    panMotor.writeMicroseconds(1500);
    delay(1000);
    leftMotor.writeMicroseconds(1500);
    rightMotor.writeMicroseconds(1500);
  }
  break;
  case 0x13:
  {
    panMotor.writeMicroseconds(1500);
    leftMotor.writeMicroseconds(LNeutral);
    rightMotor.writeMicroseconds(RNeutral);
  }
  break;
}
}
}

void compareDistance()
{
  if (leftDistance>rightDistance) //if left is less obstructed 
  { 
    leftMotor.writeMicroseconds(LBackward); 
    rightMotor.writeMicroseconds(RForward); //turn left 
    delay(500); 
  } 
  else if (rightDistance>leftDistance) //if right is less obstructed 
  { 
    leftMotor.writeMicroseconds(LForward); 
    rightMotor.writeMicroseconds(RBackward); //turn right 
    delay(500); 
  } 
  else //if they are equally obstructed 
  { 
    leftMotor.writeMicroseconds(LForward); 
    rightMotor.writeMicroseconds(RBackward); //turn 180 degrees 
    delay(1000); 
  } 
}

long ping()
{
  // Send out PING))) signal pulse 
  pinMode(trigpin, OUTPUT); 
  pinMode(echopin,INPUT); 
  digitalWrite(trigpin, LOW); 
  delayMicroseconds(2); 
  digitalWrite(trigpin, HIGH); 
  delayMicroseconds(10); 
  digitalWrite(trigpin, LOW); 
 //Get duration it takes to receive echo 
duration = pulseIn(echopin, HIGH); 
//Convert duration into distance 
return duration / 29 / 2; 
}

Hi

What is the DC-DC converter part number or photograph.

What does the voltage measure on the Li-Ion battery when you have it disconnected and connected to the converter?
Likewise when you use the 4xAA pack?

Also what is the output voltage of the converter with each battery loaded and unloaded?

Sorry to ask so much, but these measurements will help to understand your problem and provide some suggestions.

Tom..... :slight_smile:

  1. here is a link: http://www.amazon.com/dp/B00QK556TE/ref=sr_ph?ie=UTF8&qid=1429370436&sr=1&keywords=E-Bro+Mini+USB+Car+12V+to+5V+Power+Supply+DC-DC+Step-down+Buck+Volt+Convert+8-20V+Waterproof
  2. It is always 5V when connected, same with the 4xAAA
  3. It is always 5V at 3A

Can anyone verify this code?
It's supposed to run three voice commands:

  1. Stop
  2. Wander
  3. Look Around
//zapduino rocked this
#include <Servo.h>
 
//right servo wheel
const int rForward = 0;
const int rStop = 90;
const int rReverse = 180;
const int rPin = 11;
 
//left servo wheel
const int lForward = 0;
const int lStop = 90;
const int lReverse = 180;
const int lPin = 10;
 
//head servo
const int pLeft = 0;
const int pCenter = 90;
const int pRight = 180;
const int pPin = 9;
 
//sonar pins
const int trigPin = 7;
const int echoPin = 3;
 
//collision threshold in centimeters
const int collisionThresh = 10;
 
//obstacle distances
int lObstacle, rObstacle;
byte com;
 
//servo declarations
Servo panMotor;
Servo rMotor;
Servo lMotor;
 
void setup() {
  rMotor.attach(rPin);
  rMotor.write(rStop);
 
  lMotor.attach(lPin);
  lMotor.write(lStop);
 
  panMotor.attach(pPin);
  panMotor.write(pCenter);
 
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
 
  Serial.begin(9600);
  Serial.write(0xAA);//Group 1
  Serial.write(0x37); //Voice Commands
  delay(1000);
  Serial.write(0xAA);//Group 1
  Serial.write(0x21);//Testing
  delay(2000);
}
 
void loop() {
 
  if(Serial.available()) {
    com = Serial.read();
  }
  switch(com) {
    case 0x11:
      stop();
      break;
    case 0x12:
      wander();
      break;
    case 0x13:
      look();
      break;
  }
}
 
void look() {
  stop();
  panMotor.write(pLeft);
  delay(1000);
  panMotor.write(pRight);
  delay(1000);
  panMotor.write(pCenter);
}
 
void wander() {
  forward();
  panMotor.write(pCenter);
  if(ping() <= collisionThresh)
  {
    stop();
    panMotor.write(pLeft);
    delay(20);
    lObstacle = ping();
   
    panMotor.write(pRight);
    delay(40);
    rObstacle = ping();
   
    panMotor.write(pCenter);
    if(lObstacle <= collisionThresh) {
      right();
      while(ping() <= collisionThresh) {
        delay(5);
      }
      stop();
     
    } else {
      left();
      while(ping() <= collisionThresh) {
        delay(5);
      }
      stop();      
    }
  }
}
 
void forward() {
  lMotor.write(lForward);
  rMotor.write(rForward);
}
 
void reverse() {
  lMotor.write(lReverse);
  rMotor.write(rReverse);
}
 
void left() {
  lMotor.write(lReverse);
  rMotor.write(rForward);    
}
 
void right() {
  lMotor.write(lForward);
  rMotor.write(rReverse);
}
 
void stop() {
  lMotor.write(lStop);
  rMotor.write(rStop);  
}
 
int ping() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(trigPin, LOW);
 
  long duration = pulseIn(echoPin, HIGH);
 
  return (int)(duration / 29 / 2); //centimeters
}