diff --git a/src/CurrentState.cpp b/src/CurrentState.cpp index b04602a..9c26735 100644 --- a/src/CurrentState.cpp +++ b/src/CurrentState.cpp @@ -86,7 +86,7 @@ void CurrentState::setEndStopState(unsigned int axis, unsigned int position, boo endStopState[axis][position] = state; } -void CurrentState::setStepsPerMm(int stepsX, int stepsY, int stepsZ) +void CurrentState::setStepsPerMm(long stepsX, long stepsY, long stepsZ) { stepsPerMmX = stepsX; stepsPerMmY = stepsY; diff --git a/src/CurrentState.h b/src/CurrentState.h index 84455bc..018e5fb 100644 --- a/src/CurrentState.h +++ b/src/CurrentState.h @@ -43,16 +43,16 @@ public: void resetEmergencyStop(); bool isEmergencyStop(); - void setStepsPerMm(int stepsX, int stepsY, int stepsZ); + void setStepsPerMm(long stepsX, long stepsY, long stepsZ); private: CurrentState(); CurrentState(CurrentState const &); void operator=(CurrentState const &); - int stepsPerMmX; - int stepsPerMmY; - int stepsPerMmZ; + long stepsPerMmX; + long stepsPerMmY; + long stepsPerMmZ; bool emergencyStop = false; }; diff --git a/src/StepperControl.cpp b/src/StepperControl.cpp index bcd3a0b..4f695ab 100644 --- a/src/StepperControl.cpp +++ b/src/StepperControl.cpp @@ -826,7 +826,7 @@ int StepperControl::calibrateAxis(int axis) encoderEnabled = &motorConsEncoderEnabled[2]; axisStatus = &axisSubStep[2]; //axisStepsPerMm = &axisStepsPerMm[2]; - axisStepsPerMm = &stepsPerMm[1]; + axisStepsPerMm = &stepsPerMm[2]; break; default: Serial.print("R99 Calibration error: invalid axis selected\r\n"); diff --git a/src/farmbot_arduino_controller.cpp b/src/farmbot_arduino_controller.cpp index c2eec65..8678511 100644 --- a/src/farmbot_arduino_controller.cpp +++ b/src/farmbot_arduino_controller.cpp @@ -173,6 +173,7 @@ void setup() pinMode(X_STEP_PIN, OUTPUT); pinMode(X_DIR_PIN, OUTPUT); pinMode(X_ENABLE_PIN, OUTPUT); + pinMode(E_STEP_PIN, OUTPUT); pinMode(E_DIR_PIN, OUTPUT); pinMode(E_ENABLE_PIN, OUTPUT); @@ -222,7 +223,7 @@ void setup() pinMode(UTM_E, INPUT_PULLUP); pinMode(UTM_F, INPUT_PULLUP); pinMode(UTM_G, INPUT_PULLUP); - pinMode(UTM_H, INPUT_PULLUP); + if (UTM_H > 0) { pinMode(UTM_H, INPUT_PULLUP) }; pinMode(UTM_I, INPUT_PULLUP); pinMode(UTM_J, INPUT_PULLUP); pinMode(UTM_K, INPUT_PULLUP); @@ -268,6 +269,9 @@ void setup() // Initialize the inactivity check lastAction = millis(); + pinGuardCurrentTime = millis(); + pinGuardLastCheck = millis(); + if (ParameterList::getInstance()->getValue(MOVEMENT_HOME_AT_BOOT_Z) == 1) { Serial.print("R99 HOME Z ON STARTUP\r\n"); @@ -301,24 +305,25 @@ void loop() StepperControl::getInstance()->handleMovementInterrupt(); } + pinGuardCurrentTime = millis(); + if (pinGuardCurrentTime < pinGuardLastCheck) + { + pinGuardLastCheck = pinGuardCurrentTime; + } + else + { + if (pinGuardCurrentTime - pinGuardLastCheck >= 1000) + { + pinGuardLastCheck += 1000; + + // check the pins for timeouts + PinGuard::getInstance()->checkPins(); + } + } + if (Serial.available()) { - unsigned long pinGuardLastCheck; - pinGuardCurrentTime = millis(); - if (pinGuardCurrentTime < pinGuardLastCheck) - { - pinGuardLastCheck = pinGuardCurrentTime; - } - else - { - if (pinGuardLastCheck - pinGuardCurrentTime >= 999) - { - // check the pins for timeouts - PinGuard::getInstance()->checkPins(); - } - } - // Save current time stamp for timeout actions lastAction = millis(); diff --git a/src/pins.h b/src/pins.h index f303ce4..fbad230 100644 --- a/src/pins.h +++ b/src/pins.h @@ -134,13 +134,16 @@ #define X_STEP_PIN 26 // X1_STEP_PIN #define X_DIR_PIN 27 // X1_DIR_PIN #define X_ENABLE_PIN 25 // X1_ENABLE_PIN + #define E_STEP_PIN 15 // X2_STEP_PIN #define E_DIR_PIN 30 // X2_DIR_PIN #define E_ENABLE_PIN 14 // X2_ENABLE_PIN + #define X_MIN_PIN 69 #define X_MAX_PIN 68 #define X_ENCDR_A 16 #define X_ENCDR_B 17 + #define X2_ENCDR_A 22 #define X2_ENCDR_B 39 #define X_ENCDR_A_Q -1 // N/A diff --git a/src/src.vcxproj b/src/src.vcxproj index 90ad932..eb7dc1f 100644 --- a/src/src.vcxproj +++ b/src/src.vcxproj @@ -174,7 +174,7 @@ - + \ No newline at end of file