 // Maximum PWM setting.  Valid values are 0 (off) to 255 (full on)
 const int MAX_PWM = 255;
 
-// PWM setting for low speed mode when approaching an end stop.
-// Valid values are 0 (off) to 255 (full on)
-const int LOW_SPEED_PWM_OPEN = 110;
-const int LOW_SPEED_PWM_CLOSE = 60;
-
 const int MAX_DOOR_SPEED = 0x3FFF;
 
-// This value controls the slope of the soft start
-const int RAMP_UP_VALUE = 32; // amount to increase speed per cycle
+// Door low speed when approaching an end stop.
+// Valid values are 0 (off) to MAX_DOOR_SPEED (full on)
+const int DOOR_LOW_SPEED_CLOSE = 60 << 6;
+const int DOOR_LOW_SPEED_OPEN = 95 << 6;
+
+
+// This value controls the slope of the soft start / stop
+const int DOOR_SPEED_RAMP = 32; // amount to change speed per cycle
 
 // Initial speed for the motor when reversing. If negative, motor will not be started until the ramp up has
 // brought the value above 0.
-const int INITIAL_REVERSING_MOTOR_SPEED = -1 * 128 * RAMP_UP_VALUE;
+const int INITIAL_REVERSING_MOTOR_SPEED = -4096 / DOOR_SPEED_RAMP;
 
 // Arbitrary value defining when to shut down the motor if it has been on for this many update cycles.
-const unsigned int DOOR_MOTOR_WATCHDOG_MAX = 2600;
+const unsigned int DOOR_MOTOR_WATCHDOG_CLOSE_MAX = 2600;
+const unsigned int DOOR_MOTOR_WATCHDOG_OPEN_MAX = 2700;
 
 // Arbitrary value defining when to slow motor down 
-const unsigned int DOOR_MOTOR_WATCHDOG_LOW_SPEED = 1800;
+const unsigned int DOOR_MOTOR_WATCHDOG_CLOSE_LOW_SPEED = 1700;
+const unsigned int DOOR_MOTOR_WATCHDOG_OPEN_LOW_SPEED = 1900;
 
 // Globals
 

  }

  doorWatchdog = 0;
  doorState = DOOR_STATE_OPENING;
}


  }

  doorWatchdog = 0;
  doorWatchdogMax = DOOR_MOTOR_WATCHDOG_CLOSE_MAX;
  doorWatchdogLowSpeedCutover = DOOR_MOTOR_WATCHDOG_CLOSE_LOW_SPEED;
  doorLowSpeed = DOOR_LOW_SPEED_CLOSE;
  doorState = DOOR_STATE_CLOSING;
}


/**
 * Updates the speed of the motor.  The PWM field will be incremented by DOOR_SPEED_RAMP
 * each time this method is called until the MAX_PWM is reached.  If the door is no longer opening
 * or closing, no speed change will occur. If the speed is negative, no speed change will occur.
 * 
 * In order to not bang into the limit switches, after a pre-determined amount of time, the motor
 * speed will be ramped down to a low speed value appropriate for the door direction.
 * 
 * Finally, this method increments and checks a watchdog counter in case the limit switches
 * are never tripped.  If the motor runs for too long, it is stopped and the door state becomes
