I have a vertical machining centre and need to add a 4th rotary axis using a stepper motor.
At the moment I use a mechanical rotary axis that is controlled by the z axis of the machine - the z axis pushes a plunger and this rotates the rotary axis a set angle, the longer the stroke the greater the rotation.
Unfortunately the mechanical rotary axis is not very accurate.
The machine does not have a step and direction output so I thought that I could use a switch to activate a set step and direction value to a stepper motor via an Arduino and a Gecko stepper motor driver.
For example rotate 90 degrees in a clockwise direction.
The control will be activated by the z axis of the machine by simply touching a switch.
I have some experience with Gecko drives, stepper motors and Mach4 software having made a 4 axis foam cutter.
Is this a possible scenario ?
ramtec:
so I thought that I could use a switch to activate a set step and direction value to a stepper motor via an Arduino and a Gecko stepper motor driver.
An Arduino can certainly control a Gecko driver.
I don't really understand how you want things to happen - for example do you want to move 90deg for every press of the switch? (which would be easy to do).
Will this be the only stepper motor on the machine or are there others controlled by Mach4?
...R
thanks for replying Robin,
There is only one stepper motor on the machine - the machine is a Fadal VMC with the standard 3 axis motion it has its own propriety controller (HS88 ) and yes it can be upgraded to a 4th axis machine but the cost is prohibitive at about $20,000.
I have the mechanics made and will power the axis with a stepper motor thru a gearbox to drive the 4th axis this is a rotary axis at right angles to the vertical (Z axis ) of the machine.
I don't want Mach4 to control the stepper, since Arduino can control a stepper motor using a Gecko drive.
What I want to do is control the Arduino by way of a switch to output a set step and direction to the Gecko and so make the rotary table turn a set angle.
The switch can be pressed by the Z axis of the VMC - I can create G code to have the Z axis come down over a switch and press it any number of times. So if the step and direction is programmed into the Arduino, for example N steps per 15 degrees then for 90 degrees I would command the VMC to press the switch 90/15 = 6 times.
Better yet if the Arduino can be programmed for various steps then I could have switches for say 2 degrees or 5 degrees or 90 degrees etc.
Any information and better ideas are most welcome.
ramtec:
I can create G code to have the Z axis come down over a switch and press it any number of times. So if the step and direction is programmed into the Arduino, for example N steps per 15 degrees then for 90 degrees I would command the VMC to press the switch 90/15 = 6 times.
Better yet if the Arduino can be programmed for various steps then I could have switches for say 2 degrees or 5 degrees or 90 degrees etc.
Any information and better ideas are most welcome.
Either of these would be easy to implement.
I'm guessing you don't have any Arduino experience so I suggest you buy an Uno (the best starter device) and study some of the examples that come with the Arduino IDE (the free programming system that you download to your PC).
This test code should make your motor move if it is correctly connected to the Gecko step and direction and GND pins.
// testing a stepper motor with a Pololu A4988 driver board or equivalent
// 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 = 100;
byte ledPin = 13;
int pulseWidthMicros = 20; // microseconds
int millisbetweenSteps = 25; // 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); // probably not needed
digitalWrite(stepPin, LOW);
delay(millisbetweenSteps);
digitalWrite(ledPin, !digitalRead(ledPin));
}
}
void loop()
{
}
...R
Thanks for the code Robin,
I have a Arduino UNO but I need to get the Gecko and stepper motor.
This will take a week to get organised.
In the meantime I will do some studying on stepper motor examples.
All done ;D
might be a bit messy but it works.
here is my code.
checking on how to put the code in here
/*
Switch Program
Written by: Jeremy Blum (with stepper code added by Tony)
*/
int ButtonA = 8; //9000 steps = 90 degrees
int ButtonB = 9; //27000 steps = 270 degress
int ButtonC = 7; //1500 steps = 15 degrees
int ledPin = 13;
boolean lastButton = LOW;
boolean ledOn = false;
void setup()
{
pinMode(ButtonA, INPUT);
pinMode(ButtonB, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(10,OUTPUT); //direction
pinMode(11,OUTPUT); //step
}
void loop()
{
if (digitalRead(ButtonA) == HIGH && lastButton == LOW)
{
ledOn = !ledOn;
lastButton = HIGH;
}if (digitalRead(ButtonA) == HIGH && lastButton == HIGH)
{ digitalWrite(10, HIGH);
for(int n = 0; n <9000; n++) // 9000 steps 90 degrees
{
digitalWrite(11, HIGH);
delayMicroseconds(300);
digitalWrite(11, LOW);
delayMicroseconds(300);}}
else
{
//lastButton = LOW;
lastButton = digitalRead(ButtonA);
}
digitalWrite(ledPin, ledOn);
{
if (digitalRead(ButtonB) == HIGH && lastButton == LOW)
{
ledOn = !ledOn;
lastButton = HIGH;
}if (digitalRead(ButtonB) == HIGH && lastButton == HIGH)
{ digitalWrite(10, HIGH);
for(int n = 0; n <27000; n++) // 27000 steps = 270 degrees
{
digitalWrite(11, HIGH);
delayMicroseconds(300);
digitalWrite(11, LOW);
delayMicroseconds(300);}}
else
{
//lastButton = LOW;
lastButton = digitalRead(ButtonB);
}
if (digitalRead(ButtonC) == HIGH && lastButton == LOW)
{
ledOn = !ledOn;
lastButton = HIGH;
}if (digitalRead(ButtonC) == HIGH && lastButton == HIGH)
{ digitalWrite(10, HIGH);
for(int n = 0; n <1500; n++) // 1500 steps = 15 degrees
{
digitalWrite(11, HIGH);
delayMicroseconds(300);
digitalWrite(11, LOW);
delayMicroseconds(300);}}
else
{
//lastButton = LOW;
lastButton = digitalRead(ButtonC);
}
}}
ramtec:
All done ;D
might be a bit messy but it works.
here is my code.
Glad to hear it works
...R