L293 Driver not stopping

So I'm building a line following robot that is directly wired from the Atmega8 to a L293 motor driver chip and then obviously to some motors.

The Atmega8 is sending manual PWM signal to the L293 driver on the forward pins. By that I mean I have code like:

void motor_pacer();{

ticked++

if( ticked <= duty_cycle)

PORTD |= LEFT_FORWARD;

else if(ticked <= period)

PORTD &= ~LEFT_FORWARD;

else

ticked=0;

}

All other pins on the L293 are logic low. Except obviously for the 2 Vcc pins which are supplied by a 6V battery and also for one enable.

Without the L293 motor driver in all the voltages are showing what I expect. Importantly the enable to one motor is high while the enable pin to the other is low and PWM is being sent to one forward pin. However when I insert the L293 motor driver in both motors switch on and the voltage on both enable pins has become high.

How do I fix this?

Thanks

You’ve said that "All other

You’ve said that “All other pins on the L293 are logic low” - what exactly is the other enable (the one that should be off) connected to?

enable pins

The other enable pin is connected to directly to the Atmega8 on PORTD. One enable is on PD6 and the other is PD7.

Hmmm… assuming that

Hmmm… assuming that there’s no extra code somewhere that turns the enable on (since the output pin has been tested as staying low), and that the PORTD pins PD6 and PD7 are configured as digital outputs, the only other sources for this problem are in the wiring/soldering, or in the L293 IC itself.

If you’ve got a spare L293 try dropping that in to see if you get the same problem. A photo of your wiring might help us track down the problem.

Problem is definitely not

Problem is definitely not motor driver itself as I have tested other chips

Everything looks fine, are

Everything looks fine, are you able to attach the full code?
At this stage I can only imagine that there’s a wiring error or solder bridge/short somewhere on the actual board.

int main(void){ DDRD |=

int main(void)
{  
 DDRD |= MOTOR_MASK;  //setting IO
 PORTD &= (~REVERSE_MOTOR_RIGHT & ~REVERSE_MOTOR_LEFT);
 motor_stop()
 period = 100;
 duty_cycle = 5;

 

 while(1){
  PORTD |= (ENABLE_MOTOR_RIGHT);
  PORTD &=~ (ENABLE_MOTOR_LEFT);
 

 ticked++;
 

 if(ticked < duty_cycle || ticked == duty_cycle)
 { 

  if(motor_status == LEFT)
   motor_turn_right();
 
  if(motor_status == STRAIGHT){

   motor_run();
   
  }   
 
  if(motor_status == RIGHT)
   motor_turn_left();
   
  PORTB |= BIT(0);
 }
 

 if(ticked > duty_cycle)
 {
  motor_stop();
  PORTB = 0x00;

 }

 if(ticked > period)
 {
  ticked = 0;
 }

}

  

 return 0;
}

**Sorry disregard that code i just posted. **

int main(void)

int period;
int duty_cycle;
int ticked;
 DDRD |= MOTOR_MASK;  //setting IO
 PORTD &= (~REVERSE_MOTOR_RIGHT & ~REVERSE_MOTOR_LEFT);
PORTD &= (~FORWARD_MOTOR_LEFT & ~FORWARD_MOTOR_RIGHT);
 period = 100;
 duty_cycle = 5;

 

 while(1){
  PORTD |= (ENABLE_MOTOR_RIGHT);
  PORTD &=~ (ENABLE_MOTOR_LEFT);
 

 ticked++;
 

 if(ticked < duty_cycle || ticked == duty_cycle)
 {

 PORTD |= ( FORWARD_MOTOR_RIGHT);
 PORTD &= ( ~FORWARD_MOTOR_LEFT);
 }
 

 if(ticked > duty_cycle)
 {
  PORTD &= (~FORWARD_MOTOR_LEFT & ~FORWARD_MOTOR_RIGHT);
 
 }

 if(ticked > period)
 {
  ticked = 0;
 }

}

 

 return 0;
}

Could you also please add

Could you also please add the constant initialisation part of the code? =)

Is this what you mean by constants?

/* Motor */
#define FORWARD_MOTOR_LEFT   BIT(3)
#define REVERSE_MOTOR_LEFT  BIT(2)
#define ENABLE_MOTOR_LEFT   BIT(7)
#define FORWARD_MOTOR_RIGHT  BIT(5)
#define REVERSE_MOTOR_RIGHT  BIT(4)
#define ENABLE_MOTOR_RIGHT  BIT(6)

#define MOTOR_MASK (FORWARD_MOTOR_LEFT | ENABLE_MOTOR_LEFT | FORWARD_MOTOR_RIGHT | ENABLE_MOTOR_RIGHT | REVERSE_MOTOR_RIGHT | REVERSE_MOTOR_LEFT)

So I’ve done some more

So I’ve done some more testing…

I’ve taken out both the motors and the signals on the motor driver are as one would expect. Importantly one enable is low as well as the corresponding forward and reverse pins. However when a motor is connected to our working side (ie high inputs), then the other side goes high aswell.

Very confusing…!

Confusing is right…When

Confusing is right…
When you say the other side goes high as well, do you mean the other outputs, the other inputs, or both?

Both go high

Both go high

Sounds more and more like

Sounds more and more like there’s a short circuit across the motor driver pins on the board side, have you got a multimeter you can test them with?

Yeh I’ve got a multimeter

Yeh I’ve got a multimeter and oscilloscope etc. I have tested the resistance between a few pins, mainly just the motor outputs and the enable pins and all the resistances are in the mega ohms.

I added a 15nF capacitor between the enable pin that is meant to be off and ground and I got this waveform from the enable pin.

http://imgur.com/14Ran.png

Sorry about the size, i can’t seem to resize it easily on win xp.

Try changing this part of

Try changing this part of the code:
PORTD |= (ENABLE_MOTOR_RIGHT);
PORTD &=~ (ENABLE_MOTOR_LEFT);
to this:
PORTD = B01000000;

Had to use hex so 0x40 as

Had to use hex so 0x40 as the compilier didnt like B01000000.

But that gives the same result as before.

What happens if you comment

What happens if you comment out the contents of the while loop, and stick the following in there:
PORTD = 0x96;

If the other half of the driver is still acting up with the above then it has to be a hardware issue surely.

I get all sorts of crazyness

I get all sorts of crazyness from that.

But importantly the enable that was low is still being pulled high when the motor is connected.

What’s crazy is that the inputs (forward and reverse) that are given to the ‘on’ motor switch when the motor is connected. ie the one that was high goes low and the one that was low goes high… I’m pretty sure

Are you totally sure you’ve

Are you totally sure you’ve got the L293 IC hooked up correctly? Have a good check through with the datasheet on hand just to be sure.