Just 1/4 Revolution

Hello ,

im using this library code

#include "Stepper.h"

// change the steps variable to the number of steps on your motor
int step= 25600;

// create and attaches a stepper motor
// with 100 steps to pins 0, 1, 2 and 3

Stepper stepper(step, 8, 9, 10, 11);


void setup()
{
  // set the speed of the motor to 20 rpms
  stepper.setSpeed(1600);
}

void loop()
{
  
  stepper.step(5120);
  delay(6000);
  
 
  
  }

with Ardino Uno + 8 lead stepper motor (Unipolar connection)+ attached stepper drive

all connection as the code said but when i run the motor the motor just rotate 1/4 Revolution i noted that the max accepted microstepping setup was 6400 steps and when i tried to run the code with 6400*4 to give me one revolution

why 1/4 Revolution???

and what is the best configuration and set up for .and really i need 1/128 micro step to get more accurate.

Thank you

Image from Original Post so we don't have to download it. See this Image Guide

...R
NOTE - when you changed the image it broke the link I had used

Sorry i have uplode it again

Thank you Mr.Robin2

The standard Stepper library is not suitable for a stepper driver that takes step and direction signals. Try using the AccelStepper library - it is much more comprehensive.

Or just write your own code without using a library.

...R
Stepper Motor Basics
Simple Stepper Code

Thank you so much and i didn't have any background to write a code from the beginning so i just need to learn from already written code and try to modify to learn and know every about the code and real motion effect

i will check your links and try but i just ask about why this code give only 1/4 Revolution ?

is there any special wiring for such as this stepper drivers or what ?

However Thank you again

i will check your links and try but i just ask about why this code give only 1/4 Revolution ?

is there any special wiring for such as this stepper drivers or what ?

  1. You are using the wrong library.
  2. Yes

SignTop:
is there any special wiring for such as this stepper drivers or what ?

Of course there is special wiring for a stepper driver. How could there not be? I don't think there is a single electrical item on the planet which does not require special wiring.

If you want help you need to post links to the datasheet for the driver and for your stepper motor.

...R

Thank you Mr.jremington
And may you help me for the correct library have to use

Also i have attached the PDFs for the driver and the motor as Mr.Robin2 ask.

Really i need help for this project.

Thanks in advanced

s.motor.pdf (424 KB)

drive.pdf (162 KB)

SignTop:
And may you help me for the correct library have to use

Robin2:
The standard Stepper library is not suitable for a stepper driver that takes step and direction signals. Try using the AccelStepper library - it is much more comprehensive.

Or just write your own code without using a library.

...R
Stepper Motor Basics
Simple Stepper Code

Use the AccelStepper library mentioned in reply #3, and follow the connection directions in the motor driver manual.

Set the motor current on the driver to 3.0 amperes or less.

Use an appropriate motor power supply, capable of 15-40 volts and at least 5 amperes.

Connect the STEP output of the Arduino to PUL+ and PUL- to Arduino Ground.

Connect the DIR output of the Arduino to DIR+ and DIR- to Arduino Ground.

That motor seems to have 8 wires and the stepper driver only has 4 connections. While I am not certain if the two are compatible I suggest that you connect the centre wires of the pairs of coils on each side - Red and Yellow for one side and Black and Orange for the other side. However if the wires colours for your motor are not exactly like the datasheet do not connect anything until we have figured out exactly what connects to what.

Then you will have 4 motor wires to connect to the driver's A+ and A- for one coil and B+ and B- for the other one.

Then connect Pul+, Dir+ and ENA+ to the Arduino 5v pin and the corresponding - pins to the relevant Arduino I/0 pins. I'm not sure if it is actually necessary to connect the ENA- to anything. You need to read the datasheet carefully.

It should then be possible to test the motor with my simple program.

...R

jremington:
Connect the STEP output of the Arduino to PUL+ and PUL- to Arduino Ground.

Connect the DIR output of the Arduino to DIR+ and DIR- to Arduino Ground.

The datasheet recommends that the PUL+ etc should be connected to 5v

...R

The datasheet recommends that the PUL+ etc should be connected to 5v

The input is just an optoisolator LED with built in resistor, so it doesn't matter which way it is connected.

Thank you very much

I have connected

Dir+ , PUL+ to Arduino V5
Dir - to Digital 9 (CW)
PUL- to Digital 8 (CLK)

Then setup the drive for the desired microstepping 128 (25600 steps)
and use the AccelStepper library using the following code:

#include <AccelStepper.h>
// Define a stepper motor 1 for arduino 
// direction Digital 9 (CW), pulses Digital 8 (CLK)
AccelStepper stepper(1, 8, 9);
void setup()
{  
  // Change these to suit your stepper if you want
  stepper.setMaxSpeed(3000);
  stepper.setAcceleration(3000);
  stepper.moveTo(25600);
}

void loop()
{
    stepper.run();
}

the result the motor rotate (CW) one revolution very smooth and accurately and matched the micro stepping set up -stepper.moveTo(25600 steps-.but how i can reversed the rotation since the code when i tried the remaining part of the original Loop in the code

if (stepper.distanceToGo() == 0){
stepper.moveTo( -stepper.currentPosition() );
}

the motor make two revolution to go to start point ,

now i just need how i can reversed the rotation and control the appropriate speed for thee motor ,cos after i reed this tips http://www.aquickcnc.com/wiki/Stepper_Motor_Calculations

i need to know the good speed and set up according to these tips

the motor has 8 lead and i connected it as parallel to get just 4 lead connected to the drive

Again and Again Thanks Robin2 and jremington for your help

SignTop:
if (stepper.distanceToGo() == 0){
stepper.moveTo( -stepper.currentPosition() );
}

the motor make two revolution to go to start point ,

Without thinking about the problem carefully that seems reasonable.

Moving from +2 to -2 is twice as far as moving from 0 to +2

...R

Robin2:
Without thinking about the problem carefully that seems reasonable.

Moving from +2 to -2 is twice as far as moving from 0 to +2

...R

Please Robin2 may you tell me where in the code can put the integer EXACT place

Thanks for your effort with me

Try this (which I have not tested)

#include <AccelStepper.h>
// Define a stepper motor 1 for arduino
// direction Digital 9 (CW), pulses Digital 8 (CLK)
AccelStepper stepper(1, 8, 9);

char motorPos = 'S'; // S for start F or finish

void setup()
{ 
    // Change these to suit your stepper if you want
    stepper.setMaxSpeed(3000);
    stepper.setAcceleration(3000);

}

void loop()
{
    if (stepper.distanceToGo() == 0) {
        if (motorPos == 'S') {
            stepper.moveTo(25600);
            motorPos = 'F';
        }
        else {
            stepper.moveTo(0);
            motorPos = 'S';
        }
        delay(2000); // pause between movements
    }
    stepper.run();
}

...R

Robin2:
Try this (which I have not tested)

#include <AccelStepper.h>

// Define a stepper motor 1 for arduino
// direction Digital 9 (CW), pulses Digital 8 (CLK)
AccelStepper stepper(1, 8, 9);

char motorPos = 'S'; // S for start F or finish

void setup()
{
    // Change these to suit your stepper if you want
    stepper.setMaxSpeed(3000);
    stepper.setAcceleration(3000);

}

void loop()
{
    if (stepper.distanceToGo() == 0) {
        if (motorPos == 'S') {
            stepper.moveTo(25600);
            motorPos = 'F';
        }
        else {
            stepper.moveTo(0);
            motorPos = 'S';
        }
        delay(2000); // pause between movements
    }
    stepper.run();
}




...R

Waw you are the king of codes
Thank you very much the code work very very very very very good
Thank you Robin2

and if you please any extended explanation with more details to understand the logic for the code and make some changes if i need or recommend good refrance for that if you please

Thanks dear

i tried the code with different micro stepping setup it also working very good very accurately
but may i know the best speed set up and how i can avoid the over heating for the motor

Thanks

how i can avoid the over heating for the motor

Cooling fan and/or reduce the current (and holding power) supplied to the stepper motor.