Stepper Control with Leadshine MA860 Driver

Hi All

I have spent several days checking, but still have no joy on existing questions.

I am creating a backward/forward linear drive for a project, but I am having issues with the motor controller.

At the moment, I am using the code shown below, and this will move the head back and forth, but I would like to move this across to use the AccelStepper library to allow for high speed movement.

// Stepper MA860H Stepper Driver Connections
#define PULS_VCC_Pin 7    // Pin 7 connected to Driver PULS +5V  
#define PULS_Pin 8        // Pin 8 connected to Driver PULS 1 input
#define DIR_VCC_Pin 9     // Pin 9 connected to Driver +5V  - Steps pin motor driver LOW = FORWARD
#define DIR_Pin 10        // Pin 10 connected to Driver  DIR - input 
#define LED_Pin 13 // LED Pin 

int Direction = 0; 
int Count = 0; 
int Travel = 1000;
int Speed = 1;



void setup() 
{
  pinMode(PULS_VCC_Pin, OUTPUT);
  pinMode(PULS_Pin, OUTPUT);
  pinMode(DIR_VCC_Pin, OUTPUT);
  pinMode(DIR_Pin, OUTPUT);
  pinMode(LED_Pin, OUTPUT);
  Serial.begin(9600);
}

void loop() 
{
  if(Count!=Travel)
  {
  while(Count<Travel)
    {
      digitalWrite(LED_Pin, HIGH);    
      digitalWrite(PULS_VCC_Pin, HIGH);
      digitalWrite(PULS_Pin, HIGH);
      digitalWrite(DIR_VCC_Pin, LOW);  // move forward 
      delay(Speed);                
      digitalWrite(PULS_Pin,LOW);     
      delay(Speed);
      Count++;
    }
  }
  else
    {
     while(Count>0)
      {
        digitalWrite(LED_Pin, HIGH);    
        digitalWrite(PULS_VCC_Pin, HIGH);
        digitalWrite(PULS_Pin, HIGH);
        digitalWrite(DIR_VCC_Pin, HIGH);  //move backward
        delay(Speed);                
        digitalWrite(PULS_Pin,LOW);     
        delay(Speed);
        Count--;
        //Serial.println("Direction = Backward");
        //Serial.println(Count);
      }  
    }
}

I currently have the MA860H connected as shown below:

MA860 Arduino
PULS+(+5V) Pin 7
PULS-(PUL) Pin 8
DIR+(+5V) Pin 9
DIR-(DIR) Pin 10

And according to the manual, the MA860 is set to CW/CCW Active High mode (All pins shorted together), even though it runs in different directions if I set Pin 9 High or Low.

If I try to run the driver using Pulse/Direction mode (J1 and J3 open), I get no movement when I pulse Pin 8 and Pin 10. When trying this, I re-wire this to

MA860 Arduino

PULS+(5V) 5V
PULS-(PUL) PIN 8
DIR+(5V) 5V
DIR- (DIR) PIN 10

So questions are:

Firstly- Looking at the connections, have I connected this correctly?

Secondly - Using the first wiring method, if I set up AccelStepper to use Pin 8 for step and Pin 9 for direction, I get no movement, is this set correctly?

Thirdly - How do I correctly set the microstep resolution for maximum speed?

Hopefully if I can get passed the basics, the rest may fall into place!

Thanks in advance

Lee

congeuro:
Firstly- Looking at the connections, have I connected this correctly?

You need to post a link to the Leadshine driver datasheet so we can see all the connection details.

Also post a link to the datasheet for the stepper motor.

Have you tried connecting PULS+ to the I/O pin and PULS- to GND etc.?

This Simple Stepper Code should get a your motor moving with step and direction inputs.

The AccelStepper library is not noted for very high speeds - its forte is acceleration. How many steps per second do you want to achieve?

...R
Stepper Motor Basics

Robin2:
You need to post a link to the Leadshine driver datasheet so we can see all the connection details.

Also post a link to the datasheet for the stepper motor.

Have you tried connecting PULS+ to the I/O pin and PULS- to GND etc.?

This Simple Stepper Code should get a your motor moving with step and direction inputs.

The AccelStepper library is not noted for very high speeds - its forte is acceleration. How many steps per second do you want to achieve?

...R
Stepper Motor Basics

Robin

Many thanks for the reply

Leadshine Data sheet link is:

http://www.leadshine.com/UploadFile/Down/MA860m.pdf

Motor Data sheet link is

http://www.omc-stepperonline.com/download/pdf/24HS39-3008D.pdf

The motor is connected as an 8 lead parallel connection to the driver in order to get higher speeds.

I have tried the Simple Stepper test, connected as per the pins suggested and I get forward and back movement, but the motor is very notchy and noisy

I have the driver set at 25600 steps per revolution, which seems too small to me, but from trying the different settings, it runs the smoothest with this setting.

in terms of speed, this is driving a linear shaft to get linear motion, with the head moving at a different speeds which will be read from a rotary encoder or joystick, so I would like to get this moving as fast as possible.

Thanks for the help so far.

It would be a big help if you would tell us how fast (RPM) you want the motor to rotate.

What power supply are you using for the motor - volts and amps?
Have you the correct current limit set on the stepper driver?

If this were my project I would start with nothing connected to the motor shaft and the motor wired up for single step movement. Then I would experiment with my Simple Stepper Code - trying different speeds and directions.

When I was satisfied that that all worked properly I would try micro-steps at different levels.

If you chose very small microsteps you will find it hard to get a 16MHz Arduino to create pulses fast enough for high motor RPM. In any case the motor itself may run faster with full steps. Microsteps are achieved by getting the coils to act against each other. Microsteps also reduce the available torque.

I understand from what others have said that the code in the 2nd example in Simple Stepper Code can be made to produce very fast step pulses - probably faster than AccelStepper.

Having suggested that you start with nothing on the motor shaft you will probably find that the motor runs smoother with a load.

If you are using a stepper motor it does not seem necessary to have a rotary encoder - unless the motor is undersized and at risk of missing steps.

...R

Robin2:
It would be a big help if you would tell us how fast (RPM) you want the motor to rotate.

What power supply are you using for the motor - volts and amps?
Have you the correct current limit set on the stepper driver?

If this were my project I would start with nothing connected to the motor shaft and the motor wired up for single step movement. Then I would experiment with my Simple Stepper Code - trying different speeds and directions.

When I was satisfied that that all worked properly I would try micro-steps at different levels.

If you chose very small microsteps you will find it hard to get a 16MHz Arduino to create pulses fast enough for high motor RPM. In any case the motor itself may run faster with full steps. Microsteps are achieved by getting the coils to act against each other. Microsteps also reduce the available torque.

I understand from what others have said that the code in the 2nd example in Simple Stepper Code can be made to produce very fast step pulses - probably faster than AccelStepper.

Having suggested that you start with nothing on the motor shaft you will probably find that the motor runs smoother with a load.

If you are using a stepper motor it does not seem necessary to have a rotary encoder - unless the motor is undersized and at risk of missing steps.

...R

Thanks again Robin

From a quick calculation, I want a maximum speed of around 25RPM for the motor, which should equate to the correct linear speed required.

At the moment I am using a 24V, 6.5A power supply, with the current limiting on the driver set to 4.4A, as the rated current is 4.24A according to the data sheet.

I have played around with the Simple Stepper code, and reducing the millisbetweenSteps variable to 1 dramatically smooths out the motor travel, though does not increase the speed. If I increase this, the motor starts to become noisy and notchy again.

The rotary encoders that will eventually be incorporated are to allow for user control of speed and shaft travel, not to track the position, thought I will probably add limit switches and a calibration count to allow for better positioning at a later date.

Thanks again for the help so far.

congeuro:
I have played around with the Simple Stepper code, and reducing the millisbetweenSteps variable to 1 dramatically smooths out the motor travel, though does not increase the speed. If I increase this, the motor starts to become noisy and notchy again.

You must be doing something very strange if changing millisbetweenSteps does not change the speed.

Post the code you are actually using.

...R

Here is the code as currently running.

Perhaps my descriptions wasn't oo clear. The RPM does increase, but at anything other than 1ms, the motor is really jerky and noise. At 1ms, the motion is smooth, but not fast enough for what I want.

Code shown below:

// testing a stepper motor with a Pololu A4988 driver board or equivalent
// on an Uno the onboard led will flash with each step
// this version uses delay() to manage timing

byte directionPin = 9;
byte stepPin = 8;
int numberOfSteps = 1000;
byte ledPin = 13;
int pulseWidthMicros = 2;  // microseconds
int millisbetweenSteps = 1; // milliseconds


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(3000);
  

  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() {
}

I am assuming that you have the motor set to full steps for testing.

What happens if you make the motor move slowly - with, say, 200 millisecs between steps?

Stepper motors are naturally jerky (steps ?) so I am finding it hard to understand your description of the problem. I don't know if there is really a problem or if your expectations are incorrect.

For example, is it quieter if you hold the motor in your hand while it is rotating? Or sit it on a soft surface?

Is the motor keeping position accurately?

...R

So just going through the different steps suggested.

The motor I am using is a 1.8 degree motor, so 200 steps for a full revolution. The driver I am using goes down to 400 steps (or Pulse/Revolution as its marked on the driver)

After a lot of testing with the StepperTest program, I think I have found that the issue is the dip switch settings on the driver. Basically the silk screened instructions have the DIP switch ON opposite to what the physical dip switch shows as ON!

Have set it to run at 400 steps per revolution, the highest it will go, and running much better now!

Many thanks for the patient assistance.

The datasheet you linked to in Reply #2 suggests that the Leadshine stepper driver can microstep as small as 1/128th

I presume it does single steps if all the dip switches are off.

...R

Robin2:
The datasheet you linked to in Reply #2 suggests that the Leadshine stepper driver can microstep as small as 1/128th

I presume it does single steps if all the dip switches are off.

...R

I don't think the data sheet and the actual product match!

According to the silk screening on the driver, I can only go down to 400 steps, but as you mentioned, the "manual" mentions that it can go down to 1/128ths.

Also the jumper positions in the manual do not tie into the actual control method, as according to the manual, all jumpers shorted should give you a CW/CCW control, not Pulse and Direction, which is how it is currently working with all the jumpers closed.

Doing a quick image search, the version I have seems to be different to the ones shown so may explain the difference in operation!

congeuro:
I don't think the data sheet and the actual product match!

Take some sharply focused photos of your device and post them here. That way we can see exactly what you are talking about.
If possible keep the image size to 640x480.

...R