stepper motor control using PWM and non-shield motor driver

I looking for the best way to control a NEMA 34 stepper motor (1.8º angle) http://www.act-motor.com/product/34hs_en.html with a non-arduino shield. Basically I need to send a PWM square wave on one pin of the arduino.

Most tutorials and code I have come across use four pins and either an h-bridge or other chip to control the stepper motor, using the arduino to generate all four pulse waves. But that is NOT what I need to do.

I have a stepper motor driver http://www.leadshine.com/productdetail.aspx?type=products&category=stepper-products&producttype=stepper-drives&series=M&model=MA860H

The driver receives a 5v+ signal on PUL+ and when PUL- is set LOW by the arduino it will make the motor go one step. (or so it seems!) I my sketch PUL- is connected to Pin 3.

The driver requires a minimum 1.5ms pulse, I was able to create the pulse by using a potentiometer connected to A0 and an oscilloscope until I found the right pulse width, and wrote out to the serial monitor to then hard code that delay into the sketch (310 microseconds)

I then tried using a second potentiometer connected to A1 to set the frequency or delay between the pulses to control the speed of the motor. Which seems to work.

Then I changed the code to have the first potentiometer control the direction (I should use a switch but the potentiometer was already connected). Basically if the pot is >= 500 the motor spins in one direction and <500 it spins the other.

First Problem:
If I do any serial communication however it severely slows down the motor. I believe adapting the blinkwithoutdelay sketch could help but the way it is implemented in the tutorial is confusing to me.

2nd Problem:
I'd like to be able to program in ramps for changing direction and slowing down to a stop. and also functions.

Any help appreciated

Here is what I have working so far, it is very basic, like a "Hello World" for this stepper motor, and eventually need to do this much better.

int dirpin = 2;
int steppin = 3;

int sensorPin1 = A0;        // select the input pin for the direction potentiometer
int sensorPin2 = A1;       // select the input pin for the delay potentiometer

int dirValue = 0;          // variable to store the value coming from the sensor
int sensorValue2 = 0;      // variable to store the value coming from the sensor
int pulseWidth = 310;      // this creates aprox 1.5microsceond to 2microsecond pulse width
int pulseDelay2 = 0;       // variable pulse frequency for speed of motor

void setup() 
{
pinMode(dirpin, OUTPUT);
pinMode(steppin, OUTPUT);
Serial.begin(9600);
  
}
void loop()
{
  dirValue = analogRead(sensorPin1); // read direction pot
  if (dirValue >= 500){
    digitalWrite(dirpin, LOW);       // turn CW
    delay(5);                        // delay for driver to accept direction change
  }
  else {
    digitalWrite(dirpin, HIGH);      // turn CCW
    delay(5);                        // delay for driver to accept direction change
  }
   
  sensorValue2 = analogRead(sensorPin2);   // read frequency or speed pot
  pulseDelay2 = ((sensorValue2*10)+300);   // do some math on the analogue reading, add 300 so frequency is never below pulse width
  //Serial.print("width 1 = "); Serial.print(pulseWidth); Serial.print(" delay 2 = "); Serial.println(pulseDelay2);
     
  digitalWrite(steppin, LOW);            // This LOW to HIGH change is what creates the
  delayMicroseconds(pulseWidth);         
  digitalWrite(steppin, HIGH);           // "Rising Edge" so driver knows to when to step.
  delayMicroseconds(pulseDelay2); 
 
}

http://www.airspayce.com/mikem/arduino/AccelStepper/

myStepper = AccelStepper(AccelStepper::DRIVER, STEP_PIN, DIRECTION_PIN);

Basically I need to send a PWM square wave on one pin of the arduino.

Trust me, no you don't. If you do you will have no control over how many steps the motor gets.

The driver requires a minimum 1.5ms pulse, I was able to create the pulse by using a potentiometer connected to A0 and an oscilloscope until I found the right pulse width, and wrote out to the serial monitor to then hard code that delay into the sketch (310 microseconds)

This makes no sense at all. The drive goes upto 300kHz so it'll handle very short
pulse widths indeed. The standard generic pulse width compatible with every drive
I've seen is 10us. Clearly this driver can handle about 1.5us pulse widths or it couldn't
see a 300kHz square wave.

That seems to be a standard stepper driver board that just requires step and direction signals from the Arduino.

As @johnwasser said you can use the accelStepper library to drive it.

If you just want to experiment with simple no-library code this should make it move. Just make sure your pins match the code or vice versa.

// 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);
    digitalWrite(stepPin, LOW);
    
    delay(millisbetweenSteps);
    
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
  
}

void loop() 
{ 

}

...R