Go Down

Topic: Simple Robotic Project - Help? (Read 1 time) previous topic - next topic

jmk4362

Jan 31, 2018, 02:42 pm Last Edit: Jan 31, 2018, 03:14 pm by jmk4362
Hey guys, frequent forum flyer, first time poster. I'm very new to Arduino, but excited about everything it has potential to do, so your help is appreciated in getting my project going.

Here's my situation: I am trying to make a (what should be) simple robotic vehicle with 2 DC motors in the rear, swivel wheels up front, and an H-bridge, that are controlled by an IR remote/receiver which was included in the starter kit. I used the code, edited for my specifics, and wiring schematic that can be found here: "https://electrosome.com/dc-motors-arduino-ir-remote/". My specific code is posted below.

#include <IRremote.h>

#define Next 0xFFC23D//insert code for next button
#define Prev 0xFF22DD //insert code for prev button
#define Up 0xFF906F //insert code for up button
#define Down 0xFFE01F //insert code for down button
#define Pause 0xFF02FD //insert code for play/pause button

int receiver_pin = 2; //IR receiver is connected to pin 2 of arduino

int Yellow_motor1 = 11;
int Yellow_motor2 = 12;
int Black_motor1 = 6;
int Black_motor2 = 5;

IRrecv receiver(receiver_pin); //arduino takes output from receiver
decode_results output;

void setup() {
 Serial.begin(9600);
 receiver.enableIRIn(); //start to take output from IR receiver
 //initializing all pins have connected led's as outputs
 pinMode(Yellow_motor1, OUTPUT);
 pinMode(Yellow_motor2, OUTPUT);
 pinMode(Black_motor1, OUTPUT);
 pinMode(Black_motor2, OUTPUT);

}

void loop() {
 if (receiver.decode(&output)) {
   unsigned int value = output.value;
   Serial.println(output.value, HEX);
   
   switch(value) {
     
     case Next:
       digitalWrite(Yellow_motor1, LOW);
       digitalWrite(Yellow_motor2, HIGH);
       digitalWrite(Black_motor1, HIGH);
       digitalWrite(Black_motor2, LOW);
       break;

     case Prev:
       digitalWrite(Yellow_motor1, HIGH);
       digitalWrite(Yellow_motor2, LOW);
       digitalWrite(Black_motor1, LOW);
       digitalWrite(Black_motor2, HIGH);
       break;

     case Up:
       digitalWrite(Yellow_motor1, LOW);
       digitalWrite(Yellow_motor2, HIGH);
       digitalWrite(Black_motor1, HIGH);
       digitalWrite(Black_motor2, HIGH);
       break;

       
     case Down:
       digitalWrite(Yellow_motor1, HIGH);
       digitalWrite(Yellow_motor2, HIGH);
       digitalWrite(Black_motor1, HIGH);
       digitalWrite(Black_motor2, LOW);
       break;

     case Pause:
       digitalWrite(Yellow_motor1, LOW);
       digitalWrite(Yellow_motor2, LOW);
       digitalWrite(Black_motor1, LOW);
       digitalWrite(Black_motor2, LOW);
       break;
   }
   receiver.resume();
 }

}


However, upon connecting all the components and uploading the program to the microcontroller, there are some issues. I have tried browsing everything from this forum, to stackoverflow, to Github, but I haven't been able to find my issues I'm having, so I'm hoping that someone can help me out. The issues I am having are:

-Only one of the motors spins when buttons are pressed. Specifically the motor labelled "Yellow_motor". It only spins counterclockwise and only when "Yellow_motor2" is designated as HIGH, so during cases Next, Up, and Down.

-Once the motor is spinning, the IR receiver doesn't realize that buttons are being pressed

Additional Information: I confirmed with direct battery hookup that the black motor doesn't spin at all. I also tried using different pins for the motors on the board to no avail. Could the black motor be effecting the circuit and therefore screwing everything up? Would that effect the IR receiver once the yellow motor is spinning? Why does the yellow motor only spin counterclockwise?

Any information you can provide me will be greatly appreciated. Thank you so much in advance!

slipstick

Additional Information: I confirmed with direct battery hookup that the black motor doesn't spin at all.
Do you mean that the black motor will not spin even when you connect a battery directly to it? If so you need to fix that first, possibly by fitting a working motor instead. If the gearbox is jammed so it won't turn then the motor is stalled and will be drawing loads of current and creating havoc with the battery and motor driver.

Steve

jmk4362

Do you mean that the black motor will not spin even when you connect a battery directly to it?
Correct. The motor is somehow busted/jammed. I did order new motors online, however they take forever to get through customs in Finland so I was hoping there could be another solution to this other than trying new motors. Do you happen to know if the resulting current draw would affect the IR receiver in any way?

Thanks so much Steve!

slipstick

It probably depends on how you have the robot powered. If it's a battery (what sort of battery?) any excess current can drag the voltage down so low the IR Receiver stops working. Anything is possible.

If you have no other motors to use all you can really do is disconnect that motor completely and check that everything else works o.k.

Steve


jmk4362

Well I was using a 9V hooked up similarly to the schematic, but when I disconnected the battery the yellow motor was still operational, so I immediately unplugged the Arduino. I did try your suggestion and it worked!  :)  :)  :) However, yellow motor still only spins counterclockwise, but at least the IR Receiver can now stop the yellow motor. Baby steps will get there eventually. Thanks so much for your help!

slipstick

If you are using a rectangular 9V battery as shown then that may be part of the problem too. They will not usually supply enough power to drive one motor never mind two. If you can use 6 x AA batteries instead it will work much better.

Steve

jmk4362

Alright, thanks so much for your help Steve!

James

wilfredmedlin

They will not usually supply enough power to drive one motor never mind two. If you can use 6 x AA batteries instead it will work much better.

Steve
And even if they could supply enough power, their energy is too small to let it last a decent time.

Keep Calm and call 0118 999 88199 9119725...... 3

jmk4362

Hello again! With the new motors, the remote and code functions properly, so I really appreciate the help with that issue.

However, I ran into a new problem. I took slipstick's advice and got a bigger power source. The one I was able to find readily available was 8 x AA batteries for a total of 12V power supply. The motors still have trouble rotating on their own, so sometimes I need to provide a physical tap to the propeller in order to get the motors rotating. The power supply is attached as shown in the diagram in the link above, with the positive and negative hooked up to the +/- runners on the breadboard.

Has anyone run into this problem before and/or have any ideas on how to fix it? I wasn't able to find any explanation online before posting here.

Thanks for the help!

jremington

#9
Feb 23, 2018, 06:34 pm Last Edit: Feb 23, 2018, 06:34 pm by jremington
Post a link to the product page or data sheet for the motors. The antique L293 motor driver chip is extremely inefficient and may not be able to supply enough current for the motors.

Go Up