 //////
 #define DESIREDRPM_TABLE    60      //desired RPM on output wheel
 //#define DESIREDRPM_MOTOR    600     //desired motor RPM (this may be superfulous) 
-#define DISCSLIPCOUNT       250     //How long alarm cond before alarm signal
+#define DISCSLIPCOUNT       50    //How long alarm cond before alarm signal
 #define LOCKEDDISCRPM       30     //RPM to consider as "disc stopped"
 #define ROTATIONVARIANCE    2      //Variance in RPM before alarm condition 
 
 #define LOCKEDDISCRPM       10      //RPM to consider as "disc stopped"
-#define ROTATIONVARIANCE    50      //Variance in RPM before alarm condition 
+#define ROTATIONVARIANCE    12	      //Variance in RPM before alarm condition 
 //#define TRANSMISSIONRATIO   10      //Tranmission drive ratio n:1
-#define NUMBEROFRESTARTS    5      //#of restarts attempted after stopped state
+#define NUMBEROFRESTARTS    3      //#of restarts attempted after stopped state
 #define STARTTIME           10000   //Expected ramp up time, in MS
 #define STOPTIME            10000   //Expected ramp down time, in MS
  /////////

if  (allStopVar == 0){
    calculateRPM();
    discSlipCheck();
   // lockedRotorCheck();
}
    //now = millis();
    //MQTT Connection Check

}    

void discSlipCheck(){
    if (rpm < ((DESIREDRPM_TABLE - ROTATIONVARIANCE) && (allStopVar == 0))){
        discSlipPrecond++;
        }
    else
        if (discSlipPrecond > 0 && allStopVar == 0){
        discSlipPrecond--;
        }
    if (discSlipPrecond > DISCSLIPCOUNT){
	Serial.println("Continious disc slip detected");
    client.publish(TOPIC_T, "Error: - Continuious Disc Slip Detected");
	discSlipPrecond = 0;
    }
}


void lockedRotorCheck(){
    if (rpm <= LOCKEDDISCRPM){
		Serial.println("Locked rotor. attempting restart");
        digitalWrite(STARTRELAYPIN, LOW); // immediately shut down if RPM lowByte
        client.publish(TOPIC_T, "CritErr: Disc rotation is locked, attempting restart");
		delay(STOPTIME);
		motionControlStart();
		}                            	
}

void allStop(){
