debugging
parent
be96876113
commit
6222f77016
|
@ -55,6 +55,11 @@ CommandCodeEnum Command::getGCodeEnum(char *code)
|
|||
// return F03;
|
||||
//}
|
||||
|
||||
if (strcmp(code, "F09") == 0 || strcmp(code, "F9") == 0)
|
||||
{
|
||||
return F09;
|
||||
}
|
||||
|
||||
if (strcmp(code, "F11") == 0)
|
||||
{
|
||||
return F11;
|
||||
|
|
|
@ -20,6 +20,7 @@ const char COMM_REPORT_CMD_ERROR[4] = {'R', '0', '3', '\0'};
|
|||
const char COMM_REPORT_CMD_BUSY[4] = {'R', '0', '4', '\0'};
|
||||
const char COMM_REPORT_CMD_STATUS[4] = {'R', '0', '5', '\0'};
|
||||
const char COMM_REPORT_CALIB_STATUS[4] = {'R', '0', '6', '\0'};
|
||||
const char COMM_REPORT_EMERGENCY_STOP[4] = { 'R', '8', '7', '\0' };
|
||||
const char COMM_REPORT_NO_CONFIG[4] = {'R', '8', '8', '\0'};
|
||||
const char COMM_REPORT_COMMENT[4] = {'R', '9', '9', '\0'};
|
||||
|
||||
|
@ -58,7 +59,7 @@ const long MOVEMENT_KEEP_ACTIVE_Z_DEFAULT = 1;
|
|||
|
||||
const long MOVEMENT_HOME_AT_BOOT_X_DEFAULT = 0;
|
||||
const long MOVEMENT_HOME_AT_BOOT_Y_DEFAULT = 0;
|
||||
const long MOVEMENT_HOME_AT_BOOT_Z_DEFAULT = 1;
|
||||
const long MOVEMENT_HOME_AT_BOOT_Z_DEFAULT = 0;
|
||||
|
||||
const long MOVEMENT_ENABLE_ENDPOINTS_X_DEFAULT = 0;
|
||||
const long MOVEMENT_ENABLE_ENDPOINTS_Y_DEFAULT = 0;
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
*/
|
||||
|
||||
#ifndef DEBUG_H_
|
||||
#define debugMessages false
|
||||
#define debugMessages true
|
||||
#define debugInterrupt false
|
||||
#endif /* DEBUG_H_ */
|
||||
|
|
|
@ -31,7 +31,7 @@ int F09Handler::execute(Command *command)
|
|||
Serial.print("R99 Reset emergency stop\r\n");
|
||||
}
|
||||
|
||||
CurrentState::getInstance()->setEmergencyStop();
|
||||
CurrentState::getInstance()->resetEmergencyStop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -31,12 +31,34 @@ int GCodeProcessor::execute(Command *command)
|
|||
long Q = command->getQ();
|
||||
CurrentState::getInstance()->setQ(Q);
|
||||
|
||||
// Do not execute the command when the config complete parameter is not
|
||||
// set by the raspberry pi and it's asked to do a move command
|
||||
|
||||
//Only allow reset of emergency stop when emergency stop is engaged
|
||||
|
||||
if (CurrentState::getInstance()->isEmergencyStop())
|
||||
{
|
||||
if (!(
|
||||
command->getCodeEnum() == F09 ||
|
||||
command->getCodeEnum() == F20 ||
|
||||
command->getCodeEnum() == F21 ||
|
||||
command->getCodeEnum() == F22 ||
|
||||
command->getCodeEnum() == F81 ||
|
||||
command->getCodeEnum() == F82 ||
|
||||
command->getCodeEnum() == F83 ))
|
||||
{
|
||||
|
||||
Serial.print(COMM_REPORT_EMERGENCY_STOP);
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Tim 2017-04-15 Disable until the raspberry code is ready
|
||||
/*
|
||||
if (ParameterList::getInstance()->getValue(PARAM_CONFIG_OK) != 1) {
|
||||
// Do not execute the command when the config complete parameter is not
|
||||
// set by the raspberry pi and it's asked to do a move command
|
||||
|
||||
if (ParameterList::getInstance()->getValue(PARAM_CONFIG_OK) != 1)
|
||||
{
|
||||
if ( command->getCodeEnum() == G00 ||
|
||||
command->getCodeEnum() == G01 ||
|
||||
command->getCodeEnum() == F11 ||
|
||||
|
@ -44,13 +66,14 @@ int GCodeProcessor::execute(Command *command)
|
|||
command->getCodeEnum() == F13 ||
|
||||
command->getCodeEnum() == F14 ||
|
||||
command->getCodeEnum() == F15 ||
|
||||
command->getCodeEnum() == F16 ) {
|
||||
command->getCodeEnum() == F16 )
|
||||
{
|
||||
|
||||
Serial.print(COMM_REPORT_NO_CONFIG);
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Return error when no command or invalid command is found
|
||||
|
|
|
@ -326,14 +326,14 @@ int StepperControl::moveToCoords(long xDest, long yDest, long zDest,
|
|||
Serial.print(" deactivate motor X due to missed steps");
|
||||
Serial.print("\r\n");
|
||||
|
||||
//if (axisX.movingToHome())
|
||||
//{
|
||||
// encoderX.setPosition(0);
|
||||
// axisX.setCurrentPosition(0);
|
||||
// Serial.print("R99");
|
||||
// Serial.print(" home position X axis detected with encoder");
|
||||
// Serial.print("\r\n");
|
||||
//}
|
||||
if (xHome)
|
||||
{
|
||||
encoderX.setPosition(0);
|
||||
axisX.setCurrentPosition(0);
|
||||
Serial.print("R99");
|
||||
Serial.print(" home position X axis detected with encoder");
|
||||
Serial.print("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (motorConsMissedSteps[1] > motorConsMissedStepsMax[1])
|
||||
|
@ -343,14 +343,14 @@ int StepperControl::moveToCoords(long xDest, long yDest, long zDest,
|
|||
Serial.print(" deactivate motor Y due to missed steps");
|
||||
Serial.print("\r\n");
|
||||
|
||||
//if (axisY.movingToHome())
|
||||
//{
|
||||
// encoderY.setPosition(0);
|
||||
// axisY.setCurrentPosition(0);
|
||||
// Serial.print("R99");
|
||||
// Serial.print(" home position Y axis detected with encoder");
|
||||
// Serial.print("\r\n");
|
||||
//}
|
||||
if (yHome)
|
||||
{
|
||||
encoderY.setPosition(0);
|
||||
axisY.setCurrentPosition(0);
|
||||
Serial.print("R99");
|
||||
Serial.print(" home position Y axis detected with encoder");
|
||||
Serial.print("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (motorConsMissedSteps[2] > motorConsMissedStepsMax[2])
|
||||
|
@ -360,14 +360,14 @@ int StepperControl::moveToCoords(long xDest, long yDest, long zDest,
|
|||
Serial.print(" deactivate motor Z due to missed steps");
|
||||
Serial.print("\r\n");
|
||||
|
||||
//if (axisZ.movingToHome())
|
||||
//{
|
||||
// encoderZ.setPosition(0);
|
||||
// axisZ.setCurrentPosition(0);
|
||||
// Serial.print("R99");
|
||||
// Serial.print(" home position Z axis detected with encoder");
|
||||
// Serial.print("\r\n");
|
||||
//}
|
||||
if (zHome)
|
||||
{
|
||||
encoderZ.setPosition(0);
|
||||
axisZ.setCurrentPosition(0);
|
||||
Serial.print("R99");
|
||||
Serial.print(" home position Z axis detected with encoder");
|
||||
Serial.print("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (axisX.endStopAxisReached(false))
|
||||
|
|
|
@ -86,7 +86,7 @@ private:
|
|||
long speedMin[3] = { 0, 0, 0 };
|
||||
long stepsAcc[3] = { 0, 0, 0 };
|
||||
bool motorInv[3] = { false, false, false };
|
||||
bool motorMaxSize[3] = { false, false, false };
|
||||
long motorMaxSize[3] = { 0, 0, 0};
|
||||
bool motorKeepActive[3] = { false, false, false };
|
||||
bool motor2Inv[3] = { false, false, false };
|
||||
bool motor2Enbl[3] = { false, false, false };
|
||||
|
|
|
@ -398,11 +398,11 @@ void StepperControlAxis::loadCoordinates(long sourcePoint, long destinationPoint
|
|||
{
|
||||
if (coordDestinationPoint < 0)
|
||||
{
|
||||
coordDestinationPoint = abs(motorMaxSize);
|
||||
coordDestinationPoint = -abs(motorMaxSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
coordDestinationPoint = -abs(motorMaxSize);
|
||||
coordDestinationPoint = abs(motorMaxSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -228,8 +228,14 @@ void loop()
|
|||
{
|
||||
StepperControl::getInstance()->disableMotors();
|
||||
PinControl::getInstance()->resetPinsUsed();
|
||||
if (debugMessages)
|
||||
{
|
||||
Serial.print(COMM_REPORT_COMMENT);
|
||||
Serial.print(" Going to safe state");
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
}
|
||||
}
|
||||
previousEmergencyStop == CurrentState::getInstance()->isEmergencyStop();
|
||||
previousEmergencyStop = CurrentState::getInstance()->isEmergencyStop();
|
||||
|
||||
// Check if parameters are changes, and if so load the new settings
|
||||
if (lastParamChangeNr != ParameterList::getInstance()->paramChangeNumber())
|
||||
|
@ -260,8 +266,23 @@ void loop()
|
|||
{
|
||||
// After an idle time, send the idle message
|
||||
|
||||
Serial.print(COMM_REPORT_CMD_IDLE);
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
if (CurrentState::getInstance()->isEmergencyStop())
|
||||
{
|
||||
Serial.print(COMM_REPORT_EMERGENCY_STOP);
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
|
||||
if (debugMessages)
|
||||
{
|
||||
Serial.print(COMM_REPORT_COMMENT);
|
||||
Serial.print(" Emergency stop engaged");
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.print(COMM_REPORT_CMD_IDLE);
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
}
|
||||
|
||||
StepperControl::getInstance()->storePosition();
|
||||
CurrentState::getInstance()->printPosition();
|
||||
|
|
Loading…
Reference in New Issue