From 0f330947b9630f2cc95e715af34f8be7d701155c Mon Sep 17 00:00:00 2001 From: Matthew Pearce Date: Fri, 2 Feb 2018 16:32:52 +0000 Subject: [PATCH 1/5] New features: 1. Heated bed support. 2. Support for G20/G21 code for Slic3r 3. UArm grove lcd module support Ensure that you remove the Base LCD Library and replace with this: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads/Newliquidcrystal_1.3.5.zip --- lib/Marlin/Configuration.h | 14 +++++++++----- lib/Marlin/pins_Swift.h | 4 ++-- lib/Marlin/ultralcd_impl_HD44780.h | 5 +++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/Marlin/Configuration.h b/lib/Marlin/Configuration.h index c2ac019..3a1fdf5 100644 --- a/lib/Marlin/Configuration.h +++ b/lib/Marlin/Configuration.h @@ -148,7 +148,7 @@ // Optional custom name for your RepStrap or other custom machine // Displayed in the LCD "Ready" message -//#define CUSTOM_MACHINE_NAME "3D Printer" +#define CUSTOM_MACHINE_NAME "UArm Swift Pro" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) @@ -251,7 +251,7 @@ #define TEMP_SENSOR_1 0 #define TEMP_SENSOR_2 0 #define TEMP_SENSOR_3 0 -#define TEMP_SENSOR_BED 0 +#define TEMP_SENSOR_BED 1 // This makes temp sensor 1 a redundant sensor for sensor 0. If the temperatures difference between these sensors is to high the print will be aborted. //#define TEMP_SENSOR_1_AS_REDUNDANT @@ -396,7 +396,7 @@ */ #define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders -//#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed +#define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed //=========================================================================== //============================= Mechanical Settings ========================= @@ -837,7 +837,7 @@ // // G20/G21 Inch mode support // -//#define INCH_MODE_SUPPORT +#define INCH_MODE_SUPPORT // // M149 Set temperature units support @@ -1008,7 +1008,7 @@ // IMPORTANT NOTE: The U8glib library is required for Full Graphic Display! // https://github.com/olikraus/U8glib_Arduino // -//#define ULTRA_LCD // Character based +#define ULTRA_LCD // Character based //#define DOGLCD // Full graphics display // @@ -1228,6 +1228,10 @@ // //#define LCM1602 +// Grove controller + +#define LCD_GROVE_RGB + // // PANELOLU2 LCD with status LEDs, // separate encoder and click inputs. diff --git a/lib/Marlin/pins_Swift.h b/lib/Marlin/pins_Swift.h index ca58c2a..aa52ba6 100644 --- a/lib/Marlin/pins_Swift.h +++ b/lib/Marlin/pins_Swift.h @@ -108,13 +108,13 @@ //#define PS_ON_PIN 12 // PS POWER #define TEMP_0_PIN 13 // ANALOG NUMBERING #define TEMP_1_PIN -1 // 14 // ANALOG NUMBERING -#define TEMP_BED_PIN -1 //15 // ANALOG NUMBERING +#define TEMP_BED_PIN 15 //15 // ANALOG NUMBERING #define HEATER_0_PIN 9 #define FAN_PIN 8 -#define HEATER_BED_PIN -1 +#define HEATER_BED_PIN 39 #define VALVE_EN 4 //#define PUMP_EN //PG4 diff --git a/lib/Marlin/ultralcd_impl_HD44780.h b/lib/Marlin/ultralcd_impl_HD44780.h index ab120c2..14a6f19 100644 --- a/lib/Marlin/ultralcd_impl_HD44780.h +++ b/lib/Marlin/ultralcd_impl_HD44780.h @@ -166,6 +166,11 @@ extern volatile uint8_t buttons; //an extended version of the last checked butt #include #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); +#elif ENABLED(LCD_GROVE_RGB) + #define LCD_CLASS Grovergb_lcd + #include + #include "Grovergb_lcd.h" + LCD_CLASS lcd; #else // Standard directly connected LCD implementations #include From db801d94e9430d70b0c480518c6e0ff5a016ef5d Mon Sep 17 00:00:00 2001 From: Felix Kolk Date: Mon, 12 Feb 2018 23:13:22 +0100 Subject: [PATCH 2/5] new command M2121 Vx for angular position of joints --- lib/Marlin/Marlin_main.cpp | 4 +++ lib/Marlin/uArmSwift.cpp | 53 ++++++++++++++++++++++++++++++++++++++ lib/Marlin/uArmSwift.h | 1 + 3 files changed, 58 insertions(+) diff --git a/lib/Marlin/Marlin_main.cpp b/lib/Marlin/Marlin_main.cpp index de5ca59..648a0d5 100644 --- a/lib/Marlin/Marlin_main.cpp +++ b/lib/Marlin/Marlin_main.cpp @@ -8416,6 +8416,10 @@ void process_next_command() { case 2120: uarm_gcode_M2120(); break; + + case 2121: + uarm_gcode_M2121(); + break; case 2122: uarm_gcode_M2122(); diff --git a/lib/Marlin/uArmSwift.cpp b/lib/Marlin/uArmSwift.cpp index e7d9b1d..28fcc27 100644 --- a/lib/Marlin/uArmSwift.cpp +++ b/lib/Marlin/uArmSwift.cpp @@ -399,6 +399,38 @@ void reportPos() reportString(result); } +void reportPos2() // report servo angles +{ + char result[128]; + //@3 X154.714 Y194.915 Z10.217\n + //msprintf(result, "@3 X%f Y%f Z%f\r\n", ); + float angle[NUM_AXIS]; + float pos[NUM_AXIS]; + + if (!isPowerPlugIn()) + { + MYSERIAL.println("No Power Connected!"); + return ; + } + + for (int i = 0; i < NUM_AXIS; i++) + { + angle[i] = get_current_angle(i); + } + + msprintf(result,"@3 Ax%f, Ay%f, Az%f, Ae%f\r\n", angle[X_AXIS], angle[Y_AXIS], angle[Z_AXIS], angle[E_AXIS]); + + // get current pos + // getXYZFromAngle(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS], angle[X_AXIS], angle[Y_AXIS], angle[Z_AXIS]); + + // debugPrint("cur_pos: %f, %f, %f\r\n", pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS]); + + // msprintf(result, "@3 X%f Y%f Z%f R%f\r\n", pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS], angle[3]); + + reportString(result); +} + + void rotate_frontend_motor() { float angle = 0; @@ -468,6 +500,27 @@ void uarm_gcode_M2120() } } +void uarm_gcode_M2121() +{ + float interval = 0; + if (code_seen('V')) + { + interval = code_value_float(); + + interval *= 1000; + + if (interval == 0) + { + removeReportService(3); + } + else + { + addReportService(3, interval, reportPos2); + } + } +} + + void uarm_gcode_M2122() { uint8_t value = 0; diff --git a/lib/Marlin/uArmSwift.h b/lib/Marlin/uArmSwift.h index 424e5ce..a7f72d1 100644 --- a/lib/Marlin/uArmSwift.h +++ b/lib/Marlin/uArmSwift.h @@ -58,6 +58,7 @@ void uarm_gcode_G1(); void uarm_gcode_M2000(); void uarm_gcode_M2120(); +void uarm_gcode_M2121(); void uarm_gcode_M2122(); uint8_t uarm_gcode_M2200(char reply[]); From 7c6a8ae523a3d9892c235514195a91d5bf6b8bb5 Mon Sep 17 00:00:00 2001 From: Felix Kolk Date: Mon, 12 Feb 2018 23:32:10 +0100 Subject: [PATCH 3/5] new function get_current_angle2 for quicker encoder reading --- lib/Marlin/uArmCalibration.cpp | 137 +++++++++++++++++++++++++++++++++ lib/Marlin/uArmCalibration.h | 1 + lib/Marlin/uArmSwift.cpp | 2 +- 3 files changed, 139 insertions(+), 1 deletion(-) diff --git a/lib/Marlin/uArmCalibration.cpp b/lib/Marlin/uArmCalibration.cpp index 2c266b7..8da4739 100644 --- a/lib/Marlin/uArmCalibration.cpp +++ b/lib/Marlin/uArmCalibration.cpp @@ -252,6 +252,143 @@ float get_current_angle(uint8_t index) //return angle; } +float get_current_angle2(uint8_t index) +{ + if (index > E_AXIS) + return 0; + + if (index == E_AXIS) + return get_current_angle_adc(index); + + float angle = 0.0; + + + uint16_t value[5] = {0.0}; + uint16_t max_value = 0; + uint16_t min_value = 0xffff; + uint32_t sum_value = 0; + bool invalid = false; + + do + { + invalid = false; + sum_value = 0; + max_value = 0; + min_value = 0xffff; + + for (int i = 0 ; i < 1; i++) + { + value[i] = get_current_angle_adc(index); + //debugPrint("value[%d] = %d\r\n", i, value[i]); + + if (max_value < value[i]) + max_value = value[i]; + + if (min_value > value[i]) + min_value = value[i]; + + sum_value += value[i]; + + + } + + if (max_value - min_value > 20) + invalid = true; + }while(invalid); + + //uint16_t cur_value = (sum_value - max_value - min_value) / 3;//get_current_angle_adc(index); + + uint16_t cur_value= sum_value; + //debugPrint("cur_value = %d\r\n", cur_value); + + + //uint16_t cur_value = get_current_angle_adc(index); + uint16_t diff = 0; + + if (cur_value > reference_angle_value[index]) + { + diff = cur_value - reference_angle_value[index]; + angle = (*reference_angle_p)[index] + diff * 360.0 / 4096; + } + else if (cur_value < reference_angle_value[index]) + { + diff = reference_angle_value[index] - cur_value; + angle = (*reference_angle_p)[index] - diff * 360.0 / 4096; + } + else + { + angle = (*reference_angle_p)[index]; + } + + //debugPrint("cur_value = %d\r\n", cur_value); + //debugPrint("reference_value = %d\r\n", reference_angle_value[index]); + + //debugPrint("angle = %f\r\n", angle); + + float origin_angle = angle; + float min = 0, max = 0; + + if (angle > 360) + { + angle -= 360; + } + + if (angle < 0) + { + angle += 360; + } + //debugPrint("angle2 = %f\r\n", angle); + + switch (index) + { + + case X_AXIS: + min = 0; + max = 180; + break; + + case Y_AXIS: + min = LOWER_ARM_MIN_ANGLE; + max = LOWER_ARM_MAX_ANGLE; + break; + + case Z_AXIS: + min = UPPER_ARM_MIN_ANGLE; + max = UPPER_ARM_MAX_ANGLE; + break; + + } + + if (angle >= min && angle <= max) + { + return angle; + } + else if (diff > 2048) + { + if (origin_angle < 0) + { + return max; + } + else + { + return min; + } + } + else + { + if (origin_angle < 0) + { + return min; + } + else + { + return max; + } + } + + //return angle; +} + diff --git a/lib/Marlin/uArmCalibration.h b/lib/Marlin/uArmCalibration.h index d8ecf30..be95174 100644 --- a/lib/Marlin/uArmCalibration.h +++ b/lib/Marlin/uArmCalibration.h @@ -20,6 +20,7 @@ #include "Z_IIC.h" float get_current_angle(uint8_t index); +float get_current_angle2(uint8_t index); void init_reference_angle_value(); void update_reference_angle_value(uint16_t value[NUM_AXIS]); void update_reference_angle_value_B(uint16_t value[NUM_AXIS]); diff --git a/lib/Marlin/uArmSwift.cpp b/lib/Marlin/uArmSwift.cpp index 28fcc27..1f60374 100644 --- a/lib/Marlin/uArmSwift.cpp +++ b/lib/Marlin/uArmSwift.cpp @@ -415,7 +415,7 @@ void reportPos2() // report servo angles for (int i = 0; i < NUM_AXIS; i++) { - angle[i] = get_current_angle(i); + angle[i] = get_current_angle2(i); } msprintf(result,"@3 Ax%f, Ay%f, Az%f, Ae%f\r\n", angle[X_AXIS], angle[Y_AXIS], angle[Z_AXIS], angle[E_AXIS]); From a090127f0d90079625fa787910dda831cb0a68d0 Mon Sep 17 00:00:00 2001 From: mattuna15 Date: Tue, 13 Feb 2018 09:04:02 +0000 Subject: [PATCH 4/5] Update update.log Added details of changes --- update.log | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/update.log b/update.log index d55bba9..2762458 100644 --- a/update.log +++ b/update.log @@ -1,3 +1,13 @@ +v3.2.0 20180213 M2121 command added which provides reduced averaging and accuracy but improves speed and keeps the arm movement undisturbed. +also the new command reports angular positions only + +v3.2.0 20180205 +Heated bed support - thermistor input into A15, digital heater bed switch on D39 +Support for G20/G21 code for Slic3r +UArm grove lcd module support +Ensure that you remove the Base LCD Library and replace with this: +https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads/Newliquidcrystal_1.3.5.zip + v3.2.0 20171025 new stable version release. From dff4b2e0074aaa0c767bd27bf0b9d6ab9df102c8 Mon Sep 17 00:00:00 2001 From: Matthew Pearce Date: Wed, 28 Feb 2018 16:17:38 +0000 Subject: [PATCH 5/5] Oled support, connect an I2C old device to the grove port on the side. --- lib/Marlin/Conditionals_LCD.h | 8 ++++++++ lib/Marlin/Configuration.h | 4 ++-- lib/Marlin/pins_Swift.h | 16 +++++++++------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/Marlin/Conditionals_LCD.h b/lib/Marlin/Conditionals_LCD.h index 29c67bf..ce8d9d4 100644 --- a/lib/Marlin/Conditionals_LCD.h +++ b/lib/Marlin/Conditionals_LCD.h @@ -131,6 +131,14 @@ * I2C PANELS */ +#if defined (SSD1306_OLED_I2C_CONTROLLER) +#define DOGLCD +#define U8GLIB_SSD1306 +#define ULTIPANEL +#define NEWPANEL +#endif + + #if ENABLED(LCD_I2C_SAINSMART_YWROBOT) // This uses the LiquidCrystal_I2C library ( https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home ) // Make sure it is placed in the Arduino libraries directory. diff --git a/lib/Marlin/Configuration.h b/lib/Marlin/Configuration.h index 3a1fdf5..56b40c9 100644 --- a/lib/Marlin/Configuration.h +++ b/lib/Marlin/Configuration.h @@ -1008,8 +1008,8 @@ // IMPORTANT NOTE: The U8glib library is required for Full Graphic Display! // https://github.com/olikraus/U8glib_Arduino // -#define ULTRA_LCD // Character based -//#define DOGLCD // Full graphics display +#define SSD1306_OLED_I2C_CONTROLLER + // // SD CARD diff --git a/lib/Marlin/pins_Swift.h b/lib/Marlin/pins_Swift.h index aa52ba6..40206a9 100644 --- a/lib/Marlin/pins_Swift.h +++ b/lib/Marlin/pins_Swift.h @@ -131,15 +131,17 @@ #define SLED_PIN -1 #endif +#define MOSFET_D_PIN -1 +#define SD_DETECT_PIN -1 - - #define MOSFET_D_PIN -1 - - - - - +#ifdef SSD1306_OLED_I2C_CONTROLLER +#define LCD_SDSS -1 +#define BTN_EN1 35 // A1 - rotary encoder A +#define BTN_EN2 33 // A2 - rotary encoder B +#define BTN_ENC 32 // A3 - rotary encoder push switch +// #define BEEPER_PIN 31 // RX1 - piezo beeper +#endif #ifndef FAN_PIN #define FAN_PIN 4 // IO pin. Buffer needed