I stand on the shoulders of giants, at least that's my excuse for being uncreative and lazy!
Hardware:
500 Watt step up/step down transformer supplying ~ 60 volts A/C to
MA860h
http://www.leadshine.com/UploadFile/Down/MA860Hm.pdf
To drive:
a NEMA 34 stepper motor like this:
The application is to drive the headstock spindle on a Sherline Lathe driving 1:1 desired maximum 1000 rpm with a stretch goal of 2000 rpm. I have checked that the setup is working using this code which I "borrowed" from someone else:
/*
driver MA860H
Pul+ goes to +5V
Pul- goes to Arduino Pin 9
Dir+ goes to +5V
Dir- goes to to Arduino Pin 8
Enable+ to nothing
Enable- to nothing
*/
int sensorPin = A3;
int sensorValue = 0;
void setup() {
pinMode(8, OUTPUT); //direction pin
pinMode(9, OUTPUT); //step pin
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
//Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(sensorPin);
sensorValue = map(sensorValue,0,1023,0,200);
digitalWrite(9, HIGH);
delayMicroseconds(sensorValue);
digitalWrite(9, LOW);
delayMicroseconds(sensorValue);
//Serial.println(sensorValue);
}
This will produce a speed of around 420 rpm when the pot on A3 gets to zero. The motor is 200 steps per revolution and the driver was 1/4 stepping when this was achieved.
So I did a little research and found this:
http://wiki.linuxcnc.org/cgi-bin/wiki.pl?Stepper_Drive_Timing
entry #46 down, or 10 up from the bottom if that's easier
Note these times are in nanoseconds. This is an empirical list, but a good starting place for a reality check. This project has been done before (told you I wasn't original) using a PIC 16F1719. I happen to have an Arduino Duemilanove (ATmega328 version) and so I thought I would try that before investing in anything else.
So, a 16mhz clock cycles at 62.5 nanoseconds, I need 1500 nanoseconds-so 24 clock cycles high and 24 cycles low. Assuming 1/4 stepping that will be 800 of those per revolution and that must be multiplied by 17 (per second) to reach 1000rpm and 34 (per second) to reach 2000rpm. Am I math numb, or are there ways to do this? So far I have briefly looked at stepper.h and AccelStepper and I don't think they will help. I'm looking at TimerOne and direct port switching right now.
Should I stop wasting time and move on, or is this possible with some patience?
Thanks,
Fats