6 Wire Stepper and ULN2803A

Hi there, I wonder if someone could point me to a diagram to wire the following.

Arduino UNU
ULN2803A
Potenionmeter
FWD/Reverse switch

The plan is to have the POT control the speed of the stepper

I found the idea here, but I don't quite understand his schematic and cant tell if he is powering the Stepper seperately from the Arduino

I would start with this If I could, and then move on to the POT / fwd / rev version.

Any help would be greatly appreciated,
Thanks.

The motors are powered by their own power supply, meaning the system power runs to the motors and the system power supplies the upstream side of the arduino's regulator.

Thanks and totally understood - I have built one this way with a DC motor

Now I need to figure out how to build the same thing with the link above - its schematic that I dont quite understand - i'd love a breadboard illustration of it

Or do you know where I can find instructions on wireing the above ULN2803A and a 6 wire stepper with pot?

What don't you understand about the schematic? The letters A to F are the windings and the letter on the output of the chip shows what winding is attached to what pin.

I understand what pins to use and where to wire them - its powering the moter seperately from the arduino that I am little miffed about, I just cant visualize it on the breadboard :confused:

Just wire the + from the power supply to the center taps of the motor, and make sure the common diode pin on the ULN2803A is also connected to it. Then wire the - from the power supply to the arduino ground.
See:-
http://www.thebox.myzen.co.uk/Tutorial/Power_Supplies.html

This is the schematic I am attempting to build onto a breadbaord

I hesitate as I am not sure how the battery is hooked up.

Could someone please show me the light here :slight_smile:

Thanks again everyone.

Still not sure what you are not getting. The battery attaches to the + and - terminals and the ground goes to the arduino ground.

Thanks for your input, i have wired it using your advice as follows

I am getting holding torque, but the motor does not step - I can feel it going back and forth in tiny increments, almost like on/off steps.
Any Ideas?

here is my sketch

#include <Stepper.h> //include the function library
#define STEPS 200 //1.8 deg motor (200 steps per revolution)
#define D0 13 // Arduino digital output numbers
#define D1 12
#define D2 11
#define D3 10
Stepper stepper(STEPS, D0, D1, D2, D3); //create the stepper

void setup() 
{
  stepper.setSpeed(30); //set speed to 30 rpm
  delay(1000); 
  stepper.step(2000); //move 200 steps = 360 deg in one direction
 // delay(1000); 
 // stepper.step(-200); //move 200 steps = 360 deg in the opposite direction
}

void loop() 
{}

I SUppose at this point, my question is - How do the colors of the wires from the stepper relate to the diagram below?

It would help if you followed the schematic completely. Assuming the arduino is powered up and your "To Arduino Pins" are in fact connected to the Arduino, you are still missing two connections to the ULN2803 and a tie between the grounds of the 12 v power source and the Arduino.

And, you connections to the stepper also did not follow the schematic.

Thanks for your advice - My issue is that I dont fully understand the schematic.

Firstly I am unsure as to what color wires from the stepper coordinate with what pins on the ULN2803a o,1,2,3 vs D,C,F,A, E,B from the stepper motor.

Secondly I dont see where the GND runs to from the stepper (B).

Take a look at the image attached, I am attempting to figure this out before wiring anything and I do appreacite your input.

First, you really should learn how to read an electronic schematic. Google is your friend here and a simple search will get you many sources for this.

Second, you need to determine which wire on the stepper motor is which. A multimeter is your friend here, if you do not have the schematic for the motor. And Google, again is your friend to find the schematic for the motor.

The schematic is showing the ground of the 12v battery connected to pin 9, which is also connected to the ground of the Arduino. Your drawing does not show a pin 9 connection to the Arduino ground, and is showing a connection to the stepper motor to ground, which is not in the schematic.

The schematic is showing the center wire in each winding (E and B) on the motor connected to both the positive side of the battery and pin 10. Assuming red and black are E and B, you have one correctly connected to the positive side of the 12v and one incorrectly connected to ground.

Looking at the schematic, again google is your friend here, shows that E and B are the Yellow and White wires, not the Red and Black. One winding is Red, White, and Blue. The other one is Black, Yellow, Green. http://cnsoyo.com/product_show_e.asp?id=8

Google is also your friend if you do not know how a chip's pins are numbered. Search terms "ic pin numbers"

You should also note that right and left side power busses on a solderless breadboard are not connected to one another and must be bussed by you during your breadboarding phase. All ?IC's have an index notch usually centerline unless directly adjacent to pin 1. With the index notch pointed away from you and the pins pointing down, pin 1 is in your upper left and increments in a counter clockwise fashion. The same way as depicted in the connection drawing.

Thank you sooo much everyone, I managed to figure out what wires to send to what pins thanks to you all your help.

Here is the revised schematic

With the following code

/* 
 Stepper Motor Control - speed control
 
 This program drives a unipolar or bipolar stepper motor. 
 The motor is attached to digital pins 8 - 11 of the Arduino.
 A potentiometer is connected to analog input 0.
 
 The motor will rotate in a clockwise direction. The higher the potentiometer value,
 the faster the motor speed. Because setSpeed() sets the delay between steps, 
 you may notice the motor is less responsive to changes in the sensor value at
 low speeds.
 
 Created 30 Nov. 2009
 Modified 28 Oct 2010
 by Tom Igoe
 
 */

#include <Stepper.h>

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
// for your motor


// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);            

int stepCount = 0;         // number of steps the motor has taken

void setup() {
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // read the sensor value:
  int sensorReading = analogRead(A0);
  // map it to a range from 0 to 100:
  int motorSpeed = map(sensorReading, 0, 1023, 0, 100);
  // set the motor speed:
  if (motorSpeed > 0) {
    myStepper.setSpeed(motorSpeed);
    // step 1/100 of a revolution:
    myStepper.step(stepsPerRevolution/100);
       Serial.println(stepCount);
  } 
}

Now my next question is in reguards to the functionality of this
I would like to have the POT work as speed control as well as Forward Reverse when it passes the halfway mark.
So 0-511 = forward with speed varience
and
512-1023 being reverse with speed varience.

This would eliminate having to add a forward and reverse switch

Does anyone have any Ideas on how to modify the sketch to do this?

Well you have mapped the reading to 0 - 100, so if it is over 50 then set the direction the other way.
Use the if statement for this.

For the speed:-
When it is around 50 you want it slow so for the speed subtract the reading from 50 and take the absolute value abs() function to always get a positive value.

Wicked thanks :slight_smile:

I got it working - sort of with this

#include <Stepper.h>

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
// for your motor


// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);            

int stepCount = 0;         // number of steps the motor has taken

void setup() {
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // read the sensor value:
  int sensorReading = analogRead(A0);
  // map it to a range from 0 to 100:
  int motorSpeed = map(sensorReading, 0, 1023, 0, 100);
  // set the motor speed:
    
  if (motorSpeed > 50) {
    myStepper.setSpeed(motorSpeed);
    // step 1/100 of a revolution:
    myStepper.step(stepsPerRevolution/50);
    Serial.print("Forward steps:" );
    Serial.println(stepCount);
    stepCount++;
  } else {
       if (motorSpeed < 50){
        myStepper.setSpeed(motorSpeed);
        // step 1/100 of a revolution:
        myStepper.step(-stepsPerRevolution/50);
        Serial.print(" Reverse steps:" );
        Serial.println(stepCount);
        stepCount++;
          }
  } 
}

It seems though that the speed varience is off
For example if the POT is at between 49 and 51 the speed should be the same, just in different directions - right?
And when at 23 and 1000 - same speed just differernt directions

What is in fact happening is the the direction is changing now, but the speed variates from 0-100 not from 0 to 50 and 50 to 0.

Thoughts? Does this make sense?

Well you didn't do all I said did you. Here is your code corrected:-

#include <Stepper.h>

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
// for your motor


// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);            

int stepCount = 0;         // number of steps the motor has taken

void setup() {
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // read the sensor value:
  int sensorReading = analogRead(A0);
  // map it to a range from 0 to 100:
  int knobReading = map(sensorReading, 0, 1023, 0, 100);
  // set the motor speed:
    
  if (knobReading > 50) {
    myStepper.setSpeed((knobReading-50) * 2);
    // step 1/100 of a revolution:
    myStepper.step(stepsPerRevolution/50);
    Serial.print("Forward steps:" );
    Serial.println(stepCount);
    stepCount++;
  } else {
       if (knobReading < 50){
        myStepper.setSpeed((50 - knobReading) * 2);
        // step 1/100 of a revolution:
        myStepper.step(-stepsPerRevolution/50);
        Serial.print(" Reverse steps:" );
        Serial.println(stepCount);
        stepCount++;
          }
  } 
}

Thanks so very much for this help :slight_smile:

It is working quite well.

2 Things though

1: Proir to adding the direction change, the stepper stepped very smoothly, now it seems to vibrate a lot more, almost like it is labouring to step.

2: When I max the knob out to either 0 or 100 the stepper stutters and does not rotate, it just steps in place (you can feel it stepping with no rotation).

I should probably add the I have added a 16x2 LCD and change the stepper pins from;
8, 9 , 10, 11
to
3, 4, 5, 6

I just loaded the previous Sketch to eliminate the LCD as a factor using the new pins, with the same choppy step results as mentioned above

Any thoughts on this?

Ok i seem to be the Knob here - In reguards to the post above, this issue was that the Batteries running the stepper were running low.

:slight_smile: But at least we know now!