Current and stall sensitivity added to parameters

pull/118/head
Tim Evers 2019-04-22 23:48:02 +02:00
parent 6d7ac1fa58
commit 7b668b4a7f
6 changed files with 76 additions and 19 deletions

View File

@ -141,6 +141,16 @@
const long MOVEMENT_STOP_AT_MAX_Y_DEFAULT = 0;
const long MOVEMENT_STOP_AT_MAX_Z_DEFAULT = 0;
// motor current (used with TMC2130)
const long MOVEMENT_MOTOR_CURRENT_X_DEFAULT = 600;
const long MOVEMENT_MOTOR_CURRENT_Y_DEFAULT = 600;
const long MOVEMENT_MOTOR_CURRENT_Z_DEFAULT = 600;
// stall sensitivity (used with TMC2130)
const long MOVEMENT_STALL_SENSITIVITY_X_DEFAULT = 30;
const long MOVEMENT_STALL_SENSITIVITY_Y_DEFAULT = 30;
const long MOVEMENT_STALL_SENSITIVITY_Z_DEFAULT = 30;
// Use encoder (0 or 1)
const long ENCODER_ENABLED_X_DEFAULT = 0;
const long ENCODER_ENABLED_Y_DEFAULT = 0;

View File

@ -439,6 +439,26 @@ void ParameterList::loadDefaultValue(int id)
paramValues[id] = MOVEMENT_STOP_AT_MAX_Z_DEFAULT;
break;
case MOVEMENT_MOTOR_CURRENT_X:
paramValues[id] = MOVEMENT_MOTOR_CURRENT_X_DEFAULT;
break;
case MOVEMENT_MOTOR_CURRENT_Y:
paramValues[id] = MOVEMENT_MOTOR_CURRENT_Y_DEFAULT;
break;
case MOVEMENT_MOTOR_CURRENT_Z:
paramValues[id] = MOVEMENT_MOTOR_CURRENT_Z_DEFAULT;
break;
case MOVEMENT_STALL_SENSITIVITY_X:
paramValues[id] = MOVEMENT_STALL_SENSITIVITY_X_DEFAULT;
break;
case MOVEMENT_STALL_SENSITIVITY_Y:
paramValues[id] = MOVEMENT_STALL_SENSITIVITY_Y_DEFAULT;
break;
case MOVEMENT_STALL_SENSITIVITY_Z:
paramValues[id] = MOVEMENT_STALL_SENSITIVITY_Z_DEFAULT;
break;
case ENCODER_ENABLED_X:
paramValues[id] = ENCODER_ENABLED_X_DEFAULT;
break;
@ -617,6 +637,12 @@ bool ParameterList::validParam(int id)
case MOVEMENT_MAX_SPD_X:
case MOVEMENT_MAX_SPD_Y:
case MOVEMENT_MAX_SPD_Z:
case MOVEMENT_MOTOR_CURRENT_X:
case MOVEMENT_MOTOR_CURRENT_Y:
case MOVEMENT_MOTOR_CURRENT_Z:
case MOVEMENT_STALL_SENSITIVITY_X:
case MOVEMENT_STALL_SENSITIVITY_Y:
case MOVEMENT_STALL_SENSITIVITY_Z:
case ENCODER_ENABLED_X:
case ENCODER_ENABLED_Y:
case ENCODER_ENABLED_Z:

View File

@ -81,6 +81,16 @@ enum ParamListEnum
MOVEMENT_INVERT_2_ENDPOINTS_Y = 76,
MOVEMENT_INVERT_2_ENDPOINTS_Z = 77,
// motor current (used with TMC2130)
MOVEMENT_MOTOR_CURRENT_X = 81,
MOVEMENT_MOTOR_CURRENT_Y = 82,
MOVEMENT_MOTOR_CURRENT_Z = 83,
// stall sensitivity (used with TMC2130)
MOVEMENT_STALL_SENSITIVITY_X = 85,
MOVEMENT_STALL_SENSITIVITY_Y = 86,
MOVEMENT_STALL_SENSITIVITY_Z = 87,
// encoder settings
ENCODER_ENABLED_X = 101,
ENCODER_ENABLED_Y = 102,

View File

@ -179,9 +179,20 @@ void StepperControl::loadSettings()
void StepperControl::initTMC2130()
{
/**/
axisX.initTMC2130();
axisY.initTMC2130();
axisZ.initTMC2130();
int motorCurrent;
int stallSensitivity;
motorCurrent = ParameterList::getInstance()->getValue(MOVEMENT_MOTOR_CURRENT_X);
stallSensitivity = ParameterList::getInstance()->getValue(MOVEMENT_STALL_SENSITIVITY_X);
axisX.initTMC2130(motorCurrent, stallSensitivity);
motorCurrent = ParameterList::getInstance()->getValue(MOVEMENT_MOTOR_CURRENT_X);
stallSensitivity = ParameterList::getInstance()->getValue(MOVEMENT_STALL_SENSITIVITY_X);
axisY.initTMC2130(motorCurrent, stallSensitivity);
motorCurrent = ParameterList::getInstance()->getValue(MOVEMENT_MOTOR_CURRENT_X);
stallSensitivity = ParameterList::getInstance()->getValue(MOVEMENT_STALL_SENSITIVITY_X);
axisZ.initTMC2130(motorCurrent, stallSensitivity);
}
#endif

View File

@ -100,7 +100,7 @@ void StepperControlAxis::test()
}
#if defined(FARMDUINO_EXP_V20)
void StepperControlAxis::initTMC2130()
void StepperControlAxis::initTMC2130(int motorCurrent, int stallSensitivity)
{
/*
TMC2130X.begin(); // Initiate pins and registeries
@ -124,14 +124,14 @@ void StepperControlAxis::initTMC2130()
TMC2130A = &TMC2130Z;
}
TMC2130A->begin(); // Initiate pins and registeries
TMC2130A->begin(); // Initiate pins and registeries
TMC2130A->rms_current(160); // Set the required current in mA
TMC2130A->microsteps(0); // Minimum of micro steps needed
TMC2130A->chm(true); // Set the chopper mode to classic const. off time
TMC2130A->diag1_stall(1); // Activate stall diagnostics
TMC2130A->sgt(30); // Set stall detection sensitivity. most -64 to +64 least
TMC2130A->shaft_dir(0); // Set direction
TMC2130A->rms_current(motorCurrent); // Set the required current in mA
TMC2130A->microsteps(0); // Minimum of micro steps needed
TMC2130A->chm(true); // Set the chopper mode to classic const. off time
TMC2130A->diag1_stall(1); // Activate stall diagnostics
TMC2130A->sgt(stallSensitivity); // Set stall detection sensitivity. most -64 to +64 least
TMC2130A->shaft_dir(0); // Set direction
//TMC2130A->SilentStepStick2130(600); // Set stepper current to 600mA
//TMC2130A->stealthChop(1); // Enable extremely quiet stepping
@ -139,14 +139,14 @@ void StepperControlAxis::initTMC2130()
if (channelLabel == 'X')
{
TMC2130B->begin(); // Initiate pins and registeries
TMC2130B->begin(); // Initiate pins and registeries
TMC2130B->rms_current(160); // Set the required current in mA
TMC2130B->microsteps(0); // Minimum of micro steps needed
TMC2130B->chm(true); // Set the chopper mode to classic const. off time
TMC2130B->diag1_stall(1); // Activate stall diagnostics
TMC2130B->sgt(30); // Set stall detection sensitivity. most -64 to +64 least
TMC2130B->shaft_dir(0); // Set direction
TMC2130B->rms_current(motorCurrent); // Set the required current in mA
TMC2130B->microsteps(0); // Minimum of micro steps needed
TMC2130B->chm(true); // Set the chopper mode to classic const. off time
TMC2130B->diag1_stall(1); // Activate stall diagnostics
TMC2130B->sgt(stallSensitivity); // Set stall detection sensitivity. most -64 to +64 least
TMC2130B->shaft_dir(0); // Set direction
//TMC2130B->SilentStepStick2130(600); // Set stepper current to 600mA

View File

@ -92,7 +92,7 @@ public:
bool movementStarted;
#if defined(FARMDUINO_EXP_V20)
void initTMC2130();
void initTMC2130(int motorCurrent, int stallSensitivity);
bool stallDetected();
#endif