Add timeout for auto enable

This commit is contained in:
Anders Sandstrom
2022-02-01 12:23:23 +01:00
parent bfddbedcdd
commit 8637d3a9ed
5 changed files with 1104 additions and 2176 deletions

View File

@@ -125,6 +125,8 @@ ecmcGrbl::ecmcGrbl(char* configStr,
limitsSummary_ = 0;
limitsSummaryOld_ = 0;
spindleAcceleration_ = 0;
cfgAutoEnableTimeOutSecs_ = ECMC_PLUGIN_AUTO_ENABLE_TIME_OUT_SEC;
autoEnableTimeOutCounter_ = 0;
grblCommandBufferIndex_ = 0;
grblCommandBuffer_.clear();
@@ -467,9 +469,26 @@ void ecmcGrbl::doMainWorker() {
}
}
int ecmcGrbl::setAllAxesEnable(int enable) {
if(cfgXAxisId_ >= 0) {
setAxisEnable(cfgXAxisId_, enable);
}
if(cfgYAxisId_ >= 0 ) {
setAxisEnable(cfgYAxisId_, enable);
}
if(cfgZAxisId_ >=0 ) {
setAxisEnable(cfgZAxisId_, enable);
}
if(cfgSpindleAxisId_ >= 0) {
setAxisEnable(cfgSpindleAxisId_, enable);
}
return 0;
}
void ecmcGrbl::autoEnableAxisAtStart(int ecmcAxisId) {
if(!cfgAutoEnableAtStart_ || autoEnableExecuted_ || getEcmcEpicsIOCState()!=16) {
if(!cfgAutoEnableAtStart_ || autoEnableExecuted_ || getEcmcEpicsIOCState()!=16 || errorCode_) {
return;
}
@@ -485,7 +504,7 @@ bool ecmcGrbl::getEcmcAxisEnabled(int ecmcAxisId) {
return ena;
}
bool ecmcGrbl::getAllConfiguredAxisEnabled() {
bool ecmcGrbl::getAllAxesEnabled() {
int ena = 1;
if(cfgXAxisId_ >= 0 && ena) {
ena = getEcmcAxisEnabled(cfgXAxisId_);
@@ -520,8 +539,22 @@ void ecmcGrbl::preExeAxes() {
//spindle
autoEnableAxisAtStart(cfgSpindleAxisId_);
if(getAllConfiguredAxisEnabled()) {
if(getAllAxesEnabled()) {
autoEnableExecuted_ = 1;
autoEnableTimeOutCounter_ = 0;
} else {
if(cfgAutoEnableAtStart_) {
if(autoEnableTimeOutCounter_ >= cfgAutoEnableTimeOutSecs_/exeSampleTimeMs_*1000) {
errorCode_ = ECMC_PLUGIN_AUTO_ENABLE_TIMEOUT_ERROR_CODE;
if(errorCode_!=errorCodeOld_) {
printf("GRBL: ERROR: Auto enable timeout 0x%x\n",errorCode_);
}
setAllAxesEnable(0);
} else {
autoEnableTimeOutCounter_++;
}
}
}
}

View File

@@ -54,7 +54,8 @@ class ecmcGrbl : public asynPortDriver {
int getBusy();
int getParserBusy();
int getCodeRowNum();
int setAllAxesEnable(int enable);
bool getAllAxesEnabled();
private:
void parseConfigStr(char *configStr);
void preExeAxes();
@@ -65,7 +66,6 @@ class ecmcGrbl : public asynPortDriver {
void checkLimits(int ecmcAxisId);
void giveControlToEcmcIfNeeded();
bool getEcmcAxisEnabled(int ecmcAxisId);
bool getAllConfiguredAxisEnabled();
double getEcmcAxisActPos(int axis);
void syncAxisPositionIfNotEnabled(int ecmcAxisId, int grblAxisId);
static std::string to_string(int value);
@@ -97,6 +97,8 @@ class ecmcGrbl : public asynPortDriver {
int limitsSummary_;
int limitsSummaryOld_;
double spindleAcceleration_;
int cfgAutoEnableTimeOutSecs_;
int autoEnableTimeOutCounter_;
};
#endif /* ECMC_GRBL_H_ */

View File

@@ -31,6 +31,9 @@
#define ECMC_PLUGIN_LOAD_FILE_ERROR_CODE 0x103
#define ECMC_PLUGIN_LIMIT_SWITCH_VIOLATION_ERROR_CODE 0x104
#define ECMC_PLUGIN_SPINDLE_ACC_ERROR_CODE 0x105
#define ECMC_PLUGIN_AUTO_ENABLE_TIMEOUT_ERROR_CODE 0x106
#define ECMC_PLUGIN_AUTO_ENABLE_TIME_OUT_SEC 5
#define ECMC_PLUGIN_GRBL_GRBL_STARTUP_STRING "for help]"
#define ECMC_PLUGIN_GRBL_GRBL_OK_STRING "ok"

File diff suppressed because it is too large Load Diff

View File

@@ -82,7 +82,7 @@ epicsEnvSet("PLUGIN_VER" ,"develop")
require ecmc_plugin_grbl $(PLUGIN_VER)
epicsEnvSet(ECMC_PLUGIN_FILNAME,"/home/pi/epics/base-7.0.5/require/${E3_REQUIRE_VERSION}/siteMods/ecmc_plugin_grbl/$(PLUGIN_VER)/lib/${EPICS_HOST_ARCH=linux-x86_64}/libecmc_plugin_grbl.so")
epicsEnvSet(ECMC_PLUGIN_CONFIG,"DBG_PRINT=1;X_AXIS=1;Y_AXIS=2;SPINDLE_AXIS=3;AUTO_ENABLE=1;AUTO_START=1;") # Only one option implemented in this plugin
epicsEnvSet(ECMC_PLUGIN_CONFIG,"DBG_PRINT=0;X_AXIS=1;Y_AXIS=2;SPINDLE_AXIS=3;AUTO_ENABLE=1;AUTO_START=1;") # Only one option implemented in this plugin
${SCRIPTEXEC} ${ecmccfg_DIR}loadPlugin.cmd, "PLUGIN_ID=0,FILE=${ECMC_PLUGIN_FILNAME},CONFIG='${ECMC_PLUGIN_CONFIG}', REPORT=1"
epicsEnvUnset(ECMC_PLUGIN_FILNAME)
epicsEnvUnset(ECMC_PLUGIN_CONFIG)