L293D: PWM doesn't work in one of the motors

I’m using an L293D motor driver IC and the Arduino Uno R3 to control two 12V, 200 RPM DC motors (2~4Kgcm torque). I’ve attached the code and circuit. I wired the connections as per the circuit. (no extra components; simply connected the Arduino pins defined in the program to the ones shown in the picture)

The code has two functions - demoOne() & demoTwo(). demoOne() runs the two motors in one direction for 2 seconds and in the opposite direction for another 2 seconds. demoTwo() controls the two motors using PWM - 0 to 255 and back to 0.

demoOne() works perfectly fine. Both motors run in one direction for two seconds and reverse their direction in the next two secs. Problem is with demoTwo(). Only one of the motors follows PWM. The other simply runs at a constant speed.

I measured the voltages at the PWM pins of the Arduino Uno R3 using a multimeter. Without connections to the L293D IC, the voltages at the two pins are pulse width modulated. But when I wire the two pins to the IC, only one of those are pulse width modulated. The other simply reads 1.8volts. I tried using different PWM pins but no luck.

I tried driving the motors one at a time (defining only the pins needed to drive one motor) and they worked fine (their speeds were pulse width modulated). The problem arises when I try to drive the two motors at the same time.

I’ve been facing this issue for two to three days now and I tried searching solutions online but couldn’t find any. Please help me out. Thanks in advance.

MOTOR_driver_check.ino (2.12 KB)

Circuit.png

check the cables connected between motor and ld293 pin outs. remove cable from both ends and check continuty of each wire/jumperwire. my son too had same prob yesterday,and found the jumper wires to one motor were open,
try and see if its resolved
regards

nkavinash:
check the cables connected between motor and ld293 pin outs.

The way I understand OP's explanation, the function demoOne() works correctly, but demoTwo() doesn't, which would indicate the connections are good.

With it working correctly with one motor at a time, but not both, that would indictate power supply to me, but that doesn't make sense in the light of demoOne() working.

Hi,
OPs circuit;
Circuit.png
What pins do you have A, B and Enable1 connected to?

Can you post a picture of your project so we can see your component layout please?

Thanks… Tom… :slight_smile:

Thanks a lot for your response.

wilfredmedlin:
The way I understand OP’s explanation, the function demoOne() works correctly, but demoTwo() doesn’t, which would indicate the connections are good.

With it working correctly with one motor at a time, but not both, that would indicate power supply to me, but that doesn’t make sense in the light of demoOne() working.

Yes, there are no loose connections since the motors run perfectly fine when demoOne() is executed. And power supply doesn’t seem to be a problem too. I’m using a 12V, 1A AC - DC adapter to power the motors. The maximum current rating of the motor is 300mA. So, I guess power supply isn’t a problem.

TomGeorge:
Hi,
OPs circuit;
Circuit.png
What pins do you have A, B and Enable1 connected to?

Can you post a picture of your project so we can see your component layout please?

Thanks… Tom… :slight_smile:

Sure!! I’ve attached the connections to the Arduino and L293D. Thanks a lot! :slight_smile:

Hi,
Does your protoboard have breaks in the red and blue line down the side?
If so they indicate that the side power bus lines are not continuous.
Protoboards1.jpg
Tom… :slight_smile:

TomGeorge:
Hi,
Does your protoboard have breaks in the red and blue line down the side?
If so they indicate that the side power bus lines are not continuous.
Protoboards1.jpg
Tom… :slight_smile:

No. They don’t have breaks. They’re continuous.

Hi,

void loop()
{
 // demoOne();
 // delay(1000);
  demoTwo();
  delay(1000);
}

Can you comment out the two lines I have shown exampled above, and run the code.

Thanks.. Tom... :slight_smile:

TomGeorge:
Hi,

void loop()

{
// demoOne();
// delay(1000);
  demoTwo();
  delay(1000);
}




Can you comment out the two lines I have shown exampled above, and run the code.

Thanks.. Tom... :)

Tried just that. Same result. One motor runs at variable speed and the other at a constant speed. :sob: :sob:

Post full details of your motors - are they the same? What is their stall current? Is their stall current
higher than the absolute maximum current rating of the L293D?
Have you tried swapping which motor is connected to which sets of outputs of the L293D?
Have you tested each half of the L293D independently from the same set of Arduino output pins?
Have you tried each set of Arduino output pins independently.

When you have a fault where one of two things is failing, the first and simplest debugging technique
is swapping things around - this will tell you if the fault is in the motor, driver or arduino or wiring.

The L293D is a very feeble motor driver, most motors exceed its 0.6A current maximum, note, so that's
my first intuition, lack of current handling.

Newcomers usually underestimate the massive difference in power requirements of motors v. logic circuits,
its orders of magnitude different.

Hi,
Can you post a picture of your project so we can see your component layout please?

Can you swap the wires over between pins 10 and 11 please?
Tell us what happens when you run with demo1 commented out?

Thanks.. Tom... :slight_smile:

MarkT:
Post full details of your motors - are they the same? What is their stall current? Is their stall current
higher than the absolute maximum current rating of the L293D?
Have you tried swapping which motor is connected to which sets of outputs of the L293D?
Have you tested each half of the L293D independently from the same set of Arduino output pins?
Have you tried each set of Arduino output pins independently.

When you have a fault where one of two things is failing, the first and simplest debugging technique
is swapping things around - this will tell you if the fault is in the motor, driver or arduino or wiring.

The L293D is a very feeble motor driver, most motors exceed its 0.6A current maximum, note, so that’s
my first intuition, lack of current handling.

Newcomers usually underestimate the massive difference in power requirements of motors v. logic circuits,
its orders of magnitude different.

Thanks a lot for your time. Yes, the motors are the same. This is all I know about the motors:

200RPM 12V DC motors with Gearbox
3000RPM base motor
6mm shaft diameter with an internal hole
125gm weight
Same size motor available in various rpm
0.5kgcm torque
No-load current = 60 mA(Max), Load current = 300 mA(Max)

I did swap the motors. They work fine. There’s no difference in their performance when swapped. I didn’t test each half of the L293D separately. I’ll do that during this weekend and get back to you. Thanks for the tip. I tested only one half and it worked fine (the variation in speed was gradual as desired). But I did try each set of Arduino output pins independently.
Yes, I know that the L293D couldn’t handle high values of power. That’s why I initially used the L298N. But that didn’t work. The motors won’t reverse. That’s why I had to switch to L293D. I thought of using the IC directly instead of using a breakout board (as is the case with L298N).

TomGeorge:
Hi,
Can you post a picture of your project so we can see your component layout please?

Can you swap the wires over between pins 10 and 11 please?
Tell us what happens when you run with demo1 commented out?

Thanks… Tom… :slight_smile:

Thanks a lot for your time. Sure, I’ve attached a picture of my project for your reference. Yes, I did run the code after commenting out demoOne(). The speed of one of the motors increases gradually and decreases gradually (as expected). But the speed of the other motor stays constant (not the max. speed nor the min. speed, somewhere in between).

Hi,
OPs pic.
d4c6ca9885212819b9cc2ce7ee06e2677a3933af.jpg
Thanks… Tom… :slight_smile:

Hi,
Did you take the wire out of pin 10 on the UNO and place it in Pin 11 on the UNO?
AND;
Did you take the wire out of pin 11 on the UNO and place it in Pin 10 on the UNO?

Thanks.. Tom.... :slight_smile:

TomGeorge:
Hi,
Did you take the wire out of pin 10 on the UNO and place it in Pin 11 on the UNO?
AND;
Did you take the wire out of pin 11 on the UNO and place it in Pin 10 on the UNO?

Thanks.. Tom.... :slight_smile:

It worked!! Turns out there was a problem with the jumpers. The voltage at the end of the jumper wire was not pulse-width-modulated. I replaced the jumpers with single strand wires and it worked fine!! Thanks a lot for your help, everyone.

However, I ran into another problem... This is a self-balancing robot project. The Uno takes input from ADXL335 and uses PID to compute the required velocity of wheels.
The motors were running and suddenly all the LEDs on the Arduino board started burning. I don't know what happened. I tried resetting the board, but that didn't work. I disconnected the Uno and reconnected it and now, the built-in LED on the Uno is constantly burning and pressing the reset button doesn't have any impact. The Arduino is "stuck"?!!

I'm not able to upload code to the Uno. It takes a long time and in the end, I get an error(s):

Sketch uses 1482 bytes (4%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xf2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xf2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xf2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xf2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xf2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xf2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xf2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xf2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xf2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xf2
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

Have I fried the Uno???!!!

Hi,
Do you have a DMM?

Disconnect the UNO from all the I/O and see if you can load the "Blink without Delay" sketch?

Tom... :slight_smile:

TomGeorge:
Hi,
Do you have a DMM?

Disconnect the UNO from all the I/O and see if you can load the “Blink without Delay” sketch?

Tom… :slight_smile:

Thanks a lot for your time. DMM?? Did you mean digital multimeter? Yes, I have one.

I disconnected the board from all I/O and tried uploading the “blink without delay” sketch. I couldn’t upload the code. The upload bar almost fully fills up and stays there for a good 3 to 4 minutes. Then, I get the following messages:

Sketch uses 862 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 15 bytes (0%) of dynamic memory, leaving 2033 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xc9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xc9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xc9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xc9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xc9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xc9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xc9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xc9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xc9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xc9
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

The same thing I posted earlier, but I thought I’ll let you know what exactly is happening.