Go Down

Topic: [ARDUINO UNO] Motor Drivers are not Functioning Properly without USB Connection  (Read 672 times) previous topic - next topic

Ceejay327

Hello all, I have ran into a problem with a robot I'm constructing that acts as surveillance, however I have reached an obstacle: whenever I attempt to use an external power supply instead of a USB to provide "wireless" connection, my motor drivers do not operate as planned.

NOTE: I have researched many problems similar to this that have occurred to many users of the Arduino. However, I feel that what I'm trying to tackle strays somewhat off the regular.

DETAILS OF MY SITUATION:
  • The power source I am using is a 4 AA battery pack with 1.5V each that connects to the Arduino power jack. (6V)
  • https://www.bananarobotics.com/shop/image/cache/data/sku/BR/0/1/0/0/3/BR010038-HG7881-(L9110)-Dual-Channel-Motor-Driver-Module/HG7881-(L9110)-Dual-Channel-Motor-Driver-Module-600x600.JPG <------ I am using two of these motor drivers to control a 4-Wheeled Robot (They operate on 2.5V-12V of current EACH)
  • Each Power and Ground Pin for both Motor Drivers are connected to the power rails of the breadboard I am using. The VIN Pin of the Arduino is being used to supply power to the power rails of the breadboard and there is a connection between the ground of the breadboard and the ground of the Arduino.
  • For Motor Driver 1, the connections are:
    A-IA to Pin 6 - Motor 1
    A-IB to Pin 7 - Motor 1
    B-IA to Pin 8 - Motor 2
    B-IB to Pin 2 - Motor 2
    For Motor Driver 2, the connections are:
    A-IA to Pin 9 - Motor 3
    A-IB to Pin 12 - Motor 3
    B-IA to Pin 11 - Motor 4
    B-IB to Pin 19 - Motor 4
  • const int MOTOR_A_1_SPD = 6; // Motor 1
    const int MOTOR_A_1_DIR = 7;

    const int MOTOR_B_1_SPD = 9; // Motor 2
    const int MOTOR_B_1_DIR = 2;

    const int MOTOR_A_2_SPD = 10; // Motor 3
    const int MOTOR_A_2_DIR = 12;

    const int MOTOR_B_2_SPD = 11; // Motor 4
    const int MOTOR_B_2_DIR = 19;

    byte speed = 255;

    void setup() {
      pinMode(MOTOR_A_1_SPD,OUTPUT);
      pinMode(MOTOR_A_1_DIR,OUTPUT);
      pinMode(MOTOR_B_1_SPD,OUTPUT);
      pinMode(MOTOR_B_1_DIR,OUTPUT);
      pinMode(MOTOR_A_2_SPD,OUTPUT);
      pinMode(MOTOR_A_2_DIR,OUTPUT);
      pinMode(MOTOR_B_2_SPD,OUTPUT);
      pinMode(MOTOR_B_2_DIR,OUTPUT);
    }

    void loop() {
      forward();
      delay(2000);
      backward();
      delay(2000);
    }

    void forward() {
      analogWrite(MOTOR_A_1_SPD, speed);
      digitalWrite(MOTOR_A_1_DIR, LOW);
      analogWrite(MOTOR_B_1_SPD, speed);
      digitalWrite(MOTOR_B_1_DIR, LOW);
      analogWrite(MOTOR_A_2_SPD, speed);
      digitalWrite(MOTOR_A_2_DIR, LOW);
      analogWrite(MOTOR_B_2_SPD, speed);
      digitalWrite(MOTOR_B_2_DIR, LOW);
    }
    void backward() {
      analogWrite(MOTOR_A_1_SPD, 0);
      digitalWrite(MOTOR_A_1_DIR, HIGH);
      analogWrite(MOTOR_B_1_SPD, 0);
      digitalWrite(MOTOR_B_1_DIR, HIGH);
      analogWrite(MOTOR_A_2_SPD, 0);
      digitalWrite(MOTOR_A_2_DIR, HIGH);
      analogWrite(MOTOR_B_2_SPD, 0);
      digitalWrite(MOTOR_B_2_DIR, HIGH);

    The above code is aimed at driving all 4 motors forward for 2 seconds and then backwards for 2 seconds. As mentioned in the title, when using a USB Connection to supply power, the code works FINE. However, when using 4 AA Batteries hooked into the external jack of the Arduino, here is what happens:

    None of my motors begin to drive forward or backward, BUT sometimes what would happen is my motors being to operate and WOULD drive forward, BUT NOT backwards, but something weird would occur. What I mean is that it would execute the "forward(); and delay(2000);" commands and NOT the "backwards();" BUT the Arduino would execute the backward's delay:

    backward();
    delay(2000); <---- THIS LINE WOULD BE EXECUTED ALONG WITH FORWARD AND THE OTHER DELAY. IT WOULD ESSENTIALLY RUN THE MOTORS FORWARD FOR 2 SECONDS AND THEN WAIT FOR 4 SECONDS AND THEN REPEAT, BUT IT ONLY DOES THIS ABOUT 3 TIMES BEFORE IT DOESN'T WORK AT ALL.

    }
     


HERE IS WHAT I HAVE TRIED:

  • Wire the RX and TX Pins directly
  • Wire the TX Pin to the GROUND with a 10k Ohm Resistor
  • Wired a battery with wires instead of a battery pack with a jack
  • Connected BOTH Ground Pins to BOTH rails of the breadboard
  • Used the 5V and 3.3V Pins to transmit power to the Breadboard
  • I had other devices mounted to breadboard and COMPLETLY DISCONNECTED THEM


Guys, I am at a complete loss of what to do. The only other thing I can think to attempt is to supply more voltage to the power rails of the breadboard. I have to create a surveillance robot that can avoid obstacles using a ultrasonic sensor, track an entity using a PIR Sensor, and take pictures and store it on an SD Card using a JPEG Camera while it is panning and tilting using a platform.

mauried

The most likley cause will be the AA batteries not being able to provide enough current to drive the motors without their voltage sagging.
Try using bigger batteries or differant chemistry batteries such as Lipos.
Also can you drive the motors with differant batteries to the ones supplying the Arduinos power.

Ceejay327

The most likley cause will be the AA batteries not being able to provide enough current to drive the motors without their voltage sagging.
Try using bigger batteries or differant chemistry batteries such as Lipos.
Also can you drive the motors with differant batteries to the ones supplying the Arduinos power.

Had the Arduino not executed my code so weirdly, that would have been my first conclusion. But I thought that a lack of voltage wouldn't effect HOW the code was executed. I guess anything can happen when there isn't enough voltage.

rpt007

Quote
The power source I am using is a 4 AA battery pack with 1.5V each that connects to the Arduino power jack. (6V)
That's why it can't work.
If you read the specs of an Arduino, you will see that the power jack input should be in the range of 7V .. 12V.
Arduino's power jack's input goes to a voltage regulator which needs at least 7V to operate regularly.

So you should go with 5..6 battery cells (= 7.5 ... 9V).

The following link will give you more information:
http://www.open-electronics.org/the-power-of-arduino-this-unknown/

Attention: don't use the +5V pin as input when you are operating with more than 5.25V !! You might immediately fry your device.
Before you ask:
Did you really read and understand How to use this forum ?
AND:
Do you have already some solution or is a part of the problem sitting in front of the screen?  :)

Go Up