Custom PWM while other commands are running

Hey everybody, I'm trying to use the Arduino to receive Serial commands and then send pulses out, but I cannot use the built in analogWrite because the device I'm communicating with (Victor 883) requires different high and low pulse periods than the default analogWrite. I have written code that does this successfully:

void drive(int dir, int percent){
  int pulse;
  if(dir == 0 || percent == 0){
    pulse = 1500;
  }else if(dir == 1){ // forward
    pulse = map(percent, 0, 100, 1550, 2010);
  }else{ // reverse
    pulse = map(percent, 0, 100, 1490, 1060);
  }
  digitalWrite(motorPin, HIGH);
  delayMicroseconds(pulse);
  digitalWrite(motorPin, LOW);
  delay(37);
  delayMicroseconds(3000 - pulse);
}

But now I need to put this in another program that is constantly polling serial devices and communicating to a computer and these delays are messing up the timing in this code. If I use analogWrite, I could maintain the pulses while these serial events were happening, but I don't know how to do that with my own custom pulse function. Can anyone point me in the right direction?

blink without delay:

watch the microseconds go by, when you get to a time you, make the output change as needed.

Here's a simple version that does even length pulses to get you started:

byte outputPin = 2;  // or whatever you use
byye pinState;
unsigned long changeTime; // 32 bit number

void setup(){
pinMode (outputPin, OUTPUT);
}

void loop(){
if (micros() >= changeTime){
changeTime = changeTime + 250; // set up next transition time
pinState = 1-pinstate; // 1,0,1,0,1,0
digitalWrite (outputPin, pinState); // other ways to do this too, some significantly faster

  }
}