Hello,
I am using an L293b to drive a couple 24VDC motors (left and right side both control a single motor), I believe I have wired the circuit correctly as indicated in the diagram from the datasheet (it showed a different wiring on the right side, I used the wiring shown on the left side for both motors). I am using an Arduino Uno to control the signals, with the following code (just ignore the stuff about valves - those go with the transistors on the breadboard):
const int onPin = 13;
const int motor1cwPin = 3;
const int motor1ccwPin = 5;
const int motor2cwPin = 6;
const int motor2ccwPin = 9;
const int valve1Pin = 10;
const int valve2Pin = 11;
int cycle = 0;
int cycle10count = 0;
int switchState = 0;
void setup()
{
pinMode(onPin, INPUT_PULLUP);
pinMode(motor1cwPin, OUTPUT);
pinMode(motor1ccwPin, OUTPUT);
pinMode(motor2cwPin, OUTPUT);
pinMode(motor2ccwPin, OUTPUT);
pinMode(valve1Pin, OUTPUT);
pinMode(valve2Pin, OUTPUT);
digitalWrite(motor1cwPin, LOW); //I think all this part may be superfluous, but I put it in anyway
digitalWrite(motor1ccwPin, LOW);
digitalWrite(motor2cwPin, LOW);
digitalWrite(motor2ccwPin, LOW);
digitalWrite(valve1Pin, LOW);
digitalWrite(valve2Pin, LOW);
Serial.begin(9600);
}
void loop()
{
switchState = digitalRead(onPin);
if (switchState == LOW)
{
testRun();
}
}
void testRun()
{
cycle = ++cycle;
//Serial.println("clockwise1");
digitalWrite(valve2Pin, HIGH);
digitalWrite(motor1ccwPin, LOW);
analogWrite(motor1cwPin, 255);
delay(5000);
digitalWrite(motor1cwPin, LOW);
digitalWrite(valve2Pin, LOW);
//Serial.println("clockwise2");
digitalWrite(valve1Pin, HIGH);
digitalWrite(motor2ccwPin, LOW);
analogWrite(motor2cwPin, 255);
delay(5000);
digitalWrite(motor2cwPin, LOW);
digitalWrite(valve1Pin, LOW);
//Serial.println("counter clockwise1");
cycle = ++cycle;
digitalWrite(valve2Pin, HIGH);
digitalWrite(motor1cwPin, LOW);
analogWrite(motor1ccwPin, 255);
delay(5000);
digitalWrite(motor1ccwPin, LOW);
digitalWrite(valve2Pin, LOW);
//Serial.println("counter clockwise2");
digitalWrite(valve1Pin, HIGH);
digitalWrite(motor2cwPin, LOW);
analogWrite(motor2ccwPin, 255);
delay(5000);
digitalWrite(motor2ccwPin, LOW);
digitalWrite(valve1Pin, LOW);
//if (cycle10count == cycle % 10)
{
Serial.print("cycle = ");
Serial.print(cycle);
Serial.println();
}
}
I am powering the logic for the chip from the Arduino, and powering the motors with a 24DCV supply.
The problem is... the right side works fine, but the left side motor will turn on before I activate the program or even hook up the 24v (looks like it is pulling the 5v from the Arduino/logic supply - it turns very slowly). It will also still turn if I unhook the enable pin on that side of the IC.
When I hook up the 24v and turn on the program it will only turn in one direction (even when both pins are low) going full speed and when it is supposed to turn the other way it just slows down (so the 24v is disabled and it's just pulling 5v from the board again.)
I have used this same circuit and program before (the stuff about the valves is new), and it didn't act like this then, although it's not the "same" circuit since I disassembled the first one and reassembled this one fresh.
I have stared at this circuit for hours and I'm fairly certain it is wired exactly the same on both sides, and the electronics expert at my office is perplexed as well.
I'm embarrassed to admit I blew out my Atmega when I tried to ground the motor outputs (with the 24v hooked up) in a desperate last ditch, so I'm waiting on a new one I ordered before I can try anything again, although I can still fiddle with the IC by itself. I have a few of those still, I've only blown out about half of the ones I had on hand.
I would be most grateful for any thoughts on this.


