From 770c5cdbaf7dd416b96e4fa9ed88bcc4078af66c Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Sun, 6 Jul 2014 11:39:48 +1200 Subject: [PATCH 1/8] Changed include to allow compilation --- Marlin/qr_solve.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/qr_solve.cpp b/Marlin/qr_solve.cpp index 0a491281c5c9..8e99ef8ed8a1 100644 --- a/Marlin/qr_solve.cpp +++ b/Marlin/qr_solve.cpp @@ -4,7 +4,7 @@ #include #include -#include +//#include //# include "r8lib.h" From 8463027034d15fcfd05691e5d5a03d70070da4cf Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Sun, 6 Jul 2014 11:41:09 +1200 Subject: [PATCH 2/8] Added series of defines to allow either the FSR to be read by an analog input, or as a digital input (ZMIN) --- Marlin/Configuration.h | 56 ++++++++++++++++++++++++++++-------------- Marlin/Marlin_main.cpp | 45 +++++++++++++++++++++++++-------- 2 files changed, 72 insertions(+), 29 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index d6b9da90fbca..f727c3eb6ee4 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -106,16 +106,16 @@ #define DELTA_SEGMENTS_PER_SECOND 100 // Center-to-center distance of the holes in the diagonal push rods. -#define DELTA_DIAGONAL_ROD 186.0 // mm +#define DELTA_DIAGONAL_ROD 214.5 // mm // Horizontal offset from middle of printer to smooth rod center. -#define DELTA_SMOOTH_ROD_OFFSET 128.0 // mm +#define DELTA_SMOOTH_ROD_OFFSET 139.0 // mm // Horizontal offset of the universal joints on the end effector. -#define DELTA_EFFECTOR_OFFSET 19.9 // mm +#define DELTA_EFFECTOR_OFFSET 20.0 // mm // Horizontal offset of the universal joints on the carriages. -#define DELTA_CARRIAGE_OFFSET 19.5 // mm +#define DELTA_CARRIAGE_OFFSET 12.0 // mm // Horizontal distance bridged by diagonal push rods when effector is centered. #define DELTA_RADIUS (DELTA_SMOOTH_ROD_OFFSET-DELTA_EFFECTOR_OFFSET-DELTA_CARRIAGE_OFFSET) @@ -226,8 +226,8 @@ // If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it // Ultimaker - #define DEFAULT_Kp 22.2 - #define DEFAULT_Ki 1.08 + #define DEFAULT_Kp 35.98 + #define DEFAULT_Ki 3.12 #define DEFAULT_Kd 114 // MakerGear @@ -320,7 +320,7 @@ // The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins. const bool X_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. const bool Y_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. -const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. +const bool Z_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool X_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. const bool Y_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. @@ -426,7 +426,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o // with accurate bed leveling, the bed is sampled in a ACCURATE_BED_LEVELING_POINTSxACCURATE_BED_LEVELING_POINTS grid and least squares solution is calculated // Note: this feature occupies 10'206 byte #define ACCURATE_BED_LEVELING - + #ifdef ACCURATE_BED_LEVELING #define ACCURATE_BED_LEVELING_POINTS 9 #define ACCURATE_BED_LEVELING_GRID_X ((RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION) / (ACCURATE_BED_LEVELING_POINTS - 1)) @@ -439,11 +439,29 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o #define NONLINEAR_BED_LEVELING #endif - // Force Sensing Resistors under the print surface, wired to heated bed thermistor input. + // Force Sensing Resistors under the print surface, wired to either the Z_MIN input, + // or the TEMP_1_PIN analog input (used for bed temperature) // Autolevel by measuring how much the hotend is pushing down, without separate Z probe. #define FSR_BED_LEVELING + + // Define this if you wish to use the bed temperature analog input to read the FSR + // This is called TEMP_1_PIN + #define FSR_BED_TEMPERATURE + + // Define FSR_Z_MIN to use the Z_MIN digital input as the bed sensor + // Check your readings using M119 before trying automatic leveling using Z_MIN + // you will also have to set the following above + // const bool Z_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. + //#define FSR_Z_MIN #endif +// Do a sanity check to make sure that only one of FSR_Z_MIN or FSR_BED_TEMPERATURE are +// defined. +#ifdef FSR_Z_MIN +#ifdef FSR_BED_TEMPERATURE + #error you can only define ONE of FSR_Z_MIN or FSR_BED_TEMPERATURE +#endif +#endif // The position of the homing switches #define MANUAL_HOME_POSITIONS // If defined, MANUAL_*_HOME_POS below will be used @@ -453,7 +471,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o // For deltabots this means top and center of the Cartesian print volume. #define MANUAL_X_HOME_POS 0 #define MANUAL_Y_HOME_POS 0 -#define MANUAL_Z_HOME_POS 210 // For delta: Distance between nozzle and print surface after homing. +#define MANUAL_Z_HOME_POS 206.8 // For delta: Distance between nozzle and print surface after homing. //// MOVEMENT SETTINGS #define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E @@ -464,14 +482,14 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o #define XYZ_FULL_STEPS_PER_ROTATION 200 #define XYZ_MICROSTEPS 16 #define XYZ_BELT_PITCH 2 -#define XYZ_PULLEY_TEETH 17 -#define XYZ_STEPS (XYZ_FULL_STEPS_PER_ROTATION * XYZ_MICROSTEPS / double(XYZ_BELT_PITCH) / double(XYZ_PULLEY_TEETH)) +#define XYZ_PULLEY_TEETH 16 +#define XYZ_STEPS (0.97 * XYZ_FULL_STEPS_PER_ROTATION * XYZ_MICROSTEPS / double(XYZ_BELT_PITCH) / double(XYZ_PULLEY_TEETH)) -#define DEFAULT_AXIS_STEPS_PER_UNIT {XYZ_STEPS, XYZ_STEPS, XYZ_STEPS, 100} +#define DEFAULT_AXIS_STEPS_PER_UNIT {XYZ_STEPS, XYZ_STEPS, XYZ_STEPS, 520} #define DEFAULT_MAX_FEEDRATE {200, 200, 200, 200} // (mm/sec) -#define DEFAULT_MAX_ACCELERATION {9000,9000,9000,9000} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot. +#define DEFAULT_MAX_ACCELERATION {4500,4500,4500,4500} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot. -#define DEFAULT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves +#define DEFAULT_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for printing moves #define DEFAULT_RETRACT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for retracts // Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing). @@ -481,9 +499,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o // #define EXTRUDER_OFFSET_Y {0.0, 5.00} // (in mm) for each extruder, offset of the hotend on the Y axis // The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously) -#define DEFAULT_XYJERK 20.0 // (mm/sec) -#define DEFAULT_ZJERK 20.0 // (mm/sec) -#define DEFAULT_EJERK 20.0 // (mm/sec) +#define DEFAULT_XYJERK 2.0 // (mm/sec) +#define DEFAULT_ZJERK 2.0 // (mm/sec) +#define DEFAULT_EJERK 5.0 // (mm/sec) //=========================================================================== //=============================Additional Features=========================== @@ -623,7 +641,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o #endif // Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs -#define LCD_I2C_VIKI +//#define LCD_I2C_VIKI #ifdef LCD_I2C_VIKI // This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 ) // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory. diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index a40b01b890ab..bd1783bbafd4 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -883,8 +883,34 @@ static void set_bed_level_equation(float z_at_xLeft_yFront, float z_at_xRight_yF } #endif // ACCURATE_BED_LEVELING -bool touching_print_surface(int threshold) { - return rawBedSample() < threshold; + +#ifdef FSR_BED_TEMPERATURE +int bed_sensor_threshold; +#endif + +void setup_bed_sensor_threshold() { +#ifdef FSR_BED_TEMPERATURE + int analog_fsr_untouched = rawBedSample(); + bed_sensor_threshold = analog_fsr_untouched * 95L / 100; +#else + // nothing needs to be done. This routine sets up a threshold +#endif +} + +int read_bed_touch() { +#ifdef FSR_BED_TEMPERATURE + return rawBedSample(); +#else + return digitalRead(Z_MIN_PIN); +#endif +} + +bool touching_print_surface() { +#ifdef FSR_BED_TEMPERATURE + return read_bed_touch() < bed_sensor_threshold; +#else + return read_bed_touch(); +#endif } static void run_z_probe() { @@ -896,9 +922,8 @@ static void run_z_probe() { float step = 0.05; int direction = -1; // Consider the glass touched if the raw ADC value is reduced by 5% or more. - int analog_fsr_untouched = rawBedSample(); - int threshold = analog_fsr_untouched * 95L / 100; - while (!touching_print_surface(threshold)) { + setup_bed_sensor_threshold(); + while (!touching_print_surface()) { destination[Z_AXIS] += step * direction; prepare_move_raw(); st_synchronize(); @@ -906,12 +931,12 @@ static void run_z_probe() { while (step > 0.005) { step *= 0.8; feedrate *= 0.8; - direction = touching_print_surface(threshold) ? 1 : -1; + direction = touching_print_surface() ? 1 : -1; destination[Z_AXIS] += step * direction; prepare_move_raw(); st_synchronize(); } - #else + #else /* FSR_BED_LEVELING */ enable_endstops(true); float start_z = current_position[Z_AXIS]; long start_steps = st_get_position(Z_AXIS); @@ -929,8 +954,8 @@ static void run_z_probe() { current_position[Z_AXIS] = mm; calculate_delta(current_position); plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]); - #endif -#else + #endif /* FSR_BED_LEVELING */ +#else /* DELTA */ feedrate = homing_feedrate[Z_AXIS]; // move down until you find the bed @@ -1106,7 +1131,7 @@ static float probe_pt(float x, float y, float z_before) { SERIAL_PROTOCOL(measured_z); #ifdef FSR_BED_LEVELING SERIAL_PROTOCOLPGM(" FSR: "); - SERIAL_PROTOCOL(rawBedSample()); + SERIAL_PROTOCOL(read_bed_touch()); #endif SERIAL_PROTOCOLPGM("\n"); return measured_z; From 27ef70ae94351709112f72a61340172c13165a42 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Wed, 9 Jul 2014 22:00:52 +1200 Subject: [PATCH 3/8] Added a new file that contains all the usual calibration inputs for a typical delta printer. This makes hunting for the configuration options, and setting them a little easier for the novice user. It also makes it easier to develop Marlin firmware without spamming the main configuration.h with local changes. --- Marlin/Calibration.h | 80 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Marlin/Calibration.h diff --git a/Marlin/Calibration.h b/Marlin/Calibration.h new file mode 100644 index 000000000000..669583a16d85 --- /dev/null +++ b/Marlin/Calibration.h @@ -0,0 +1,80 @@ +/** + * This file contains the important calibration settings for your Delta printer + * in one place. + * + * During calibration of your printer, each one of these will be customized + * to suit your printers geometry, and stepper motor setup. + * + * See the file Configuration.h for the meaning of each of these confituration + * options. + * + * NOTE: This file contains values that would suit a Kossel Mini. If you have + * a Kossel Air, or other printer, these will be quite different. + **/ + +#ifndef __CALIBRATION_H +#define __CALIBRATION_H + +// +#define MOTHERBOARD 33 + +// Define this to set a custom name for your generic Mendel, +#define STRING_CONFIG_H_AUTHOR "(tmolteno, Mini Kossel)" // Who made the changes. + +//=========================================================================== +//============================== Delta Settings ============================= +//=========================================================================== + +// First thing to calibrate is the manual home position +// For delta: Distance between nozzle and print surface after homing. +#define MANUAL_Z_HOME_POS 206.8 + +// Center-to-center distance of the holes in the diagonal push rods. +#define DELTA_DIAGONAL_ROD 214.5 // mm + +// Horizontal offset from middle of printer to smooth rod center. +#define DELTA_SMOOTH_ROD_OFFSET 139.0 // mm + +// Horizontal offset of the universal joints on the end effector. +#define DELTA_EFFECTOR_OFFSET 20.0 // mm + +// Horizontal offset of the universal joints on the carriages. +#define DELTA_CARRIAGE_OFFSET 12.0 // mm + +// Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers). +#define DELTA_PRINTABLE_RADIUS 75.0 + + +// Stepper Motor And Gear Calibration + +#define XYZ_FULL_STEPS_PER_ROTATION 200 +#define XYZ_MICROSTEPS 16 +#define XYZ_BELT_PITCH 2 // millimeters +#define XYZ_PULLEY_TEETH 16 + +// After printing a test cube, insert a factor here that will scale your object to +// the correct dimensions +#define SCALING_FACTOR 0.97 + +// During extruder calibration, modify this value so that +// the extruder extrudes the correct length. +#define EXTRUDER_STEPS 520 + +#define DEFAULT_MAX_FEEDRATE {200, 200, 200, 200} // (mm/sec) +#define DEFAULT_MAX_ACCELERATION {4500,4500,4500,4500} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot. + +/* Reduce these for smoother printing */ +#define DEFAULT_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for printing moves +#define DEFAULT_RETRACT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for retracts + +// The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously) +#define DEFAULT_XYJERK 2.0 // (mm/sec) +#define DEFAULT_ZJERK 2.0 // (mm/sec) +#define DEFAULT_EJERK 5.0 // (mm/sec) + +//=========================================================================== +//=============================Additional Features=========================== +//=========================================================================== + + +#endif //____CALIBRATION_H From 2e1335bb6e0f625790c44a3b7ede1b87edf4b667 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Wed, 9 Jul 2014 22:08:02 +1200 Subject: [PATCH 4/8] Include the local calibration file, and modify the order of includes to allow the most common calibrations to be stored in Calibration.h. --- Marlin/Configuration.h | 122 +++++++++++++++++++++++++---------------- Marlin/Makefile | 7 ++- 2 files changed, 80 insertions(+), 49 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index f727c3eb6ee4..594b9932c5d8 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -5,6 +5,9 @@ // Advanced settings can be found in Configuration_adv.h // BASIC SETTINGS: select your board type, temperature sensor type, axis scaling, and endstop configuration +// Use a separate configuration file for your local calibration settings. +#include "Calibration.h" + //=========================================================================== //============================= DELTA Printer =============================== //=========================================================================== @@ -94,34 +97,48 @@ // Define this to have the electronics keep the power supply off on startup. If you don't know what this is leave it. // #define PS_DEFAULT_OFF -//=========================================================================== -//============================== Delta Settings ============================= -//=========================================================================== -// Enable DELTA kinematics + + #define DELTA -// Make delta curves from many straight lines (linear interpolation). -// This is a trade-off between visible corners (not enough segments) -// and processor overload (too many expensive sqrt calls). -#define DELTA_SEGMENTS_PER_SECOND 100 +#ifndef __CALIBRATION_H + // Override your calibration settings in Calibration.h + + //=========================================================================== + //============================== Delta Settings ============================= + //=========================================================================== + // Enable DELTA kinematics + + // The following values are for a Kossel Air. For sensible starting values + // for a Kossel Mini, see Calibration.h + + // Center-to-center distance of the holes in the diagonal push rods. + #define DELTA_DIAGONAL_ROD 186.0 // mm -// Center-to-center distance of the holes in the diagonal push rods. -#define DELTA_DIAGONAL_ROD 214.5 // mm + // Horizontal offset from middle of printer to smooth rod center. + #define DELTA_SMOOTH_ROD_OFFSET 128.0 // mm -// Horizontal offset from middle of printer to smooth rod center. -#define DELTA_SMOOTH_ROD_OFFSET 139.0 // mm + // Horizontal offset of the universal joints on the end effector. + #define DELTA_EFFECTOR_OFFSET 19.9 // mm -// Horizontal offset of the universal joints on the end effector. -#define DELTA_EFFECTOR_OFFSET 20.0 // mm + // Horizontal offset of the universal joints on the carriages. + #define DELTA_CARRIAGE_OFFSET 19.5 // mm -// Horizontal offset of the universal joints on the carriages. -#define DELTA_CARRIAGE_OFFSET 12.0 // mm + // Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers). + #define DELTA_PRINTABLE_RADIUS 75.0 + +#endif // __CALIBRATION_H + +// Make delta curves from many straight lines (linear interpolation). +// This is a trade-off between visible corners (not enough segments) +// and processor overload (too many expensive sqrt calls). +#define DELTA_SEGMENTS_PER_SECOND 100 // Horizontal distance bridged by diagonal push rods when effector is centered. #define DELTA_RADIUS (DELTA_SMOOTH_ROD_OFFSET-DELTA_EFFECTOR_OFFSET-DELTA_CARRIAGE_OFFSET) -// Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers). -#define DELTA_PRINTABLE_RADIUS 75.0 +// Diagonal rod squared +#define DELTA_DIAGONAL_ROD_2 pow(DELTA_DIAGONAL_ROD,2) // Effective X/Y positions of the three vertical towers. #define SIN_60 0.8660254037844386 @@ -133,8 +150,6 @@ #define DELTA_TOWER3_X 0.0 // back middle tower #define DELTA_TOWER3_Y DELTA_RADIUS -// Diagonal rod squared -#define DELTA_DIAGONAL_ROD_2 pow(DELTA_DIAGONAL_ROD,2) //=========================================================================== //=============================Thermal Settings ============================ @@ -320,7 +335,7 @@ // The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins. const bool X_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. const bool Y_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. -const bool Z_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. +const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. const bool X_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. const bool Y_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. @@ -453,15 +468,16 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o // you will also have to set the following above // const bool Z_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. //#define FSR_Z_MIN -#endif +#endif // ENABLE_AUTO_BED_LEVELING // Do a sanity check to make sure that only one of FSR_Z_MIN or FSR_BED_TEMPERATURE are // defined. #ifdef FSR_Z_MIN -#ifdef FSR_BED_TEMPERATURE - #error you can only define ONE of FSR_Z_MIN or FSR_BED_TEMPERATURE -#endif -#endif + const bool Z_MIN_ENDSTOP_INVERTING = true; + #ifdef FSR_BED_TEMPERATURE + #error you can only define ONE of FSR_Z_MIN or FSR_BED_TEMPERATURE + #endif // FSR_BED_TEMPERATURE +#endif // FSR_Z_MIN // The position of the homing switches #define MANUAL_HOME_POSITIONS // If defined, MANUAL_*_HOME_POS below will be used @@ -471,37 +487,49 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o // For deltabots this means top and center of the Cartesian print volume. #define MANUAL_X_HOME_POS 0 #define MANUAL_Y_HOME_POS 0 -#define MANUAL_Z_HOME_POS 206.8 // For delta: Distance between nozzle and print surface after homing. +#ifndef MANUAL_Z_HOME_POS + #define MANUAL_Z_HOME_POS 210 // For delta: Distance between nozzle and print surface after homing. +#endif + //// MOVEMENT SETTINGS #define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E #define HOMING_FEEDRATE {200*60, 200*60, 200*60, 0} // set the homing speeds (mm/min) // default settings -#define XYZ_FULL_STEPS_PER_ROTATION 200 -#define XYZ_MICROSTEPS 16 -#define XYZ_BELT_PITCH 2 -#define XYZ_PULLEY_TEETH 16 -#define XYZ_STEPS (0.97 * XYZ_FULL_STEPS_PER_ROTATION * XYZ_MICROSTEPS / double(XYZ_BELT_PITCH) / double(XYZ_PULLEY_TEETH)) +#ifndef __CALIBRATION_H + // Override these settings in Calibration.h + + #define XYZ_FULL_STEPS_PER_ROTATION 200 + #define XYZ_MICROSTEPS 16 + #define XYZ_BELT_PITCH 2 + #define XYZ_PULLEY_TEETH 16 + + #define SCALING_FACTOR 1.0 // Modify this in Calibration.h after you've printed a test cube + + #define EXTRUDER_STEPS 100 -#define DEFAULT_AXIS_STEPS_PER_UNIT {XYZ_STEPS, XYZ_STEPS, XYZ_STEPS, 520} -#define DEFAULT_MAX_FEEDRATE {200, 200, 200, 200} // (mm/sec) -#define DEFAULT_MAX_ACCELERATION {4500,4500,4500,4500} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot. + #define DEFAULT_MAX_FEEDRATE {200, 200, 200, 200} // (mm/sec) + #define DEFAULT_MAX_ACCELERATION {9000,9000,9000,9000} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot. -#define DEFAULT_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for printing moves -#define DEFAULT_RETRACT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for retracts + #define DEFAULT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves + #define DEFAULT_RETRACT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for retracts -// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing). -// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder). -// For the other hotends it is their distance from the extruder 0 hotend. -// #define EXTRUDER_OFFSET_X {0.0, 20.00} // (in mm) for each extruder, offset of the hotend on the X axis -// #define EXTRUDER_OFFSET_Y {0.0, 5.00} // (in mm) for each extruder, offset of the hotend on the Y axis + // Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing). + // The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder). + // For the other hotends it is their distance from the extruder 0 hotend. + // #define EXTRUDER_OFFSET_X {0.0, 20.00} // (in mm) for each extruder, offset of the hotend on the X axis + // #define EXTRUDER_OFFSET_Y {0.0, 5.00} // (in mm) for each extruder, offset of the hotend on the Y axis -// The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously) -#define DEFAULT_XYJERK 2.0 // (mm/sec) -#define DEFAULT_ZJERK 2.0 // (mm/sec) -#define DEFAULT_EJERK 5.0 // (mm/sec) + // The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously) + #define DEFAULT_XYJERK 20.0 // (mm/sec) + #define DEFAULT_ZJERK 20.0 // (mm/sec) + #define DEFAULT_EJERK 20.0 // (mm/sec) +#endif /* __CALIBRATION_H */ + +#define XYZ_STEPS (SCALING_FACTOR * XYZ_FULL_STEPS_PER_ROTATION * XYZ_MICROSTEPS / double(XYZ_BELT_PITCH) / double(XYZ_PULLEY_TEETH)) +#define DEFAULT_AXIS_STEPS_PER_UNIT {XYZ_STEPS, XYZ_STEPS, XYZ_STEPS, EXTRUDER_STEPS} //=========================================================================== //=============================Additional Features=========================== @@ -640,6 +668,8 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o #endif +// Define your LCD version in Calibration.h + // Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs //#define LCD_I2C_VIKI #ifdef LCD_I2C_VIKI diff --git a/Marlin/Makefile b/Marlin/Makefile index 3bd0ae3bf49b..2c936f79e7a4 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -37,10 +37,10 @@ # from the commandline with "make HARDWARE_MOTHERBOARD=71" for example # This defined the board you are compiling for (see Configuration.h for the options) -HARDWARE_MOTHERBOARD ?= 11 +HARDWARE_MOTHERBOARD ?= 33 # Arduino source install directory, and version number -ARDUINO_INSTALL_DIR ?= /Applications/Arduino.app/Contents/Resources/Java +ARDUINO_INSTALL_DIR ?= /usr/share/arduino ARDUINO_VERSION ?= 105 # You can optionally set a path to the avr-gcc tools. Requires a trailing slash. (ex: /usr/local/avr-gcc/bin) @@ -49,7 +49,7 @@ AVR_TOOLS_PATH ?= #Programmer configuration UPLOAD_RATE ?= 115200 AVRDUDE_PROGRAMMER ?= arduino -UPLOAD_PORT ?= /dev/arduino +UPLOAD_PORT ?= /dev/ttyACM0 #Directory used to build files in, contains all the build files, from object files to the final hex file. BUILD_DIR ?= applet @@ -214,6 +214,7 @@ TARGET = $(notdir $(CURDIR)) # directory is added here VPATH = . +VPATH += ./libraries/Time/Time VPATH += $(BUILD_DIR) VPATH += $(HARDWARE_SRC) ifeq ($(HARDWARE_VARIANT), arduino) From a4c6362d94867f8603e41876cf466bf4338c46a2 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Wed, 9 Jul 2014 22:13:32 +1200 Subject: [PATCH 5/8] Removed the VPATH for the Time library. It isnt used --- Marlin/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Marlin/Makefile b/Marlin/Makefile index 2c936f79e7a4..0b6fb005076a 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -214,7 +214,6 @@ TARGET = $(notdir $(CURDIR)) # directory is added here VPATH = . -VPATH += ./libraries/Time/Time VPATH += $(BUILD_DIR) VPATH += $(HARDWARE_SRC) ifeq ($(HARDWARE_VARIANT), arduino) From ffceeda599f35ad837fbf21f276f0cba179e679c Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Thu, 10 Jul 2014 08:26:35 +1200 Subject: [PATCH 6/8] Set the build radius for a Kossel Mini. Add instructions for options not in this file --- Marlin/Calibration.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Marlin/Calibration.h b/Marlin/Calibration.h index 669583a16d85..ad6a726870b3 100644 --- a/Marlin/Calibration.h +++ b/Marlin/Calibration.h @@ -15,7 +15,7 @@ #ifndef __CALIBRATION_H #define __CALIBRATION_H -// +// This is a RAMPS board #define MOTHERBOARD 33 // Define this to set a custom name for your generic Mendel, @@ -42,7 +42,7 @@ #define DELTA_CARRIAGE_OFFSET 12.0 // mm // Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers). -#define DELTA_PRINTABLE_RADIUS 75.0 +#define DELTA_PRINTABLE_RADIUS 80.0 // Stepper Motor And Gear Calibration @@ -72,9 +72,6 @@ #define DEFAULT_ZJERK 2.0 // (mm/sec) #define DEFAULT_EJERK 5.0 // (mm/sec) -//=========================================================================== -//=============================Additional Features=========================== -//=========================================================================== - +// All remaining calibration options are in the file Configuration.h #endif //____CALIBRATION_H From d65cd41f1e11ccc334e52f4aed7064a09d2f35b0 Mon Sep 17 00:00:00 2001 From: tmolteno Date: Sun, 21 Jun 2015 14:09:45 +1200 Subject: [PATCH 7/8] Updated to allow simultaneous heated bed and use the extra thermometer input to read the force sensitive resistors for the level sensing and auto callibration --- Marlin/Calibration.h | 4 +- Marlin/Configuration.h | 15 +- Marlin/Makefile | 531 +++++++++++------------------------------ Marlin/Marlin.pde | 56 ----- Marlin/Marlin_main.cpp | 13 +- Marlin/pins.h | 2 +- Marlin/temperature.cpp | 8 +- Marlin/temperature.h | 13 + 8 files changed, 175 insertions(+), 467 deletions(-) delete mode 100644 Marlin/Marlin.pde diff --git a/Marlin/Calibration.h b/Marlin/Calibration.h index ad6a726870b3..816235a3b9b6 100644 --- a/Marlin/Calibration.h +++ b/Marlin/Calibration.h @@ -27,7 +27,7 @@ // First thing to calibrate is the manual home position // For delta: Distance between nozzle and print surface after homing. -#define MANUAL_Z_HOME_POS 206.8 +#define MANUAL_Z_HOME_POS 204.1 // Center-to-center distance of the holes in the diagonal push rods. #define DELTA_DIAGONAL_ROD 214.5 // mm @@ -58,7 +58,7 @@ // During extruder calibration, modify this value so that // the extruder extrudes the correct length. -#define EXTRUDER_STEPS 520 +#define EXTRUDER_STEPS 450 #define DEFAULT_MAX_FEEDRATE {200, 200, 200, 200} // (mm/sec) #define DEFAULT_MAX_ACCELERATION {4500,4500,4500,4500} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot. diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 594b9932c5d8..6391408a3be0 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -187,9 +187,9 @@ // 110 is Pt100 with 1k pullup (non standard) #define TEMP_SENSOR_0 5 -#define TEMP_SENSOR_1 0 -#define TEMP_SENSOR_2 0 -#define TEMP_SENSOR_BED 2 +#define TEMP_SENSOR_1 1 +#define TEMP_SENSOR_2 2 +#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 @@ -462,7 +462,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o // Define this if you wish to use the bed temperature analog input to read the FSR // This is called TEMP_1_PIN #define FSR_BED_TEMPERATURE - + #define FSR_TEMP_SENSOR_2 // Define FSR_Z_MIN to use the Z_MIN digital input as the bed sensor // Check your readings using M119 before trying automatic leveling using Z_MIN // you will also have to set the following above @@ -479,6 +479,13 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o #endif // FSR_BED_TEMPERATURE #endif // FSR_Z_MIN +#ifdef FSR_TEMP_SENSOR_2 + #ifndef TEMP_2_PIN + #warning You must define TEMP_2_PIN if FSR_TEMP_SENSOR_2 is defined +#define TEMP_2_PIN 15 //Analog numbering + #endif +#endif + // The position of the homing switches #define MANUAL_HOME_POSITIONS // If defined, MANUAL_*_HOME_POS below will be used #define BED_CENTER_AT_0_0 // If defined, the center of the bed is at (X=0, Y=0) diff --git a/Marlin/Makefile b/Marlin/Makefile index 0b6fb005076a..927b7c09c5c9 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -1,287 +1,60 @@ -# Sprinter Arduino Project Makefile -# -# Makefile Based on: -# Arduino 0011 Makefile -# Arduino adaptation by mellis, eighthave, oli.keller -# Marlin adaption by Daid -# -# This has been tested with Arduino 0022. +# Arduino makefile # # This makefile allows you to build sketches from the command line # without the Arduino environment (or Java). # -# Detailed instructions for using the makefile: +# The Arduino environment does preliminary processing on a sketch before +# compiling it. If you're using this makefile instead, you'll need to do +# a few things differently: +# +# - Give your program's file a .cpp extension (e.g. foo.cpp). +# +# - Put this line at top of your code: #include +# +# - Write prototypes for all your functions (or define them before you +# call them). A prototype declares the types of parameters a +# function will take and what type of value it will return. This +# means that you can have a call to a function before the definition +# of the function. A function prototype looks like the first line of +# the function, with a semi-colon at the end. For example: +# int digitalRead(int pin); # -# 1. Modify the line containg "ARDUINO_INSTALL_DIR" to point to the directory that -# contains the Arduino installation (for example, under Mac OS X, this -# might be /Applications/Arduino.app/Contents/Resources/Java). +# Instructions for using the makefile: # -# 2. Modify the line containing "UPLOAD_PORT" to refer to the filename +# 1. Copy this file into the folder with your sketch. +# +# 2. Below, modify the line containing "TARGET" to refer to the name of +# of your program's file without an extension (e.g. TARGET = foo). +# +# 3. Modify the line containg "ARDUINO" to point the directory that +# contains the Arduino core (for normal Arduino installations, this +# is the lib/targets/arduino sub-directory). +# +# 4. Modify the line containing "PORT" to refer to the filename # representing the USB or serial connection to your Arduino board -# (e.g. UPLOAD_PORT = /dev/tty.USB0). If the exact name of this file -# changes, you can use * as a wildcard (e.g. UPLOAD_PORT = /dev/tty.usb*). +# (e.g. PORT = /dev/tty.USB0). If the exact name of this file +# changes, you can use * as a wildcard (e.g. PORT = /dev/tty.USB*). # -# 3. Set the line containing "MCU" to match your board's processor. -# Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth -# or Diecimila have the atmega168. If you're using a LilyPad Arduino, -# change F_CPU to 8000000. If you are using Gen7 electronics, you -# probably need to use 20000000. Either way, you must regenerate -# the speed lookup table with create_speed_lookuptable.py. +# 5. At the command line, change to the directory containing your +# program's file and the makefile. # -# 4. Type "make" and press enter to compile/verify your program. +# 6. Type "make" and press enter to compile/verify your program. # -# 5. Type "make upload", reset your Arduino board, and press enter to +# 7. Type "make upload", reset your Arduino board, and press enter to # upload your program to the Arduino board. # -# Note that all settings are set with ?=, this means you can override them -# from the commandline with "make HARDWARE_MOTHERBOARD=71" for example - -# This defined the board you are compiling for (see Configuration.h for the options) -HARDWARE_MOTHERBOARD ?= 33 - -# Arduino source install directory, and version number -ARDUINO_INSTALL_DIR ?= /usr/share/arduino -ARDUINO_VERSION ?= 105 - -# You can optionally set a path to the avr-gcc tools. Requires a trailing slash. (ex: /usr/local/avr-gcc/bin) -AVR_TOOLS_PATH ?= - -#Programmer configuration -UPLOAD_RATE ?= 115200 -AVRDUDE_PROGRAMMER ?= arduino -UPLOAD_PORT ?= /dev/ttyACM0 - -#Directory used to build files in, contains all the build files, from object files to the final hex file. -BUILD_DIR ?= applet - -# This defines whether Liquid_TWI2 support will be built -LIQUID_TWI2 ?= 0 - -# this defines if Wire is needed -WIRE ?= 0 - -############################################################################ -# Below here nothing should be changed... - -# Here the Arduino variant is selected by the board type -# HARDWARE_VARIANT = "arduino", "Sanguino", "Gen7", ... -# MCU = "atmega1280", "Mega2560", "atmega2560", "atmega644p", ... - -#Gen7 -ifeq ($(HARDWARE_MOTHERBOARD),10) -HARDWARE_VARIANT ?= Gen7 -MCU ?= atmega644 -F_CPU ?= 20000000 -else ifeq ($(HARDWARE_MOTHERBOARD),11) -HARDWARE_VARIANT ?= Gen7 -MCU ?= atmega644p -F_CPU ?= 20000000 -else ifeq ($(HARDWARE_MOTHERBOARD),12) -HARDWARE_VARIANT ?= Gen7 -MCU ?= atmega644p -F_CPU ?= 20000000 -else ifeq ($(HARDWARE_MOTHERBOARD),13) -HARDWARE_VARIANT ?= Gen7 -MCU ?= atmega1284p -F_CPU ?= 20000000 - -#RAMPS -else ifeq ($(HARDWARE_MOTHERBOARD),3) -HARDWARE_VARIANT ?= arduino -MCU ?= atmega2560 -else ifeq ($(HARDWARE_MOTHERBOARD),33) -HARDWARE_VARIANT ?= arduino -MCU ?= atmega2560 -else ifeq ($(HARDWARE_MOTHERBOARD),34) -HARDWARE_VARIANT ?= arduino -MCU ?= atmega2560 - -#Duemilanove w/ ATMega328P pin assignment -else ifeq ($(HARDWARE_MOTHERBOARD),4) -HARDWARE_VARIANT ?= arduino -HARDWARE_SUB_VARIANT ?= standard -MCU ?= atmega328p - -#Gen6 -else ifeq ($(HARDWARE_MOTHERBOARD),5) -HARDWARE_VARIANT ?= Gen6 -MCU ?= atmega644p -else ifeq ($(HARDWARE_MOTHERBOARD),51) -HARDWARE_VARIANT ?= Gen6 -MCU ?= atmega644p - -#Sanguinololu -else ifeq ($(HARDWARE_MOTHERBOARD),6) -HARDWARE_VARIANT ?= Sanguino -MCU ?= atmega644p -else ifeq ($(HARDWARE_MOTHERBOARD),62) -HARDWARE_VARIANT ?= Sanguino -MCU ?= atmega644p -else ifeq ($(HARDWARE_MOTHERBOARD),63) -HARDWARE_VARIANT ?= Sanguino -MCU ?= atmega644p -else ifeq ($(HARDWARE_MOTHERBOARD),65) -HARDWARE_VARIANT ?= Sanguino -MCU ?= atmega1284p -else ifeq ($(HARDWARE_MOTHERBOARD),66) -HARDWARE_VARIANT ?= Sanguino -MCU ?= atmega1284p - -#Ultimaker -else ifeq ($(HARDWARE_MOTHERBOARD),7) -HARDWARE_VARIANT ?= arduino -MCU ?= atmega2560 -else ifeq ($(HARDWARE_MOTHERBOARD),71) -HARDWARE_VARIANT ?= arduino -MCU ?= atmega1280 - -#Teensylu -else ifeq ($(HARDWARE_MOTHERBOARD),8) -HARDWARE_VARIANT ?= Teensy -MCU ?= at90usb1286 -else ifeq ($(HARDWARE_MOTHERBOARD),81) -HARDWARE_VARIANT ?= Teensy -MCU ?= at90usb1286 -else ifeq ($(HARDWARE_MOTHERBOARD),82) -HARDWARE_VARIANT ?= Teensy -MCU ?= at90usb646 -else ifeq ($(HARDWARE_MOTHERBOARD),83) -HARDWARE_VARIANT ?= Teensy -MCU ?= at90usb1286 -else ifeq ($(HARDWARE_MOTHERBOARD),84) -HARDWARE_VARIANT ?= Teensy -MCU ?= at90usb1286 - -#Gen3+ -else ifeq ($(HARDWARE_MOTHERBOARD),9) -HARDWARE_VARIANT ?= Sanguino -MCU ?= atmega644p - -#Megatronics -else ifeq ($(HARDWARE_MOTHERBOARD),70) -HARDWARE_VARIANT ?= arduino -MCU ?= atmega2560 - -#Alpha OMCA board -else ifeq ($(HARDWARE_MOTHERBOARD),90) -HARDWARE_VARIANT ?= SanguinoA -MCU ?= atmega644 - -#Final OMCA board -else ifeq ($(HARDWARE_MOTHERBOARD),91) -HARDWARE_VARIANT ?= Sanguino -MCU ?= atmega644p - -#Rambo -else ifeq ($(HARDWARE_MOTHERBOARD),301) -HARDWARE_VARIANT ?= arduino -MCU ?= atmega2560 - -# Azteeg -else ifeq ($(HARDWARE_MOTHERBOARD),67) -HARDWARE_VARIANT ?= arduino -MCU ?= atmega2560 -else ifeq ($(HARDWARE_MOTHERBOARD),68) -HARDWARE_VARIANT ?= arduino -MCU ?= atmega2560 - -endif - -# Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py -# if you are setting this to something other than 16MHz -# Set to 16Mhz if not yet set. -F_CPU ?= 16000000 - -# Arduino containd the main source code for the Arduino -# Libraries, the "hardware variant" are for boards -# that derives from that, and their source are present in -# the main Marlin source directory -ifeq ($(HARDWARE_VARIANT), arduino) -HARDWARE_DIR = $(ARDUINO_INSTALL_DIR)/hardware -else -ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true) -HARDWARE_DIR = ../ArduinoAddons/Arduino_1.x.x -else -HARDWARE_DIR = ../ArduinoAddons/Arduino_0.xx -endif -endif -HARDWARE_SRC = $(HARDWARE_DIR)/$(HARDWARE_VARIANT)/cores/arduino - -TARGET = $(notdir $(CURDIR)) - -# VPATH tells make to look into these directory for source files, -# there is no need to specify explicit pathnames as long as the -# directory is added here - -VPATH = . -VPATH += $(BUILD_DIR) -VPATH += $(HARDWARE_SRC) -ifeq ($(HARDWARE_VARIANT), arduino) -VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidCrystal -VPATH += $(ARDUINO_INSTALL_DIR)/libraries/SPI -ifeq ($(LIQUID_TWI2), 1) -VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire -VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility -VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidTWI2 -endif -ifeq ($(WIRE), 1) -VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire -VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility -endif -else -VPATH += $(HARDWARE_DIR)/libraries/LiquidCrystal -VPATH += $(HARDWARE_DIR)/libraries/SPI -ifeq ($(LIQUID_TWI2), 1) -VPATH += $(HARDWARE_DIR)/libraries/Wire -VPATH += $(HARDWARE_DIR)/libraries/Wire/utility -VPATH += $(HARDWARE_DIR)/libraries/LiquidTWI2 -endif -ifeq ($(WIRE), 1) -VPATH += $(HARDWARE_DIR)/libraries/Wire -VPATH += $(HARDWARE_DIR)/libraries/Wire/utility -endif -endif -ifeq ($(HARDWARE_VARIANT), arduino) -HARDWARE_SUB_VARIANT ?= mega -VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/variants/$(HARDWARE_SUB_VARIANT) -else -HARDWARE_SUB_VARIANT ?= standard -VPATH += $(HARDWARE_DIR)/$(HARDWARE_VARIANT)/variants/$(HARDWARE_SUB_VARIANT) -endif -SRC = wiring.c \ - wiring_analog.c wiring_digital.c \ - wiring_pulse.c \ - wiring_shift.c WInterrupts.c -ifeq ($(HARDWARE_VARIANT), Teensy) -SRC = wiring.c -VPATH += $(ARDUINO_INSTALL_DIR)/hardware/teensy/cores/teensy -endif -CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp \ - MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp \ - SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp \ - stepper.cpp temperature.cpp cardreader.cpp ConfigurationStore.cpp \ - watchdog.cpp SPI.cpp Servo.cpp Tone.cpp ultralcd.cpp digipot_mcp4451.cpp \ - vector_3.cpp qr_solve.cpp -ifeq ($(LIQUID_TWI2), 0) -CXXSRC += LiquidCrystal.cpp -else -SRC += twi.c -CXXSRC += Wire.cpp LiquidTWI2.cpp -endif - -ifeq ($(WIRE), 1) -SRC += twi.c -CXXSRC += Wire.cpp -endif - -#Check for Arduino 1.0.0 or higher and use the correct sourcefiles for that version -ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true) -CXXSRC += main.cpp -else -SRC += pins_arduino.c main.c -endif - +# $Id$ + +PORT = /dev/ttyACM* +TARGET = Marlin_main +ARDUINO = /usr/share/arduino/hardware/arduino/cores/arduino/ +# SRC = $(ARDUINO)/buffer.c $(ARDUINO)/pins_arduino.c \ +# $(ARDUINO)/Serial.c $(ARDUINO)/uart.c $(ARDUINO)/wiring.c +CXXSRC = $(TARGET).cpp $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WRandom.cpp +MCU = atmega8 +F_CPU = 16000000 FORMAT = ihex +UPLOAD_RATE = 19200 # Name of this Makefile (used for "make depend"). MAKEFILE = Makefile @@ -293,73 +66,51 @@ DEBUG = stabs OPT = s -DEFINES ?= - -# Program settings -CC = $(AVR_TOOLS_PATH)avr-gcc -CXX = $(AVR_TOOLS_PATH)avr-g++ -OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy -OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump -AR = $(AVR_TOOLS_PATH)avr-ar -SIZE = $(AVR_TOOLS_PATH)avr-size -NM = $(AVR_TOOLS_PATH)avr-nm -AVRDUDE = avrdude -REMOVE = rm -f -MV = mv -f - # Place -D or -U options here -CDEFS = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)} -CXXDEFS = $(CDEFS) +CDEFS = -DF_CPU=$(F_CPU) +CXXDEFS = -DF_CPU=$(F_CPU) -ifeq ($(HARDWARE_VARIANT), Teensy) -CDEFS += -DUSB_SERIAL -SRC += usb.c pins_teensy.c -CXXSRC += usb_api.cpp -endif - -# Add all the source directories as include directories too -CINCS = ${addprefix -I ,${VPATH}} -CXXINCS = ${addprefix -I ,${VPATH}} +# Place -I options here +CINCS = -I$(ARDUINO) +CXXINCS = -I$(ARDUINO) # Compiler flag to set the C Standard level. # c89 - "ANSI" C # gnu89 - c89 plus GCC extensions # c99 - ISO C99 standard (not yet fully implemented) # gnu99 - c99 plus GCC extensions -#CSTANDARD = -std=gnu99 +CSTANDARD = -std=gnu99 CDEBUG = -g$(DEBUG) CWARN = -Wall -Wstrict-prototypes -CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct \ - -fshort-enums -w -ffunction-sections -fdata-sections \ - -DARDUINO=$(ARDUINO_VERSION) -ifneq ($(HARDWARE_MOTHERBOARD),) -CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD} -endif +CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums #CEXTRA = -Wa,-adhlns=$(<:.c=.lst) -CEXTRA = -fno-use-cxa-atexit -CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING) -CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING) -#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs -LDFLAGS = -lm +CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA) +CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) +#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs +LDFLAGS = # Programming support using avrdude. Settings and variables. -AVRDUDE_PORT = $(UPLOAD_PORT) -AVRDUDE_WRITE_FLASH = -U flash:w:$(BUILD_DIR)/$(TARGET).hex:i -ifeq ($(shell uname -s), Linux) -AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/hardware/tools/avrdude.conf -else -AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf -endif -AVRDUDE_FLAGS = -D -C $(AVRDUDE_CONF) \ - -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \ - -b $(UPLOAD_RATE) +AVRDUDE_PROGRAMMER = stk500 +AVRDUDE_PORT = $(PORT) +AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +AVRDUDE_FLAGS = -F -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \ + -b $(UPLOAD_RATE) + +# Program settings +CC = avr-gcc +CXX = avr-g++ +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +NM = avr-nm +AVRDUDE = avrdude +REMOVE = rm -f +MV = mv -f # Define all object files. -OBJ = ${patsubst %.c, $(BUILD_DIR)/%.o, ${SRC}} -OBJ += ${patsubst %.cpp, $(BUILD_DIR)/%.o, ${CXXSRC}} -OBJ += ${patsubst %.S, $(BUILD_DIR)/%.o, ${ASRC}} +OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o) # Define all listing files. LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst) @@ -367,81 +118,52 @@ LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst) # Combine all necessary flags and optional flags. # Add target processor to flags. ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) -ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS) - -# set V=1 (eg, "make V=1") to print the full commands etc. -ifneq ($V,1) - Pecho=@echo - P=@ -else - Pecho=@: - P= -endif +ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + # Default target. -all: sizeafter - -build: $(BUILD_DIR) elf hex - -# Creates the object directory -$(BUILD_DIR): - $P mkdir -p $(BUILD_DIR) - -elf: $(BUILD_DIR)/$(TARGET).elf -hex: $(BUILD_DIR)/$(TARGET).hex -eep: $(BUILD_DIR)/$(TARGET).eep -lss: $(BUILD_DIR)/$(TARGET).lss -sym: $(BUILD_DIR)/$(TARGET).sym - -# Program the device. -# Do not try to reset an arduino if it's not one -upload: $(BUILD_DIR)/$(TARGET).hex -ifeq (${AVRDUDE_PROGRAMMER}, arduino) - stty hup < $(UPLOAD_PORT); true -endif +all: build + +build: elf hex eep + +elf: $(TARGET).elf +hex: $(TARGET).hex +eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym + +# Program the device. +upload: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) -ifeq (${AVRDUDE_PROGRAMMER}, arduino) - stty -hup < $(UPLOAD_PORT); true -endif - # Display size of file. -HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex -ELFSIZE = $(SIZE) --mcu=$(MCU) -C $(BUILD_DIR)/$(TARGET).elf; \ - $(SIZE) $(BUILD_DIR)/$(TARGET).elf -sizebefore: - $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi -sizeafter: build - $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. COFFCONVERT=$(OBJCOPY) --debugging \ - --change-section-address .data-0x800000 \ - --change-section-address .bss-0x800000 \ - --change-section-address .noinit-0x800000 \ - --change-section-address .eeprom-0x810000 +--change-section-address .data-0x800000 \ +--change-section-address .bss-0x800000 \ +--change-section-address .noinit-0x800000 \ +--change-section-address .eeprom-0x810000 -coff: $(BUILD_DIR)/$(TARGET).elf - $(COFFCONVERT) -O coff-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof +coff: $(TARGET).elf + $(COFFCONVERT) -O coff-avr $(TARGET).elf $(TARGET).cof extcoff: $(TARGET).elf - $(COFFCONVERT) -O coff-ext-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof + $(COFFCONVERT) -O coff-ext-avr $(TARGET).elf $(TARGET).cof .SUFFIXES: .elf .hex .eep .lss .sym -.PRECIOUS: .o .elf.hex: - $(Pecho) " COPY $@" - $P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ + $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ .elf.eep: -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ + --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ # Create extended listing file from ELF output file. .elf.lss: @@ -451,35 +173,48 @@ extcoff: $(TARGET).elf .elf.sym: $(NM) -n $< > $@ - # Link: create ELF output file from library. -$(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h - $(Pecho) " CXX $@" - $P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ -L. $(OBJ) $(LDFLAGS) -$(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE) - $(Pecho) " CC $<" - $P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@ -$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.cpp Configuration.h Configuration_adv.h $(MAKEFILE) - $(Pecho) " CXX $<" - $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@ +# Link: create ELF output file from object files. +$(TARGET).elf: $(OBJ) + $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) -$(BUILD_DIR)/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE) - $(Pecho) " CXX $<" - $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@ +# Compile: create object files from C++ source files. +.cpp.o: + $(CXX) -c $(ALL_CXXFLAGS) $< -o $@ -# Target: clean project. -clean: - $(Pecho) " RM $(BUILD_DIR)/*" - $P $(REMOVE) $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep $(BUILD_DIR)/$(TARGET).cof $(BUILD_DIR)/$(TARGET).elf \ - $(BUILD_DIR)/$(TARGET).map $(BUILD_DIR)/$(TARGET).sym $(BUILD_DIR)/$(TARGET).lss $(BUILD_DIR)/$(TARGET).cpp \ - $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d) - $(Pecho) " RMDIR $(BUILD_DIR)/" - $P rm -rf $(BUILD_DIR) +# Compile: create object files from C source files. +.c.o: + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +.c.s: + $(CC) -S $(ALL_CFLAGS) $< -o $@ -.PHONY: all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter +# Assemble: create object files from assembler source files. +.S.o: + $(CC) -c $(ALL_ASFLAGS) $< -o $@ -# Automaticaly include the dependency files created by gcc --include ${wildcard $(BUILD_DIR)/*.d} + + +# Target: clean project. +clean: + $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).cof $(TARGET).elf \ + $(TARGET).map $(TARGET).sym $(TARGET).lss \ + $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d) + +depend: + if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \ + then \ + sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \ + $(MAKEFILE).$$$$ && \ + $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \ + fi + echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \ + >> $(MAKEFILE); \ + $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE) + +.PHONY: all build elf hex eep lss sym program coff extcoff clean depend diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde deleted file mode 100644 index 79c934bf0f74..000000000000 --- a/Marlin/Marlin.pde +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ - -/* - Reprap firmware based on Sprinter and grbl. - Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - */ - -/* - This firmware is a mashup between Sprinter and grbl. - (https://github.com/kliment/Sprinter) - (https://github.com/simen/grbl/tree) - - It has preliminary support for Matthew Roberts advance algorithm - http://reprap.org/pipermail/reprap-dev/2011-May/003323.html - */ - -/* All the implementation is done in *.cpp files to get better compatibility with avr-gcc without the Arduino IDE */ -/* Use this file to help the Arduino IDE find which Arduino libraries are needed and to keep documentation on GCode */ - -#include "Configuration.h" -#include "pins.h" - -#ifdef ULTRA_LCD - #if defined(LCD_I2C_TYPE_PCF8575) - #include - #include - #elif defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008) - #include - #include - #elif defined(DOGLCD) - #include // library for graphics LCD by Oli Kraus (https://code.google.com/p/u8glib/) - #else - #include // library for character LCD - #endif -#endif - -#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1 -#include -#endif - -#if defined(DIGIPOT_I2C) - #include -#endif diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index bd1783bbafd4..93aa15abc42e 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -890,7 +890,8 @@ int bed_sensor_threshold; void setup_bed_sensor_threshold() { #ifdef FSR_BED_TEMPERATURE - int analog_fsr_untouched = rawBedSample(); + + int analog_fsr_untouched = rawFSRSample(); bed_sensor_threshold = analog_fsr_untouched * 95L / 100; #else // nothing needs to be done. This routine sets up a threshold @@ -899,7 +900,7 @@ void setup_bed_sensor_threshold() { int read_bed_touch() { #ifdef FSR_BED_TEMPERATURE - return rawBedSample(); + return rawFSRSample(); #else return digitalRead(Z_MIN_PIN); #endif @@ -2009,7 +2010,11 @@ void process_commands() SERIAL_PROTOCOL_F(degBed(),1); SERIAL_PROTOCOLPGM(" /"); SERIAL_PROTOCOL_F(degTargetBed(),1); - #endif //TEMP_BED_PIN + #endif //TEMP_2_PIN + #if defined(TEMP_2_PIN) && TEMP_2_PIN > -1 + SERIAL_PROTOCOLPGM(" T2:"); + SERIAL_PROTOCOL(rawFSRSample()); + #endif //TEMP_2_PIN for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) { SERIAL_PROTOCOLPGM(" T"); SERIAL_PROTOCOL(cur_extruder); @@ -2044,7 +2049,7 @@ void process_commands() SERIAL_PROTOCOLPGM(" ADC B:"); SERIAL_PROTOCOL_F(degBed(),1); SERIAL_PROTOCOLPGM("C->"); - SERIAL_PROTOCOL_F(rawBedTemp()/OVERSAMPLENR,0); + SERIAL_PROTOCOL_F(rawBedTemp(),0); #endif for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) { SERIAL_PROTOCOLPGM(" T"); diff --git a/Marlin/pins.h b/Marlin/pins.h index f84f51699428..213496e53f90 100644 --- a/Marlin/pins.h +++ b/Marlin/pins.h @@ -550,7 +550,7 @@ #define TC1 4 // ANALOG NUMBERING Thermo couple on Azteeg X3Pro #define TC2 5 // ANALOG NUMBERING Thermo couple on Azteeg X3Pro #else - #define TEMP_2_PIN -1 // ANALOG NUMBERING + #define TEMP_2_PIN 15 // ANALOG NUMBERING #endif #if MOTHERBOARD == 35 diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index e830223c492c..84504dbc7d3a 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -43,6 +43,8 @@ int current_temperature_raw[EXTRUDERS] = { 0 }; float current_temperature[EXTRUDERS] = { 0.0 }; int current_temperature_bed_raw = 0; int raw_temp_bed_sample = 0; +int raw_temp_1_sample = 0; +int raw_temp_2_sample = 0; float current_temperature_bed = 0.0; #ifdef TEMP_SENSOR_1_AS_REDUNDANT int redundant_temperature_raw = 0; @@ -1159,7 +1161,8 @@ ISR(TIMER0_COMPB_vect) break; case 5: // Measure TEMP_1 #if defined(TEMP_1_PIN) && (TEMP_1_PIN > -1) - raw_temp_1_value += ADC; + raw_temp_1_sample = ADC; + raw_temp_1_value += raw_temp_1_sample; #endif temp_state = 6; break; @@ -1178,7 +1181,8 @@ ISR(TIMER0_COMPB_vect) break; case 7: // Measure TEMP_2 #if defined(TEMP_2_PIN) && (TEMP_2_PIN > -1) - raw_temp_2_value += ADC; + raw_temp_2_sample = ADC; + raw_temp_2_value += raw_temp_2_sample; #endif temp_state = 0; temp_count++; diff --git a/Marlin/temperature.h b/Marlin/temperature.h index dafa4cc58ba4..8e6c6beb7e19 100644 --- a/Marlin/temperature.h +++ b/Marlin/temperature.h @@ -40,6 +40,9 @@ extern float current_temperature[EXTRUDERS]; extern int current_temperature_bed_raw; #endif extern int raw_temp_bed_sample; +extern int raw_temp_1_sample; +extern int raw_temp_2_sample; + extern int target_temperature_bed; extern float current_temperature_bed; #ifdef TEMP_SENSOR_1_AS_REDUNDANT @@ -89,6 +92,16 @@ FORCE_INLINE int rawBedSample() { return raw_temp_bed_sample; } +FORCE_INLINE int rawFSRSample() { +#ifdef FSR_TEMP_SENSOR_1 + return raw_temp_1_sample; +#elif defined(FSR_TEMP_SENSOR_2) + return raw_temp_2_sample; +#else + return raw_temp_bed_sample; +#endif +} + FORCE_INLINE float degBed() { return current_temperature_bed; }; From 74dffc6d78f93875028dcdb55fe73f9b38a01869 Mon Sep 17 00:00:00 2001 From: tmolteno Date: Sat, 23 Jan 2016 10:37:11 +1300 Subject: [PATCH 8/8] Fix up new z distance --- Marlin/Calibration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Calibration.h b/Marlin/Calibration.h index 816235a3b9b6..47139971ee1f 100644 --- a/Marlin/Calibration.h +++ b/Marlin/Calibration.h @@ -27,7 +27,7 @@ // First thing to calibrate is the manual home position // For delta: Distance between nozzle and print surface after homing. -#define MANUAL_Z_HOME_POS 204.1 +#define MANUAL_Z_HOME_POS 200.1 // Center-to-center distance of the holes in the diagonal push rods. #define DELTA_DIAGONAL_ROD 214.5 // mm