Stuck with project please help

Hi Guys

a year or so back I was helped to create a stepper motor solution for my home aquarium, and up to now its worked great but I have found the Arduino motor shield was unable to keep up with the my demands so I have increased the stepper driver.

I really struggled with the code as I am not technically minded in anyway, infact I still don’t understand what it does apart form when I change 3 key areas to get the solution to do what I want.

Heres the question. on the new stepper driver I have set it up to produce 3.7A and set the micro step table to 2, I have wired in the parallel stepper motor, power and GND, But I am at a loss to the Step + Step - and the Directions + and Direction -

I have really tried to understand the below and tried a few configurations of what I think make sense and whats shown onto of the Motor shield but nothings working.

Can anyone tell me where to put the cable into the Arduino to get this back up and running - My fish tank really needs to have this operational again ASAP.

DIR(A/B) are pins 13 and 12 on the Motor shield , but I also have Brake on (9&8) and PWM A&B on (3,11)

Both of these are mentioned in the below code and before all I have to do was wire up the Motor shield and slide it onto the arduino

Please please anyone advise would be great

The code is below the kind chap help me write

// Bounce.pde
// -- mode: C++ --
// Make a single stepper bounce from one limit to another
//
// Copyright (C) 2012 Mike McCauley
// Id: Random.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem

#include <AccelStepper.h>

// Define a stepper and the pins it will use
AccelStepper stepper(2, 12, 13); // dir_a and dir_b pins used
const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;

void setup(){

Serial.begin(9600);
stepper.setMaxSpeed(780);
stepper.setAcceleration(1550);
stepper.moveTo(135);

pinMode(pwmA, OUTPUT);
pinMode(pwmB, OUTPUT);
pinMode(brakeA, OUTPUT);
pinMode(brakeB, OUTPUT);
digitalWrite(pwmA, HIGH);
digitalWrite(pwmB, HIGH);
digitalWrite(brakeA, LOW);
digitalWrite(brakeB, LOW);
// initialize the serial port:

}

void loop()
{
// If at the end of travel go to the other end
if (stepper.distanceToGo() == 0)
stepper.moveTo(-stepper.currentPosition());
stepper.run();

}

please can some one respond 13 views, someone can surely point me in the right direction

I’m one of your 13 views that didn’t post anything. I didn’t have any answers because it isn’t very clear what you want this stepper to do or how it is supposed to work. So I’ve got nothing. Maybe if you could provide some details you would get more responses.

What is the stepper supposed to do? What stepper do you have? What driver do you have? Anything else you think might be pertinent to the discussion.

Without knowing that sort of stuff, there’s really nothing I can do other than guess and I’d hate to lead you wrong.

RichardWalton: so I have increased the stepper driver.

If that means that youhave replaced a motor shield with a specialized stepper driver boardyou need to tell us what driver board you are using.

It would also be a good idea to post a link to the datasheet for your stepper motor.

You may find some useful stuff in stepper motor basics.

...R

Thank you for responding these are very good points so apologies if I wasn’t clear.

The software does what I need the stepper motor to do - it rotates the reactor for my tank, below is the Youtube video I done after I got it all working.

I want to now change to a new Driver attached below - as you can see I need to attache the arduino Uno to the step and directions terminals and my question is how ? or on what numbers on the Arduino based on the code I attached in my original post.

I will be supplying the Arduino with a power supply so would I also need to connect the GND + Vin on the Arduino to the Stepper Driver GND + Vin also.

I am trying to see anything online but most tutorials are discussing the software or stepper motor not how to wire the Arduino

Can you help please

does this help? I have also read through this and it doesn't assist how to wire up the Arduino

stepper motor basics.

Do you have a datasheet for that stepper driver? That would be where you find out what you want to know. It will tell you what signals it expects and how it works. Then you program Arduino to send what it wants.

I have the stepper wired in using Parallel config as per the instructions from the company,

This is the code saved to my Arduino

// Bounce.pde
// -*- mode: C++ -*-
// Make a single stepper bounce from one limit to another
//
// Copyright (C) 2012 Mike McCauley
// $Id: Random.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $

#include <AccelStepper.h>

// Define a stepper and the pins it will use
  AccelStepper stepper(2, 12, 13); // dir_a and dir_b pins used
const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;

void setup(){
  
Serial.begin(9600); 
 stepper.setMaxSpeed(780);
  stepper.setAcceleration(1550);
  stepper.moveTo(135);
  

pinMode(pwmA, OUTPUT);
pinMode(pwmB, OUTPUT);
pinMode(brakeA, OUTPUT);
pinMode(brakeB, OUTPUT);
digitalWrite(pwmA, HIGH);
digitalWrite(pwmB, HIGH);
digitalWrite(brakeA, LOW);
digitalWrite(brakeB, LOW);
// initialize the serial port:
 
}

void loop()
{
    // If at the end of travel go to the other end
    if (stepper.distanceToGo() == 0)
      stepper.moveTo(-stepper.currentPosition());
    stepper.run();
    
}

Would you be so kind as to share said instructions with us? I mean if you want us to be able to help you figure out how to control it.

Sorry instruction for what? I’m not following you. I have sent you the data sheet from their Website thats who’s me how to wire in the Motor into the Stepper Driver.

I really need help as this has been of my tank now for about 6 days and starting to have a huge impact.

I have also linked below the wiring digram that has the power supply , stepper motor and Stepper drive if this what you mean, I am not sure whats what on here that can help.

I have set the switches up to 3.7A and 2 Micro steps if this helps.

My Arduino code that I have is posted above

I have also added a picture that shows what I need to connect = sorry I am not technical so I am very sorry if I confuse the issue what seem very basic to you guys here

Thanks again

RichardWalton: I have the stepper wired in using Parallel config as per the instructions from the company,

Whatever instructions you're talking about here. The only attachments you've put in this post are pictures and screenshots. Do you have a pdf or a website or something I can go to so I can see how this thing is supposed to work?

There has to be something somewhere that tells what sort of signal it needs?

For some reason it won't let me attach the PDF so I have screen shotted the PDF showing the wiring digram that shows the parralelle configuration in my previous post

This is the PDF for the 4NM Stepper motor http://cnc4you.co.uk/resources/Stepper%20Motor%20Nema%2023%2060BYGH401-03%204Nm.pdf

On my previous post I have also added the link for the conf of the Stepper driver, power supply etc http://cnc4you.co.uk/resources/CW5045%20+%20KK01%20Wiring%20Diagram.pdf

is this what you need ?

The wiring arrangements are clearly shown in the picture FullSizeRender.jpg in Reply #4. (I can't imagine why you thought we might want a picture of your Uno).

Where is says step+ step- etc connect the - connections to Arduino GND and connect the + connections to the appropriate Arduino I/O pin. I'm not sure if it is necessary to connect Enable (Ena) - it will probably work without it connected.

The connections for the motor coils and the motor power supply are also shown clearly.

If you are using the AccelStepper library the correct defintion will be RTFM AccelStepper stepper(1, StepPin, DirPin);

...R

Robin,

I have the motor and oils all connect correctly the only thing missing is how I connect the arduino now to the stepper driver.

Thanks you so much for breaking this down into easy steps for me to read. I added the Arduino juts in case someone could have edited the pic and sent it back with arrows on where to connect. How do I work out the Arduino correct I/O pin? As IU said because I was using an Arduino Motor shield, all I need to do was connect the wires accordingly

I currently have both the Direction and Step - in the 2 GND slots - all I now need is to know where both ++ go on what number, please can you just help me just understand this.

I have also gone into the software and changed read this - how do I now set the Step and direction pins and what should these be ? as I can't load whilst it like this, I have read the linked page what is RTFM ?

// Define a stepper and the pins it will use
 AccelStepper stepper(1, StepPin, DirPin); // dir_a and dir_b pins used
const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;

void setup(){
  
Serial.begin(9600); 
 stepper.setMaxSpeed(780);
  stepper.setAcceleration(1550);
  stepper.moveTo(135);

RichardWalton: How do I work out the Arduino correct I/O pin?

You can choose any I/O pins just as long as the program uses the pins that the driver is connected to (or the driver is connected to the pins the program uses).

For example

byte stepPin = 7;
byte dirPin = 8;

Then connect the wires to those pins.

...R

Can you help me understand where

byte stepPin = 7;
byte dirPin = 8;

would be inserted into the following code, as a gentleman on this forum PeterH helped me with this Stepper code but it was designed for the Motor Shield

Would I still need this part ?
const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;

and would I change the below to replicate the 7&8 numbers

pinMode(pwmA, OUTPUT);
pinMode(pwmB, OUTPUT);
pinMode(brakeA, OUTPUT);
pinMode(brakeB, OUTPUT);
digitalWrite(pwmA, HIGH);
digitalWrite(pwmB, HIGH);
digitalWrite(brakeA, LOW);
digitalWrite(brakeB, LOW);

Code: [Select]
// Bounce.pde
// -*- mode: C++ -*-
// Make a single stepper bounce from one limit to another
//
// Copyright (C) 2012 Mike McCauley
// $Id: Random.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $

#include <AccelStepper.h>

// Define a stepper and the pins it will use
  AccelStepper stepper(2, 12, 13); // dir_a and dir_b pins used
const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;

void setup(){
  
Serial.begin(9600); 
 stepper.setMaxSpeed(780);
  stepper.setAcceleration(1550);
  stepper.moveTo(135);
  

pinMode(pwmA, OUTPUT);
pinMode(pwmB, OUTPUT);
pinMode(brakeA, OUTPUT);
pinMode(brakeB, OUTPUT);
digitalWrite(pwmA, HIGH);
digitalWrite(pwmB, HIGH);
digitalWrite(brakeA, LOW);
digitalWrite(brakeB, LOW);
// initialize the serial port:
 
}

void loop()
{
    // If at the end of travel go to the other end
    if (stepper.distanceToGo() == 0)
      stepper.moveTo(-stepper.currentPosition());
    stepper.run();
    
}

Ok I have gone back to basics and loaded a standard example, Stepper one Revolution so there should be nothing wrong with the code.

I have the Stepper motor wired to the Stepper driver A+/- B+/- wired in Bipolar Parallel - then V + GND wired in from my PCU. I have Step - and DIR- both going to the 2 GND on the Arduino, right hand side on the power section I have then connected the STEP + DIR+ to 8 & 11 of the Arduino and nothing, where am I going wrong.

Without getting the basic to work I can't fix my project or find a way to reverse the problem, it works fine on the motor shield and the pins on the motor shield push into the Arduino soI must be able to put them same port into this new stepper to have the same response.

"This program drives a unipolar or bipolar stepper motor. The motor is attached to digital pins 8 - 11 of the Arduino."

Have a look at this simple stepper code that does not need any library. It uses pin 9 for Direction and Pin 8 for Step.

It should get things moving, and I hope it is obvious how it works.

...R

Thanks for responding Robin, I went back to basics last night and and was playing around with the Stepper basic library.

I have just tried the attached code and yes its obvious how the code works, but it looks like I have a wiring issue as nothing happens

I have been trying to do as much research as possible and there loads of info on code but none on how to wire the stepper Driver and Arduino together.

I have attached my Stepper Driver Step + to 9 and then My Dir + to 8 with then both the - going to the Arduino GND.

The Arduino is connected to the Mac - has power The Stepper controller is connected to the 36V power supply The Stepper motor is connect to the Stepper controller via Bipolar Parallel wiring

Whats missing ?

RichardWalton: Whats missing ?

I mentioned in Reply #12 that the Ena connections may not be needed - maybe I was wrong. Try connecting Ena- to GND and then try Ena+ to 5v. If that does not help, try connecting Ena+ to GND.

If neither works draw a diagram showing all your wiring connections and post a photo of the drawing. Also post the code that you are actually using.

...R