Go Down

Topic: Stepper motor controller and arduino (Read 11926 times) previous topic - next topic

Alexisa

Mar 15, 2014, 03:54 pm Last Edit: Mar 15, 2014, 04:08 pm by Alexisa Reason: 1
I have bought 4 stepper motors and with them a 4 axis tb6560 stepper motor driver.
http://reprap.org/mediawiki/images/e/e9/TB6560.jpg

I am wanting to make a small circuit to control the stepper motor speed with a potentiometer just to test the interfacing between the controller, stepper motors and arduino.
However, I found that the tb6560 only has a parallel port, manual interface port(looks to fit a VGA cable) and another smaller port. Does anyone know how to connect arduino to this driver to be able to take values from the potentiometer through arduino to the driver then the motors.
I saw someone managed to manual insert pins into the port and allow an arduino to send values to the driver.
http://www.youtube.com/watch?v=e0A9BLPatVY
And also found someone managed to make what looks like a DIY parallel shield converter shield to do the same thing.
https://www.youtube.com/watch?v=NC5coa6mIVk

Also how would I interface/code to the arduino in the above youtube link there is something about gbrl and there is also mach3? any hard code that would work?
I am specifically looking to know how it would be wired manually through the parallel port and make simple pin outputs from the arduino to driver and work.

Anyone have any idea? I'm really stuck!

Robin2

You don't say whether the stepper driver board has a male or female D connector. You should have no trouble buying a matching connector that you can connect wires to to make a simple interface to your Arduino.

You will need a pin wiring diagram for the D connector so you know what connects to what.

I'm guessing there is a ground connection and a step and direction connection for each stepper motor. That would amount to 9 pins. There may also be connections for other functions - maybe an enable for each motor, and maybe connections to choose whether microstepping is used.

Have you a link to the specifications for the driver board?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Alexisa

Thank you for you help, Here are the specifications of the driver  https://www.machsupport.com/forum/index.php?action=dlattach;topic=15903.0;attach=23971.
Also I was perhaps hoping for a more specific solution as I am still not quite sure on what to do.
Also the board has a male d connector and I do have a female to female d connector.

Can you help?
Or anyone else have input?

Robin2

You need a female connector to connect to a male connector. I'm guessing what you have is "gender bender" intended to be a bridge between two identical connectors. Just buy the right part, they aren't expensive.

As I suspected the 25pin D connector takes signals for 4 stepper and the spindle drive. Lets just focus on Pins 4, 1 and 16 which are Enable, Direction and Step for the X axis motor.

I don't know whether its essential to connect Enable - some driver boards allow the motor to run without it being connected in which case you would just use it to disable the motor. It will have to be either HIGH or LOW so it will only take a few moments to test.

The following code should make the motor move if you connect Arduino pin 9 to the direction pin and Arduino pin 8 to the step pin in the D Connector. My code doesn't use enable. For testing you could just manually connect it to 5v or 0v.

The spec sheet doesn't say which pins in the D connector are for Ground. It's essential to connect the Ground to the Arduino ground. Assuming it is designed to connect to a standard PC parallel port D connector then you should be able to find a full pinout diagram on the web.

Code: [Select]
// testing a stepper motor with a Pololu A4988 driver board
// on an Uno the onboard led will flash with each step
// as posted on Arduino Forum at http://forum.arduino.cc/index.php?topic=208905.0

byte directionPin = 9;
byte stepPin = 8;
int numberOfSteps = 50;
byte ledPin = 13;
int pulseWidthMicros = 50;  // microseconds
int millisbetweenSteps = 50; // 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);
    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);
    digitalWrite(stepPin, LOW);
   
    delay(millisbetweenSteps);
   
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
 
}

void loop()
{

}


Hope this helps

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Alexisa

#4
Mar 16, 2014, 10:44 am Last Edit: Mar 16, 2014, 10:49 am by Alexisa Reason: 1
Thankyou for this help and information.

I tried it with female to male connecter wired without a converter just to test it and nothing happened.
It is most likely my wiring (those wires for direction and step were meant to connect to the PWM pins on the arduino right?)
Could it also be because there are not enough pulses.
I am using a geared stepper motor which makes it slower.

Thanks

Robin2

#5
Mar 16, 2014, 01:02 pm Last Edit: Mar 16, 2014, 01:04 pm by Robin2 Reason: 1
The code I posted is very simple so that you can easily change parts of it - for example the number of steps. It should be obvious, but my code only runs once every time the Arduino is reset.

The Arduino PWM has NOTHING to do with driving stepper motors. Any of the Arduino pins can be used as long as they are programmed to produce the appropriate step pulses.

How have you connected the enable pin?

How have you connected Arduino ground to the driver board ground?

Best thing would be for you to post a diagram of exactly how you have things wired up - both to the Arduino and to the motor. A photo of a clear pencil sketch will be fine.

Also, how have you set the DIP switches on the driver board for microstepping and whatever else they do? For testing its best to use single (full) steps.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Alexisa

I believe it is my wiring, I tried testing just the steppers and tb6560 board with the Mach3 software it came with and could not get the motors to move at all, there wasn't even any juttering. I believe either my polarity of either pairs of  the 4 wires of the geared steppers may be wrong or, the sheet/table with which pins are which on the D25 port may be wrong.
(I could not find a complete table with all 25 pins of the D25 port)

Robin2

As I suggested, show us a diagram of how it is wired and we may be able to help.

Google "parallel port pinout"

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Alexisa

hahah, it works, finally, thankyou so much for your help.
I'm just editing the code now to decrease the juttee when turning and increase to find out what one rotation is. It is a geared stepper motor so it will require a lot more turning to get one rotation.
Just quickly, what would you increase or decrease in the code to make the stepper faster or slower?

I have attached a diagram of the arduino and tb6560 driver wiring I have done.
Also, thought I'd let you know, the enable pin DOES need to be connected to 5v or the stepper will not move.
Still can't get it to move with the Mach3 software though, probably the pin set up.

Any other information you could give me?
Thank you so much for your help you have given me,

thanks
Alexis

Robin2

In my code the speed is governed by the value in the variable millisbetweenSteps.

I'm afraid I have no experience of Mach3. I think its a Windows program and I don't do Windows. Isn't there a Mach3 forum?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Alexisa

Ok.
The motor is running, but there is a problem.

It is not changing direction now. I'm pretty sure it was yesterday but it is not today.
I copy and pasted the code that you posted for me.
What could be wrong?

Alexisa

haha, never mind, I made an absolutely dumb mistake.
The wire I was connecting to the arduino had slipped out
It now changes direction fine

Thankyou

Alexis

Robin2


I made an absolutely dumb mistake.


Welcome to the club :)

Glad its working.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

ACrespin124

Good evening, Robin2 and others!

  I ran into a problem trying to implement the code you suggested to Alexisa above for the TB6560 Driver, and I can't seem to get it to make my stepper move.  I had it running fine on my original code, but with your even simpler code it will only "enable" the stepper with holding power, but it won't actually step during either of the movement blocks.  The grounds are tied together between the driver and the arduino, and I've double and triple checked my connections.  Since I'm getting half of it to work (holding torque), I'm kind of confused as to why it's not abiding by your code.

My DIP switches are set to the current of the Stepper motor (2 amps) with 20% stop current, set back to no microstepping (1=1), and 0% decay.  I have the serial monitor open with some minor changes to the code telling me that it can't be the board or the code itself since it's working as it should... what could be wrong?

Code: [Select]
// testing a stepper motor with a Pololu A4988 driver board
// on an Uno the onboard led will flash with each step
// as posted on Arduino Forum at http://forum.arduino.cc/index.php?topic=208905.0
byte StepperStart = 12;
byte directionPin = 11;
byte stepPin = 10;
int numberOfSteps = 50;
byte ledPin = 13;
int pulseWidthMicros = 100;  // microseconds
int millisbetweenSteps = 100; // milliseconds

void setup()
{

  Serial.begin(9600);
  Serial.println("Starting StepperTest");
  digitalWrite(ledPin, LOW);
 
  delay(2000);
  pinMode(StepperStart, OUTPUT);
  pinMode(directionPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
 
  delay(100);
 
  digitalWrite(StepperStart, HIGH);
  Serial.println("Stepper Online");
  delay(1000);
 

  digitalWrite(directionPin, HIGH);
  Serial.println("Stepper Direction Set Positive");
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(pulseWidthMicros);
    digitalWrite(stepPin, LOW);
    Serial.println("Stepped");
    delay(millisbetweenSteps);
   
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
 
  delay(3000);
 

  digitalWrite(directionPin, LOW);
  Serial.println("Stepper Direction Set Negative");
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(pulseWidthMicros);
    digitalWrite(stepPin, LOW);
    Serial.println("Stepped");
    delay(millisbetweenSteps);
   
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
 
}

void loop()
{

}

Robin2

I had it running fine on my original code, but with your even simpler code it will only "enable" the stepper with holding power, but it won't actually step during either of the movement blocks.
I'm tempted to ask why you bother with my code if your own code works ?  :)

I think you need to make a pencil drawing showing ALL the connections and post a photo of the drawing.

It may also be useful to post the working code.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up