Additional ExtraMotor Gcode

Hi,

I want to add an additional Extramotor Gcode. I implemented the additional code in the Driver.h / Driver.ccp

Driver.h:

[...]

class MotorDriverInterface
{
public:
    virtual void initialize() = 0;
    virtual float getPosition() = 0;
    virtual void setCurrentAs(float newPos) = 0;
    virtual void gotoPosition(float newPos) = 0;
    virtual void enable() = 0;
    virtual void disable() = 0;
    virtual float getEndstopStatus() = 0;
};

/**
Simple class to drive a stepper motor with fixed speed.
*/
template<int stepPin, int dirPin, int enablePin,bool invertDir, bool invertEnable, int endstopPin >
class StepperDriver : public MotorDriverInterface

[...]


#if defined(NUM_MOTOR_DRIVERS) && NUM_MOTOR_DRIVERS > 0
class GCode;
extern void commandG201(GCode &code);
extern void commandG202(GCode &code);
extern void commandG203(GCode &code);
extern void commandG204(GCode &code);
extern void commandG205(GCode &code); //Homing
extern void disableAllMotorDrivers();
extern MotorDriverInterface *getMotorDriver(int idx);
extern void initializeAl
lMotorDrivers();
#endif

and Driver.ccp

[...]

void commandG205(GCode &code)
{
      int id = 0;
    if(code.hasP())
        id = code.P;
    if(id < 0) id = 0;
    if(id >= NUM_MOTOR_DRIVERS) id = 0;
    motorDrivers[id]->setCurrentAs(300);
    while(motorDrivers[id]->getEndstopStatus() == 1){
      for(float i =300; i > 0; i--){
        motorDrivers[id]->gotoPosition(i);
        if(motorDrivers[id]->getEndstopStatus() == 0){
          break;
        }
      }
    }
    motorDrivers[id]->setCurrentAs(0);
}


[...]

But the Problem is, that I can't name it G205, because when I try to start the Gcode in Repetier-Host, it tells me "Unknown command: N14 G205". However when i rename my homing function to G204, which is allready used for the enable/disable the motor, it works how it should be.

Do you have any ideas how to solve this problem?

Thanks in advance

Jpod

Comments

  • Hello Jpod,

    THe Firmware scans the GCode. Also there you need to define your G205 command. Go to Commands.cpp at
    and add your G205 section. Otherwise, of course, the Firmware tells you "Uknown Command" which is defined in 'default:...'

    ########################################################################################
    #if defined(NUM_MOTOR_DRIVERS) && NUM_MOTOR_DRIVERS > 0
            case 201:
                commandG201(*com);
                break;
            case 202:
                commandG202(*com);
                break;
            case 203:
                commandG203(*com);
                break;
            case 204:
                commandG204(*com);
                break;
            default:
                if(!EVENT_UNHANDLED_G_CODE(com) && Printer::debugErrors()) {
                    Com::printF(Com::tUnknownCommand);
                    com->printCommand();
                }

    ########################################################################################

    What is N14? I am not sure that the Firmware will interprete this correctly.

    Hope this helps you.
    Ben
  • Thanks man!

    After I added the G205 command to the commands.cpp, it works :-)
    You helped me so much!

    N14 was a command which Repetierhost writes in the command line. I don't now, what this command is used for.

    Thanks
    Jpod
Sign In or Register to comment.