Welcome! Log In Create A New Profile

Advanced

Manual leveling bed routine

Posted by tiwanacote 
Manual leveling bed routine
October 07, 2015 04:18PM
Hi!

I'm looking to implement a manual calibration bed routine quick and simple from the LCD menu. I am seeking the printer go from pre-setted 4 points to points only by pressing the OK button. Thats why 90% of my prints are from SD card, mainly because use the machine in a garage and don´t want to smell ABS odors.

(The main question for those who know about firmware code is at the end of post)


This was what I coded...



In Configuration.h:

// Define 4 points on bed
#define MANUALBEDCALIBRATION_X1 10
#define MANUALBEDCALIBRATION_Y1 10
#define MANUALBEDCALIBRATION_X2 10
#define MANUALBEDCALIBRATION_Y2 180
#define MANUALBEDCALIBRATION_X3 180
#define MANUALBEDCALIBRATION_Y3 180
#define MANUALBEDCALIBRATION_X4 180
#define MANUALBEDCALIBRATION_Y4 10
#define MANUALBEDCALIBRATION_ZOUT 5 // It is to ward off the platform to prevent collision in the first movement

Into uilang.h:

// Some text for user
#define UI_TEXT_WIZ_BED_CAL1 "Adjust bed"
#define UI_TEXT_WIZ_BED_CAL2 "screw using a paper"
#define UI_TEXT_WIZ_BED_CAL3 "Then press OK to next
#define UI_TEXT_BED_CALIBRATION "Bed calibration"

In uimenu.h:

// Show text into LCD after extruder reached points
#if UI_ROWS >= 4
UI_WIZARD_BED_CAL(ui_wiz_bed_calibration, UI_ACTION_BED_CALIBRATION, UI_TEXT_WIZ_BED_CAL1, UI_TEXT_WIZ_BED_CAL2, UI_TEXT_WIZ_BED_CAL3, UI_TEXT_CLICK_DONE)
#else
UI_WIZARD_BED_CAL(ui_wiz_bed_calibration, UI_ACTION_BED_CALIBRATION, UI_TEXT_WIZ_BED_CAL1, UI_TEXT_CLICK_DONE)
#endif

// Add a new menu action entry INTO "Quick menu". When user select "Bed calibration" set action
UI_MENU_ACTIONCOMMAND_FILTER(ui_menu_bed_calibration,UI_TEXT_BED_CALIBRATION,UI_ACTION_BED_CALIBRATION,0,MENU_MODE_PRINTING)
#define UI_BED_CALIBRATION ,&ui_menu_bed_calibration
#define UI_BED_CALIBRATION_COUNT 1

// Modify this two lines (Add UI_BED_CALIBRATION and UI_BED_CALIBRATION_COUNT)
#define UI_MENU_QUICK {UI_MENU_ADDCONDBACK &ui_menu_home_all BABY_ENTRY ,&ui_menu_quick_speedmultiply,&ui_menu_quick_flowmultiply UI_BED_CALIBRATION UI_TOOGLE_LIGHT_ENTRY UI_CHANGE_FIL_ENT,&ui_menu_quick_preheat_pla,&ui_menu_quick_preheat_abs,&ui_menu_quick_cooldown,&ui_menu_quick_origin,&ui_menu_quick_stopstepper MENU_PSON_ENTRY DEBUG_PRINT_EXTRA}
UI_MENU(ui_menu_quick,UI_MENU_QUICK,8+BABY_CNT+UI_MENU_BACKCNT+MENU_PSON_COUNT+DEBUG_PRINT_COUNT+UI_TOGGLE_LIGHT_COUNT+UI_CHANGE_FIL_CNT+UI_BED_CALIBRATION_COUNT)

in ui.cpp:

// Implement it in the okAction function as one case
case UI_ACTION_BED_CALIBRATION:
if(!allowMoves) return false;
GCode::executeFString(PSTR("G28 X0 Y0 Z0")); // Home axis X and Y
Printer::setOrigin(0, 0, 0); // Now this is the new (0,0) coords
GCode::executeFString(PSTR("G90")); // Set absolute coordinates
Printer::moveToReal(0, 0, MANUALBEDCALIBRATION_ZOUT, 0, Printer::homingFeedrate[Z_AXIS]); // Ward off the platform to prevent collision in the first movement
Printer::moveToReal(MANUALBEDCALIBRATION_X1, MANUALBEDCALIBRATION_Y1, 0, 0, Printer::homingFeedrate[Z_AXIS]);
pushMenu(&ui_wiz_bed_calibration, true); // Imprime en la pantalla




Until here I get to the first movement to point 1

A) First question: Could someone explain me in simple words how is defined "mtype"? And the IF condition to be added in int UIDisplay : : okAction(bool allowMoves) is equal to?

B ) Wich is the best way to continue and implement what I´m looking for?

Regards
Re: Manual leveling bed routine
October 08, 2015 02:30AM
Wizards are pages where you can listen to next/previous and ok events. So you have to decide how you want to do it. Simplest is to have 4 pages - one for each point and for each "ok" action you do

popMenu(false);
            pushMenu(&ui_wiz_jamwaitheat, true);

to switch between pages and also move to next point.

mtype is menuType whcih is set to 5 = WIzard page. Defines how the pages are shown. Here more interesting is the action contained which is used to distinguish between all the pages or action in executeAction.


Repetier-Software - the home of Repetier-Host (Windows, Linux and Mac OS X) and Repetier-Firmware.
Repetier-Server - the solution to control your printer from everywhere.
Visit us on Facebook and Twitter!
Re: Manual leveling bed routine
October 15, 2015 03:57PM
Thanks!

The final implementation for those interested to get into the firmware is:


In Configuration.h:

// Define 4 points on bed
#define FEATURE_MANUALBEDCALIBRATION 1
#define MANUALBEDCALIBRATION_X1 70
#define MANUALBEDCALIBRATION_Y1 30
#define MANUALBEDCALIBRATION_X2 70
#define MANUALBEDCALIBRATION_Y2 160
#define MANUALBEDCALIBRATION_X3 220
#define MANUALBEDCALIBRATION_Y3 160
#define MANUALBEDCALIBRATION_X4 220
#define MANUALBEDCALIBRATION_Y4 30
#define MANUALBEDCALIBRATION_ZOUT 5 // It is to ward off the platform to prevent collision in the first movement


Into uilang.h:

// Into your language option
#define UI_TEXT_BED_CALIBRATION "Bed calibration"
#define UI_TEXT_WIZ_BED_CAL21 "Press next"
#define UI_TEXT_WIZ_BED_CAL22 "point P2"
#define UI_TEXT_WIZ_BED_CAL23 " < OK > "

#define UI_TEXT_WIZ_BED_CAL31 "Press next"
#define UI_TEXT_WIZ_BED_CAL32 "point P3"
#define UI_TEXT_WIZ_BED_CAL33 " < OK > "

#define UI_TEXT_WIZ_BED_CAL41 "Press next"
#define UI_TEXT_WIZ_BED_CAL42 "point P4"
#define UI_TEXT_WIZ_BED_CAL43 " < OK > "

#define UI_TEXT_WIZ_BED_CALRET1 "Press next"
#define UI_TEXT_WIZ_BED_CALRET2 "Return"
#define UI_TEXT_WIZ_BED_CALRET3 " < OK > "

#define UI_TEXT_WIZ_MOVING_1 " "
#define UI_TEXT_WIZ_MOVING_2 "Moviendo..."
#define UI_TEXT_WIZ_MOVING_3 " "
#define UI_TEXT_NOTHING " "



In uimenu.h:

// After...
#if FEATURE_RETRACTION
#if UI_ROWS >= 4
...
...
#endif


#if FEATURE_MANUALBEDCALIBRATION
#if UI_ROWS >= 4
UI_WIZARD4(ui_wiz_bed_calibration_p2, UI_ACTION_BED_CALIBRATION_P1, UI_TEXT_WIZ_BED_CAL21, UI_TEXT_WIZ_BED_CAL22, UI_TEXT_WIZ_BED_CAL23, UI_TEXT_CLICK_DONE)
UI_WIZARD4(ui_wiz_bed_calibration_p3, UI_ACTION_BED_CALIBRATION_P2, UI_TEXT_WIZ_BED_CAL31, UI_TEXT_WIZ_BED_CAL32, UI_TEXT_WIZ_BED_CAL33, UI_TEXT_CLICK_DONE)
UI_WIZARD4(ui_wiz_bed_calibration_p4, UI_ACTION_BED_CALIBRATION_P3, UI_TEXT_WIZ_BED_CAL41, UI_TEXT_WIZ_BED_CAL42, UI_TEXT_WIZ_BED_CAL43, UI_TEXT_CLICK_DONE)
UI_WIZARD4(ui_wiz_bed_calibration_return, UI_ACTION_BED_CALIBRATION_RETURN, UI_TEXT_WIZ_BED_CALRET1, UI_TEXT_WIZ_BED_CALRET2, UI_TEXT_WIZ_BED_CALRET3, UI_TEXT_CLICK_DONE)

#else
UI_WIZARD4(ui_wiz_bed_calibration_p2, UI_ACTION_BED_CALIBRATION_P1, UI_TEXT_WIZ_BED_CAL21, UI_TEXT_CLICK_DONE)
UI_WIZARD4(ui_wiz_bed_calibration_p3, UI_ACTION_BED_CALIBRATION_P2, UI_TEXT_WIZ_BED_CAL31, UI_TEXT_CLICK_DONE)
UI_WIZARD4(ui_wiz_bed_calibration_p4, UI_ACTION_BED_CALIBRATION_P3, UI_TEXT_WIZ_BED_CAL41, UI_TEXT_CLICK_DONE)
UI_WIZARD4(ui_wiz_bed_calibration_return, UI_ACTION_BED_CALIBRATION_RETURN, UI_TEXT_WIZ_BED_CALRET1, UI_TEXT_CLICK_DONE)
#endif
#endif


#if UI_ROWS >= 4
UI_WIZARD4(ui_wiz_moving, UI_ACTION_MOVING, UI_TEXT_WIZ_MOVING_1, UI_TEXT_WIZ_MOVING_2, UI_TEXT_WIZ_MOVING_3, UI_TEXT_NOTHING)
#else
UI_WIZARD2(ui_wiz_moving, UI_ACTION_MOVING, UI_TEXT_MOVING_1, UI_TEXT_NOTHING)
#endif

// After actions...:
UI_MENU_ACTIONCOMMAND(ui_menu_quick_preheat_pla,UI_TEXT_PREHEAT_PLA,UI_ACTION_PREHEAT_PLA)
UI_MENU_ACTIONCOMMAND(ui_menu_quick_preheat_abs,UI_TEXT_PREHEAT_ABS,UI_ACTION_PREHEAT_ABS)



UI_MENU_ACTIONCOMMAND_FILTER(ui_menu_bed_calibration,UI_TEXT_BED_CALIBRATION,UI_ACTION_BED_CALIBRATION,0,MENU_MODE_PRINTING)
#define UI_BED_CALIBRATION ,&ui_menu_bed_calibration
#define UI_BED_CALIBRATION_COUNT 1

// Add red words
//#define UI_MENU_QUICK {UI_MENU_ADDCONDBACK &ui_menu_home_all BABY_ENTRY ,&ui_menu_quick_speedmultiply,&ui_menu_quick_flowmultiply UI_BED_CALIBRATION UI_TOOGLE_LIGHT_ENTRY
UI_CHANGE_FIL_ENT,&ui_menu_quick_preheat_pla,&ui_menu_quick_preheat_abs,&ui_menu_quick_cooldown,&ui_menu_quick_origin,&ui_menu_quick_stopstepper MENU_PSON_ENTRY DEBUG_PRINT_EXTRA}
//UI_MENU(ui_menu_quick,UI_MENU_QUICK,8+BABY_CNT+UI_MENU_BACKCNT+MENU_PSON_COUNT+DEBUG_PRINT_COUNT+UI_TOGGLE_LIGHT_COUNT+UI_CHANGE_FIL_CNT +UI_BED_CALIBRATION_COUNT)


in ui.cpp:

// In int UIDisplay : : okAction(bool allowMoves)

#if FEATURE_MANUALBEDCALIBRATION
case UI_ACTION_BED_CALIBRATION_P1: // Calibrating P1 is finished
//if(!allowMoves) return false;
popMenu(false);
pushMenu(&ui_wiz_moving, true); // Print moving...
Printer::moveToReal(MANUALBEDCALIBRATION_X2, MANUALBEDCALIBRATION_Y2, 0, 0, Printer::homingFeedrate[X_AXIS]);
Commands::waitUntilEndOfAllMoves();
pushMenu(&ui_wiz_bed_calibration_p3, true);
break;
case UI_ACTION_BED_CALIBRATION_P2: // Calibrating P2 is finished
//if(!allowMoves) return false;
popMenu(false);
pushMenu(&ui_wiz_moving, true); // Print moving...
Printer::moveToReal(MANUALBEDCALIBRATION_X3, MANUALBEDCALIBRATION_Y3, 0, 0, Printer::homingFeedrate[X_AXIS]);
Commands::waitUntilEndOfAllMoves();
pushMenu(&ui_wiz_bed_calibration_p4, true);
break;
case UI_ACTION_BED_CALIBRATION_P3: // Calibrating P3 is finished
//if(!allowMoves) return false;
popMenu(false);
pushMenu(&ui_wiz_moving, true); // Print moving...
Printer::moveToReal(MANUALBEDCALIBRATION_X4, MANUALBEDCALIBRATION_Y4, 0, 0, Printer::homingFeedrate[X_AXIS]);
Commands::waitUntilEndOfAllMoves();
pushMenu(&ui_wiz_bed_calibration_return, true);
break;
case UI_ACTION_BED_CALIBRATION_RETURN:
//if(!allowMoves) return false;
popMenu(false);
pushMenu(&ui_wiz_moving, true); // Print moving...
Printer::moveToReal(0, 0, 0, 0, Printer::homingFeedrate[X_AXIS]);
Commands::waitUntilEndOfAllMoves();
popMenu(true);

break;
#endif



// Next, in int UIDisplay : : executeAction(int action, bool allowMoves)

case UI_ACTION_BED_CALIBRATION:
if(!allowMoves) return false;
popMenu(false);
pushMenu(&ui_wiz_moving, true); // Imprime en la pantalla: Moviendo...
GCode::executeFString(PSTR("G28 X0 Y0 Z0"));
Printer::setOrigin(0, 0, 0);
GCode::executeFString(PSTR("G90")); // Set absolute coordinates - por las dudas
Printer::moveToReal(0, 0, MANUALBEDCALIBRATION_ZOUT, 0, Printer::homingFeedrate[X_AXIS]);
Printer::moveToReal(MANUALBEDCALIBRATION_X1, MANUALBEDCALIBRATION_Y1, 0, 0, Printer::homingFeedrate[X_AXIS]);
Commands::waitUntilEndOfAllMoves();
pushMenu(&ui_wiz_bed_calibration_p2, true); // Imprime en la pantalla: Ir al P2
break;



In ui.h:


#define UI_ACTION_BED_CALIBRATION 1205
#define UI_ACTION_BED_CALIBRATION_P1 1206 // SOME OF THEM MAY BE GOES INTO WIZARd
#define UI_ACTION_BED_CALIBRATION_P2 1207
#define UI_ACTION_BED_CALIBRATION_P3 1208
#define UI_ACTION_BED_CALIBRATION_RETURN 1209
#define UI_ACTION_MOVING 1210



Then look for this UI_MATRIX (in all code ) and add:

#define UI_MATRIX_ACTIONS {UI_ACTION_HOME_ALL, UI_ACTION_TOP_MENU, UI_ACTION_SET_ORIGIN, UI_ACTION_BED_CALIBRATION, UI_ACTION_BED_CALIBRATION_P1, UI_ACTION_BED_CALIBRATION_P2, UI_ACTION_BED_CALIBRATION_P3, UI_ACTION_BED_CALIBRATION_RETURN, UI_ACTION_MOVING, UI_ACTION_NEXT,\
UI_ACTION_HOME_Z, UI_ACTION_MENU_ZPOS, UI_ACTION_COOLDOWN, UI_ACTION_OK,\
UI_ACTION_HOME_Y, UI_ACTION_MENU_YPOSFAST, UI_ACTION_PREHEAT_ABS, UI_ACTION_PREVIOUS,\
UI_ACTION_HOME_X, UI_ACTION_MENU_XPOSFAST, UI_ACTION_DISABLE_STEPPER, UI_ACTION_BACK}



Regards

Tiwanacote
Sorry, only registered users may post in this forum.

Click here to login