Endstop for extramotor does not work


I have an extra motor with an mechanical endstop to change the tools. I use an Arduino Due with the radds board.  The extra motor works well without problems. But with the G203 command to home the extra motor, the endstop triggers, but does not stop the motor. Then I have to reset the printer.

I already tested the endstop for the x-axis with the same settings and there the endstop worked. I also tested it with the X-Max pin, but also the endstop does not trigger.

I hope somebody can help me. I have absolutely no idea what the problem can be.

//#define MOTOR_DRIVER_x StepperDriverWithEndstop<int stepPin, int dirPin, int enablePin,bool invertDir, bool invertEnable,int endstop_pin,
// bool invertEndstop,bool minEndstop, bool endstopPullup> var(float steps per mm,float speed, float max.distance)
#define MOTOR_DRIVER_1(var) StepperDriverWithEndstop<35,33,37,0,1,ORIG_Z_MAX_PIN,0,1,1> var(20,10,110)

Thanks in advance


  • Homing is G205 P0 S0 E0 not G203.

    For clarity, you defined motor range to be 0 - 110 and at 0 you have the min end stop.

    Looking into the code in drivers.h line 125++ I think there is a bug

        void gotoPosition(float newPos) {
            bool up = false;
            if (newPos < 0)
                newPos = 0;
            if (newPos > maxDistance)
                newPos = maxDistance;
            int32_t target = floor(newPos * stepsPerMM + 0.5f) - position;
            position += target;
            if (target > 0) {
                HAL::digitalWrite(dirPin, !invertDir);
            } else {
                target = -target;
                up = true;
                HAL::digitalWrite(dirPin, invertDir);

    is how it should look like. You see I changed the 2 lines with up = to the opposite. Please try that and report if it then works.
  • Thank you for your response.

    I changed the settings in drivers.h, but without success. I have still the same problem

  • Probably endstop is not set up correctly. Go to Drivers.cpp and modify commandG203 so it outputs endstop status. Then test untriggered and triggered what it returns. Also did you wire endstop against gnd? With pullup it must be against gnd to work at all.

    // G203 P<motorId>            - Report current motor position
    void commandG203(GCode& code) {
        int id = 0;
        if (code.hasP())
            id = code.P;
        if (id < 0)
            id = 0;
        if (id >= NUM_MOTOR_DRIVERS)
            id = 0;
        Com::printF(PSTR("Motor"), id);
        Com::printF(PSTR(" Pos:"), motorDrivers[id]->getPosition());
        Com::printFLN(" Endstop Hit:", motorDrivers[id]->endstopHit());

Sign In or Register to comment.