Go Down

Topic: L293D Motor Shield puzzle (Read 197 times) previous topic - next topic

quilkin

I have been using one of these cheap eBay modules to drive small 6V motors, in bidirectional mode. The motors draw about 300mA under load, 400mA stalled.
To start, I only had one motor fitted and all seemed to work well. I then added more load to the single motor; it was clearly struggling so I added a further motor and shared the load; I had the two motors connected to the M1 and M2 outputs. The motors still struggled, but what was odd was that after a few seconds (even with no load) they reduced speed to almost nothing.
On checking the voltage output , sure enough it started out at around 4.5V but then dropped after a few seconds to less than 2V. Same with both outputs - and the chip became very warm so I turned it off. This could be repeated.
I then realised that I'd get better results by using the 'other' chip on the board (i.e. M3,M4) so rewired it and changed the code accordingly. Now, with the same PWM control levels, the M1 motor output gives about half the voltage as the M3 output. (At least it appears to stay at that level rather than fading away.) It's not to to with the motors, I swapped them around and get the same results.

I understand that these L293D moudles are an old design and not great, and there are better units to be had (although no stock available anywhere at present). I seem to have permanantly damaged one of the chips on the board , even though I've never knowlingly drawn more than 400mA from each of its two outputs. I'm powering the unit with a 12V LiIon rechargeable battery and the level on that stays perfect throughout, so it's not a power supply problem.

I can order another of these boards, but wondered if anyone had any similar experience and what the 'real' ratings of these are.
I don't think my code is relevant; it's too big to fit all here but I'm 100% certain that all motors are being driven the same: I'm using the motors() function exclusively to control the motors:
Code: [Select]

// ---------------------------------
// motor
//
// Select the motor (1-4), the command,
// and the speed (0-255).
// The commands are: FORWARD, BACKWARD, BRAKE, RELEASE.
//
void motor(int nMotor, int command, int speed)
{
  int motorA, motorB;

  if (nMotor >= 1 && nMotor <= 4)
  { 
    switch (nMotor)
    {
    case 1:
      motorA   = MOTOR1_A;
      motorB   = MOTOR1_B;
      break;
    case 2:
      motorA   = MOTOR2_A;
      motorB   = MOTOR2_B;
      break;
    case 3:
      motorA   = MOTOR3_A;
      motorB   = MOTOR3_B;
      break;
    case 4:
      motorA   = MOTOR4_A;
      motorB   = MOTOR4_B;
      break;
    default:
      break;
    }

    switch (command)
    {
    case FORWARD:
      motor_output (motorA, HIGH, speed);
      motor_output (motorB, LOW, -1);     // -1: no PWM set
      break;
    case BACKWARD:
      motor_output (motorA, LOW, speed);
      motor_output (motorB, HIGH, -1);    // -1: no PWM set
      break;
    case BRAKE:
      // The AdaFruit library didn't implement a brake.
      // The L293D motor driver ic doesn't have a good
      // brake anyway.
      // It uses transistors inside, and not mosfets.
      // Some use a software break, by using a short
      // reverse voltage.
      // This brake will try to brake, by enabling
      // the output and by pulling both outputs to ground.
      // But it isn't a good break.
      motor_output (motorA, LOW, 255); // 255: fully on.
      motor_output (motorB, LOW, -1);  // -1: no PWM set
      break;
    case RELEASE:
      motor_output (motorA, LOW, 0);  // 0: output floating.
      motor_output (motorB, LOW, -1); // -1: no PWM set
      break;
    default:
      break;
    }
  }
}
// drive all four outputs the same
void motors(int command, int speed) {
  motor(1,command,speed);
  motor(2,command,speed);
  motor(3,command,speed);
  motor(4,command,speed);
 
}

groundFungus

#1
Nov 12, 2018, 10:51 pm Last Edit: Nov 12, 2018, 10:53 pm by groundFungus
I would recommend these Pololu DC motor drivers.  They are not expensive, smaller and are WAY better drivers than the ancient and inefficient L293 modules.  Practically no voltage drop versus the 2 to 4 volts of the L293.

MarkT

I have been using one of these cheap eBay modules to drive small 6V motors, in bidirectional mode. The motors draw about 300mA under load, 400mA stalled.
To start, I only had one motor fitted and all seemed to work well. I then added more load to the single motor; it was clearly struggling so I added a further motor and shared the load; I had the two motors connected to the M1 and M2 outputs. The motors still struggled, but what was odd was that after a few seconds (even with no load) they reduced speed to almost nothing.

What you are describing is not "sharing the load", but "increasing the load" - brushed motors have a considerable
current draw even when idling, so doubling up the motors will increase the electrical load.

The L293D doesn't have much current handling, you are close to the limit with one motor I think.

BTW if a motor is rated at 300mA continuous duty, the stall current is likely over 1A - I don't believe that
400mA figure!
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

quilkin

I would recommend these Pololu DC motor drivers.  They are not expensive, smaller and are WAY better drivers than the ancient and inefficient L293 modules.  Practically no voltage drop versus the 2 to 4 volts of the L293.
Thanks for that, I've already ordered one of these now (wanted somethng easily piggybacked onto the Uno board) but I'll look into the Polulo ones later if I need to.

quilkin

What you are describing is not "sharing the load", but "increasing the load" - brushed motors have a considerable
current draw even when idling, so doubling up the motors will increase the electrical load.

The L293D doesn't have much current handling, you are close to the limit with one motor I think.

BTW if a motor is rated at 300mA continuous duty, the stall current is likely over 1A - I don't believe that
400mA figure!
Sorry, I didn't explain properly. I meant sharing the mechanical load (in this case, powering both sets of wheels with separate motors rather than just one motor driving the whole thing). And the 300mA was measured with a fairly heavy load, not just idling. The spec sheet suggests 600mA but that seems just for one output, not using two or more at the same time, and is overoptimistic at best.

MarkT

#5
Nov 14, 2018, 12:40 pm Last Edit: Nov 14, 2018, 12:40 pm by MarkT
Two motors will increase the electrical load as you have to overcome friction in two sets of brushes and
bearings.  This is not negligible in small motors.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

quilkin

Two motors will increase the electrical load as you have to overcome friction in two sets of brushes and
bearings.  This is not negligible in small motors.
Yes, of course the electrical load will be increased as well, but I was sharing it between two outputs of the controller board, rather than just one (as explained in my original post).

Anyway I have now fitted an L298 controller board and it is working much better. So the L293 controller just doesn't perform to anything like it's spec - maybe this info will be of use to others in the future.

Go Up