Stepper with driver,can i use it with arduino?

Hello!
for 2 days I try to move this stepper with driver on the back. With arduino I managed to move it with a single pin, I tried to make an if with the motor and a sensor, but it doesn’t stop completely and I can’t control it. My question is how can I connect it to arduino, on the net I can’t find anything like that …
Attach the photo:
I try to found something about “Stepper” library,but i got just exemples without a list with comands.
Regards,Alex.

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

...R

alexandru271:
for 2 days I try to move this stepper with driver on the back. With arduino I managed to move it with a single pin, I tried to make an if with the motor and a sensor, but it doesn't stop completely and I can't control it.

You have not posted your program or your wiring diagram or a link to the datasheet for your stepper motor so I don't know what you might be doing wrong.

An Arduino should be able to control that driver, but it would also be useful if you post a link to the datasheet for the driver.

...R
Stepper Motor Basics
Simple Stepper Code

Hello!Sorry about my mistake.I have here the link to the stepper,it's about a 17MD102S-00.

https://www.anaheimautomation.com/products/stepper/stepper-integrated-item.php?sID=47&pt=i&tID=132&cID=50

I still have a 17MD motor without a driver on the back, I managed to move it a bit with an LCDA86H, the project I'm trying to complete is to move a servo between 2 sensors, when it reaches the first to return to the other and after again.
I will leave the code below, until now I wanted to make it change its direction when the sensor indicates the value 1, but I do not succeed in any color.

int senzor = 5;  // Push button for reverse
int driverPUL = 7;    // PUL- pin
int driverDIR = 6;    // DIR- pin
int spd = A0;     // Potentiometer
 
// Variables

 
int pd = 500;       // Pulse Delay period
boolean setdir = LOW; // Set Direction
int senzor1=1;
// Interrupt Handler
 
void revmotor (){
 
  setdir = !setdir;
  
}
 
 
void setup() {
 
  pinMode (driverPUL, OUTPUT);
  pinMode (driverDIR, OUTPUT);
  Serial.begin(9600);
  
  
}
 
void loop() {
  senzor1=digitalRead(senzor);
  Serial.print(senzor1);
 while(senzor1==0){  
    pd = map((analogRead(spd)),0,1023,2000,50);
    digitalWrite(driverDIR,setdir);
    digitalWrite(driverPUL,HIGH);
    delayMicroseconds(pd);
    digitalWrite(driverPUL,LOW);
    delayMicroseconds(pd);
 }
 if(senzor1==1){
  digitalWrite(driverDIR,!setdir);
  digitalWrite(driverPUL,HIGH);
  delayMicroseconds(pd);
  digitalWrite(driverPUL,LOW);
  delayMicroseconds(pd);
 }
  delay(100);
}

Thanks!:slight_smile:

Sorry but I don't have any clear idea of what you have tried, what exactly happened or what you want it to do that is different.

Start simple (and slow). Try the code in the examples in my link.

...R

Dear Robin, I viewed the 2 links you left and I have ambiguities. My project is for the stepper to walk between 2 sensors, when it reaches point a, to change direction to b, when it reaches b , to change the direction to a. I try to move an axis between two sensors, I still try to understand how I could make the stepper go only a number of steps, but I fail. I tried the code I found in -a link and the stepper goes very slowly and heats up, from what I notice, at low speeds it is required, the engine is currently coupled to 2 reducers.

byte directionPin = 6;
byte stepPin = 7;
int numberOfSteps = 500;
byte ledPin = 13;
int pulseWidthMicros = 20;  // microseconds
int millisbetweenSteps = 250; // milliseconds - or try 1000 for slower steps


void setup() {

  Serial.begin(9600);
  Serial.println("Starting StepperTest");
  digitalWrite(ledPin, LOW);
  
  delay(2000);

  pinMode(directionPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  
 
  digitalWrite(directionPin, HIGH);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(pulseWidthMicros); // this line is probably unnecessary
    digitalWrite(stepPin, LOW);
    
    delay(millisbetweenSteps);
    
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
  
  delay(2000);
  

  digitalWrite(directionPin, LOW);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    // delayMicroseconds(pulseWidthMicros); // probably not needed
    digitalWrite(stepPin, LOW);
    
    delay(millisbetweenSteps);
    
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
}

void loop() {
}

How can i set the speed?i see something with the “Stepper” library “setSpeed” ,but I can’t find enough information to use it.

…A

alexandru271:
from what I notice, at low speeds it is required, the engine is currently coupled to 2 reducers.

I don't understand what you mean by "it is required" or what you mean by "currently coupled to 2 reducers"

What stepper motor power supply are you using (volts and amps) ?

It is normal for stepper motors to be hot - uncomfortable to touch.

How can i set the speed?i see something with the "Stepper" library "setSpeed" ,but I can't find enough information to use it.

If you are using my code then the variable millisBetweenSteps controls the speed.

I would not use the standard Stepper library for your motor. The AccelStepper library is much more competent. It sets the speed as the number of steps per second. Also, it is generally a good idea to accelerate a stepper motor if you want it to operate at higher speeds.

ALWAYS start your testing with very slow speeds. When you know you can make the motor move reliably at slow speeds you can experiment with higher speeds.

If you can't control the motor effectively with my simple code then I would not expect it to work with anything more complicated,

...R