Pages: [1] 2   Go Down
Author Topic: L293D And Stepper  (Read 753 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I cannot for the life of me figure out how to use a L293D with a Stepper Motor from ( http://www.adafruit.com/products/324 ) I have it wired as shown in the photo. I don't even know if the the code I'm using even works but whatever. All I know is nothing happens when I try anything.


* Diagram.png (259.27 KB, 973x687 - viewed 78 times.)
Logged

0
Offline Offline
Shannon Member
****
Karma: 199
Posts: 11639
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Firstly you apparently haven't connected the motor supply to the L293D!  The two power
strips on each side of the breadboard aren't linked.  (Also you may need to check that
they don't have a break in the middle, many do).

Secondly what is the motor power supply (not 2 AA batteries as in the picture I hope).

There are plenty of example circuits using the L293D dotted around these forums and
the internet to compare against.

[ also I've just noticed you haven't connected either enable input - I think
that's necessary (they certainly need to be HIGH for any output current) ]
« Last Edit: February 05, 2014, 07:55:15 pm by MarkT » Logged

[ I won't respond to messages, use the forum please ]

BCC AZ USA
Offline Offline
Edison Member
*
Karma: 32
Posts: 1129
It gets hot so it must be working
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

check your wiring.  It looks like you have the motor connected to the 293 inputs and the arduino outputs connected to where the motor would connect.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok so I thought I had the power going to both sides but where would I hook up on the other side. And no I'm not using two AA as my power I'm using 12V. And I think I connected the enable pins and this is the code I'm using but I don't think it's correct at all.

**Code**

#include <Stepper.h>
 
int E1 = 2;
int E2 = 3;
int in1Pin = 12;
int in2Pin = 11;
int in3Pin = 10;
int in4Pin = 9;
 
Stepper motor(200, in1Pin, in2Pin, in3Pin, in4Pin); 
 
void setup()
{
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(in3Pin, OUTPUT);
  pinMode(in4Pin, OUTPUT);
  digitalWrite(E1, LOW);
  digitalWrite(E2, LOW);
 
  // this line is for Leonardo's, it delays the serial interface
  // until the terminal window is opened
  while (!Serial);
 
  Serial.begin(9600);
  motor.setSpeed(20);
}
 
void loop()
{
  if (Serial.available())
  digitalWrite(E1, LOW);
  digitalWrite(E2, LOW);
  {
    int steps = Serial.parseInt();
    motor.step(steps);
  }
}

**Code**


* Diagram 2.png (251.97 KB, 926x666 - viewed 26 times.)
Logged

UK
Offline Offline
Faraday Member
**
Karma: 101
Posts: 6128
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Life would be so much easier (both connections and programming) if you used a "proper" stepper motor driver board such the Pololu A4988. The L293 is primarily intended for regular DC motors.

...R
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I have the L293D and the interwebs said I could use it so if somebody would give me some helpful information like markT and groundfungus did that would be greatly appreciated.
Logged

BCC AZ USA
Offline Offline
Edison Member
*
Karma: 32
Posts: 1129
It gets hot so it must be working
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
void loop()
{
  if (Serial.available())
  digitalWrite(E1, LOW); 
  digitalWrite(E2, LOW);
  {
    int steps = Serial.parseInt();
    motor.step(steps);
  }
}

As MarkT pointed out. the enables must be HIGH for the outputs to function. 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok so I made some changes. I changed the enables to HIGH I can't believed I missed that.  I also switched the Output and Input pins and supposedly supplied power to both sides. Yet still nothing happens.

**Code**

#include <Stepper.h>
 
int E1 = 2;
int E2 = 3;
int in1Pin = 12;
int in2Pin = 11;
int in3Pin = 10;
int in4Pin = 9;
 
Stepper motor(200, in1Pin, in2Pin, in3Pin, in4Pin); 
 
void setup()
{
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(in3Pin, OUTPUT);
  pinMode(in4Pin, OUTPUT);
  digitalWrite(E1, LOW);
  digitalWrite(E2, LOW);
 
  // this line is for Leonardo's, it delays the serial interface
  // until the terminal window is opened
  while (!Serial);
 
  Serial.begin(9600);
  motor.setSpeed(20);
}
 
void loop()
{
  if (Serial.available())
  digitalWrite(E1, HIGH);
  digitalWrite(E2, HIGH);
  {
    int steps = Serial.parseInt();
    motor.step(steps);
  }
}
**Code**


* Diagram3.PNG (135.52 KB, 720x515 - viewed 29 times.)
Logged

BCC AZ USA
Offline Offline
Edison Member
*
Karma: 32
Posts: 1129
It gets hot so it must be working
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In the Fritzing I see no connection from pin 16 to the 5V logic supply.  I would also suggest that you take out the serial part and try hard coding the steps variable.  Get one thing working at a time.
Logged

0
Offline Offline
Shannon Member
****
Karma: 199
Posts: 11639
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In the Fritzing I see no connection from pin 16 to the 5V logic supply.  I would also suggest that you take out the serial part and try hard coding the steps variable.  Get one thing working at a time.
pin 20, not pin 16, this has already been pointed out.
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Full Member
***
Karma: 2
Posts: 199
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Pin 20 on a 16 pin dip?

Quote
Quote from: groundfungus on Today at 05:52:04 pm
In the Fritzing I see no connection from pin 16 to the 5V logic supply.  I would also suggest that you take out the serial part and try hard coding the steps variable.  Get one thing working at a time.
Quote
pin 20, not pin 16, this has already been pointed out.

As groundfungus said . Also do not hook up the motor supply to pin 16.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok so what are the pin numbers that the stepper power supply goto? 8 and 16? And they're both positive right? Cuz the stepper power ground just goes to ground on the chip yes?
« Last Edit: February 06, 2014, 06:05:24 pm by Kameechewa » Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 199
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Pin 8 is for the power supply to the motor (12 volts in your case) and pin 16 is for the logic (system)supply voltage(the 5V pin on the due).

Your fritzing shows a due which is a 3.3V logic  system where an UNO is 5V.

The L293D has a minimum of about 4.5V for its logic supply voltage. So it needs the 5V from the due. It should be able to see the output from the due (3.3V) as a high.

So in your first fritzing it looks like you had the power hooked up correctly but not the others.

I would first use a known program  to test the stepper. Go  with the example programs for steppers found in the example area of the file tab.
Logged

Online Online
Faraday Member
**
Karma: 80
Posts: 3787
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok so what are the pin numbers that the stepper power supply goto? 8 and 16?

No. Stepper power goes to 8, logic power goes to 16.

Have a look at this thread where I ran a stepper from first principles with no library.
Logged

Although I answer in good faith, remember always: Your Mileage May Vary.
Get me on LinkedIn: za.linkedin.com/in/jimbrownza/

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for all the help everyone. I finally have it turning but I can't get it to like spin it just goes a little of the way and then grinds like its going too fast or too slow. So i don't know whats wrong with my code but owell.
Logged

Pages: [1] 2   Go Up
Jump to: