Experimental interrupt
parent
6222f77016
commit
a3b62463e3
|
@ -38,7 +38,7 @@ const int COMM_REPORT_CALIBRATE_STATUS_TO_HOME = 1;
|
|||
const int COMM_REPORT_CALIBRATE_STATUS_TO_END = 2;
|
||||
const int COMM_REPORT_CALIBRATE_STATUS_ERROR = -1;
|
||||
|
||||
const int MOVEMENT_INTERRUPT_SPEED = 200; // Interrupt cycle in micro seconds
|
||||
const int MOVEMENT_INTERRUPT_SPEED = 100; // Interrupt cycle in micro seconds
|
||||
|
||||
const unsigned int MOVEMENT_SPEED_BASE_TIME = 2000;
|
||||
const unsigned int MOVEMENT_DELAY = 250;
|
||||
|
|
|
@ -308,6 +308,19 @@ int StepperControl::moveToCoords(long xDest, long yDest, long zDest,
|
|||
checkAxisSubStatus(&axisY, &axisSubStep[1]);
|
||||
checkAxisSubStatus(&axisZ, &axisSubStep[2]);
|
||||
|
||||
if (axisX.isStepDone())
|
||||
{
|
||||
axisX.checkMovement();
|
||||
axisY.checkMovement();
|
||||
axisZ.checkMovement();
|
||||
|
||||
//checkAxisVsEncoder(&axisX, &encoderX, &motorConsMissedSteps[0], &motorLastPosition[0], &motorConsEncoderLastPosition[0], &motorConsEncoderUseForPos[0], &motorConsMissedStepsDecay[0], &motorConsEncoderEnabled[0]);
|
||||
//checkAxisVsEncoder(&axisY, &encoderY, &motorConsMissedSteps[1], &motorLastPosition[1], &motorConsEncoderLastPosition[1], &motorConsEncoderUseForPos[1], &motorConsMissedStepsDecay[1], &motorConsEncoderEnabled[1]);
|
||||
//checkAxisVsEncoder(&axisZ, &encoderZ, &motorConsMissedSteps[2], &motorLastPosition[2], &motorConsEncoderLastPosition[2], &motorConsEncoderUseForPos[2], &motorConsMissedStepsDecay[2], &motorConsEncoderEnabled[2]);
|
||||
|
||||
axisX.resetStepDone();
|
||||
}
|
||||
|
||||
if (debugInterrupt)
|
||||
{
|
||||
delayMicroseconds(100);
|
||||
|
@ -887,7 +900,6 @@ int StepperControl::calibrateAxis(int axis)
|
|||
// Handle movement by checking each axis
|
||||
void StepperControl::handleMovementInterrupt(void)
|
||||
{
|
||||
|
||||
encoderX.readEncoder();
|
||||
encoderY.readEncoder();
|
||||
encoderZ.readEncoder();
|
||||
|
@ -895,10 +907,6 @@ void StepperControl::handleMovementInterrupt(void)
|
|||
axisX.checkTiming();
|
||||
axisY.checkTiming();
|
||||
axisZ.checkTiming();
|
||||
|
||||
checkAxisVsEncoder(&axisX, &encoderX, &motorConsMissedSteps[0], &motorLastPosition[0], &motorConsEncoderLastPosition[0], &motorConsEncoderUseForPos[0], &motorConsMissedStepsDecay[0], &motorConsEncoderEnabled[0]);
|
||||
checkAxisVsEncoder(&axisY, &encoderY, &motorConsMissedSteps[1], &motorLastPosition[1], &motorConsEncoderLastPosition[1], &motorConsEncoderUseForPos[1], &motorConsMissedStepsDecay[1], &motorConsEncoderEnabled[1]);
|
||||
checkAxisVsEncoder(&axisZ, &encoderZ, &motorConsMissedSteps[2], &motorLastPosition[2], &motorConsEncoderLastPosition[2], &motorConsEncoderUseForPos[2], &motorConsMissedStepsDecay[2], &motorConsEncoderEnabled[2]);
|
||||
}
|
||||
|
||||
int debugPrintCount = 0;
|
||||
|
|
|
@ -266,7 +266,7 @@ void StepperControlAxis::checkTiming()
|
|||
|
||||
// Negative flank for the steps
|
||||
resetMotorStep();
|
||||
checkMovement();
|
||||
/**/ // checkMovement();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -38,6 +38,12 @@ void blinkLed()
|
|||
// - encoders
|
||||
// - pin guard
|
||||
//
|
||||
|
||||
unsigned long interruptStartTime = 0;
|
||||
unsigned long interruptStopTime = 0;
|
||||
unsigned long interruptDuration = 0;
|
||||
unsigned long interruptDurationMax = 0;
|
||||
|
||||
bool interruptBusy = false;
|
||||
int interruptSecondTimer = 0;
|
||||
void interrupt(void)
|
||||
|
@ -48,6 +54,7 @@ void interrupt(void)
|
|||
|
||||
if (interruptBusy == false)
|
||||
{
|
||||
interruptStartTime = micros();
|
||||
|
||||
interruptBusy = true;
|
||||
StepperControl::getInstance()->handleMovementInterrupt();
|
||||
|
@ -60,6 +67,18 @@ void interrupt(void)
|
|||
//blinkLed();
|
||||
}
|
||||
|
||||
interruptStopTime = micros();
|
||||
|
||||
if (interruptStopTime > interruptStartTime)
|
||||
{
|
||||
interruptDuration = interruptStopTime - interruptStartTime;
|
||||
}
|
||||
|
||||
if (interruptDuration > interruptDurationMax)
|
||||
{
|
||||
interruptDurationMax = interruptDuration;
|
||||
}
|
||||
|
||||
interruptBusy = false;
|
||||
}
|
||||
}
|
||||
|
@ -146,6 +165,8 @@ void setup()
|
|||
{
|
||||
StepperControl::getInstance()->moveToCoords(0, 0, 0, 0, 0, 0, false, false, true);
|
||||
}
|
||||
|
||||
Serial.print("R99 ARDUINO STARTUP \r\n");
|
||||
}
|
||||
|
||||
// The loop function is called in an endless loop
|
||||
|
@ -187,6 +208,7 @@ void loop()
|
|||
|
||||
if (incomingChar == '\n' || incomingCommandPointer >= INCOMING_CMD_BUF_SIZE)
|
||||
{
|
||||
/**/ interruptDurationMax = 0;
|
||||
|
||||
char commandChar[incomingCommandPointer + 1];
|
||||
for (int i = 0; i < incomingCommandPointer - 1; i++)
|
||||
|
@ -242,9 +264,12 @@ void loop()
|
|||
{
|
||||
lastParamChangeNr = ParameterList::getInstance()->paramChangeNumber();
|
||||
|
||||
Serial.print(COMM_REPORT_COMMENT);
|
||||
Serial.print(" loading parameters ");
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
if (debugMessages)
|
||||
{
|
||||
Serial.print(COMM_REPORT_COMMENT);
|
||||
Serial.print(" loading parameters");
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
}
|
||||
|
||||
StepperControl::getInstance()->loadSettings();
|
||||
PinGuard::getInstance()->loadConfig();
|
||||
|
@ -297,6 +322,13 @@ void loop()
|
|||
Serial.print(freeMemory());
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
|
||||
Serial.print(COMM_REPORT_COMMENT);
|
||||
Serial.print(" IND DUR ");
|
||||
Serial.print(interruptDuration);
|
||||
Serial.print(" MAX ");
|
||||
Serial.print(interruptDurationMax);
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
|
||||
Serial.print(COMM_REPORT_COMMENT);
|
||||
Serial.print(" Cycle ");
|
||||
Serial.print(cycleCounter);
|
||||
|
|
|
@ -173,7 +173,7 @@
|
|||
</ImportGroup>
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<UserProperties vm.programmer_name="avrisp" arduino.upload.port="COM3" />
|
||||
<UserProperties vm.programmer_name="avrisp" arduino.upload.port="COM4" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
Loading…
Reference in New Issue