From 995766fd012139a8894e13d8b323e8d2e82410c2 Mon Sep 17 00:00:00 2001 From: Ludwig Petrosyan Date: Thu, 8 Feb 2018 11:34:43 +0100 Subject: [PATCH 01/13] create grbl_lcd --- {grbl => grbl_lcd}/config.h | 0 {grbl => grbl_lcd}/coolant_control.c | 0 {grbl => grbl_lcd}/coolant_control.h | 0 {grbl => grbl_lcd}/cpu_map.h | 0 {grbl => grbl_lcd}/defaults.h | 0 {grbl => grbl_lcd}/eeprom.c | 0 {grbl => grbl_lcd}/eeprom.h | 0 {grbl => grbl_lcd}/examples/grblUpload/grblUpload.ino | 0 {grbl => grbl_lcd}/examples/grblUpload/license.txt | 0 {grbl => grbl_lcd}/gcode.c | 0 {grbl => grbl_lcd}/gcode.h | 0 {grbl => grbl_lcd}/grbl.h | 0 {grbl => grbl_lcd}/jog.c | 0 {grbl => grbl_lcd}/jog.h | 0 {grbl => grbl_lcd}/limits.c | 0 {grbl => grbl_lcd}/limits.h | 0 {grbl => grbl_lcd}/main.c | 0 {grbl => grbl_lcd}/motion_control.c | 0 {grbl => grbl_lcd}/motion_control.h | 0 {grbl => grbl_lcd}/nuts_bolts.c | 0 {grbl => grbl_lcd}/nuts_bolts.h | 0 {grbl => grbl_lcd}/planner.c | 0 {grbl => grbl_lcd}/planner.h | 0 {grbl => grbl_lcd}/print.c | 0 {grbl => grbl_lcd}/print.h | 0 {grbl => grbl_lcd}/probe.c | 0 {grbl => grbl_lcd}/probe.h | 0 {grbl => grbl_lcd}/protocol.c | 0 {grbl => grbl_lcd}/protocol.h | 0 {grbl => grbl_lcd}/report.c | 0 {grbl => grbl_lcd}/report.h | 0 {grbl => grbl_lcd}/serial.c | 0 {grbl => grbl_lcd}/serial.h | 0 {grbl => grbl_lcd}/settings.c | 0 {grbl => grbl_lcd}/settings.h | 0 {grbl => grbl_lcd}/sleep.c | 0 {grbl => grbl_lcd}/sleep.h | 0 {grbl => grbl_lcd}/spindle_control.c | 0 {grbl => grbl_lcd}/spindle_control.h | 0 {grbl => grbl_lcd}/stepper.c | 0 {grbl => grbl_lcd}/stepper.h | 0 {grbl => grbl_lcd}/system.c | 0 {grbl => grbl_lcd}/system.h | 0 43 files changed, 0 insertions(+), 0 deletions(-) rename {grbl => grbl_lcd}/config.h (100%) rename {grbl => grbl_lcd}/coolant_control.c (100%) rename {grbl => grbl_lcd}/coolant_control.h (100%) rename {grbl => grbl_lcd}/cpu_map.h (100%) rename {grbl => grbl_lcd}/defaults.h (100%) rename {grbl => grbl_lcd}/eeprom.c (100%) rename {grbl => grbl_lcd}/eeprom.h (100%) rename {grbl => grbl_lcd}/examples/grblUpload/grblUpload.ino (100%) rename {grbl => grbl_lcd}/examples/grblUpload/license.txt (100%) rename {grbl => grbl_lcd}/gcode.c (100%) rename {grbl => grbl_lcd}/gcode.h (100%) rename {grbl => grbl_lcd}/grbl.h (100%) rename {grbl => grbl_lcd}/jog.c (100%) rename {grbl => grbl_lcd}/jog.h (100%) rename {grbl => grbl_lcd}/limits.c (100%) rename {grbl => grbl_lcd}/limits.h (100%) rename {grbl => grbl_lcd}/main.c (100%) rename {grbl => grbl_lcd}/motion_control.c (100%) rename {grbl => grbl_lcd}/motion_control.h (100%) rename {grbl => grbl_lcd}/nuts_bolts.c (100%) rename {grbl => grbl_lcd}/nuts_bolts.h (100%) rename {grbl => grbl_lcd}/planner.c (100%) rename {grbl => grbl_lcd}/planner.h (100%) rename {grbl => grbl_lcd}/print.c (100%) rename {grbl => grbl_lcd}/print.h (100%) rename {grbl => grbl_lcd}/probe.c (100%) rename {grbl => grbl_lcd}/probe.h (100%) rename {grbl => grbl_lcd}/protocol.c (100%) rename {grbl => grbl_lcd}/protocol.h (100%) rename {grbl => grbl_lcd}/report.c (100%) rename {grbl => grbl_lcd}/report.h (100%) rename {grbl => grbl_lcd}/serial.c (100%) rename {grbl => grbl_lcd}/serial.h (100%) rename {grbl => grbl_lcd}/settings.c (100%) rename {grbl => grbl_lcd}/settings.h (100%) rename {grbl => grbl_lcd}/sleep.c (100%) rename {grbl => grbl_lcd}/sleep.h (100%) rename {grbl => grbl_lcd}/spindle_control.c (100%) rename {grbl => grbl_lcd}/spindle_control.h (100%) rename {grbl => grbl_lcd}/stepper.c (100%) rename {grbl => grbl_lcd}/stepper.h (100%) rename {grbl => grbl_lcd}/system.c (100%) rename {grbl => grbl_lcd}/system.h (100%) diff --git a/grbl/config.h b/grbl_lcd/config.h similarity index 100% rename from grbl/config.h rename to grbl_lcd/config.h diff --git a/grbl/coolant_control.c b/grbl_lcd/coolant_control.c similarity index 100% rename from grbl/coolant_control.c rename to grbl_lcd/coolant_control.c diff --git a/grbl/coolant_control.h b/grbl_lcd/coolant_control.h similarity index 100% rename from grbl/coolant_control.h rename to grbl_lcd/coolant_control.h diff --git a/grbl/cpu_map.h b/grbl_lcd/cpu_map.h similarity index 100% rename from grbl/cpu_map.h rename to grbl_lcd/cpu_map.h diff --git a/grbl/defaults.h b/grbl_lcd/defaults.h similarity index 100% rename from grbl/defaults.h rename to grbl_lcd/defaults.h diff --git a/grbl/eeprom.c b/grbl_lcd/eeprom.c similarity index 100% rename from grbl/eeprom.c rename to grbl_lcd/eeprom.c diff --git a/grbl/eeprom.h b/grbl_lcd/eeprom.h similarity index 100% rename from grbl/eeprom.h rename to grbl_lcd/eeprom.h diff --git a/grbl/examples/grblUpload/grblUpload.ino b/grbl_lcd/examples/grblUpload/grblUpload.ino similarity index 100% rename from grbl/examples/grblUpload/grblUpload.ino rename to grbl_lcd/examples/grblUpload/grblUpload.ino diff --git a/grbl/examples/grblUpload/license.txt b/grbl_lcd/examples/grblUpload/license.txt similarity index 100% rename from grbl/examples/grblUpload/license.txt rename to grbl_lcd/examples/grblUpload/license.txt diff --git a/grbl/gcode.c b/grbl_lcd/gcode.c similarity index 100% rename from grbl/gcode.c rename to grbl_lcd/gcode.c diff --git a/grbl/gcode.h b/grbl_lcd/gcode.h similarity index 100% rename from grbl/gcode.h rename to grbl_lcd/gcode.h diff --git a/grbl/grbl.h b/grbl_lcd/grbl.h similarity index 100% rename from grbl/grbl.h rename to grbl_lcd/grbl.h diff --git a/grbl/jog.c b/grbl_lcd/jog.c similarity index 100% rename from grbl/jog.c rename to grbl_lcd/jog.c diff --git a/grbl/jog.h b/grbl_lcd/jog.h similarity index 100% rename from grbl/jog.h rename to grbl_lcd/jog.h diff --git a/grbl/limits.c b/grbl_lcd/limits.c similarity index 100% rename from grbl/limits.c rename to grbl_lcd/limits.c diff --git a/grbl/limits.h b/grbl_lcd/limits.h similarity index 100% rename from grbl/limits.h rename to grbl_lcd/limits.h diff --git a/grbl/main.c b/grbl_lcd/main.c similarity index 100% rename from grbl/main.c rename to grbl_lcd/main.c diff --git a/grbl/motion_control.c b/grbl_lcd/motion_control.c similarity index 100% rename from grbl/motion_control.c rename to grbl_lcd/motion_control.c diff --git a/grbl/motion_control.h b/grbl_lcd/motion_control.h similarity index 100% rename from grbl/motion_control.h rename to grbl_lcd/motion_control.h diff --git a/grbl/nuts_bolts.c b/grbl_lcd/nuts_bolts.c similarity index 100% rename from grbl/nuts_bolts.c rename to grbl_lcd/nuts_bolts.c diff --git a/grbl/nuts_bolts.h b/grbl_lcd/nuts_bolts.h similarity index 100% rename from grbl/nuts_bolts.h rename to grbl_lcd/nuts_bolts.h diff --git a/grbl/planner.c b/grbl_lcd/planner.c similarity index 100% rename from grbl/planner.c rename to grbl_lcd/planner.c diff --git a/grbl/planner.h b/grbl_lcd/planner.h similarity index 100% rename from grbl/planner.h rename to grbl_lcd/planner.h diff --git a/grbl/print.c b/grbl_lcd/print.c similarity index 100% rename from grbl/print.c rename to grbl_lcd/print.c diff --git a/grbl/print.h b/grbl_lcd/print.h similarity index 100% rename from grbl/print.h rename to grbl_lcd/print.h diff --git a/grbl/probe.c b/grbl_lcd/probe.c similarity index 100% rename from grbl/probe.c rename to grbl_lcd/probe.c diff --git a/grbl/probe.h b/grbl_lcd/probe.h similarity index 100% rename from grbl/probe.h rename to grbl_lcd/probe.h diff --git a/grbl/protocol.c b/grbl_lcd/protocol.c similarity index 100% rename from grbl/protocol.c rename to grbl_lcd/protocol.c diff --git a/grbl/protocol.h b/grbl_lcd/protocol.h similarity index 100% rename from grbl/protocol.h rename to grbl_lcd/protocol.h diff --git a/grbl/report.c b/grbl_lcd/report.c similarity index 100% rename from grbl/report.c rename to grbl_lcd/report.c diff --git a/grbl/report.h b/grbl_lcd/report.h similarity index 100% rename from grbl/report.h rename to grbl_lcd/report.h diff --git a/grbl/serial.c b/grbl_lcd/serial.c similarity index 100% rename from grbl/serial.c rename to grbl_lcd/serial.c diff --git a/grbl/serial.h b/grbl_lcd/serial.h similarity index 100% rename from grbl/serial.h rename to grbl_lcd/serial.h diff --git a/grbl/settings.c b/grbl_lcd/settings.c similarity index 100% rename from grbl/settings.c rename to grbl_lcd/settings.c diff --git a/grbl/settings.h b/grbl_lcd/settings.h similarity index 100% rename from grbl/settings.h rename to grbl_lcd/settings.h diff --git a/grbl/sleep.c b/grbl_lcd/sleep.c similarity index 100% rename from grbl/sleep.c rename to grbl_lcd/sleep.c diff --git a/grbl/sleep.h b/grbl_lcd/sleep.h similarity index 100% rename from grbl/sleep.h rename to grbl_lcd/sleep.h diff --git a/grbl/spindle_control.c b/grbl_lcd/spindle_control.c similarity index 100% rename from grbl/spindle_control.c rename to grbl_lcd/spindle_control.c diff --git a/grbl/spindle_control.h b/grbl_lcd/spindle_control.h similarity index 100% rename from grbl/spindle_control.h rename to grbl_lcd/spindle_control.h diff --git a/grbl/stepper.c b/grbl_lcd/stepper.c similarity index 100% rename from grbl/stepper.c rename to grbl_lcd/stepper.c diff --git a/grbl/stepper.h b/grbl_lcd/stepper.h similarity index 100% rename from grbl/stepper.h rename to grbl_lcd/stepper.h diff --git a/grbl/system.c b/grbl_lcd/system.c similarity index 100% rename from grbl/system.c rename to grbl_lcd/system.c diff --git a/grbl/system.h b/grbl_lcd/system.h similarity index 100% rename from grbl/system.h rename to grbl_lcd/system.h From 324ef70c59d7aafc5ccbab490ebe5eeb7d56f5cb Mon Sep 17 00:00:00 2001 From: Ludwig Petrosyan Date: Fri, 9 Feb 2018 16:07:43 +0100 Subject: [PATCH 02/13] added lcd staf --- grbl_lcd/{print.c => cprint.c} | 0 grbl_lcd/{print.h => cprint.h} | 4 +- grbl_lcd/examples/grblUpload/grblUpload.ino | 2 +- grbl_lcd/grbl.h | 4 +- grbl_lcd/lcd.cpp | 84 +++++++++++++++++++++ grbl_lcd/lcd.h | 13 ++++ grbl_lcd/main.c | 10 +++ grbl_lcd/report.c | 6 ++ grbl_lcd/stepper.c | 50 +++++++++++- 9 files changed, 167 insertions(+), 6 deletions(-) rename grbl_lcd/{print.c => cprint.c} (100%) rename grbl_lcd/{print.h => cprint.h} (97%) create mode 100644 grbl_lcd/lcd.cpp create mode 100644 grbl_lcd/lcd.h diff --git a/grbl_lcd/print.c b/grbl_lcd/cprint.c similarity index 100% rename from grbl_lcd/print.c rename to grbl_lcd/cprint.c diff --git a/grbl_lcd/print.h b/grbl_lcd/cprint.h similarity index 97% rename from grbl_lcd/print.h rename to grbl_lcd/cprint.h index 31e0a576c..35ab99fe8 100644 --- a/grbl_lcd/print.h +++ b/grbl_lcd/cprint.h @@ -19,8 +19,8 @@ along with Grbl. If not, see . */ -#ifndef print_h -#define print_h +#ifndef cprint_h +#define cprint_h void printString(const char *s); diff --git a/grbl_lcd/examples/grblUpload/grblUpload.ino b/grbl_lcd/examples/grblUpload/grblUpload.ino index 581b6b3d7..1fb64f7f4 100644 --- a/grbl_lcd/examples/grblUpload/grblUpload.ino +++ b/grbl_lcd/examples/grblUpload/grblUpload.ino @@ -23,7 +23,7 @@ For advanced users: Copyright (c) 2015 Sungeun K. Jeon Released under the MIT-license. See license.txt for details. ***********************************************************************/ - +#include #include // Do not alter this file! diff --git a/grbl_lcd/grbl.h b/grbl_lcd/grbl.h index fc8b8884a..0a97ed10d 100644 --- a/grbl_lcd/grbl.h +++ b/grbl_lcd/grbl.h @@ -21,6 +21,7 @@ #ifndef grbl_h #define grbl_h + // Grbl versioning system #define GRBL_VERSION "1.1f" #define GRBL_VERSION_BUILD "20170802" @@ -52,7 +53,7 @@ #include "limits.h" #include "motion_control.h" #include "planner.h" -#include "print.h" +#include "cprint.h" #include "probe.h" #include "protocol.h" #include "report.h" @@ -61,6 +62,7 @@ #include "stepper.h" #include "jog.h" #include "sleep.h" +#include "lcd.h" // --------------------------------------------------------------------------------------- // COMPILE-TIME ERROR CHECKING OF DEFINE VALUES: diff --git a/grbl_lcd/lcd.cpp b/grbl_lcd/lcd.cpp new file mode 100644 index 000000000..20110521a --- /dev/null +++ b/grbl_lcd/lcd.cpp @@ -0,0 +1,84 @@ + +#include +#include "lcd.h" + +//#ifdef __cplusplus +//extern "C" { +//#endif + + + +// initialize the library by associating any needed LCD interface pin +// with the arduino pin number it is connected to +const int rs = 22, en = 24, d4 = 26, d5 = 28, d6 = 30, d7 = 32; +LiquidCrystal lcd(rs, en, d4, d5, d6, d7); + +void setup_lcd() { + // set up the LCD's number of columns and rows: + lcd.begin(20, 4); + // Print a message to the LCD. + //lcd.print("MXYZ:"); + //lcd.setCursor(0, 1); + //lcd.print("WXYZ:"); + + lcd.setCursor(0, 0); + lcd.print(000.00); + lcd.setCursor(7, 0); + lcd.print(000.00); + lcd.setCursor(14, 0); + lcd.print(000.00); + + //lcd.setCursor(0, 1); + //lcd.print(000.00); + //lcd.setCursor(7, 1); + //lcd.print(000.00); + //lcd.setCursor(14, 1); + //lcd.print(000.00); + + lcd.setCursor(0, 2); + lcd.print("STEP:"); + lcd.setCursor(10, 2); + lcd.print("JOG:"); + lcd.setCursor(0, 3); + lcd.print("hello,CNC!"); +} + +extern "C" void SetUpLCD() +{ + setup_lcd(); +} + +extern "C" void SetCursorLCD(uint8_t i, uint8_t r) +{ + lcd.setCursor(i, r); +} + +extern "C" void PrintLCD(double pos) +{ + lcd.print(pos); +} + +extern "C" void PrintPosLCD(float x, float y, float z) +{ + lcd.setCursor(0, 0); + lcd.print(x); + lcd.setCursor(7, 0); + lcd.print(y); + lcd.setCursor(14, 0); + lcd.print(z); +} + +extern "C" void PrintWcoLCD(float x, float y, float z) +{ + lcd.setCursor(0, 1); + lcd.print(x); + lcd.setCursor(7, 1); + lcd.print(y); + lcd.setCursor(14, 1); + lcd.print(z); +} + + +//#ifdef __cplusplus +//} +//#endif diff --git a/grbl_lcd/lcd.h b/grbl_lcd/lcd.h new file mode 100644 index 000000000..42e53d0af --- /dev/null +++ b/grbl_lcd/lcd.h @@ -0,0 +1,13 @@ +#ifndef lcd_h +#define lcd_h + +//void SetUpLCD(); +void setup_lcd(); + +//extern "C" void SetUpLCD() +//{ + //void setup_lcd(); +//} + + +#endif diff --git a/grbl_lcd/main.c b/grbl_lcd/main.c index 2b5438720..289839d1e 100644 --- a/grbl_lcd/main.c +++ b/grbl_lcd/main.c @@ -66,6 +66,16 @@ int main(void) if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; } #endif + SetUpLCD(); + + SetCursorLCD(0, 1); + PrintLCD(123.45); + SetCursorLCD(7, 1); + PrintLCD(678.91); + SetCursorLCD(14, 1); + PrintLCD(245.76); + PrintPosLCD(123.56, 25.45, 112.33); + // Grbl initialization loop upon power-up or a system abort. For the latter, all processes // will return to this loop to be cleanly re-initialized. for(;;) { diff --git a/grbl_lcd/report.c b/grbl_lcd/report.c index 07598494a..ea7b8e419 100644 --- a/grbl_lcd/report.c +++ b/grbl_lcd/report.c @@ -500,10 +500,15 @@ void report_realtime_status() // Report machine position if (bit_istrue(settings.status_report_mask,BITFLAG_RT_STATUS_POSITION_TYPE)) { printPgmString(PSTR("|MPos:")); + PrintPosLCD((float)print_position[0], (float)print_position[1],(float)print_position[2]); } else { printPgmString(PSTR("|WPos:")); + PrintPosLCD((float)print_position[0], (float)print_position[1],(float)print_position[2]); } + //PrintPosLCD((float)print_position[0], (float)print_position[1],(float)print_position[2]); report_util_axis_values(print_position); + + //PrintPosLCD(123.56, 25.45, 112.33); // Returns planner and serial read buffer states. #ifdef REPORT_FIELD_BUFFER_STATE @@ -567,6 +572,7 @@ void report_realtime_status() if (sys.report_ovr_counter == 0) { sys.report_ovr_counter = 1; } // Set override on next report. printPgmString(PSTR("|WCO:")); report_util_axis_values(wco); + // PrintWcoLCD(wco[0], wco[1],wco[2]) } #endif diff --git a/grbl_lcd/stepper.c b/grbl_lcd/stepper.c index d0fc3aa71..ac0e0d089 100644 --- a/grbl_lcd/stepper.c +++ b/grbl_lcd/stepper.c @@ -391,8 +391,11 @@ ISR(TIMER1_COMPA_vect) // Enable step pulse reset timer so that The Stepper Port Reset Interrupt can reset the signal after // exactly settings.pulse_microseconds microseconds, independent of the main Timer1 prescaler. - TCNT0 = st.step_pulse_time; // Reload Timer0 counter - TCCR0B = (1< Date: Tue, 13 Feb 2018 13:09:48 +0100 Subject: [PATCH 03/13] compilation C++ in C extern error fixed --- grbl_lcd/lcd.cpp | 179 +++++++++++++++++++++++++++++++++++++++------ grbl_lcd/lcd.h | 54 +++++++++++++- grbl_lcd/main.c | 11 +-- grbl_lcd/report.c | 47 ++++++++++-- grbl_lcd/stepper.c | 9 +++ grbl_lcd/stepper.h | 2 + 6 files changed, 261 insertions(+), 41 deletions(-) diff --git a/grbl_lcd/lcd.cpp b/grbl_lcd/lcd.cpp index 20110521a..9bba7617c 100644 --- a/grbl_lcd/lcd.cpp +++ b/grbl_lcd/lcd.cpp @@ -10,39 +10,123 @@ // initialize the library by associating any needed LCD interface pin // with the arduino pin number it is connected to -const int rs = 22, en = 24, d4 = 26, d5 = 28, d6 = 30, d7 = 32; -LiquidCrystal lcd(rs, en, d4, d5, d6, d7); +//const int rs = 22, en = 24, d4 = 26, d5 = 28, d6 = 30, d7 = 32; +//LiquidCrystal lcd(rs, en, d4, d5, d6, d7); +const int rs = 52, rw = 50, en = 48, d4 = 46, d5 = 44, d6 = 42, d7 = 40; +LiquidCrystal lcd(rs, rw, en, d4, d5, d6, d7); + + +//extern "C"{ void setup_lcd() { - // set up the LCD's number of columns and rows: lcd.begin(20, 4); - // Print a message to the LCD. - //lcd.print("MXYZ:"); - //lcd.setCursor(0, 1); - //lcd.print("WXYZ:"); - lcd.setCursor(0, 0); + lcd.setCursor(0, 1); lcd.print(000.00); - lcd.setCursor(7, 0); + lcd.setCursor(7, 1); lcd.print(000.00); - lcd.setCursor(14, 0); + lcd.setCursor(14, 1); lcd.print(000.00); - //lcd.setCursor(0, 1); - //lcd.print(000.00); - //lcd.setCursor(7, 1); - //lcd.print(000.00); - //lcd.setCursor(14, 1); - //lcd.print(000.00); - lcd.setCursor(0, 2); + lcd.setCursor(0, 3); lcd.print("STEP:"); - lcd.setCursor(10, 2); + lcd.setCursor(10, 3); lcd.print("JOG:"); - lcd.setCursor(0, 3); - lcd.print("hello,CNC!"); + lcd.setCursor(0, 0); + lcd.print("******"); + lcd.setCursor(7, 0); + lcd.print("F:"); + lcd.setCursor(14, 0); + lcd.print("S:"); +} + + void SetUpLCD() +{ + setup_lcd(); +} + + void SetCursorLCD(uint8_t i, uint8_t r) +{ + lcd.setCursor(i, r); +} + + void PrintLCD(double pos) +{ + lcd.print(pos); +} + + void PrintFeedLCD(float f) +{ + lcd.setCursor(9, 0); + lcd.print(f); + lcd.setCursor(13, 0); + lcd.print(" S:"); +} + + + void PrintPwmLCD(uint16_t f) +{ + lcd.setCursor(16, 0); + lcd.print(" "); + lcd.setCursor(16, 0); + lcd.print(f); +} + + void PrintSpindleLCD(float f) +{ + lcd.setCursor(16, 0); + lcd.print(" "); + lcd.setCursor(16, 0); + lcd.print(f); +} + + void PrintStatusLCD(char* st) +{ + lcd.setCursor(0, 0); + lcd.print(st); +} + + void PrintPosLCD(float x, float y, float z) +{ + lcd.setCursor(0, 1); + lcd.print(x); + lcd.setCursor(7, 1); + lcd.print(y); + lcd.setCursor(14, 1); + lcd.print(z); +} + + void PrintPosLCDX(float x) +{ + lcd.setCursor(0, 1); + lcd.print(x); } + void PrintPosLCDY(float y) +{ + lcd.setCursor(7, 1); + lcd.print(y); +} + + void PrintPosLCDZ(float z) +{ + lcd.setCursor(14, 1); + lcd.print(z); +} + + void PrintWcoLCD(float x, float y, float z) +{ + lcd.setCursor(0, 2); + lcd.print(x); + lcd.setCursor(7, 2); + lcd.print(y); + lcd.setCursor(14, 2); + lcd.print(z); +} + +//} +/* extern "C" void SetUpLCD() { setup_lcd(); @@ -58,26 +142,73 @@ extern "C" void PrintLCD(double pos) lcd.print(pos); } -extern "C" void PrintPosLCD(float x, float y, float z) +extern "C" void PrintFeedLCD(float f) +{ + lcd.setCursor(9, 0); + lcd.print(f); + lcd.setCursor(13, 0); + lcd.print(" S:"); +} + + +extern "C" void PrintPwmLCD(uint16_t f) +{ + lcd.setCursor(16, 0); + lcd.print(" "); + lcd.print(f); +} + +extern "C" void PrintSpindleLCD(float f) +{ + lcd.setCursor(16, 0); + lcd.print(" "); + lcd.print(f); +} + +extern "C" void PrintStatusLCD(char* st) { lcd.setCursor(0, 0); + lcd.print(st); +} + +extern "C" void PrintPosLCD(float x, float y, float z) +{ + lcd.setCursor(0, 1); lcd.print(x); - lcd.setCursor(7, 0); + lcd.setCursor(7, 1); lcd.print(y); - lcd.setCursor(14, 0); + lcd.setCursor(14, 1); lcd.print(z); } -extern "C" void PrintWcoLCD(float x, float y, float z) +extern "C" void PrintPosLCDX(float x) { lcd.setCursor(0, 1); lcd.print(x); +} + +extern "C" void PrintPosLCDY(float y) +{ lcd.setCursor(7, 1); lcd.print(y); +} + +extern "C" void PrintPosLCDZ(float z) +{ lcd.setCursor(14, 1); lcd.print(z); } +extern "C" void PrintWcoLCD(float x, float y, float z) +{ + lcd.setCursor(0, 2); + lcd.print(x); + lcd.setCursor(7, 2); + lcd.print(y); + lcd.setCursor(14, 2); + lcd.print(z); +} +*/ //#ifdef __cplusplus //} diff --git a/grbl_lcd/lcd.h b/grbl_lcd/lcd.h index 42e53d0af..b0d3990d3 100644 --- a/grbl_lcd/lcd.h +++ b/grbl_lcd/lcd.h @@ -1,7 +1,10 @@ #ifndef lcd_h #define lcd_h -//void SetUpLCD(); +#ifdef __cplusplus + extern "C" { +#endif + void setup_lcd(); //extern "C" void SetUpLCD() @@ -10,4 +13,53 @@ void setup_lcd(); //} +/* +extern "C" { +void SetUpLCD(); +void SetCursorLCD(uint8_t i, uint8_t r); +void PrintLCD(double pos); +void PrintFeedLCD(float f); +void PrintPwmLCD(uint16_t f); +void PrintSpindleLCD(float f); +void PrintStatusLCD(char* st); +void PrintPosLCD(float x, float y, float z); +void PrintPosLCDX(float x); +void PrintPosLCDY(float y); +void PrintPosLCDZ(float z); +void PrintWcoLCD(float x, float y, float z); +} +*/ + +/* +extern "C" void SetUpLCD(); +extern "C" void SetCursorLCD(uint8_t i, uint8_t r); +extern "C" void PrintLCD(double pos); +extern "C" void PrintFeedLCD(float f); +extern "C" void PrintPwmLCD(uint16_t f); +extern "C" void PrintSpindleLCD(float f); +extern "C" void PrintStatusLCD(char* st); +extern "C" void PrintPosLCD(float x, float y, float z); +extern "C" void PrintPosLCDX(float x); +extern "C" void PrintPosLCDY(float y); +extern "C" void PrintPosLCDZ(float z); +extern "C" void PrintWcoLCD(float x, float y, float z); +*/ + +void SetUpLCD(); +void SetCursorLCD(uint8_t i, uint8_t r); +void PrintLCD(double pos); +void PrintFeedLCD(float f); +void PrintPwmLCD(uint16_t f); +void PrintSpindleLCD(float f); +void PrintStatusLCD(char* st); +void PrintPosLCD(float x, float y, float z); +void PrintPosLCDX(float x); +void PrintPosLCDY(float y); +void PrintPosLCDZ(float z); +void PrintWcoLCD(float x, float y, float z); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/grbl_lcd/main.c b/grbl_lcd/main.c index 289839d1e..a8ccd8de6 100644 --- a/grbl_lcd/main.c +++ b/grbl_lcd/main.c @@ -68,14 +68,9 @@ int main(void) SetUpLCD(); - SetCursorLCD(0, 1); - PrintLCD(123.45); - SetCursorLCD(7, 1); - PrintLCD(678.91); - SetCursorLCD(14, 1); - PrintLCD(245.76); - PrintPosLCD(123.56, 25.45, 112.33); - + PrintPosLCD(000.00, 000.00, 000.00); + PrintWcoLCD(000.00, 000.00, 000.00); + // Grbl initialization loop upon power-up or a system abort. For the latter, all processes // will return to this loop to be cleanly re-initialized. for(;;) { diff --git a/grbl_lcd/report.c b/grbl_lcd/report.c index ea7b8e419..e43c12869 100644 --- a/grbl_lcd/report.c +++ b/grbl_lcd/report.c @@ -452,19 +452,38 @@ void report_realtime_status() // Report current machine state and sub-states serial_write('<'); switch (sys.state) { - case STATE_IDLE: printPgmString(PSTR("Idle")); break; - case STATE_CYCLE: printPgmString(PSTR("Run")); break; + case STATE_IDLE: + printPgmString(PSTR("Idle")); + PrintStatusLCD("Idle "); + break; + case STATE_CYCLE: + printPgmString(PSTR("Run")); + PrintStatusLCD("Run "); + break; case STATE_HOLD: if (!(sys.suspend & SUSPEND_JOG_CANCEL)) { printPgmString(PSTR("Hold:")); if (sys.suspend & SUSPEND_HOLD_COMPLETE) { serial_write('0'); } // Ready to resume else { serial_write('1'); } // Actively holding + PrintStatusLCD("Hold "); break; } // Continues to print jog state during jog cancel. - case STATE_JOG: printPgmString(PSTR("Jog")); break; - case STATE_HOMING: printPgmString(PSTR("Home")); break; - case STATE_ALARM: printPgmString(PSTR("Alarm")); break; - case STATE_CHECK_MODE: printPgmString(PSTR("Check")); break; + case STATE_JOG: + printPgmString(PSTR("Jog")); + PrintStatusLCD("Jog "); + break; + case STATE_HOMING: + printPgmString(PSTR("Home")); + PrintStatusLCD("Home "); + break; + case STATE_ALARM: + printPgmString(PSTR("Alarm")); + PrintStatusLCD("Alarm "); + break; + case STATE_CHECK_MODE: + printPgmString(PSTR("Check")); + PrintStatusLCD("Check "); + break; case STATE_SAFETY_DOOR: printPgmString(PSTR("Door:")); if (sys.suspend & SUSPEND_INITIATE_RESTORE) { @@ -480,8 +499,12 @@ void report_realtime_status() serial_write('2'); // Retracting } } + PrintStatusLCD("Door "); break; - case STATE_SLEEP: printPgmString(PSTR("Sleep")); break; + case STATE_SLEEP: + printPgmString(PSTR("Sleep")); + PrintStatusLCD("Sleep "); + break; } float wco[N_AXIS]; @@ -501,6 +524,8 @@ void report_realtime_status() if (bit_istrue(settings.status_report_mask,BITFLAG_RT_STATUS_POSITION_TYPE)) { printPgmString(PSTR("|MPos:")); PrintPosLCD((float)print_position[0], (float)print_position[1],(float)print_position[2]); + //PrintPosLCD(123.56, 25.45, 112.33); + //PrintPosLCDX((float)print_position[0]); } else { printPgmString(PSTR("|WPos:")); PrintPosLCD((float)print_position[0], (float)print_position[1],(float)print_position[2]); @@ -539,6 +564,12 @@ void report_realtime_status() serial_write(','); printFloat(sys.spindle_speed,N_DECIMAL_RPMVALUE); #endif + PrintFeedLCD(st_get_realtime_rate()); + //PrintPwmLCD(st_get_pwm_rate()); + PrintSpindleLCD(sys.spindle_speed); + + + #ifdef REPORT_FIELD_PIN_STATE uint8_t lim_pin_state = limits_get_state(); @@ -572,7 +603,7 @@ void report_realtime_status() if (sys.report_ovr_counter == 0) { sys.report_ovr_counter = 1; } // Set override on next report. printPgmString(PSTR("|WCO:")); report_util_axis_values(wco); - // PrintWcoLCD(wco[0], wco[1],wco[2]) + PrintWcoLCD(wco[0], wco[1],wco[2]); } #endif diff --git a/grbl_lcd/stepper.c b/grbl_lcd/stepper.c index ac0e0d089..f9838b650 100644 --- a/grbl_lcd/stepper.c +++ b/grbl_lcd/stepper.c @@ -1232,3 +1232,12 @@ float st_get_realtime_rate() } return 0.0f; } + +uint16_t st_get_pwm_rate() +{ + if (sys.state & (STATE_CYCLE | STATE_HOMING | STATE_HOLD | STATE_JOG | STATE_SAFETY_DOOR)){ + return prep.current_spindle_pwm; + } + return 0; +} + diff --git a/grbl_lcd/stepper.h b/grbl_lcd/stepper.h index b552d542a..4305889af 100644 --- a/grbl_lcd/stepper.h +++ b/grbl_lcd/stepper.h @@ -56,4 +56,6 @@ void st_update_plan_block_parameters(); // Called by realtime status reporting if realtime rate reporting is enabled in config.h. float st_get_realtime_rate(); +uint16_t st_get_pwm_rate(); + #endif From 2bee72957e0082b3d5e29d08dbd7338caa7e4a23 Mon Sep 17 00:00:00 2001 From: Ludwig Petrosyan Date: Tue, 13 Feb 2018 17:06:24 +0100 Subject: [PATCH 04/13] added home and zero interlock pins --- grbl_lcd/cpu_map.h | 11 +++++++---- grbl_lcd/lcd.cpp | 10 +++++++++- grbl_lcd/lcd.h | 1 + grbl_lcd/main.c | 5 +++++ grbl_lcd/protocol.c | 32 ++++++++++++++++++++++++++++++++ grbl_lcd/system.c | 40 +++++++++++++++++++++++++++++++++++++++- grbl_lcd/system.h | 41 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 134 insertions(+), 6 deletions(-) diff --git a/grbl_lcd/cpu_map.h b/grbl_lcd/cpu_map.h index 6cef4d9c3..30b6dd81d 100644 --- a/grbl_lcd/cpu_map.h +++ b/grbl_lcd/cpu_map.h @@ -90,14 +90,17 @@ #define CONTROL_DDR DDRK #define CONTROL_PIN PINK #define CONTROL_PORT PORTK - #define CONTROL_RESET_BIT 0 // MEGA2560 Analog Pin 8 - #define CONTROL_FEED_HOLD_BIT 1 // MEGA2560 Analog Pin 9 - #define CONTROL_CYCLE_START_BIT 2 // MEGA2560 Analog Pin 10 + #define CONTROL_RESET_BIT 0 // MEGA2560 Analog Pin 8 + #define CONTROL_FEED_HOLD_BIT 1 // MEGA2560 Analog Pin 9 + #define CONTROL_CYCLE_START_BIT 2 // MEGA2560 Analog Pin 10 #define CONTROL_SAFETY_DOOR_BIT 3 // MEGA2560 Analog Pin 11 + #define CONTROL_GO_HOME_BIT 4 // MEGA2560 Analog Pin 12 + #define CONTROL_SET_ZERO_BIT 5 // MEGA2560 Analog Pin 13 #define CONTROL_INT PCIE2 // Pin change interrupt enable pin #define CONTROL_INT_vect PCINT2_vect #define CONTROL_PCMSK PCMSK2 // Pin change interrupt register - #define CONTROL_MASK ((1< Date: Thu, 15 Feb 2018 10:38:35 +0100 Subject: [PATCH 05/13] added feed rate change button --- grbl_lcd/cpu_map.h | 10 ++ grbl_lcd/grbl.h | 1 + grbl_lcd/lcd.cpp | 93 +++++++++++++++--- grbl_lcd/lcd.h | 3 + grbl_lcd/main.c | 27 ++++++ grbl_lcd/protocol.c | 224 +++++++++++++++++++++++++++++++++++++++++++- grbl_lcd/protocol.h | 12 +++ grbl_lcd/report.c | 131 ++++++++++++++++++++++---- grbl_lcd/report.h | 3 + grbl_lcd/system.h | 1 + 10 files changed, 470 insertions(+), 35 deletions(-) diff --git a/grbl_lcd/cpu_map.h b/grbl_lcd/cpu_map.h index 30b6dd81d..c31853416 100644 --- a/grbl_lcd/cpu_map.h +++ b/grbl_lcd/cpu_map.h @@ -132,6 +132,16 @@ #define SPINDLE_PWM_DDR DDRH #define SPINDLE_PWM_PORT PORTH #define SPINDLE_PWM_BIT 4 // MEGA2560 Digital Pin 7 + + + #define xUpPin 53 // + #define xDownPin 51 // + #define yUpPin 49 // + #define yDownPin 47 // + #define zUpPin 45 // + #define zDownPin 43 // + #define xySetPin 41 // + #define zSetPin 39 // #endif diff --git a/grbl_lcd/grbl.h b/grbl_lcd/grbl.h index 0a97ed10d..9a49db8d2 100644 --- a/grbl_lcd/grbl.h +++ b/grbl_lcd/grbl.h @@ -38,6 +38,7 @@ #include #include #include +#include // Define the Grbl system include files. NOTE: Do not alter organization. #include "config.h" diff --git a/grbl_lcd/lcd.cpp b/grbl_lcd/lcd.cpp index 04bb2d585..4e4c836e1 100644 --- a/grbl_lcd/lcd.cpp +++ b/grbl_lcd/lcd.cpp @@ -1,6 +1,8 @@ #include #include "lcd.h" +#include +//#include //#ifdef __cplusplus //extern "C" { @@ -31,13 +33,13 @@ void setup_lcd() { lcd.setCursor(0, 3); lcd.print("STEP:"); - lcd.setCursor(11, 3); - lcd.print("JOG:"); + lcd.setCursor(14, 3); + lcd.print("SF:"); lcd.setCursor(0, 0); lcd.print("******"); lcd.setCursor(7, 0); lcd.print("F:"); - lcd.setCursor(14, 0); + lcd.setCursor(13, 0); lcd.print("S:"); } @@ -51,12 +53,38 @@ void setup_lcd() { lcd.setCursor(i, r); } + +void PrintMillsLCD(int of, uint8_t cn) +{ + char str[20]; + + sprintf(str,"%-7d", cn); + lcd.setCursor(10+of, 3); + lcd.print(str); + //lcd.print(" "); + //lcd.setCursor(12+of, 3); + //lcd.print(cn); +} + +void PrintXyzPinsLCD(int of, float f) +{ + lcd.setCursor(10+of, 3); + //lcd.print(" "); + //lcd.setCursor(12+of, 3); + lcd.print(f); +} + + void PrintComandLCD(char* st) { + char str[20]; + + sprintf(str,"%-6s", st); lcd.setCursor(0, 3); - lcd.print(" "); - lcd.setCursor(0, 3); - lcd.print(st); + lcd.print(str); + //lcd.print(" "); + //lcd.setCursor(0, 3); + //lcd.print(st); } void PrintLCD(double pos) @@ -66,8 +94,16 @@ void PrintComandLCD(char* st) void PrintFeedLCD(float f) { - lcd.setCursor(9, 0); - lcd.print(f); + char str[20]; + + sprintf(str,"F:%-3i", (int)f); + + //sprintf(str,"F:%f", f); + lcd.setCursor(7, 0); + + lcd.print(str); + //lcd.setCursor(9, 0); + //lcd.print(f); lcd.setCursor(13, 0); lcd.print(" S:"); } @@ -75,18 +111,28 @@ void PrintComandLCD(char* st) void PrintPwmLCD(uint16_t f) { + char str[20]; + + sprintf(str,"%-.4d", f); lcd.setCursor(16, 0); - lcd.print(" "); - lcd.setCursor(16, 0); - lcd.print(f); + lcd.print(str); + + + //lcd.print(" "); + //lcd.setCursor(16, 0); + //lcd.print(f); } void PrintSpindleLCD(float f) { + char str[420]; + + sprintf(str,"%-4i", (int)f); lcd.setCursor(16, 0); - lcd.print(" "); - lcd.setCursor(16, 0); - lcd.print(f); + lcd.print(str); + //lcd.print(" "); + //lcd.setCursor(16, 0); + //lcd.print(f); } void PrintStatusLCD(char* st) @@ -103,6 +149,8 @@ void PrintComandLCD(char* st) lcd.print(y); lcd.setCursor(14, 1); lcd.print(z); + lcd.setCursor(19, 1); + lcd.print("W"); } void PrintPosLCDX(float x) @@ -131,8 +179,25 @@ void PrintComandLCD(char* st) lcd.print(y); lcd.setCursor(14, 2); lcd.print(z); + lcd.setCursor(19, 2); + lcd.print("M"); } +void PrintSfeedLCD(int f) +{ + char str[20]; + + sprintf(str,"%-.3d", f); + lcd.setCursor(17, 3); + lcd.print(str); + + + //lcd.print(" "); + //lcd.setCursor(16, 0); + //lcd.print(f); +} + + //} /* extern "C" void SetUpLCD() diff --git a/grbl_lcd/lcd.h b/grbl_lcd/lcd.h index 67b89eb34..b080f2493 100644 --- a/grbl_lcd/lcd.h +++ b/grbl_lcd/lcd.h @@ -58,6 +58,9 @@ void PrintPosLCDY(float y); void PrintPosLCDZ(float z); void PrintWcoLCD(float x, float y, float z); void PrintComandLCD(char* st); +void PrintMillsLCD(int of, uint8_t cn); +void PrintXyzPinsLCD(int of, float f); +void PrintSfeedLCD(int f); #ifdef __cplusplus } diff --git a/grbl_lcd/main.c b/grbl_lcd/main.c index fc057f2d8..3f5aaa9f4 100644 --- a/grbl_lcd/main.c +++ b/grbl_lcd/main.c @@ -33,6 +33,10 @@ volatile uint8_t sys_rt_exec_motion_override; // Global realtime executor bitfla volatile uint8_t sys_rt_exec_accessory_override; // Global realtime executor bitflag variable for spindle/coolant overrides. volatile uint8_t sys_rt_exec_axis; // added Global realtime executor bitflag variable for axis movement. volatile uint8_t sys_rt_exec_position; // added Global realtime executor bitflag variable for homing and zeroing. + +volatile uint8_t main_count; +volatile uint8_t protocol_count; + #ifdef DEBUG volatile uint8_t sys_rt_exec_debug; #endif @@ -41,6 +45,19 @@ volatile uint8_t sys_rt_exec_position; // added Global realtime executor bitfl int main(void) { // Initialize system upon power-up. + + //added + pinMode(xUpPin, INPUT_PULLUP); + pinMode(xDownPin, INPUT_PULLUP); + pinMode(yUpPin, INPUT_PULLUP); + pinMode(yDownPin, INPUT_PULLUP); + pinMode(zUpPin, INPUT_PULLUP); + pinMode(zDownPin, INPUT_PULLUP); + pinMode(xySetPin, INPUT_PULLUP); + pinMode(zSetPin, INPUT_PULLUP); + + + //end added serial_init(); // Setup serial baud rate and interrupts settings_init(); // Load Grbl settings from EEPROM stepper_init(); // Configure stepper pins and interrupt timers @@ -73,10 +90,15 @@ int main(void) PrintPosLCD(000.00, 000.00, 000.00); PrintWcoLCD(000.00, 000.00, 000.00); + main_count = 0; + protocol_count = 0; + // Grbl initialization loop upon power-up or a system abort. For the latter, all processes // will return to this loop to be cleanly re-initialized. for(;;) { + main_count++; + //PrintMillsLCD(0, main_count); // Reset system variables. uint8_t prior_state = sys.state; memset(&sys, 0, sizeof(system_t)); // Clear system struct variable. @@ -93,6 +115,11 @@ int main(void) sys_rt_exec_axis = 0; // added sys_rt_exec_position = 0; // added + + sys.sfeed_rate = 250; + + + // Reset Grbl primary systems. serial_reset_read_buffer(); // Clear serial read buffer diff --git a/grbl_lcd/protocol.c b/grbl_lcd/protocol.c index b72a06795..0eff07896 100644 --- a/grbl_lcd/protocol.c +++ b/grbl_lcd/protocol.c @@ -71,8 +71,23 @@ void protocol_main_loop() uint8_t line_flags = 0; uint8_t char_counter = 0; uint8_t c; + + //added + float pin_x = 0.0; + float pin_y = 0.0; + float pin_z = 0.0; + int pin_pressed = 0; + + //char* axis_move_buttons = "G91G0X+0.01Y+0.01Z+0.01:G90"; + //sfeed positio is 24 + char* axis_move_buttons = "G91G1X+0.01Y+0.01Z+0.01F250"; + + //end added for (;;) { + uint8_t rt_exec_m = 0; // Temp variable to avoid calling volatile multiple times. + //protocol_count++; + //PrintMillsLCD(4, protocol_count); // Process one line of incoming serial data, as the data becomes available. Performs an // initial filtering by removing spaces and comments and capitalizing all letters. while((c = serial_read()) != SERIAL_NO_DATA) { @@ -101,7 +116,7 @@ void protocol_main_loop() report_status_message(STATUS_SYSTEM_GC_LOCK); } else { // Parse and execute g-code block. - PrintComandLCD(line); + //PrintComandLCD(line); report_status_message(gc_execute_line(line)); } @@ -151,6 +166,96 @@ void protocol_main_loop() } } + if(c == SERIAL_NO_DATA){ + //added + rt_exec_m = sys_rt_exec_axis; // Copy volatile sys_rt_exec_alarm. + if (rt_exec_m) { + if (sys.state != STATE_HOLD){ + PrintComandLCD("AXIS"); + } + //system_clear_exec_axis_flag(uint8_t mask); + } + + + rt_exec_m = sys_rt_exec_position; // Copy volatile sys_rt_exec_alarm. + if (rt_exec_m) { + if (sys.state != STATE_HOLD){ + if (rt_exec_m & EXEC_GO_HOME){ + PrintComandLCD("HOME"); + report_status_message(gc_execute_line( "G90G0X0Y0Z0")); + system_clear_exec_position_flag(EXEC_GO_HOME); + } + if (rt_exec_m & EXEC_SET_ZERO){ + PrintComandLCD("SFEED"); + //report_status_message(gc_execute_line( "G92X0Y0Z0")); + if(sys.sfeed_rate == 250) sys.sfeed_rate = 50; else sys.sfeed_rate += 50; + system_clear_exec_position_flag(EXEC_SET_ZERO); + } + } + + } + //protocol_read_axispins(); + pin_x = 0.0; + pin_y = 0.0; + pin_z = 0.0; + pin_pressed = 0; + pin_pressed = protocol_read_axisxyz(&pin_x, &pin_y, &pin_z); + //PrintMillsLCD(0, pin_pressed); + //PrintXyzPinsLCD(2, pin_x); + //PrintXyzPinsLCD(4, pin_y); + //PrintXyzPinsLCD(6, pin_z); + if(pin_pressed){ + //axis_move_buttons + if(pin_x < 0) axis_move_buttons[6] = '-'; else axis_move_buttons[6] = '+'; + if(pin_y < 0) axis_move_buttons[12] = '-'; else axis_move_buttons[12] = '+'; + if(pin_z < 0) axis_move_buttons[18] = '-'; else axis_move_buttons[18] = '+'; + if(!pin_x) axis_move_buttons[10] = '0'; else axis_move_buttons[10] = '1'; + if(!pin_y) axis_move_buttons[16] = '0'; else axis_move_buttons[16] = '1'; + if(!pin_z) axis_move_buttons[22] = '0'; else axis_move_buttons[22] = '1'; + axis_move_buttons[24] = '0'; + switch (sys.sfeed_rate){ + case 50: + axis_move_buttons[24] = '0'; + axis_move_buttons[25] = '5'; + axis_move_buttons[26] = '0'; + break; + case 100: + axis_move_buttons[24] = '1'; + axis_move_buttons[25] = '0'; + axis_move_buttons[26] = '0'; + break; + case 150: + axis_move_buttons[24] = '1'; + axis_move_buttons[25] = '5'; + axis_move_buttons[26] = '0'; + break; + case 200: + axis_move_buttons[24] = '2'; + axis_move_buttons[25] = '0'; + axis_move_buttons[26] = '0'; + break; + case 250: + axis_move_buttons[24] = '2'; + axis_move_buttons[25] = '5'; + axis_move_buttons[26] = '0'; + break; + } + //PrintComandLCD(&axis_move_buttons[22]); + report_status_message(gc_execute_line(axis_move_buttons)); + }else{ + pin_pressed = protocol_read_axissetxy(); + if(pin_pressed){ + report_status_message(gc_execute_line("G92X0Y0")); + }else{ + pin_pressed = protocol_read_axissetz(); + if(pin_pressed){ + report_status_message(gc_execute_line("G92Z0")); + } + } + } + + //end added + } // If there are no more characters in the serial read buffer to be processed and executed, // this indicates that g-code streaming has either filled the planner buffer or has @@ -158,6 +263,9 @@ void protocol_main_loop() protocol_auto_cycle_start(); protocol_execute_realtime(); // Runtime command check point. + + //Print status to LCD + report_lcd_status(); if (sys.abort) { return; } // Bail to main() program loop to reset system. #ifdef SLEEP_ENABLE @@ -248,7 +356,7 @@ void protocol_exec_rt_system() // Execute system abort. if (rt_exec & EXEC_RESET) { - PrintComandLCD(" "); + PrintComandLCD("RESET "); sys.abort = true; // Only place this is set true. return; // Nothing else to do but exit. } @@ -485,6 +593,7 @@ void protocol_exec_rt_system() } } + /* //added rt_exec = sys_rt_exec_axis; // Copy volatile sys_rt_exec_alarm. if (rt_exec) { @@ -513,7 +622,7 @@ void protocol_exec_rt_system() } //end added - + */ #ifdef DEBUG if (sys_rt_exec_debug) { @@ -529,6 +638,115 @@ void protocol_exec_rt_system() } +//added +/* + #define xUpPin 53 // + #define xDownPin 51 // + #define yUpPin 49 // + #define yDownPin 47 // + #define zUpPin 45 // + #define zDownPin 43 // + #define xySetPin 41 // + #define zSetPin 39 // +*/ +void protocol_read_axispins() +{ + uint8_t pinValue = 0; + int val = 0; + + val = digitalRead(xUpPin); + pinValue += val; + + val = digitalRead(xDownPin); + pinValue += ((val & 0x1)<<1); + + val = digitalRead(yUpPin); + pinValue += ((val & 0x1)<<2); + + val = digitalRead(yDownPin); + pinValue += ((val & 0x1)<<3); + + val = digitalRead(zUpPin); + pinValue += ((val & 0x1)<<4); + + val = digitalRead(zDownPin); + pinValue += ((val & 0x1)<<5); + + val = digitalRead(xySetPin); + pinValue += ((val & 0x1)<<6); + + val = digitalRead(zSetPin); + pinValue += ((val & 0x1)<<7); + + PrintMillsLCD(0, pinValue); +} + +int protocol_read_axisxyz(float* x, float* y, float* z) +{ + uint8_t pinValue = 0; + int val = 0; + + val = digitalRead(xUpPin); + if(!val){ + pinValue++; + *x = 1; + } + + val = digitalRead(xDownPin); + if(!val){ + pinValue++; + *x = -1; + } + + val = digitalRead(yUpPin); + if(!val){ + pinValue++; + *y = 1; + } + + val = digitalRead(yDownPin); + if(!val){ + pinValue++; + *y = -1; + } + + val = digitalRead(zUpPin); + if(!val){ + pinValue++; + *z = 1; + } + + val = digitalRead(zDownPin); + if(!val){ + pinValue++; + *z = -1; + } + + return pinValue; +} + +int protocol_read_axissetxy() +{ + int pinValue = 0; + int val = 0; + + val = digitalRead(xySetPin); + if(!val) pinValue = 1; + + return pinValue; +} + +int protocol_read_axissetz() +{ + int pinValue = 0; + int val = 0; + + val = digitalRead(zSetPin); + if(!val) pinValue = 1; + + return pinValue; +} +//end added // Handles Grbl system suspend procedures, such as feed hold, safety door, and parking motion. // The system will enter this loop, create local variables for suspend tasks, and return to diff --git a/grbl_lcd/protocol.h b/grbl_lcd/protocol.h index 56acba30f..a8b584023 100644 --- a/grbl_lcd/protocol.h +++ b/grbl_lcd/protocol.h @@ -41,4 +41,16 @@ void protocol_auto_cycle_start(); // Block until all buffered steps are executed void protocol_buffer_synchronize(); +//added read digital pins for axis moving +void protocol_read_axispins(); + +//added read digital pins for axis moving +int protocol_read_axisxyz(float* x, float* y, float* z); +//added read digital pins for axis moving +int protocol_read_axissetxy(); +//added read digital pins for axis moving +int protocol_read_axissetz(); + + +extern volatile uint8_t protocol_count; #endif diff --git a/grbl_lcd/report.c b/grbl_lcd/report.c index e43c12869..dcfbbae7f 100644 --- a/grbl_lcd/report.c +++ b/grbl_lcd/report.c @@ -454,35 +454,35 @@ void report_realtime_status() switch (sys.state) { case STATE_IDLE: printPgmString(PSTR("Idle")); - PrintStatusLCD("Idle "); + //PrintStatusLCD("Idle "); break; case STATE_CYCLE: printPgmString(PSTR("Run")); - PrintStatusLCD("Run "); + //PrintStatusLCD("Run "); break; case STATE_HOLD: if (!(sys.suspend & SUSPEND_JOG_CANCEL)) { printPgmString(PSTR("Hold:")); if (sys.suspend & SUSPEND_HOLD_COMPLETE) { serial_write('0'); } // Ready to resume else { serial_write('1'); } // Actively holding - PrintStatusLCD("Hold "); + //PrintStatusLCD("Hold "); break; } // Continues to print jog state during jog cancel. case STATE_JOG: printPgmString(PSTR("Jog")); - PrintStatusLCD("Jog "); + //PrintStatusLCD("Jog "); break; case STATE_HOMING: printPgmString(PSTR("Home")); - PrintStatusLCD("Home "); + //PrintStatusLCD("Home "); break; case STATE_ALARM: printPgmString(PSTR("Alarm")); - PrintStatusLCD("Alarm "); + //PrintStatusLCD("Alarm "); break; case STATE_CHECK_MODE: printPgmString(PSTR("Check")); - PrintStatusLCD("Check "); + //PrintStatusLCD("Check "); break; case STATE_SAFETY_DOOR: printPgmString(PSTR("Door:")); @@ -499,11 +499,11 @@ void report_realtime_status() serial_write('2'); // Retracting } } - PrintStatusLCD("Door "); + //PrintStatusLCD("Door "); break; case STATE_SLEEP: printPgmString(PSTR("Sleep")); - PrintStatusLCD("Sleep "); + //PrintStatusLCD("Sleep "); break; } @@ -523,9 +523,7 @@ void report_realtime_status() // Report machine position if (bit_istrue(settings.status_report_mask,BITFLAG_RT_STATUS_POSITION_TYPE)) { printPgmString(PSTR("|MPos:")); - PrintPosLCD((float)print_position[0], (float)print_position[1],(float)print_position[2]); - //PrintPosLCD(123.56, 25.45, 112.33); - //PrintPosLCDX((float)print_position[0]); + //PrintPosLCD((float)print_position[0], (float)print_position[1],(float)print_position[2]); } else { printPgmString(PSTR("|WPos:")); PrintPosLCD((float)print_position[0], (float)print_position[1],(float)print_position[2]); @@ -533,8 +531,6 @@ void report_realtime_status() //PrintPosLCD((float)print_position[0], (float)print_position[1],(float)print_position[2]); report_util_axis_values(print_position); - //PrintPosLCD(123.56, 25.45, 112.33); - // Returns planner and serial read buffer states. #ifdef REPORT_FIELD_BUFFER_STATE if (bit_istrue(settings.status_report_mask,BITFLAG_RT_STATUS_BUFFER_STATE)) { @@ -564,9 +560,8 @@ void report_realtime_status() serial_write(','); printFloat(sys.spindle_speed,N_DECIMAL_RPMVALUE); #endif - PrintFeedLCD(st_get_realtime_rate()); - //PrintPwmLCD(st_get_pwm_rate()); - PrintSpindleLCD(sys.spindle_speed); + //PrintFeedLCD(st_get_realtime_rate()); + //PrintSpindleLCD(sys.spindle_speed); @@ -603,7 +598,7 @@ void report_realtime_status() if (sys.report_ovr_counter == 0) { sys.report_ovr_counter = 1; } // Set override on next report. printPgmString(PSTR("|WCO:")); report_util_axis_values(wco); - PrintWcoLCD(wco[0], wco[1],wco[2]); + //PrintWcoLCD(wco[0], wco[1],wco[2]); } #endif @@ -645,3 +640,103 @@ void report_realtime_status() } #endif + +// Prints real-time data to LCD. This function grabs a real-time snapshot of the stepper subprogram + // and the actual location of the CNC machine. Users may change the following function to their + // specific needs, but the desired real-time data report must be as short as possible. This is + // requires as it minimizes the computational overhead and allows grbl to keep running smoothly, + // especially during g-code programs with fast, short line segments and high frequency reports (5-20Hz). +void report_lcd_status() +{ + uint8_t idx; + int32_t current_position[N_AXIS]; // Copy current state of the system position variable + memcpy(current_position,sys_position,sizeof(sys_position)); + float print_position[N_AXIS]; + float wpos_position[N_AXIS]; + system_convert_array_steps_to_mpos(print_position,current_position); + + // Report current machine state and sub-states + switch (sys.state) { + case STATE_IDLE: + PrintStatusLCD("Idle "); + break; + case STATE_CYCLE: + PrintStatusLCD("Run "); + break; + case STATE_HOLD: + if (!(sys.suspend & SUSPEND_JOG_CANCEL)) { + PrintStatusLCD("Hold "); + break; + } // Continues to print jog state during jog cancel. + case STATE_JOG: + PrintStatusLCD("Jog "); + break; + case STATE_HOMING: + PrintStatusLCD("Home "); + break; + case STATE_ALARM: + PrintStatusLCD("Alarm "); + break; + case STATE_CHECK_MODE: + PrintStatusLCD("Check "); + break; + case STATE_SAFETY_DOOR: + PrintStatusLCD("Door "); + break; + case STATE_SLEEP: + PrintStatusLCD("Sleep "); + break; + } + + float wco[N_AXIS]; + if (bit_isfalse(settings.status_report_mask,BITFLAG_RT_STATUS_POSITION_TYPE) || + (sys.report_wco_counter == 0) ) { + for (idx=0; idx< N_AXIS; idx++) { + // Apply work coordinate offsets and tool length offset to current position. + wco[idx] = gc_state.coord_system[idx]+gc_state.coord_offset[idx]; + if (idx == TOOL_LENGTH_OFFSET_AXIS) { wco[idx] += gc_state.tool_length_offset; } + wpos_position[idx] = print_position[idx] - wco[idx]; + + //if (bit_isfalse(settings.status_report_mask,BITFLAG_RT_STATUS_POSITION_TYPE)) { + // print_position[idx] -= wco[idx]; + //} + + } + } + + // Report machine position + //if (bit_istrue(settings.status_report_mask,BITFLAG_RT_STATUS_POSITION_TYPE)) { + // PrintPosLCD((float)print_position[0], (float)print_position[1],(float)print_position[2]); + //} else { + // PrintPosLCD((float)print_position[0], (float)print_position[1],(float)print_position[2]); + //} + + PrintPosLCD((float)wpos_position[0], (float)wpos_position[1],(float)wpos_position[2]); + PrintWcoLCD((float)print_position[0], (float)print_position[1],(float)print_position[2]); + + // Report realtime feed speed + PrintFeedLCD(st_get_realtime_rate()); + //PrintPwmLCD(st_get_pwm_rate()); + PrintSpindleLCD(sys.spindle_speed); + + #ifdef REPORT_FIELD_WORK_COORD_OFFSET + /* + if (sys.report_wco_counter > 0) { sys.report_wco_counter--; } + else { + if (sys.state & (STATE_HOMING | STATE_CYCLE | STATE_HOLD | STATE_JOG | STATE_SAFETY_DOOR)) { + sys.report_wco_counter = (REPORT_WCO_REFRESH_BUSY_COUNT-1); // Reset counter for slow refresh + } else { sys.report_wco_counter = (REPORT_WCO_REFRESH_IDLE_COUNT-1); } + if (sys.report_ovr_counter == 0) { sys.report_ovr_counter = 1; } // Set override on next report. + printPgmString(PSTR("|WCO:")); + report_util_axis_values(wco); + PrintWcoLCD(wco[0], wco[1],wco[2]); + } + */ + if (sys.report_wco_counter == 0){ + //PrintWcoLCD(wco[0], wco[1],wco[2]); + } + #endif + + PrintSfeedLCD(sys.sfeed_rate); + +} diff --git a/grbl_lcd/report.h b/grbl_lcd/report.h index f1480026a..0b4e59369 100644 --- a/grbl_lcd/report.h +++ b/grbl_lcd/report.h @@ -124,6 +124,9 @@ void report_execute_startup_message(char *line, uint8_t status_code); // Prints build info and user info void report_build_info(char *line); +// Prints realtime status to LCD +void report_lcd_status(); + #ifdef DEBUG void report_realtime_debug(); #endif diff --git a/grbl_lcd/system.h b/grbl_lcd/system.h index a684658c7..29b6585fe 100644 --- a/grbl_lcd/system.h +++ b/grbl_lcd/system.h @@ -171,6 +171,7 @@ typedef struct { uint8_t override_ctrl; // Tracks override control states. #endif float spindle_speed; + int sfeed_rate; } system_t; extern system_t sys; From 52d592601e84c5e6aaba7bf5b6a897c2f0e4b4a0 Mon Sep 17 00:00:00 2001 From: Ludwig Date: Sat, 17 Feb 2018 22:20:48 +0100 Subject: [PATCH 06/13] added control buttons --- grbl_lcd/cpu_map.h | 55 ++++++++++++++++++++++++++++++++++---------- grbl_lcd/lcd.cpp | 9 ++++++++ grbl_lcd/lcd.h | 1 + grbl_lcd/main.c | 5 ++++ grbl_lcd/protocol.c | 56 ++++++++++++++++++++++++++++++++++++++------- grbl_lcd/protocol.h | 2 ++ grbl_lcd/report.c | 41 ++++++++++++++++++++++++--------- grbl_lcd/system.c | 5 +++- grbl_lcd/system.h | 12 ++++++---- 9 files changed, 150 insertions(+), 36 deletions(-) diff --git a/grbl_lcd/cpu_map.h b/grbl_lcd/cpu_map.h index c31853416..3dc391e36 100644 --- a/grbl_lcd/cpu_map.h +++ b/grbl_lcd/cpu_map.h @@ -90,17 +90,18 @@ #define CONTROL_DDR DDRK #define CONTROL_PIN PINK #define CONTROL_PORT PORTK - #define CONTROL_RESET_BIT 0 // MEGA2560 Analog Pin 8 + #define CONTROL_RESET_BIT 0 // MEGA2560 Analog Pin 8 #define CONTROL_FEED_HOLD_BIT 1 // MEGA2560 Analog Pin 9 #define CONTROL_CYCLE_START_BIT 2 // MEGA2560 Analog Pin 10 - #define CONTROL_SAFETY_DOOR_BIT 3 // MEGA2560 Analog Pin 11 - #define CONTROL_GO_HOME_BIT 4 // MEGA2560 Analog Pin 12 + #define CONTROL_SAFETY_DOOR_BIT 3 // MEGA2560 Analog Pin 11 + #define CONTROL_GO_HOME_BIT 4 // MEGA2560 Analog Pin 12 #define CONTROL_SET_ZERO_BIT 5 // MEGA2560 Analog Pin 13 + #define CONTROL_SET_SPINDLE_BIT 6 // MEGA2560 Analog Pin 14 #define CONTROL_INT PCIE2 // Pin change interrupt enable pin #define CONTROL_INT_vect PCINT2_vect #define CONTROL_PCMSK PCMSK2 // Pin change interrupt register // #define CONTROL_MASK ((1< Date: Sat, 24 Feb 2018 14:54:38 +0100 Subject: [PATCH 07/13] added new control buttons --- grbl_lcd/cpu_map.h | 37 ++-- grbl_lcd/lcd.cpp | 39 ++++ grbl_lcd/lcd.h | 3 + grbl_lcd/main.c | 8 +- grbl_lcd/protocol.c | 428 +++++++++++++++++++++++++++++--------------- grbl_lcd/protocol.h | 5 + grbl_lcd/report.c | 107 ++++++----- grbl_lcd/report.h | 1 + grbl_lcd/system.c | 1 + grbl_lcd/system.h | 1 + 10 files changed, 418 insertions(+), 212 deletions(-) diff --git a/grbl_lcd/cpu_map.h b/grbl_lcd/cpu_map.h index 3dc391e36..82564d9ba 100644 --- a/grbl_lcd/cpu_map.h +++ b/grbl_lcd/cpu_map.h @@ -135,25 +135,28 @@ #define SPINDLE_PWM_BIT 4 // MEGA2560 Digital Pin 7 - #define xUpPin 53 // - #define xDownPin 51 // - #define yUpPin 49 // - #define yDownPin 47 // - #define zUpPin 45 // - #define zDownPin 43 // - #define xySetPin 41 // - #define zSetPin 39 // - #define pwmSetPin 37 // + #define xUpPin 53 //45 // + #define xDownPin 51 //44 // + #define yUpPin 49 //43 // + #define yDownPin 47 //42 // + #define zUpPin 45 //41 // + #define zDownPin 43 //40 // + #define xySetPin 41 //39 // + #define zSetPin 39 //38 // + #define StepSetPin 38 //37 // + #define pwmSetPin 36 //36 // + #define zHometPin 35 //36 // + #define xyHomePin 37 //36 // /* * pins used for LCD - * rs = 52, - * rw = 50, - * en = 48, - * d4 = 46, - * d5 = 44, - * d6 = 42, - * d7 = 40; + * rs = 53, 52 + * rw = 52, 50 + * en = 51, 48 + * d4 = 50, 46 + * d5 = 49, 44 + * d6 = 48, 42 + * d7 = 47; 40 * * pins used by grbl * step pulse X = 24 @@ -171,7 +174,7 @@ * added * home = A12 * feed = A13 - * spindle on/off = A14 //to do + * spindle on/off = A14 */ #endif diff --git a/grbl_lcd/lcd.cpp b/grbl_lcd/lcd.cpp index c282bd3d9..a70d3df20 100644 --- a/grbl_lcd/lcd.cpp +++ b/grbl_lcd/lcd.cpp @@ -96,6 +96,45 @@ void PrintComandCountLCD(int cnt) lcd.print(str); } +void PrintComandWcoLCD(float x, float y, float z) +{ + lcd.setCursor(0, 3); + lcd.print(x); + lcd.setCursor(3, 3); + lcd.print(" "); + lcd.setCursor(4, 3); + lcd.print(y); + lcd.setCursor(7, 3); + lcd.print(" "); + lcd.setCursor(8, 3); + lcd.print(z); +} + +void PrintFStepLCD(int idx){ + lcd.setCursor(9, 3); + lcd.print("STP:"); + lcd.setCursor(10, 3); + lcd.print(idx); +} + +void PrintStepLCD(int idx) +{ + lcd.setCursor(0, 3); + lcd.print("STP:"); + lcd.setCursor(4, 3); + switch (idx){ + case 0: + lcd.print("0.01"); + break; + case 1: + lcd.print("0.10"); + break; + case 2: + lcd.print("1.00"); + break; + } +} + void PrintLCD(double pos) { lcd.print(pos); diff --git a/grbl_lcd/lcd.h b/grbl_lcd/lcd.h index 958dbde93..5b149476a 100644 --- a/grbl_lcd/lcd.h +++ b/grbl_lcd/lcd.h @@ -59,9 +59,12 @@ void PrintPosLCDZ(float z); void PrintWcoLCD(float x, float y, float z); void PrintComandLCD(char* st); void PrintComandCountLCD(int cnt); +void PrintComandWcoLCD(float x, float y, float z); void PrintMillsLCD(int of, uint8_t cn); void PrintXyzPinsLCD(int of, float f); void PrintSfeedLCD(int f); +void PrintStepLCD(int idx); +void PrintFStepLCD(int idx); #ifdef __cplusplus } diff --git a/grbl_lcd/main.c b/grbl_lcd/main.c index afb403a6d..4ea2dcec4 100644 --- a/grbl_lcd/main.c +++ b/grbl_lcd/main.c @@ -36,6 +36,7 @@ volatile uint8_t sys_rt_exec_position; // added Global realtime executor bitfl volatile uint8_t main_count; volatile uint8_t protocol_count; +volatile uint8_t step_per_click; #ifdef DEBUG volatile uint8_t sys_rt_exec_debug; @@ -56,6 +57,9 @@ int main(void) pinMode(xySetPin, INPUT_PULLUP); pinMode(zSetPin, INPUT_PULLUP); pinMode(pwmSetPin, INPUT_PULLUP); + pinMode(StepSetPin, INPUT_PULLUP); + pinMode(zHometPin, INPUT_PULLUP); + pinMode(xyHomePin, INPUT_PULLUP); //end added @@ -101,7 +105,7 @@ int main(void) main_count++; //PrintMillsLCD(0, main_count); - memset(sys_position,0,sizeof(sys_position)); // Clear machine position. + //memset(sys_position,0,sizeof(sys_position)); // Clear machine position. // Reset system variables. uint8_t prior_state = sys.state; memset(&sys, 0, sizeof(system_t)); // Clear system struct variable. @@ -115,6 +119,7 @@ int main(void) sys_rt_exec_alarm = 0; sys_rt_exec_motion_override = 0; sys_rt_exec_accessory_override = 0; + step_per_click = 0; sys_rt_exec_axis = 0; // added sys_rt_exec_position = 0; // added @@ -122,6 +127,7 @@ int main(void) sys.sfeed_rate = 250; sys.cmd_count = 0; sys.cmd_count_enable = 0; + //sys.step_per_click = 0.01; diff --git a/grbl_lcd/protocol.c b/grbl_lcd/protocol.c index df8ef271b..ef5b86797 100644 --- a/grbl_lcd/protocol.c +++ b/grbl_lcd/protocol.c @@ -52,6 +52,8 @@ void protocol_main_loop() if (sys.state & (STATE_ALARM | STATE_SLEEP)) { report_feedback_message(MESSAGE_ALARM_LOCK); sys.state = STATE_ALARM; // Ensure alarm state is set. + //PrintComandLCD("ALARM "); //added + PrintStatusLCD("ALARM "); //added } else { // Check if the safety door is open. sys.state = STATE_IDLE; @@ -72,17 +74,14 @@ void protocol_main_loop() uint8_t char_counter = 0; uint8_t c; - //added - float pin_x = 0.0; - float pin_y = 0.0; - float pin_z = 0.0; - int pin_pressed = 0; - - //char* axis_move_buttons = "G91G0X+0.01Y+0.01Z+0.01:G90"; - //sfeed positio is 24 - char* axis_move_buttons = "G91G1X+0.01Y+0.01Z+0.01F250"; - - //end added + //added + float pin_x = 0.0; + float pin_y = 0.0; + float pin_z = 0.0; + int pin_pressed = 0; + char* axis_move_buttons = "G91G1X+0.01Y+0.01Z+0.01F250"; + + //end added for (;;) { uint8_t rt_exec_m = 0; // Temp variable to avoid calling volatile multiple times. @@ -123,6 +122,10 @@ void protocol_main_loop() // Reset tracking data for next line. line_flags = 0; char_counter = 0; + + // added , seems in case of fast serial data no LCD status reported, will try to put it here + report_lcd_status(); + // end added } else { @@ -166,131 +169,230 @@ void protocol_main_loop() } } + //added if(c == SERIAL_NO_DATA){ - //added - if(sys.cmd_count_enable){ sys.cmd_count++; if(sys.cmd_count == CMD_COUNT_MAX){ sys.cmd_count = 0; sys.cmd_count_enable = 0; } - //PrintComandCountLCD(sys.cmd_count); } - - rt_exec_m = sys_rt_exec_axis; // Copy volatile sys_rt_exec_alarm. - if (rt_exec_m) { - if (sys.state != STATE_HOLD){ - PrintComandLCD("AXIS"); - } - //system_clear_exec_axis_flag(uint8_t mask); + + /* seems I do not use it more, let comment for time + rt_exec_m = sys_rt_exec_axis; // Copy volatile sys_rt_exec_alarm. + if (rt_exec_m) { + if (sys.state != STATE_HOLD){ + PrintComandLCD("AXIS"); + } + } + */ + //PrintComandLCD(" "); + rt_exec_m = sys_rt_exec_position; // Copy volatile sys_rt_exec_alarm. + if (rt_exec_m) { + if (sys.state != STATE_HOLD){ + if (rt_exec_m & EXEC_GO_HOME){ + //PrintComandLCD("HOME"); + //report_status_message(gc_execute_line( "G90G0X0Y0Z0")); + + report_status_message(gc_execute_line("G90G0Z5")); + report_status_message(gc_execute_line("G0X0Y0")); + report_status_message(gc_execute_line("G90G1Z0F25")); + + system_clear_exec_position_flag(EXEC_GO_HOME); } - - - rt_exec_m = sys_rt_exec_position; // Copy volatile sys_rt_exec_alarm. - if (rt_exec_m) { - if (sys.state != STATE_HOLD){ - if (rt_exec_m & EXEC_GO_HOME){ - PrintComandLCD("HOME"); - report_status_message(gc_execute_line( "G90G0X0Y0Z0")); - system_clear_exec_position_flag(EXEC_GO_HOME); + if (rt_exec_m & EXEC_SET_ZERO){ + //PrintComandLCD("SFEED"); + if(sys.sfeed_rate == 250) sys.sfeed_rate = 50; else sys.sfeed_rate += 50; + system_clear_exec_position_flag(EXEC_SET_ZERO); + } + if (rt_exec_m & EXEC_SET_SPINDLE){ + if(spindle_get_state()){ + //PrintComandLCD("SPON "); + report_status_message(gc_execute_line( "M5S0")); + }else { + //PrintComandLCD("SPOFF "); + report_status_message(gc_execute_line( "M3S30000")); } - if (rt_exec_m & EXEC_SET_ZERO){ - if(!sys.cmd_count){ - PrintComandLCD("SFEED"); - if(sys.sfeed_rate == 250) sys.sfeed_rate = 50; else sys.sfeed_rate += 50; - sys.cmd_count_enable = 1; - } - system_clear_exec_position_flag(EXEC_SET_ZERO); + system_clear_exec_position_flag(EXEC_SET_SPINDLE); + } + } + } + + if(!sys.cmd_count){ + //protocol_read_axispins(); + pin_x = 0.0; + pin_y = 0.0; + pin_z = 0.0; + pin_pressed = 0; + pin_pressed = protocol_read_axisxyz(&pin_x, &pin_y, &pin_z); + if(pin_pressed){ + //axis_move_buttons "G91G1X+0.01Y+0.01Z+0.01F250"; + if(pin_x < 0) axis_move_buttons[6] = '-'; else axis_move_buttons[6] = '+'; + if(pin_y < 0) axis_move_buttons[12] = '-'; else axis_move_buttons[12] = '+'; + if(pin_z < 0) axis_move_buttons[18] = '-'; else axis_move_buttons[18] = '+'; + if(!pin_x){ + axis_move_buttons[7] = '0'; + axis_move_buttons[9] = '0'; + axis_move_buttons[10] = '0'; + }else{ + switch(step_per_click){ + case 0: + axis_move_buttons[7] = '0'; + axis_move_buttons[9] = '0'; + axis_move_buttons[10] = '1'; + break; + case 1: + axis_move_buttons[7] = '0'; + axis_move_buttons[9] = '1'; + axis_move_buttons[10] = '0'; + break; + case 2: + axis_move_buttons[7] = '1'; + axis_move_buttons[9] = '0'; + axis_move_buttons[10] = '0'; + break; } - if (rt_exec_m & EXEC_SET_SPINDLE){ - //uint8_t sp_state = spindle_get_state(); - //cmd_count; - //cmd_count_enable; - //CMD_COUNT_MAX - if(!sys.cmd_count){ - if(spindle_get_state()){ - PrintComandLCD("SPON "); - report_status_message(gc_execute_line( "M5S0")); - }else { - PrintComandLCD("SPOFF "); - report_status_message(gc_execute_line( "M3S30000")); - } - sys.cmd_count_enable = 1; - } - system_clear_exec_position_flag(EXEC_SET_SPINDLE); + + //axis_move_buttons[10] = '1'; + } + if(!pin_y){ + axis_move_buttons[13] = '0'; + axis_move_buttons[15] = '0'; + axis_move_buttons[16] = '0'; + }else{ + switch(step_per_click){ + case 0: + axis_move_buttons[13] = '0'; + axis_move_buttons[15] = '0'; + axis_move_buttons[16] = '1'; + break; + case 1: + axis_move_buttons[13] = '0'; + axis_move_buttons[15] = '1'; + axis_move_buttons[16] = '0'; + break; + case 2: + axis_move_buttons[13] = '1'; + axis_move_buttons[15] = '0'; + axis_move_buttons[16] = '0'; + break; } - } - - } - //protocol_read_axispins(); - pin_x = 0.0; - pin_y = 0.0; - pin_z = 0.0; - pin_pressed = 0; - pin_pressed = protocol_read_axisxyz(&pin_x, &pin_y, &pin_z); - //PrintMillsLCD(0, pin_pressed); - //PrintXyzPinsLCD(2, pin_x); - //PrintXyzPinsLCD(4, pin_y); - //PrintXyzPinsLCD(6, pin_z); - if(pin_pressed){ - //axis_move_buttons - if(pin_x < 0) axis_move_buttons[6] = '-'; else axis_move_buttons[6] = '+'; - if(pin_y < 0) axis_move_buttons[12] = '-'; else axis_move_buttons[12] = '+'; - if(pin_z < 0) axis_move_buttons[18] = '-'; else axis_move_buttons[18] = '+'; - if(!pin_x) axis_move_buttons[10] = '0'; else axis_move_buttons[10] = '1'; - if(!pin_y) axis_move_buttons[16] = '0'; else axis_move_buttons[16] = '1'; - if(!pin_z) axis_move_buttons[22] = '0'; else axis_move_buttons[22] = '1'; - axis_move_buttons[24] = '0'; - switch (sys.sfeed_rate){ - case 50: - axis_move_buttons[24] = '0'; - axis_move_buttons[25] = '5'; - axis_move_buttons[26] = '0'; - break; - case 100: - axis_move_buttons[24] = '1'; - axis_move_buttons[25] = '0'; - axis_move_buttons[26] = '0'; - break; - case 150: - axis_move_buttons[24] = '1'; - axis_move_buttons[25] = '5'; - axis_move_buttons[26] = '0'; - break; - case 200: - axis_move_buttons[24] = '2'; - axis_move_buttons[25] = '0'; - axis_move_buttons[26] = '0'; - break; - case 250: - axis_move_buttons[24] = '2'; - axis_move_buttons[25] = '5'; - axis_move_buttons[26] = '0'; - break; - } - //PrintComandLCD(&axis_move_buttons[22]); - report_status_message(gc_execute_line(axis_move_buttons)); - }else{ - pin_pressed = protocol_read_axissetxy(); - if(pin_pressed){ - report_status_message(gc_execute_line("G92X0Y0")); + //axis_move_buttons[16] = '1'; + } + if(!pin_z){ + axis_move_buttons[19] = '0'; + axis_move_buttons[21] = '0'; + axis_move_buttons[22] = '0'; + }else{ + switch(step_per_click){ + case 0: + axis_move_buttons[19] = '0'; + axis_move_buttons[21] = '0'; + axis_move_buttons[22] = '1'; + break; + case 1: + axis_move_buttons[19] = '0'; + axis_move_buttons[21] = '1'; + axis_move_buttons[22] = '0'; + break; + case 2: + axis_move_buttons[19] = '1'; + axis_move_buttons[21] = '0'; + axis_move_buttons[22] = '0'; + break; + } + //axis_move_buttons[22] = '1'; + } + axis_move_buttons[24] = '0'; + switch (sys.sfeed_rate){ + case 50: + axis_move_buttons[24] = '0'; + axis_move_buttons[25] = '5'; + axis_move_buttons[26] = '0'; + break; + case 100: + axis_move_buttons[24] = '1'; + axis_move_buttons[25] = '0'; + axis_move_buttons[26] = '0'; + break; + case 150: + axis_move_buttons[24] = '1'; + axis_move_buttons[25] = '5'; + axis_move_buttons[26] = '0'; + break; + case 200: + axis_move_buttons[24] = '2'; + axis_move_buttons[25] = '0'; + axis_move_buttons[26] = '0'; + break; + case 250: + axis_move_buttons[24] = '2'; + axis_move_buttons[25] = '5'; + axis_move_buttons[26] = '0'; + break; + } + + //PrintComandLCD(&axis_move_buttons[6]); + report_status_message(gc_execute_line(axis_move_buttons)); }else{ - pin_pressed = protocol_read_axissetz(); + pin_pressed = protocol_read_axissetxy(); + if(pin_pressed){ + report_status_message(gc_execute_line("G92X0Y0")); + }else{ + pin_pressed = protocol_read_axissetz(); if(pin_pressed){ - report_status_message(gc_execute_line("G92Z0")); + report_status_message(gc_execute_line("G92Z0")); + }else{ + pin_pressed = protocol_read_setstep(); + if(pin_pressed){ + if(step_per_click >= 2){ + step_per_click = 0; + }else{ + step_per_click += 1; + } + PrintStepLCD(step_per_click); + //PrintFStepLCD(step_per_click); + }else{ + pin_pressed = protocol_read_setpwm(); + if(pin_pressed){ + PrintComandLCD("PWM"); + }else{ + pin_pressed = protocol_read_xyzhome(); + if(pin_pressed){ + switch (pin_pressed){ + case 1: + report_status_message(gc_execute_line("G90G1Z0F25")); + //PrintComandLCD("ZHOME"); + break; + case 2: + report_status_message(gc_execute_line("G90G0Z5")); + report_status_message(gc_execute_line("G90G0X0Y0")); + //PrintComandLCD("XYHOME"); + break; + case 3: + report_status_message(gc_execute_line("G90G0Z5")); + report_status_message(gc_execute_line("G0X0Y0")); + report_status_message(gc_execute_line("G90G1Z0F25")); + //PrintComandLCD("XYZHOM"); + break; + } + } + } + } + } } } + sys.cmd_count_enable = 1; } - - //end added - } - + } + //end added + // If there are no more characters in the serial read buffer to be processed and executed, // this indicates that g-code streaming has either filled the planner buffer or has // completed. In either case, auto-cycle start, if enabled, any queued moves. protocol_auto_cycle_start(); - + protocol_execute_realtime(); // Runtime command check point. //Print status to LCD @@ -357,6 +459,8 @@ void protocol_execute_realtime() // NOTE: Do not alter this unless you know exactly what you are doing! void protocol_exec_rt_system() { + uint8_t rt_exec_m = 0; // added + uint8_t rt_exec; // Temp variable to avoid calling volatile multiple times. rt_exec = sys_rt_exec_alarm; // Copy volatile sys_rt_exec_alarm. if (rt_exec) { // Enter only if any bit flag is true @@ -385,7 +489,8 @@ void protocol_exec_rt_system() // Execute system abort. if (rt_exec & EXEC_RESET) { - PrintComandLCD("RESET "); + //PrintComandLCD("RESET "); + PrintStatusLCD("RESET"); sys.abort = true; // Only place this is set true. return; // Nothing else to do but exit. } @@ -622,37 +727,37 @@ void protocol_exec_rt_system() } } - /* - //added - rt_exec = sys_rt_exec_axis; // Copy volatile sys_rt_exec_alarm. - if (rt_exec) { - if (sys.state != STATE_HOLD){ - PrintComandLCD("AXIS"); - } - //system_clear_exec_axis_flag(uint8_t mask); -} - - rt_exec = sys_rt_exec_position; // Copy volatile sys_rt_exec_alarm. - if (rt_exec) { - if (sys.state != STATE_HOLD){ - if (rt_exec & EXEC_GO_HOME){ - PrintComandLCD("HOME"); - //report_status_message(system_execute_line( " 0) { sys.report_wco_counter--; } - else { - if (sys.state & (STATE_HOMING | STATE_CYCLE | STATE_HOLD | STATE_JOG | STATE_SAFETY_DOOR)) { - sys.report_wco_counter = (REPORT_WCO_REFRESH_BUSY_COUNT-1); // Reset counter for slow refresh - } else { sys.report_wco_counter = (REPORT_WCO_REFRESH_IDLE_COUNT-1); } - if (sys.report_ovr_counter == 0) { sys.report_ovr_counter = 1; } // Set override on next report. - printPgmString(PSTR("|WCO:")); - report_util_axis_values(wco); - PrintWcoLCD(wco[0], wco[1],wco[2]); - } - */ - if (sys.report_wco_counter == 0){ - //PrintWcoLCD(wco[0], wco[1],wco[2]); - } - #endif - - PrintSfeedLCD(sys.sfeed_rate); + //PrintSfeedLCD(sys.sfeed_rate); } diff --git a/grbl_lcd/report.h b/grbl_lcd/report.h index 0b4e59369..f92209fc8 100644 --- a/grbl_lcd/report.h +++ b/grbl_lcd/report.h @@ -126,6 +126,7 @@ void report_build_info(char *line); // Prints realtime status to LCD void report_lcd_status(); +void report_lcd_status_fast(); #ifdef DEBUG void report_realtime_debug(); diff --git a/grbl_lcd/system.c b/grbl_lcd/system.c index 23dd6c902..9bf25d7b9 100644 --- a/grbl_lcd/system.c +++ b/grbl_lcd/system.c @@ -66,6 +66,7 @@ ISR(CONTROL_INT_vect) uint8_t pin = system_control_get_state(); if (pin) { if (bit_istrue(pin,CONTROL_PIN_INDEX_RESET)) { + memset(sys_position,0,sizeof(sys_position)); // Clear machine position. mc_reset(); } else if (bit_istrue(pin,CONTROL_PIN_INDEX_CYCLE_START)) { bit_true(sys_rt_exec_state, EXEC_CYCLE_START); diff --git a/grbl_lcd/system.h b/grbl_lcd/system.h index 9cef90996..131e43db8 100644 --- a/grbl_lcd/system.h +++ b/grbl_lcd/system.h @@ -173,6 +173,7 @@ typedef struct { uint8_t override_ctrl; // Tracks override control states. #endif float spindle_speed; + //float step_per_click; int sfeed_rate; int cmd_count; int cmd_count_enable; From a682f7b01c95bb48406516859057796ff02dfe4f Mon Sep 17 00:00:00 2001 From: Ludwig Date: Mon, 26 Feb 2018 09:41:14 +0100 Subject: [PATCH 08/13] added feed step, xy to 0 and z to 0 buttons --- grbl_lcd/config.h | 2 +- grbl_lcd/protocol.c | 62 +++++++++++++++++++++++---------------------- grbl_lcd/system.h | 1 + 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/grbl_lcd/config.h b/grbl_lcd/config.h index bffc41fbc..21aa15451 100644 --- a/grbl_lcd/config.h +++ b/grbl_lcd/config.h @@ -212,7 +212,7 @@ // Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful // for some pre-built electronic boards. -// #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable. +#define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable. // Inverts the selected coolant pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful // for some pre-built electronic boards. diff --git a/grbl_lcd/protocol.c b/grbl_lcd/protocol.c index ef5b86797..42b106e37 100644 --- a/grbl_lcd/protocol.c +++ b/grbl_lcd/protocol.c @@ -187,39 +187,40 @@ void protocol_main_loop() } } */ + if(!sys.cmd_count){ //PrintComandLCD(" "); - rt_exec_m = sys_rt_exec_position; // Copy volatile sys_rt_exec_alarm. - if (rt_exec_m) { - if (sys.state != STATE_HOLD){ - if (rt_exec_m & EXEC_GO_HOME){ - //PrintComandLCD("HOME"); - //report_status_message(gc_execute_line( "G90G0X0Y0Z0")); - - report_status_message(gc_execute_line("G90G0Z5")); - report_status_message(gc_execute_line("G0X0Y0")); - report_status_message(gc_execute_line("G90G1Z0F25")); - - system_clear_exec_position_flag(EXEC_GO_HOME); - } - if (rt_exec_m & EXEC_SET_ZERO){ - //PrintComandLCD("SFEED"); - if(sys.sfeed_rate == 250) sys.sfeed_rate = 50; else sys.sfeed_rate += 50; - system_clear_exec_position_flag(EXEC_SET_ZERO); - } - if (rt_exec_m & EXEC_SET_SPINDLE){ - if(spindle_get_state()){ - //PrintComandLCD("SPON "); - report_status_message(gc_execute_line( "M5S0")); - }else { - //PrintComandLCD("SPOFF "); - report_status_message(gc_execute_line( "M3S30000")); + rt_exec_m = sys_rt_exec_position; // Copy volatile sys_rt_exec_alarm. + if (rt_exec_m) { + if (sys.state != STATE_HOLD){ + if (rt_exec_m & EXEC_GO_HOME){ + //PrintComandLCD("HOME"); + //report_status_message(gc_execute_line( "G90G0X0Y0Z0")); + + report_status_message(gc_execute_line("G90G0Z5")); + report_status_message(gc_execute_line("G0X0Y0")); + report_status_message(gc_execute_line("G90G1Z0F25")); + + system_clear_exec_position_flag(EXEC_GO_HOME); } - system_clear_exec_position_flag(EXEC_SET_SPINDLE); - } - } - } + if (rt_exec_m & EXEC_SET_ZERO){ + //PrintComandLCD("SFEED"); + if(sys.sfeed_rate == 250) sys.sfeed_rate = 50; else sys.sfeed_rate += 50; + system_clear_exec_position_flag(EXEC_SET_ZERO); + } + if (rt_exec_m & EXEC_SET_SPINDLE){ + if(spindle_get_state()){ + //PrintComandLCD("SPON "); + report_status_message(gc_execute_line( "M5S0")); + }else { + //PrintComandLCD("SPOFF "); + report_status_message(gc_execute_line( "M3S30000")); + } + system_clear_exec_position_flag(EXEC_SET_SPINDLE); + } + } + } - if(!sys.cmd_count){ + //if(!sys.cmd_count){ //protocol_read_axispins(); pin_x = 0.0; pin_y = 0.0; @@ -335,6 +336,7 @@ void protocol_main_loop() //PrintComandLCD(&axis_move_buttons[6]); report_status_message(gc_execute_line(axis_move_buttons)); + sys.cmd_count += CMD_COUNT_MIN; }else{ pin_pressed = protocol_read_axissetxy(); if(pin_pressed){ diff --git a/grbl_lcd/system.h b/grbl_lcd/system.h index 131e43db8..12dae4c43 100644 --- a/grbl_lcd/system.h +++ b/grbl_lcd/system.h @@ -150,6 +150,7 @@ #define SPINDLE_STOP_OVR_RESTORE_CYCLE bit(3) #define CMD_COUNT_MAX 25 +#define CMD_COUNT_MIN 15 // Define global system variables typedef struct { uint8_t state; // Tracks the current system state of Grbl. From 7179c698b3032870985d2e4e1c2e442ab5964edd Mon Sep 17 00:00:00 2001 From: Ludwig Date: Mon, 26 Feb 2018 13:51:50 +0100 Subject: [PATCH 09/13] added decoders for x and y --- grbl_lcd/cpu_map.h | 6 ++++++ grbl_lcd/lcd.cpp | 2 +- grbl_lcd/main.c | 24 +++++++++++++++++++++--- grbl_lcd/protocol.c | 34 ++++++++++++++++++++++++++++++++++ grbl_lcd/protocol.h | 4 ++++ grbl_lcd/system.h | 7 +++++++ 6 files changed, 73 insertions(+), 4 deletions(-) diff --git a/grbl_lcd/cpu_map.h b/grbl_lcd/cpu_map.h index 82564d9ba..3123ac36f 100644 --- a/grbl_lcd/cpu_map.h +++ b/grbl_lcd/cpu_map.h @@ -147,6 +147,12 @@ #define pwmSetPin 36 //36 // #define zHometPin 35 //36 // #define xyHomePin 37 //36 // + + #define encoderXaPin 54 + #define encoderXbPin 55 + #define encoderYaPin 56 + #define encoderYbPin 57 + /* * pins used for LCD diff --git a/grbl_lcd/lcd.cpp b/grbl_lcd/lcd.cpp index a70d3df20..97f97cb32 100644 --- a/grbl_lcd/lcd.cpp +++ b/grbl_lcd/lcd.cpp @@ -92,7 +92,7 @@ void PrintComandCountLCD(int cnt) char str[7]; sprintf(str,"%-6d", cnt); - lcd.setCursor(0, 3); + lcd.setCursor(9, 3); lcd.print(str); } diff --git a/grbl_lcd/main.c b/grbl_lcd/main.c index 4ea2dcec4..f734caad4 100644 --- a/grbl_lcd/main.c +++ b/grbl_lcd/main.c @@ -61,7 +61,18 @@ int main(void) pinMode(zHometPin, INPUT_PULLUP); pinMode(xyHomePin, INPUT_PULLUP); + pinMode(encoderXaPin, INPUT); + pinMode(encoderXbPin, INPUT); + pinMode(encoderYaPin, INPUT); + pinMode(encoderYbPin, INPUT); + + digitalWrite(encoderXaPin, LOW); + digitalWrite(encoderXbPin, LOW); + digitalWrite(encoderYaPin, LOW); + digitalWrite(encoderYbPin, LOW); + + //end added serial_init(); // Setup serial baud rate and interrupts settings_init(); // Load Grbl settings from EEPROM @@ -125,9 +136,16 @@ int main(void) sys_rt_exec_position = 0; // added sys.sfeed_rate = 250; - sys.cmd_count = 0; - sys.cmd_count_enable = 0; - //sys.step_per_click = 0.01; + sys.cmd_count = 0; + sys.cmd_count_enable = 0; + //sys.step_per_click = 0.01; + + sys.encoderXPos = 0; + sys.encoderXPinALast = LOW; + sys.nX = LOW; + sys.encoderYPos = 0; + sys.encoderYPinALast = LOW; + sys.nY = LOW; diff --git a/grbl_lcd/protocol.c b/grbl_lcd/protocol.c index 42b106e37..87ec33954 100644 --- a/grbl_lcd/protocol.c +++ b/grbl_lcd/protocol.c @@ -187,6 +187,10 @@ void protocol_main_loop() } } */ + + + protocol_read_xencoder(); + protocol_read_yencoder(); if(!sys.cmd_count){ //PrintComandLCD(" "); rt_exec_m = sys_rt_exec_position; // Copy volatile sys_rt_exec_alarm. @@ -924,6 +928,36 @@ int protocol_read_xyzhome() return pinValue; } +int protocol_read_xencoder() +{ + sys.nX = digitalRead(encoderXaPin); + if ((sys.encoderXPinALast == LOW) && (sys.nX == HIGH)) { + PrintComandLCD("X-ENCDER"); + if (digitalRead(encoderXbPin) == LOW) { + sys.encoderXPos--; + } else { + sys.encoderXPos++; + } + PrintComandCountLCD(sys.encoderXPos); + } + sys.encoderXPinALast = sys.nX; +} + +int protocol_read_yencoder() +{ + sys.nY = digitalRead(encoderYaPin); + if ((sys.encoderYPinALast == LOW) && (sys.nY == HIGH)) { + PrintComandLCD("Y-ENCDER"); + if (digitalRead(encoderYbPin) == LOW) { + sys.encoderYPos--; + } else { + sys.encoderYPos++; + } + PrintComandCountLCD(sys.encoderYPos); + } + sys.encoderYPinALast = sys.nY; +} + //end added // Handles Grbl system suspend procedures, such as feed hold, safety door, and parking motion. diff --git a/grbl_lcd/protocol.h b/grbl_lcd/protocol.h index d10d22abb..97cf037d8 100644 --- a/grbl_lcd/protocol.h +++ b/grbl_lcd/protocol.h @@ -56,6 +56,10 @@ int protocol_read_setpwm(); int protocol_read_setstep(); //added read digital pins for pwm settings int protocol_read_xyzhome(); +//added read digital pins for pwm settings +int protocol_read_xencoder(); +//added read digital pins for pwm settings +int protocol_read_yencoder(); extern volatile uint8_t step_per_click; diff --git a/grbl_lcd/system.h b/grbl_lcd/system.h index 12dae4c43..b0585db53 100644 --- a/grbl_lcd/system.h +++ b/grbl_lcd/system.h @@ -178,6 +178,13 @@ typedef struct { int sfeed_rate; int cmd_count; int cmd_count_enable; + + int encoderXPos; + int encoderXPinALast; + int nX; + int encoderYPos; + int encoderYPinALast; + int nY; } system_t; extern system_t sys; From 12f9a62e1caeed77217a4357e20d45101057fa53 Mon Sep 17 00:00:00 2001 From: Ludwig Petrosyan Date: Mon, 26 Feb 2018 16:32:47 +0100 Subject: [PATCH 10/13] change pins --- grbl_lcd/cpu_map.h | 22 ++++++++++++---------- grbl_lcd/lcd.cpp | 7 +++++-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/grbl_lcd/cpu_map.h b/grbl_lcd/cpu_map.h index 3123ac36f..30dcbd1fa 100644 --- a/grbl_lcd/cpu_map.h +++ b/grbl_lcd/cpu_map.h @@ -135,18 +135,20 @@ #define SPINDLE_PWM_BIT 4 // MEGA2560 Digital Pin 7 - #define xUpPin 53 //45 // - #define xDownPin 51 //44 // - #define yUpPin 49 //43 // - #define yDownPin 47 //42 // - #define zUpPin 45 //41 // - #define zDownPin 43 //40 // - #define xySetPin 41 //39 // - #define zSetPin 39 //38 // + #define xUpPin 53 //45 // + #define xDownPin 51 //44 // + #define yUpPin 49 //43 // + #define yDownPin 47 //42 // + #define zUpPin 45 //41 // + #define zDownPin 43 //40 // + #define xySetPin 41 //39 // + #define zSetPin 39 //38 // + #define zHometPin 38 //36 // + #define xyHomePin 37 //36 // + #define StepSetPin 38 //37 // #define pwmSetPin 36 //36 // - #define zHometPin 35 //36 // - #define xyHomePin 37 //36 // + #define encoderXaPin 54 #define encoderXbPin 55 diff --git a/grbl_lcd/lcd.cpp b/grbl_lcd/lcd.cpp index 97f97cb32..122b42fd1 100644 --- a/grbl_lcd/lcd.cpp +++ b/grbl_lcd/lcd.cpp @@ -15,8 +15,11 @@ //const int rs = 22, en = 24, d4 = 26, d5 = 28, d6 = 30, d7 = 32; //LiquidCrystal lcd(rs, en, d4, d5, d6, d7); -const int rs = 52, rw = 50, en = 48, d4 = 46, d5 = 44, d6 = 42, d7 = 40; -LiquidCrystal lcd(rs, rw, en, d4, d5, d6, d7); +//const int rs = 52, rw = 50, en = 48, d4 = 46, d5 = 44, d6 = 42, d7 = 40; +//LiquidCrystal lcd(rs, rw, en, d4, d5, d6, d7); + +const int rs = 53, en = 52, d4 = 51, d5 = 50, d6 = 49, d7 = 48; +LiquidCrystal lcd(rs, en, d4, d5, d6, d7); //extern "C"{ From 6f9a154607dc3e1e65e9a2562b4061cef46ee4ac Mon Sep 17 00:00:00 2001 From: Ludwig Date: Tue, 27 Feb 2018 06:41:59 +0100 Subject: [PATCH 11/13] decoders for x and y --- grbl_lcd/cpu_map.h | 35 +++++++++++++++------------- grbl_lcd/lcd.cpp | 18 +++++++++++++- grbl_lcd/lcd.h | 2 ++ grbl_lcd/main.c | 39 +++++++++++++++++++------------ grbl_lcd/protocol.c | 57 ++++++++++++++++++++++++++++++++++++++------- grbl_lcd/protocol.h | 6 ++++- 6 files changed, 116 insertions(+), 41 deletions(-) diff --git a/grbl_lcd/cpu_map.h b/grbl_lcd/cpu_map.h index 30dcbd1fa..fbeda24b1 100644 --- a/grbl_lcd/cpu_map.h +++ b/grbl_lcd/cpu_map.h @@ -135,25 +135,28 @@ #define SPINDLE_PWM_BIT 4 // MEGA2560 Digital Pin 7 - #define xUpPin 53 //45 // - #define xDownPin 51 //44 // - #define yUpPin 49 //43 // - #define yDownPin 47 //42 // - #define zUpPin 45 //41 // - #define zDownPin 43 //40 // - #define xySetPin 41 //39 // - #define zSetPin 39 //38 // - #define zHometPin 38 //36 // - #define xyHomePin 37 //36 // + #define xUpPin 47 //45 // + #define xDownPin 46 //44 // + #define yUpPin 45 //43 // + #define yDownPin 44 //42 // + #define zUpPin 43 //41 // + #define zDownPin 42 //40 // + #define xySetPin 41 //39 // + #define zSetPin 40 //38 // + #define zHometPin 39 //36 // + #define xyHomePin 38 //36 // - #define StepSetPin 38 //37 // - #define pwmSetPin 36 //36 // + #define StepSetPin 37 //37 // + #define homeSetPin 36 //36 // home + + #define goXyPin 35 //36 // home + #define feedSetPin 34 //36 // home - #define encoderXaPin 54 - #define encoderXbPin 55 - #define encoderYaPin 56 - #define encoderYbPin 57 + #define encoderXaPin A0 + #define encoderXbPin A1 + #define encoderYaPin A2 + #define encoderYbPin A3 /* diff --git a/grbl_lcd/lcd.cpp b/grbl_lcd/lcd.cpp index 122b42fd1..81b26b0c6 100644 --- a/grbl_lcd/lcd.cpp +++ b/grbl_lcd/lcd.cpp @@ -18,7 +18,7 @@ //const int rs = 52, rw = 50, en = 48, d4 = 46, d5 = 44, d6 = 42, d7 = 40; //LiquidCrystal lcd(rs, rw, en, d4, d5, d6, d7); -const int rs = 53, en = 52, d4 = 51, d5 = 50, d6 = 49, d7 = 48; +const int rs = 52, en = 53, d4 = 50, d5 = 51, d6 = 48, d7 = 49; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); @@ -216,6 +216,22 @@ void PrintStepLCD(int idx) lcd.print(y); } +void PrintPosLCDXX(float x) +{ + lcd.setCursor(0, 3); + lcd.print(x); + lcd.setCursor(4, 3); + lcd.print(" "); +} + + void PrintPosLCDYY(float y) +{ + lcd.setCursor(7, 3); + lcd.print(y); + lcd.setCursor(11, 3); + lcd.print(" "); +} + void PrintPosLCDZ(float z) { lcd.setCursor(14, 1); diff --git a/grbl_lcd/lcd.h b/grbl_lcd/lcd.h index 5b149476a..cbc64fcc3 100644 --- a/grbl_lcd/lcd.h +++ b/grbl_lcd/lcd.h @@ -65,6 +65,8 @@ void PrintXyzPinsLCD(int of, float f); void PrintSfeedLCD(int f); void PrintStepLCD(int idx); void PrintFStepLCD(int idx); +void PrintPosLCDXX(float x); +void PrintPosLCDYY(float y); #ifdef __cplusplus } diff --git a/grbl_lcd/main.c b/grbl_lcd/main.c index f734caad4..108c78568 100644 --- a/grbl_lcd/main.c +++ b/grbl_lcd/main.c @@ -48,29 +48,38 @@ int main(void) // Initialize system upon power-up. //added - pinMode(xUpPin, INPUT_PULLUP); + pinMode(xUpPin, INPUT_PULLUP); pinMode(xDownPin, INPUT_PULLUP); - pinMode(yUpPin, INPUT_PULLUP); + pinMode(yUpPin, INPUT_PULLUP); pinMode(yDownPin, INPUT_PULLUP); - pinMode(zUpPin, INPUT_PULLUP); + pinMode(zUpPin, INPUT_PULLUP); pinMode(zDownPin, INPUT_PULLUP); pinMode(xySetPin, INPUT_PULLUP); - pinMode(zSetPin, INPUT_PULLUP); - pinMode(pwmSetPin, INPUT_PULLUP); + pinMode(zSetPin, INPUT_PULLUP); pinMode(StepSetPin, INPUT_PULLUP); - pinMode(zHometPin, INPUT_PULLUP); - pinMode(xyHomePin, INPUT_PULLUP); + pinMode(zHometPin, INPUT_PULLUP); + pinMode(xyHomePin, INPUT_PULLUP); - pinMode(encoderXaPin, INPUT); - pinMode(encoderXbPin, INPUT); - pinMode(encoderYaPin, INPUT); - pinMode(encoderYbPin, INPUT); + pinMode(homeSetPin, INPUT_PULLUP); + pinMode(goXyPin, INPUT_PULLUP); + pinMode(feedSetPin, INPUT_PULLUP); + + + //pinMode(encoderXaPin, INPUT); + //pinMode(encoderXbPin, INPUT); + //pinMode(encoderYaPin, INPUT); + //pinMode(encoderYbPin, INPUT); + + pinMode(encoderXaPin, INPUT_PULLUP); + pinMode(encoderXbPin, INPUT_PULLUP); + pinMode(encoderYaPin, INPUT_PULLUP); + pinMode(encoderYbPin, INPUT_PULLUP); - digitalWrite(encoderXaPin, LOW); - digitalWrite(encoderXbPin, LOW); - digitalWrite(encoderYaPin, LOW); - digitalWrite(encoderYbPin, LOW); + //digitalWrite(encoderXaPin, LOW); + //digitalWrite(encoderXbPin, LOW); + //digitalWrite(encoderYaPin, LOW); + //digitalWrite(encoderYbPin, LOW); //end added diff --git a/grbl_lcd/protocol.c b/grbl_lcd/protocol.c index 87ec33954..14c34ef7a 100644 --- a/grbl_lcd/protocol.c +++ b/grbl_lcd/protocol.c @@ -360,9 +360,13 @@ void protocol_main_loop() PrintStepLCD(step_per_click); //PrintFStepLCD(step_per_click); }else{ - pin_pressed = protocol_read_setpwm(); + pin_pressed = protocol_read_sethome(); if(pin_pressed){ - PrintComandLCD("PWM"); + PrintComandLCD("HOME"); + report_status_message(gc_execute_line("G90G0Z5")); + report_status_message(gc_execute_line("G0X0Y0")); + report_status_message(gc_execute_line("G90G1Z0F25")); + }else{ pin_pressed = protocol_read_xyzhome(); if(pin_pressed){ @@ -383,6 +387,17 @@ void protocol_main_loop() //PrintComandLCD("XYZHOM"); break; } + }else{ + pin_pressed = protocol_read_setfeed(); + if(pin_pressed){ + //PrintComandLCD("FEED"); + if(sys.sfeed_rate == 250) sys.sfeed_rate = 50; else sys.sfeed_rate += 50; + }else{ + pin_pressed = protocol_read_goxy(); + if(pin_pressed){ + PrintComandLCD("GOXY"); + } + } } } } @@ -887,17 +902,41 @@ int protocol_read_axissetz() return pinValue; } -int protocol_read_setpwm() +int protocol_read_sethome() +{ + int pinValue = 0; + int val = 0; + + val = digitalRead(homeSetPin); + if(!val) pinValue = 1; + + return pinValue; +} + +int protocol_read_setfeed() +{ + int pinValue = 0; + int val = 0; + + val = digitalRead(feedSetPin); + if(!val) pinValue = 1; + + return pinValue; +} + +int protocol_read_goxy() { int pinValue = 0; int val = 0; - val = digitalRead(pwmSetPin); + val = digitalRead(goXyPin); if(!val) pinValue = 1; return pinValue; } + + int protocol_read_setstep() { int pinValue = 0; @@ -932,13 +971,14 @@ int protocol_read_xencoder() { sys.nX = digitalRead(encoderXaPin); if ((sys.encoderXPinALast == LOW) && (sys.nX == HIGH)) { - PrintComandLCD("X-ENCDER"); + //PrintComandLCD("X-ENCDER"); if (digitalRead(encoderXbPin) == LOW) { sys.encoderXPos--; } else { sys.encoderXPos++; } - PrintComandCountLCD(sys.encoderXPos); + + PrintPosLCDXX(sys.encoderXPos); } sys.encoderXPinALast = sys.nX; } @@ -947,13 +987,14 @@ int protocol_read_yencoder() { sys.nY = digitalRead(encoderYaPin); if ((sys.encoderYPinALast == LOW) && (sys.nY == HIGH)) { - PrintComandLCD("Y-ENCDER"); + //PrintComandLCD("Y-ENCDER"); if (digitalRead(encoderYbPin) == LOW) { sys.encoderYPos--; } else { sys.encoderYPos++; } - PrintComandCountLCD(sys.encoderYPos); + //PrintComandCountLCD(sys.encoderYPos); + PrintPosLCDYY(sys.encoderYPos); } sys.encoderYPinALast = sys.nY; } diff --git a/grbl_lcd/protocol.h b/grbl_lcd/protocol.h index 97cf037d8..5dc5266ec 100644 --- a/grbl_lcd/protocol.h +++ b/grbl_lcd/protocol.h @@ -51,10 +51,14 @@ int protocol_read_axissetxy(); //added read digital pins for axis moving int protocol_read_axissetz(); //added read digital pins for pwm settings -int protocol_read_setpwm(); +int protocol_read_sethome(); //added read digital pins for pwm settings int protocol_read_setstep(); //added read digital pins for pwm settings +int protocol_read_setfeed(); +//added read digital pins for pwm settings +int protocol_read_goxy(); +//added read digital pins for pwm settings int protocol_read_xyzhome(); //added read digital pins for pwm settings int protocol_read_xencoder(); From b8a767007fbcded7b45923cf335a232c50e252eb Mon Sep 17 00:00:00 2001 From: Ludwig Petrosyan Date: Tue, 27 Feb 2018 19:07:51 +0100 Subject: [PATCH 12/13] add encoder --- grbl_lcd/cpu_map.h | 48 +++++++++----- grbl_lcd/lcd.cpp | 14 ++-- grbl_lcd/main.c | 35 +++++----- grbl_lcd/protocol.c | 158 ++++++++++++++++++++++++++------------------ grbl_lcd/protocol.h | 11 +-- grbl_lcd/system.c | 14 ++-- grbl_lcd/system.h | 40 +++++------ 7 files changed, 182 insertions(+), 138 deletions(-) diff --git a/grbl_lcd/cpu_map.h b/grbl_lcd/cpu_map.h index fbeda24b1..2bb3360d2 100644 --- a/grbl_lcd/cpu_map.h +++ b/grbl_lcd/cpu_map.h @@ -94,14 +94,14 @@ #define CONTROL_FEED_HOLD_BIT 1 // MEGA2560 Analog Pin 9 #define CONTROL_CYCLE_START_BIT 2 // MEGA2560 Analog Pin 10 #define CONTROL_SAFETY_DOOR_BIT 3 // MEGA2560 Analog Pin 11 - #define CONTROL_GO_HOME_BIT 4 // MEGA2560 Analog Pin 12 - #define CONTROL_SET_ZERO_BIT 5 // MEGA2560 Analog Pin 13 + #define CONTROL_HOME_BIT 4 // MEGA2560 Analog Pin 12 + #define CONTROL_FEED_BIT 5 // MEGA2560 Analog Pin 13 #define CONTROL_SET_SPINDLE_BIT 6 // MEGA2560 Analog Pin 14 #define CONTROL_INT PCIE2 // Pin change interrupt enable pin #define CONTROL_INT_vect PCINT2_vect #define CONTROL_PCMSK PCMSK2 // Pin change interrupt register // #define CONTROL_MASK ((1<= CMD_COUNT_MAX){ sys.cmd_count = 0; sys.cmd_count_enable = 0; } } - - /* seems I do not use it more, let comment for time - rt_exec_m = sys_rt_exec_axis; // Copy volatile sys_rt_exec_alarm. - if (rt_exec_m) { - if (sys.state != STATE_HOLD){ - PrintComandLCD("AXIS"); - } - } - */ - - + protocol_read_xencoder(); protocol_read_yencoder(); if(!sys.cmd_count){ @@ -196,20 +195,19 @@ void protocol_main_loop() rt_exec_m = sys_rt_exec_position; // Copy volatile sys_rt_exec_alarm. if (rt_exec_m) { if (sys.state != STATE_HOLD){ - if (rt_exec_m & EXEC_GO_HOME){ + if (rt_exec_m & EXEC_SET_HOME){ //PrintComandLCD("HOME"); - //report_status_message(gc_execute_line( "G90G0X0Y0Z0")); - report_status_message(gc_execute_line("G90G0Z5")); report_status_message(gc_execute_line("G0X0Y0")); report_status_message(gc_execute_line("G90G1Z0F25")); - system_clear_exec_position_flag(EXEC_GO_HOME); + system_clear_exec_position_flag(EXEC_SET_HOME); } - if (rt_exec_m & EXEC_SET_ZERO){ + if (rt_exec_m & EXEC_SET_FEED){ //PrintComandLCD("SFEED"); if(sys.sfeed_rate == 250) sys.sfeed_rate = 50; else sys.sfeed_rate += 50; - system_clear_exec_position_flag(EXEC_SET_ZERO); + + system_clear_exec_position_flag(EXEC_SET_FEED); } if (rt_exec_m & EXEC_SET_SPINDLE){ if(spindle_get_state()){ @@ -358,48 +356,79 @@ void protocol_main_loop() step_per_click += 1; } PrintStepLCD(step_per_click); + switch(step_per_click){ + case 0: + sys.step_click = 0.01; + break; + case 1: + sys.step_click = 0.1; + break; + case 2: + sys.step_click = 1.0; + break; + } //PrintFStepLCD(step_per_click); }else{ - pin_pressed = protocol_read_sethome(); + pin_pressed = protocol_read_xyzhome(); if(pin_pressed){ - PrintComandLCD("HOME"); - report_status_message(gc_execute_line("G90G0Z5")); - report_status_message(gc_execute_line("G0X0Y0")); - report_status_message(gc_execute_line("G90G1Z0F25")); - + switch (pin_pressed){ + case 1: + report_status_message(gc_execute_line("G90G1Z0F25")); + //PrintComandLCD("ZHOME"); + break; + case 2: + report_status_message(gc_execute_line("G90G0Z5")); + report_status_message(gc_execute_line("G90G0X0Y0")); + //PrintComandLCD("XYHOME"); + break; + case 3: + report_status_message(gc_execute_line("G90G0Z5")); + report_status_message(gc_execute_line("G0X0Y0")); + report_status_message(gc_execute_line("G90G1Z0F25")); + //PrintComandLCD("XYZHOM"); + break; + } }else{ - pin_pressed = protocol_read_xyzhome(); + pin_pressed = protocol_read_goxy(); if(pin_pressed){ - switch (pin_pressed){ - case 1: - report_status_message(gc_execute_line("G90G1Z0F25")); - //PrintComandLCD("ZHOME"); - break; - case 2: - report_status_message(gc_execute_line("G90G0Z5")); - report_status_message(gc_execute_line("G90G0X0Y0")); - //PrintComandLCD("XYHOME"); - break; - case 3: - report_status_message(gc_execute_line("G90G0Z5")); - report_status_message(gc_execute_line("G0X0Y0")); - report_status_message(gc_execute_line("G90G1Z0F25")); - //PrintComandLCD("XYZHOM"); - break; - } + //PrintComandLCD("GOXY"); + axis_goto_str[0] = '\0'; + //floatX; + //floatY; + //intFeed; + //char* axis_goto_buttons0 = "G90G1X"; + //char* axis_goto_buttons1 = "Y"; + //char* axis_goto_buttons2 = "F"; + //axis_goto_str + + //sprintf(floatX, "%i", sys.encoderXFPos); + dtostrf(sys.encoderXFPos, 3, 2, floatX); + dtostrf(sys.encoderYFPos, 3, 2, floatY); + strcat(axis_goto_str, axis_goto_buttons0); + strcat(axis_goto_str, floatX); + strcat(axis_goto_str, axis_goto_buttons1); + strcat(axis_goto_str, floatY); + strcat(axis_goto_str, axis_goto_buttons2); + sprintf(intFeed, "%-.4d", sys.sfeed_rate); + strcat(axis_goto_str, intFeed); + //PrintComandLCD(floatX); + //PrintComandLCD(axis_goto_str); + report_status_message(gc_execute_line(axis_goto_str)); + //"G90G1X+0.01Y+0.01F250"; }else{ - pin_pressed = protocol_read_setfeed(); + pin_pressed = protocol_read_xencoder0(); if(pin_pressed){ - //PrintComandLCD("FEED"); - if(sys.sfeed_rate == 250) sys.sfeed_rate = 50; else sys.sfeed_rate += 50; + sys.encoderXFPos = 0.0; + PrintPosLCDXX(sys.encoderXFPos); }else{ - pin_pressed = protocol_read_goxy(); + pin_pressed = protocol_read_yencoder0(); if(pin_pressed){ - PrintComandLCD("GOXY"); + sys.encoderYFPos = 0.0; + PrintPosLCDYY(sys.encoderYFPos); } } } - } + } } } } @@ -902,47 +931,47 @@ int protocol_read_axissetz() return pinValue; } -int protocol_read_sethome() +int protocol_read_goxy() { int pinValue = 0; int val = 0; - val = digitalRead(homeSetPin); + val = digitalRead(goXyPin); if(!val) pinValue = 1; return pinValue; } -int protocol_read_setfeed() + + +int protocol_read_setstep() { int pinValue = 0; int val = 0; - val = digitalRead(feedSetPin); + val = digitalRead(StepSetPin); if(!val) pinValue = 1; return pinValue; } -int protocol_read_goxy() +protocol_read_xencoder0() { int pinValue = 0; int val = 0; - val = digitalRead(goXyPin); + val = digitalRead(encoderSetX0); if(!val) pinValue = 1; return pinValue; } - - -int protocol_read_setstep() +protocol_read_yencoder0() { int pinValue = 0; int val = 0; - val = digitalRead(StepSetPin); + val = digitalRead(encoderSetY0); if(!val) pinValue = 1; return pinValue; @@ -973,12 +1002,12 @@ int protocol_read_xencoder() if ((sys.encoderXPinALast == LOW) && (sys.nX == HIGH)) { //PrintComandLCD("X-ENCDER"); if (digitalRead(encoderXbPin) == LOW) { - sys.encoderXPos--; + sys.encoderXFPos = sys.encoderXFPos - sys.step_click; } else { - sys.encoderXPos++; + sys.encoderXFPos = sys.encoderXFPos + sys.step_click; } - PrintPosLCDXX(sys.encoderXPos); + PrintPosLCDXX(sys.encoderXFPos); } sys.encoderXPinALast = sys.nX; } @@ -989,12 +1018,11 @@ int protocol_read_yencoder() if ((sys.encoderYPinALast == LOW) && (sys.nY == HIGH)) { //PrintComandLCD("Y-ENCDER"); if (digitalRead(encoderYbPin) == LOW) { - sys.encoderYPos--; + sys.encoderYFPos = sys.encoderYFPos - sys.step_click; } else { - sys.encoderYPos++; + sys.encoderYFPos = sys.encoderYFPos + sys.step_click; } - //PrintComandCountLCD(sys.encoderYPos); - PrintPosLCDYY(sys.encoderYPos); + PrintPosLCDYY(sys.encoderYFPos); } sys.encoderYPinALast = sys.nY; } diff --git a/grbl_lcd/protocol.h b/grbl_lcd/protocol.h index 5dc5266ec..11a4e9d68 100644 --- a/grbl_lcd/protocol.h +++ b/grbl_lcd/protocol.h @@ -51,12 +51,8 @@ int protocol_read_axissetxy(); //added read digital pins for axis moving int protocol_read_axissetz(); //added read digital pins for pwm settings -int protocol_read_sethome(); -//added read digital pins for pwm settings int protocol_read_setstep(); //added read digital pins for pwm settings -int protocol_read_setfeed(); -//added read digital pins for pwm settings int protocol_read_goxy(); //added read digital pins for pwm settings int protocol_read_xyzhome(); @@ -64,8 +60,15 @@ int protocol_read_xyzhome(); int protocol_read_xencoder(); //added read digital pins for pwm settings int protocol_read_yencoder(); +int protocol_read_xencoder0(); +int protocol_read_yencoder0(); extern volatile uint8_t step_per_click; extern volatile uint8_t protocol_count; + +extern volatile uint8_t nX; +extern volatile uint8_t nY; +extern volatile uint8_t bX; +extern volatile uint8_t bY; #endif diff --git a/grbl_lcd/system.c b/grbl_lcd/system.c index 9bf25d7b9..ef28e9063 100644 --- a/grbl_lcd/system.c +++ b/grbl_lcd/system.c @@ -49,8 +49,8 @@ uint8_t system_control_get_state() if (bit_isfalse(pin,(1< Date: Thu, 1 Mar 2018 11:39:02 +0100 Subject: [PATCH 13/13] change goto xy0 and z0 pins --- grbl_lcd/cpu_map.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grbl_lcd/cpu_map.h b/grbl_lcd/cpu_map.h index 2bb3360d2..d5b6ab79f 100644 --- a/grbl_lcd/cpu_map.h +++ b/grbl_lcd/cpu_map.h @@ -143,8 +143,8 @@ #define zDownPin 42 //40 // #define xySetPin 41 //39 // #define zSetPin 40 //38 // - #define zHometPin 39 //36 // - #define xyHomePin 38 //36 // + #define zHometPin 38 //36 // + #define xyHomePin 39 //36 // #define StepSetPin 37 //37 // #define goXyPin 36 //36 // home