Implementing G-code procedures in the firmware
Hi all,
I have a question I couldn't the answer to with the search function. The thing is that the printer I have to control needs some special procedures for homing, changing the toolheads, calibrating extruders, calibrating the HBP and more.
For example the procedure for homing is as follows:
G28 Y ; Home Y BEFORE X, this is very important
G1 Y-3.0 ; This is needed for the X to be homed, because the magnet that is detected by the hall sensor is on the Y gantry
G28 X ; Home X
G28 Z ; Home Z
G1 Y-10.0 F2400 ; Move to the fysical zero position
G92 X0 Y0 Z0 ; Set the zero position of the printer to the current position
Of course, the printer has to execute all of this code when the user presses "Home all" in simplify3D, or any other gcode sender for that matter. This might be possible by editing some of the definitions in configuration.h (although I doubt it) but it would be way easier if I could kind of "hook" this code to the G28 (home all) command. This is because I have to implement more procedures and digging into the firmware to implement all of them would be really cumbersome while I already have the gcodes corresponding to the procedures.
So my real question is:
Can I replace a command the arduino receives by a series of other commands?
Comments
Intuitively I would do it like this:
G1(Y,-3);
G28(X);
// etcetera
But that would give me errors.
GCode::executeFString(PSTR("G28 Y0"));
The onyl command you are not allowed to use is your own, so if case 28: means G28 you can not use G28 in the command as it would call yourself instead making a recusion until firmware crash.
thank you again! I implemented it by changing 28 to 50028. Next, when the board receives a G28 query it automatically sends the corresponding G50028 commands. Works like a charm !