summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Churchill <james@rfdesign.com.au>2011-07-09 23:00:03 +1000
committerJames Churchill <james@rfdesign.com.au>2011-07-09 23:00:03 +1000
commit03751180d039ef203b49e24c092a1d2627b64e2e (patch)
treed84d389274867956f90aba17fe37f6fd9f723025
parent9d518424389050394da9d45cbf3bb8f4a6d44e5c (diff)
parent3e28c2e8f00a3440873c806f780641de0ed5190f (diff)
Merge branch 'master' of git://github.com/kliment/Sprinter
-rw-r--r--Sprinter/Configuration.h162
-rw-r--r--Sprinter/FatStructs.h (renamed from Tonokip_Firmware/FatStructs.h)0
-rw-r--r--Sprinter/Makefile (renamed from Tonokip_Firmware/Makefile)6
-rw-r--r--Sprinter/Sd2Card.cpp (renamed from Tonokip_Firmware/Sd2Card.cpp)0
-rw-r--r--Sprinter/Sd2Card.h (renamed from Tonokip_Firmware/Sd2Card.h)0
-rw-r--r--Sprinter/Sd2PinMap.h (renamed from Tonokip_Firmware/Sd2PinMap.h)0
-rw-r--r--Sprinter/SdFat.h (renamed from Tonokip_Firmware/SdFat.h)0
-rw-r--r--Sprinter/SdFatUtil.h (renamed from Tonokip_Firmware/SdFatUtil.h)0
-rw-r--r--Sprinter/SdFatmainpage.h (renamed from Tonokip_Firmware/SdFatmainpage.h)0
-rw-r--r--Sprinter/SdFile.cpp (renamed from Tonokip_Firmware/SdFile.cpp)0
-rw-r--r--Sprinter/SdInfo.h (renamed from Tonokip_Firmware/SdInfo.h)0
-rw-r--r--Sprinter/SdVolume.cpp (renamed from Tonokip_Firmware/SdVolume.cpp)0
-rw-r--r--Sprinter/Sprinter.h (renamed from Tonokip_Firmware/Tonokip_Firmware.h)11
-rw-r--r--Sprinter/Sprinter.pde (renamed from Tonokip_Firmware/Tonokip_Firmware.pde)848
-rw-r--r--Sprinter/createTemperatureLookup.py (renamed from Tonokip_Firmware/createTemperatureLookup.py)0
-rw-r--r--Sprinter/pins.h (renamed from Tonokip_Firmware/pins.h)75
-rw-r--r--Sprinter/thermistortables.h159
-rw-r--r--Tonokip_Firmware/BedThermistorTable_100k.h85
-rw-r--r--Tonokip_Firmware/BedThermistorTable_200k.h42
-rw-r--r--Tonokip_Firmware/ThermistorTable_100k.h85
-rw-r--r--Tonokip_Firmware/ThermistorTable_200k.h42
-rw-r--r--Tonokip_Firmware/ThermistorTable_mendelparts.h45
-rw-r--r--Tonokip_Firmware/configuration.h156
23 files changed, 776 insertions, 940 deletions
diff --git a/Sprinter/Configuration.h b/Sprinter/Configuration.h
new file mode 100644
index 0000000..319c839
--- /dev/null
+++ b/Sprinter/Configuration.h
@@ -0,0 +1,162 @@
+#ifndef CONFIGURATION_H
+#define CONFIGURATION_H
+
+// BASIC SETTINGS: select your board type, thermistor type, axis scaling, and endstop configuration
+
+//// The following define selects which electronics board you have. Please choose the one that matches your setup
+// MEGA/RAMPS up to 1.2 = 3,
+// RAMPS 1.3 = 33
+// Gen6 = 5,
+// Sanguinololu up to 1.1 = 6
+// Sanguinololu 1.2 and above = 62
+#define MOTHERBOARD 3
+
+//// Thermistor settings:
+// 1 is 100k thermistor
+// 2 is 200k thermistor
+// 3 is mendel-parts thermistor
+#define THERMISTORHEATER 1
+#define THERMISTORBED 1
+
+//// Calibration variables
+// X, Y, Z, E steps per unit - Metric Prusa Mendel with Wade extruder:
+float axis_steps_per_unit[] = {80, 80, 3200/1.25,700};
+// Metric Prusa Mendel with Makergear geared stepper extruder:
+//float axis_steps_per_unit[] = {80,80,3200/1.25,1380};
+
+//// Endstop Settings
+#define ENDSTOPPULLUPS 1 // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
+// The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
+const bool ENDSTOPS_INVERTING = false; //set to true to invert the logic of the endstops
+
+// This determines the communication speed of the printer
+#define BAUDRATE 115200
+
+// Comment out (using // at the start of the line) to disable SD support:
+#define SDSUPPORT 1
+
+
+//// ADVANCED SETTINGS - to tweak parameters
+
+#include "thermistortables.h"
+
+// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
+const bool X_ENABLE_ON = 0;
+const bool Y_ENABLE_ON = 0;
+const bool Z_ENABLE_ON = 0;
+const bool E_ENABLE_ON = 0;
+
+// Disables axis when it's not being used.
+const bool DISABLE_X = false;
+const bool DISABLE_Y = false;
+const bool DISABLE_Z = true;
+const bool DISABLE_E = false;
+
+// Inverting axis direction
+const bool INVERT_X_DIR = false;
+const bool INVERT_Y_DIR = false;
+const bool INVERT_Z_DIR = true;
+const bool INVERT_E_DIR = false;
+
+//// ENDSTOP SETTINGS:
+// Sets direction of endstops when homing; 1=MAX, -1=MIN
+const int X_HOME_DIR = -1;
+const int Y_HOME_DIR = -1;
+const int Z_HOME_DIR = -1;
+
+const bool min_software_endstops = false; //If true, axis won't move to coordinates less than zero.
+const bool max_software_endstops = true; //If true, axis won't move to coordinates greater than the defined lengths below.
+const int X_MAX_LENGTH = 200;
+const int Y_MAX_LENGTH = 200;
+const int Z_MAX_LENGTH = 100;
+
+//// MOVEMENT SETTINGS
+const int NUM_AXIS = 4; // The axis order in all axis related arrays is X, Y, Z, E
+float max_feedrate[] = {200000, 200000, 240, 500000};
+bool axis_relative_modes[] = {false, false, false, false};
+
+// Min step delay in microseconds. If you are experiencing missing steps, try to raise the delay microseconds, but be aware this
+// If you enable this, make sure STEP_DELAY_RATIO is disabled.
+//#define STEP_DELAY_MICROS 1
+
+// Step delay over interval ratio. If you are still experiencing missing steps, try to uncomment the following line, but be aware this
+// If you enable this, make sure STEP_DELAY_MICROS is disabled. (except for Gen6: both need to be enabled.)
+//#define STEP_DELAY_RATIO 0.25
+
+// Comment this to disable ramp acceleration
+#define RAMP_ACCELERATION 1
+
+//// Acceleration settings
+#ifdef RAMP_ACCELERATION
+// 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.
+float max_start_speed_units_per_second[] = {25.0,25.0,0.2,10.0};
+long max_acceleration_units_per_sq_second[] = {1000,1000,50,10000}; // X, Y, Z and E max acceleration in mm/s^2 for printing moves or retracts
+long max_travel_acceleration_units_per_sq_second[] = {500,500,50,500}; // X, Y, Z max acceleration in mm/s^2 for travel moves
+#endif
+
+//// AD595 THERMOCOUPLE SUPPORT UNTESTED... USE WITH CAUTION!!!!
+
+//// PID settings:
+// Uncomment the following line to enable PID support. This is untested and could be disastrous. Be careful.
+//#define PIDTEMP 1
+#ifdef PIDTEMP
+#define PID_MAX 255 // limits current to nozzle
+#define PID_INTEGRAL_DRIVE_MAX 220
+#define PID_PGAIN 180 //100 is 1.0
+#define PID_IGAIN 2 //100 is 1.0
+#define PID_DGAIN 100 //100 is 1.0
+#endif
+
+// How often should the heater check for new temp readings, in milliseconds
+#define HEATER_CHECK_INTERVAL 500
+#define BED_CHECK_INTERVAL 5000
+// Comment the following line to enable heat management during acceleration
+#define DISABLE_CHECK_DURING_ACC
+#ifndef DISABLE_CHECK_DURING_ACC
+ // Uncomment the following line to disable heat management during moves
+ //#define DISABLE_CHECK_DURING_MOVE
+#endif
+// Uncomment the following line to disable heat management during travel moves (and extruder-only moves, eg: retracts), strongly recommended if you are missing steps mid print.
+// Probably this should remain commented if are using PID.
+// It also defines the max milliseconds interval after which a travel move is not considered so for the sake of this feature.
+#define DISABLE_CHECK_DURING_TRAVEL 1000
+
+//// Temperature smoothing - only uncomment this if your temp readings are noisy (Gen6 without EvdZ's 5V hack)
+//#define SMOOTHING 1
+//#define SMOOTHFACTOR 16 //best to use a power of two here - determines how many values are averaged together by the smoothing algorithm
+
+//// Experimental watchdog and minimal temp
+// The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
+// If the temperature has not increased at the end of that period, the target temperature is set to zero. It can be reset with another M104/M109
+//#define WATCHPERIOD 5000 //5 seconds
+
+//// The minimal temperature defines the temperature below which the heater will not be enabled
+#define MINTEMP 5
+
+//// Experimental max temp
+// When temperature exceeds max temp, your heater will be switched off.
+// This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure!
+// You should use MINTEMP for thermistor short/failure protection.
+#define MAXTEMP 275
+
+// Select one of these only to define how the nozzle temp is read.
+#define HEATER_USES_THERMISTOR
+//#define HEATER_USES_AD595
+//#define HEATER_USES_MAX6675
+
+// Select one of these only to define how the bed temp is read.
+#define BED_USES_THERMISTOR
+//#define BED_USES_AD595
+
+// Uncomment the following line to enable debugging. You can better control debugging below the following line
+//#define DEBUG
+#ifdef DEBUG
+ //#define DEBUG_PREPARE_MOVE //Enable this to debug prepare_move() function
+ //#define DEBUG_BRESENHAM //Enable this to debug the Bresenham algorithm
+ //#define DEBUG_RAMP_ACCELERATION //Enable this to debug all constant acceleration info
+ //#define DEBUG_MOVE_TIME //Enable this to time each move and print the result
+ //#define DEBUG_HEAT_MGMT //Enable this to debug heat management. WARNING, this will cause axes to jitter!
+ //#define DEBUG_DISABLE_CHECK_DURING_TRAVEL //Debug the namesake feature, see above in this file
+#endif
+
+#endif
diff --git a/Tonokip_Firmware/FatStructs.h b/Sprinter/FatStructs.h
index f5bdaa5..f5bdaa5 100644
--- a/Tonokip_Firmware/FatStructs.h
+++ b/Sprinter/FatStructs.h
diff --git a/Tonokip_Firmware/Makefile b/Sprinter/Makefile
index 618b384..0f9b5b7 100644
--- a/Tonokip_Firmware/Makefile
+++ b/Sprinter/Makefile
@@ -33,7 +33,7 @@
# $Id$
TARGET = $(notdir $(CURDIR))
-INSTALL_DIR = /home/chris/arduino-0022
+INSTALL_DIR = ../../arduino22/arduino-0022/
UPLOAD_RATE = 38400
AVRDUDE_PROGRAMMER = stk500v1
PORT = /dev/ttyUSB0
@@ -52,7 +52,7 @@ ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino
AVR_TOOLS_PATH = /usr/bin
SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
-$(ARDUINO)/wiring_pulse.c $(ARDUINO)/wiring_serial.c \
+$(ARDUINO)/wiring_pulse.c \
$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WMath.cpp \
$(ARDUINO)/Print.cpp ./SdFile.cpp ./SdVolume.cpp ./Sd2Card.cpp
@@ -142,7 +142,7 @@ applet_files: $(TARGET).pde
test -d applet || mkdir applet
echo '#include "WProgram.h"' > applet/$(TARGET).cpp
cat $(TARGET).pde >> applet/$(TARGET).cpp
- cat $(ARDUINO)/main.cxx >> applet/$(TARGET).cpp
+ cat $(ARDUINO)/main.cpp >> applet/$(TARGET).cpp
elf: applet/$(TARGET).elf
hex: applet/$(TARGET).hex
diff --git a/Tonokip_Firmware/Sd2Card.cpp b/Sprinter/Sd2Card.cpp
index 8222cfd..8222cfd 100644
--- a/Tonokip_Firmware/Sd2Card.cpp
+++ b/Sprinter/Sd2Card.cpp
diff --git a/Tonokip_Firmware/Sd2Card.h b/Sprinter/Sd2Card.h
index 73b46fb..73b46fb 100644
--- a/Tonokip_Firmware/Sd2Card.h
+++ b/Sprinter/Sd2Card.h
diff --git a/Tonokip_Firmware/Sd2PinMap.h b/Sprinter/Sd2PinMap.h
index 4bd75a3..4bd75a3 100644
--- a/Tonokip_Firmware/Sd2PinMap.h
+++ b/Sprinter/Sd2PinMap.h
diff --git a/Tonokip_Firmware/SdFat.h b/Sprinter/SdFat.h
index 048fa71..048fa71 100644
--- a/Tonokip_Firmware/SdFat.h
+++ b/Sprinter/SdFat.h
diff --git a/Tonokip_Firmware/SdFatUtil.h b/Sprinter/SdFatUtil.h
index 8bf9048..8bf9048 100644
--- a/Tonokip_Firmware/SdFatUtil.h
+++ b/Sprinter/SdFatUtil.h
diff --git a/Tonokip_Firmware/SdFatmainpage.h b/Sprinter/SdFatmainpage.h
index 73b3b63..73b3b63 100644
--- a/Tonokip_Firmware/SdFatmainpage.h
+++ b/Sprinter/SdFatmainpage.h
diff --git a/Tonokip_Firmware/SdFile.cpp b/Sprinter/SdFile.cpp
index 0a27159..0a27159 100644
--- a/Tonokip_Firmware/SdFile.cpp
+++ b/Sprinter/SdFile.cpp
diff --git a/Tonokip_Firmware/SdInfo.h b/Sprinter/SdInfo.h
index acde74d..acde74d 100644
--- a/Tonokip_Firmware/SdInfo.h
+++ b/Sprinter/SdInfo.h
diff --git a/Tonokip_Firmware/SdVolume.cpp b/Sprinter/SdVolume.cpp
index 3c1e641..3c1e641 100644
--- a/Tonokip_Firmware/SdVolume.cpp
+++ b/Sprinter/SdVolume.cpp
diff --git a/Tonokip_Firmware/Tonokip_Firmware.h b/Sprinter/Sprinter.h
index 4e3c7ea..7a4b8a9 100644
--- a/Tonokip_Firmware/Tonokip_Firmware.h
+++ b/Sprinter/Sprinter.h
@@ -1,7 +1,8 @@
// Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
// Licence: GPL
#include <WProgram.h>
-
+extern "C" void __cxa_pure_virtual();
+void __cxa_pure_virtual(){};
void get_command();
void process_commands();
@@ -18,7 +19,8 @@ void ClearToSend();
void get_coordinates();
void prepare_move();
-void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remaining, unsigned long z_steps_remaining, unsigned long e_steps_remaining);
+void linear_move(unsigned long steps_remaining[]);
+void do_step_update_micros(int axis);
void disable_x();
void disable_y();
void disable_z();
@@ -27,10 +29,7 @@ void enable_x();
void enable_y();
void enable_z();
void enable_e();
-void do_x_step();
-void do_y_step();
-void do_z_step();
-void do_e_step();
+void do_step(int axis);
void kill(byte debug);
diff --git a/Tonokip_Firmware/Tonokip_Firmware.pde b/Sprinter/Sprinter.pde
index ff1b411..bd6a2d8 100644
--- a/Tonokip_Firmware/Tonokip_Firmware.pde
+++ b/Sprinter/Sprinter.pde
@@ -1,8 +1,8 @@
// Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
// Licence: GPL
-#include "Tonokip_Firmware.h"
-#include "configuration.h"
+#include "Sprinter.h"
+#include "Configuration.h"
#include "pins.h"
#ifdef SDSUPPORT
@@ -57,40 +57,42 @@
//Stepper Movement Variables
-bool direction_x, direction_y, direction_z, direction_e;
-unsigned long previous_micros = 0, previous_micros_x = 0, previous_micros_y = 0, previous_micros_z = 0, previous_micros_e = 0, previous_millis_heater, previous_millis_bed_heater;
-unsigned long x_steps_to_take, y_steps_to_take, z_steps_to_take, e_steps_to_take;
+char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
+bool move_direction[NUM_AXIS];
+const int STEP_PIN[NUM_AXIS] = {X_STEP_PIN, Y_STEP_PIN, Z_STEP_PIN, E_STEP_PIN};
+unsigned long axis_previous_micros[NUM_AXIS];
+unsigned long previous_micros = 0, previous_millis_heater, previous_millis_bed_heater;
+unsigned long move_steps_to_take[NUM_AXIS];
#ifdef RAMP_ACCELERATION
- unsigned long max_x_interval = 100000000.0 / (min_units_per_second * x_steps_per_unit);
- unsigned long max_y_interval = 100000000.0 / (min_units_per_second * y_steps_per_unit);
+ unsigned long axis_max_interval[] = {100000000.0 / (max_start_speed_units_per_second[0] * axis_steps_per_unit[0]),
+ 100000000.0 / (max_start_speed_units_per_second[1] * axis_steps_per_unit[1]),
+ 100000000.0 / (max_start_speed_units_per_second[2] * axis_steps_per_unit[2]),
+ 100000000.0 / (max_start_speed_units_per_second[3] * axis_steps_per_unit[3])}; //TODO: refactor all things like this in a function, or move to setup()
+ // in a for loop
unsigned long max_interval;
- unsigned long x_steps_per_sqr_second = max_acceleration_units_per_sq_second * x_steps_per_unit;
- unsigned long y_steps_per_sqr_second = max_acceleration_units_per_sq_second * y_steps_per_unit;
- unsigned long x_travel_steps_per_sqr_second = max_travel_acceleration_units_per_sq_second * x_steps_per_unit;
- unsigned long y_travel_steps_per_sqr_second = max_travel_acceleration_units_per_sq_second * y_steps_per_unit;
+ unsigned long axis_steps_per_sqr_second[] = {max_acceleration_units_per_sq_second[0] * axis_steps_per_unit[0],
+ max_acceleration_units_per_sq_second[1] * axis_steps_per_unit[1], max_acceleration_units_per_sq_second[2] * axis_steps_per_unit[2],
+ max_acceleration_units_per_sq_second[3] * axis_steps_per_unit[3]};
+ unsigned long axis_travel_steps_per_sqr_second[] = {max_travel_acceleration_units_per_sq_second[0] * axis_steps_per_unit[0],
+ max_travel_acceleration_units_per_sq_second[1] * axis_steps_per_unit[1], max_travel_acceleration_units_per_sq_second[2] * axis_steps_per_unit[2],
+ max_travel_acceleration_units_per_sq_second[3] * axis_steps_per_unit[3]};
unsigned long steps_per_sqr_second, plateau_steps;
#endif
-#ifdef EXP_ACCELERATION
- unsigned long long_full_velocity_units = full_velocity_units * 100;
- unsigned long long_travel_move_full_velocity_units = travel_move_full_velocity_units * 100;
- unsigned long max_x_interval = 100000000.0 / (min_units_per_second * x_steps_per_unit);
- unsigned long max_y_interval = 100000000.0 / (min_units_per_second * y_steps_per_unit);
- unsigned long max_interval;
- unsigned long x_min_constant_speed_steps = min_constant_speed_units * x_steps_per_unit,
- y_min_constant_speed_steps = min_constant_speed_units * y_steps_per_unit, min_constant_speed_steps;
-#endif
boolean acceleration_enabled = false, accelerating = false;
unsigned long interval;
-float destination_x = 0.0, destination_y = 0.0, destination_z = 0.0, destination_e = 0.0;
-float current_x = 0.0, current_y = 0.0, current_z = 0.0, current_e = 0.0;
-long x_interval, y_interval, z_interval, e_interval; // for speed delay
-float feedrate = 1500, next_feedrate, z_feedrate, saved_feedrate;
+float destination[NUM_AXIS] = {0.0, 0.0, 0.0, 0.0};
+float current_position[NUM_AXIS] = {0.0, 0.0, 0.0, 0.0};
+long axis_interval[NUM_AXIS]; // for speed delay
bool home_all_axis = true;
+float feedrate = 1500, next_feedrate, saved_feedrate;
float time_for_move;
long gcode_N, gcode_LastN;
bool relative_mode = false; //Determines Absolute or Relative Coordinates
bool relative_mode_e = false; //Determines Absolute or Relative E Codes while in Absolute Coordinates mode. E is always relative in Relative Coordinates mode.
long timediff = 0;
+//experimental feedrate calc
+float d = 0;
+float axis_diff[NUM_AXIS] = {0, 0, 0, 0};
#ifdef STEP_DELAY_RATIO
long long_step_delay_ratio = STEP_DELAY_RATIO * 100;
#endif
@@ -208,11 +210,9 @@ void setup()
for(int i = 0; i < BUFSIZE; i++){
fromsd[i] = false;
}
+
//Initialize Step Pins
- if(X_STEP_PIN > -1) pinMode(X_STEP_PIN,OUTPUT);
- if(Y_STEP_PIN > -1) pinMode(Y_STEP_PIN,OUTPUT);
- if(Z_STEP_PIN > -1) pinMode(Z_STEP_PIN,OUTPUT);
- if(E_STEP_PIN > -1) pinMode(E_STEP_PIN,OUTPUT);
+ for(int i=0; i < NUM_AXIS; i++) if(STEP_PIN[i] > -1) pinMode(STEP_PIN[i],OUTPUT);
//Initialize Dir Pins
if(X_DIR_PIN > -1) pinMode(X_DIR_PIN,OUTPUT);
@@ -268,6 +268,7 @@ void setup()
initsd();
#endif
+
}
@@ -437,9 +438,6 @@ inline bool code_seen(char code)
strchr_pointer = strchr(cmdbuffer[bufindr], code);
return (strchr_pointer != NULL); //Return True if a character was found
}
- //experimental feedrate calc
-float d = 0;
-float xdiff = 0, ydiff = 0, zdiff = 0, ediff = 0;
inline void process_commands()
{
@@ -452,6 +450,9 @@ inline void process_commands()
{
case 0: // G0 -> G1
case 1: // G1
+ #if (defined DISABLE_CHECK_DURING_ACC) || (defined DISABLE_CHECK_DURING_MOVE) || (defined DISABLE_CHECK_DURING_TRAVEL)
+ manage_heater();
+ #endif
get_coordinates(); // For X Y Z E F
prepare_move();
previous_millis_cmd = millis();
@@ -469,76 +470,72 @@ inline void process_commands()
break;
case 28: //G28 Home all Axis one at a time
saved_feedrate = feedrate;
- destination_x = 0;
- current_x = 0;
- destination_y = 0;
- current_y = 0;
- destination_z = 0;
- current_z = 0;
- destination_e = 0;
- current_e = 0;
+ for(int i=0; i < NUM_AXIS; i++) {
+ destination[i] = 0;
+ current_position[i] = 0;
+ }
feedrate = 0;
-
- home_all_axis = !((code_seen('X')) || (code_seen('Y')) || (code_seen('Z')));
+
+ home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])));
if((home_all_axis) || (code_seen('X'))) {
- if((X_MIN_PIN > -1 && X_HOME_DIR==-1) || (X_MAX_PIN > -1 && X_HOME_DIR==1)) {
- current_x = 0;
- destination_x = 1.5 * X_MAX_LENGTH * X_HOME_DIR;
- feedrate = min_units_per_second * 60;
+ #if ((X_MIN_PIN > -1 && X_HOME_DIR==-1) || (X_MAX_PIN > -1 && X_HOME_DIR==1))
+ current_position[0] = 0;
+ destination[0] = 1.5 * X_MAX_LENGTH * X_HOME_DIR;
+ feedrate = max_start_speed_units_per_second[0] * 60;
prepare_move();
-
- current_x = 0;
- destination_x = -1 * X_HOME_DIR;
+
+ current_position[0] = 0;
+ destination[0] = -5 * X_HOME_DIR;
prepare_move();
-
- destination_x = 10 * X_HOME_DIR;
+
+ destination[0] = 10 * X_HOME_DIR;
prepare_move();
-
- current_x = 0;
- destination_x = 0;
+
+ current_position[0] = 0;
+ destination[0] = 0;
feedrate = 0;
- }
+ #endif
}
- if((home_all_axis) || (code_seen('Y'))) {
- if((Y_MIN_PIN > -1 && Y_HOME_DIR==-1) || (Y_MAX_PIN > -1 && Y_HOME_DIR==1)) {
- current_y = 0;
- destination_y = 1.5 * Y_MAX_LENGTH * Y_HOME_DIR;
- feedrate = min_units_per_second * 60;
+ if((home_all_axis) || (code_seen('X'))) {
+ #if ((Y_MIN_PIN > -1 && Y_HOME_DIR==-1) || (Y_MAX_PIN > -1 && Y_HOME_DIR==1))
+ current_position[1] = 0;
+ destination[1] = 1.5 * Y_MAX_LENGTH * Y_HOME_DIR;
+ feedrate = max_start_speed_units_per_second[1] * 60;
prepare_move();
-
- current_y = 0;
- destination_y = -1 * Y_HOME_DIR;
+
+ current_position[1] = 0;
+ destination[1] = -5 * Y_HOME_DIR;
prepare_move();
-
- destination_y = 10 * Y_HOME_DIR;
+
+ destination[1] = 10 * Y_HOME_DIR;
prepare_move();
-
- current_y = 0;
- destination_y = 0;
+
+ current_position[1] = 0;
+ destination[1] = 0;
feedrate = 0;
- }
+ #endif
}
- if((home_all_axis) || (code_seen('Z'))) {
- if((Z_MIN_PIN > -1 && Z_HOME_DIR==-1) || (Z_MAX_PIN > -1 && Z_HOME_DIR==1)) {
- current_z = 0;
- destination_z = 1.5 * Z_MAX_LENGTH * Z_HOME_DIR;
- feedrate = max_z_feedrate/2;
+ if((home_all_axis) || (code_seen('X'))) {
+ #if ((Z_MIN_PIN > -1 && Z_HOME_DIR==-1) || (Z_MAX_PIN > -1 && Z_HOME_DIR==1))
+ current_position[2] = 0;
+ destination[2] = 1.5 * Z_MAX_LENGTH * Z_HOME_DIR;
+ feedrate = max_feedrate[2]/2;
prepare_move();
-
- current_z = 0;
- destination_z = -1 * Z_HOME_DIR;
+
+ current_position[2] = 0;
+ destination[2] = -5 * Z_HOME_DIR;
prepare_move();
-
- destination_z = 10 * Z_HOME_DIR;
+
+ destination[2] = 10 * Z_HOME_DIR;
prepare_move();
-
- current_z = 0;
- destination_z = 0;
+
+ current_position[2] = 0;
+ destination[2] = 0;
feedrate = 0;
- }
+ #endif
}
feedrate = saved_feedrate;
@@ -551,10 +548,9 @@ inline void process_commands()
relative_mode = true;
break;
case 92: // G92
- if(code_seen('X')) current_x = code_value();
- if(code_seen('Y')) current_y = code_value();
- if(code_seen('Z')) current_z = code_value();
- if(code_seen('E')) current_e = code_value();
+ for(int i=0; i < NUM_AXIS; i++) {
+ if(code_seen(axis_codes[i])) current_position[i] = code_value();
+ }
break;
}
@@ -720,9 +716,7 @@ inline void process_commands()
{
tt=analog2temp(current_raw);
Serial.print("T:");
- Serial.println( tt );
- Serial.print("ok T:");
- Serial.print( tt );
+ Serial.print( tt );
Serial.print(" B:");
Serial.println( analog2temp(current_bed_raw) );
codenum = millis();
@@ -751,10 +745,10 @@ inline void process_commands()
if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT); //Floating
break;
case 82:
- relative_mode_e = false;
+ axis_relative_modes[3] = false;
break;
case 83:
- relative_mode_e = true;
+ axis_relative_modes[3] = true;
break;
case 84:
if(code_seen('S')){ stepper_inactive_time = code_value() * 1000; }
@@ -765,23 +759,32 @@ inline void process_commands()
max_inactive_time = code_value() * 1000;
break;
case 92: // M92
- if(code_seen('X')) x_steps_per_unit = code_value();
- if(code_seen('Y')) y_steps_per_unit = code_value();
- if(code_seen('Z')) z_steps_per_unit = code_value();
- if(code_seen('E')) e_steps_per_unit = code_value();
+ for(int i=0; i < NUM_AXIS; i++) {
+ if(code_seen(axis_codes[i])) axis_steps_per_unit[i] = code_value();
+ }
+
+ //Update start speed intervals and axis order. TODO: refactor axis_max_interval[] calculation into a function, as it
+ // should also be used in setup() as well
+ #ifdef RAMP_ACCELERATION
+ long temp_max_intervals[NUM_AXIS];
+ for(int i=0; i < NUM_AXIS; i++) {
+ axis_max_interval[i] = 100000000.0 / (max_start_speed_units_per_second[i] * axis_steps_per_unit[i]);//TODO: do this for
+ // all steps_per_unit related variables
+ }
+ #endif
break;
case 115: // M115
Serial.println("FIRMWARE_NAME:Sprinter FIRMWARE_URL:http%%3A/github.com/kliment/Sprinter/ PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1");
break;
case 114: // M114
Serial.print("X:");
- Serial.print(current_x);
+ Serial.print(current_position[0]);
Serial.print("Y:");
- Serial.print(current_y);
+ Serial.print(current_position[1]);
Serial.print("Z:");
- Serial.print(current_z);
+ Serial.print(current_position[2]);
Serial.print("E:");
- Serial.println(current_e);
+ Serial.println(current_position[3]);
break;
case 119: // M119
#if (X_MIN_PIN > -1)
@@ -810,13 +813,16 @@ inline void process_commands()
#endif
break;
#ifdef RAMP_ACCELERATION
+ //TODO: update for all axis, use for loop
case 201: // M201
- if(code_seen('X')) x_steps_per_sqr_second = code_value() * x_steps_per_unit;
- if(code_seen('Y')) y_steps_per_sqr_second = code_value() * y_steps_per_unit;
+ for(int i=0; i < NUM_AXIS; i++) {
+ if(code_seen(axis_codes[i])) axis_steps_per_sqr_second[i] = code_value() * axis_steps_per_unit[i];
+ }
break;
case 202: // M202
- if(code_seen('X')) x_travel_steps_per_sqr_second = code_value() * x_steps_per_unit;
- if(code_seen('Y')) y_travel_steps_per_sqr_second = code_value() * y_steps_per_unit;
+ for(int i=0; i < NUM_AXIS; i++) {
+ if(code_seen(axis_codes[i])) axis_travel_steps_per_sqr_second[i] = code_value() * axis_steps_per_unit[i];
+ }
break;
#endif
}
@@ -852,14 +858,10 @@ inline void ClearToSend()
inline void get_coordinates()
{
- if(code_seen('X')) destination_x = (float)code_value() + relative_mode*current_x;
- else destination_x = current_x; //Are these else lines really needed?
- if(code_seen('Y')) destination_y = (float)code_value() + relative_mode*current_y;
- else destination_y = current_y;
- if(code_seen('Z')) destination_z = (float)code_value() + relative_mode*current_z;
- else destination_z = current_z;
- if(code_seen('E')) destination_e = (float)code_value() + (relative_mode_e || relative_mode)*current_e;
- else destination_e = current_e;
+ for(int i=0; i < NUM_AXIS; i++) {
+ if(code_seen(axis_codes[i])) destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i];
+ else destination[i] = current_position[i]; //Are these else lines really needed?
+ }
if(code_seen('F')) {
next_feedrate = code_value();
if(next_feedrate > 0.0) feedrate = next_feedrate;
@@ -869,202 +871,169 @@ inline void get_coordinates()
inline void prepare_move()
{
//Find direction
- if(destination_x >= current_x) direction_x = 1;
- else direction_x = 0;
- if(destination_y >= current_y) direction_y = 1;
- else direction_y = 0;
- if(destination_z >= current_z) direction_z = 1;
- else direction_z = 0;
- if(destination_e >= current_e) direction_e = 1;
- else direction_e = 0;
+ for(int i=0; i < NUM_AXIS; i++) {
+ if(destination[i] >= current_position[i]) move_direction[i] = 1;
+ else move_direction[i] = 0;
+ }
if (min_software_endstops) {
- if (destination_x < 0) destination_x = 0.0;
- if (destination_y < 0) destination_y = 0.0;
- if (destination_z < 0) destination_z = 0.0;
+ if (destination[0] < 0) destination[0] = 0.0;
+ if (destination[1] < 0) destination[1] = 0.0;
+ if (destination[2] < 0) destination[2] = 0.0;
}
if (max_software_endstops) {
- if (destination_x > X_MAX_LENGTH) destination_x = X_MAX_LENGTH;
- if (destination_y > Y_MAX_LENGTH) destination_y = Y_MAX_LENGTH;
- if (destination_z > Z_MAX_LENGTH) destination_z = Z_MAX_LENGTH;
+ if (destination[0] > X_MAX_LENGTH) destination[0] = X_MAX_LENGTH;
+ if (destination[1] > Y_MAX_LENGTH) destination[1] = Y_MAX_LENGTH;
+ if (destination[2] > Z_MAX_LENGTH) destination[2] = Z_MAX_LENGTH;
}
-
- if(feedrate > max_feedrate) feedrate = max_feedrate;
- if(feedrate > max_z_feedrate) z_feedrate = max_z_feedrate;
- else z_feedrate = feedrate;
-
- xdiff = (destination_x - current_x);
- ydiff = (destination_y - current_y);
- zdiff = (destination_z - current_z);
- ediff = (destination_e - current_e);
- x_steps_to_take = abs(xdiff) * x_steps_per_unit;
- y_steps_to_take = abs(ydiff) * y_steps_per_unit;
- z_steps_to_take = abs(zdiff) * z_steps_per_unit;
- e_steps_to_take = abs(ediff) * e_steps_per_unit;
+ for(int i=0; i < NUM_AXIS; i++) {
+ axis_diff[i] = destination[i] - current_position[i];
+ move_steps_to_take[i] = abs(axis_diff[i]) * axis_steps_per_unit[i];
+ }
if(feedrate < 10)
feedrate = 10;
- /*
- //experimental feedrate calc
- if(abs(xdiff) > 0.1 && abs(ydiff) > 0.1)
- d = sqrt(xdiff * xdiff + ydiff * ydiff);
- else if(abs(xdiff) > 0.1)
- d = abs(xdiff);
- else if(abs(ydiff) > 0.1)
- d = abs(ydiff);
- else if(abs(zdiff) > 0.05)
- d = abs(zdiff);
- else if(abs(ediff) > 0.1)
- d = abs(ediff);
- else d = 1; //extremely slow move, should be okay for moves under 0.1mm
- time_for_move = (xdiff / (feedrate / 60000000) );
- //time = 60000000 * dist / feedrate
- //int feedz = (60000000 * zdiff) / time_for_move;
- //if(feedz > maxfeed)
- */
- #define X_TIME_FOR_MOVE ((float)x_steps_to_take / (x_steps_per_unit*feedrate/60000000))
- #define Y_TIME_FOR_MOVE ((float)y_steps_to_take / (y_steps_per_unit*feedrate/60000000))
- #define Z_TIME_FOR_MOVE ((float)z_steps_to_take / (z_steps_per_unit*z_feedrate/60000000))
- #define E_TIME_FOR_MOVE ((float)e_steps_to_take / (e_steps_per_unit*feedrate/60000000))
- time_for_move = max(X_TIME_FOR_MOVE, Y_TIME_FOR_MOVE);
- time_for_move = max(time_for_move, Z_TIME_FOR_MOVE);
- if(time_for_move <= 0) time_for_move = max(time_for_move, E_TIME_FOR_MOVE);
-
- if(x_steps_to_take) x_interval = time_for_move / x_steps_to_take * 100;
- if(y_steps_to_take) y_interval = time_for_move / y_steps_to_take * 100;
- if(z_steps_to_take) z_interval = time_for_move / z_steps_to_take * 100;
- if(e_steps_to_take && (x_steps_to_take + y_steps_to_take <= 0) ) e_interval = time_for_move / e_steps_to_take * 100;
-
- //#define DEBUGGING false
- #if 0
- if(0) {
- Serial.print("destination_x: "); Serial.println(destination_x);
- Serial.print("current_x: "); Serial.println(current_x);
- Serial.print("x_steps_to_take: "); Serial.println(x_steps_to_take);
- Serial.print("X_TIME_FOR_MVE: "); Serial.println(X_TIME_FOR_MOVE);
- Serial.print("x_interval: "); Serial.println(x_interval);
- Serial.println("");
- Serial.print("destination_y: "); Serial.println(destination_y);
- Serial.print("current_y: "); Serial.println(current_y);
- Serial.print("y_steps_to_take: "); Serial.println(y_steps_to_take);
- Serial.print("Y_TIME_FOR_MVE: "); Serial.println(Y_TIME_FOR_MOVE);
- Serial.print("y_interval: "); Serial.println(y_interval);
- Serial.println("");
- Serial.print("destination_z: "); Serial.println(destination_z);
- Serial.print("current_z: "); Serial.println(current_z);
- Serial.print("z_steps_to_take: "); Serial.println(z_steps_to_take);
- Serial.print("Z_TIME_FOR_MVE: "); Serial.println(Z_TIME_FOR_MOVE);
- Serial.print("z_interval: "); Serial.println(z_interval);
- Serial.println("");
- Serial.print("destination_e: "); Serial.println(destination_e);
- Serial.print("current_e: "); Serial.println(current_e);
- Serial.print("e_steps_to_take: "); Serial.println(e_steps_to_take);
- Serial.print("E_TIME_FOR_MVE: "); Serial.println(E_TIME_FOR_MOVE);
- Serial.print("e_interval: "); Serial.println(e_interval);
- Serial.println("");
+ //Feedrate calc based on XYZ travel distance
+ float xy_d;
+ if(abs(axis_diff[0]) > 0 || abs(axis_diff[1]) > 0 || abs(axis_diff[2])) {
+ xy_d = sqrt(axis_diff[0] * axis_diff[0] + axis_diff[1] * axis_diff[1]);
+ d = sqrt(xy_d * xy_d + axis_diff[2] * axis_diff[2]);
}
+ else if(abs(axis_diff[3]) > 0)
+ d = abs(axis_diff[3]);
+ #ifdef DEBUG_PREPARE_MOVE
+ else {
+ log_message("_PREPARE_MOVE - No steps to take!");
+ }
#endif
+ time_for_move = (d / (feedrate / 60000000.0) );
+ //Check max feedrate for each axis is not violated, update time_for_move if necessary
+ for(int i = 0; i < NUM_AXIS; i++) {
+ if(move_steps_to_take[i] && abs(axis_diff[i]) / (time_for_move / 60000000.0) > max_feedrate[i]) {
+ time_for_move = time_for_move / max_feedrate[i] * (abs(axis_diff[i]) / (time_for_move / 60000000.0));
+ }
+ }
+ //Calculate the full speed stepper interval for each axis
+ for(int i=0; i < NUM_AXIS; i++) {
+ if(move_steps_to_take[i]) axis_interval[i] = time_for_move / move_steps_to_take[i] * 100;
+ }
- linear_move(x_steps_to_take, y_steps_to_take, z_steps_to_take, e_steps_to_take); // make the move
+ #ifdef DEBUG_PREPARE_MOVE
+ log_float("_PREPARE_MOVE - Move distance on the XY plane", xy_d);
+ log_float("_PREPARE_MOVE - Move distance on the XYZ space", d);
+ log_float("_PREPARE_MOVE - Commanded feedrate", feedrate);
+ log_float("_PREPARE_MOVE - Constant full speed move time", time_for_move);
+ log_float_array("_PREPARE_MOVE - Destination", destination, NUM_AXIS);
+ log_float_array("_PREPARE_MOVE - Current position", current_position, NUM_AXIS);
+ log_ulong_array("_PREPARE_MOVE - Steps to take", move_steps_to_take, NUM_AXIS);
+ log_long_array("_PREPARE_MOVE - Axes full speed intervals", axis_interval, NUM_AXIS);
+ #endif
+
+ unsigned long move_steps[NUM_AXIS];
+ for(int i=0; i < NUM_AXIS; i++)
+ move_steps[i] = move_steps_to_take[i];
+ linear_move(move_steps); // make the move
}
-void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remaining, unsigned long z_steps_remaining, unsigned long e_steps_remaining) // make linear move with preset speeds and destinations, see G0 and G1
+void linear_move(unsigned long axis_steps_remaining[]) // make linear move with preset speeds and destinations, see G0 and G1
{
//Determine direction of movement
- if (destination_x > current_x) digitalWrite(X_DIR_PIN,!INVERT_X_DIR);
+ if (destination[0] > current_position[0]) digitalWrite(X_DIR_PIN,!INVERT_X_DIR);
else digitalWrite(X_DIR_PIN,INVERT_X_DIR);
- if (destination_y > current_y) digitalWrite(Y_DIR_PIN,!INVERT_Y_DIR);
+ if (destination[1] > current_position[1]) digitalWrite(Y_DIR_PIN,!INVERT_Y_DIR);
else digitalWrite(Y_DIR_PIN,INVERT_Y_DIR);
- if (destination_z > current_z) digitalWrite(Z_DIR_PIN,!INVERT_Z_DIR);
+ if (destination[2] > current_position[2]) digitalWrite(Z_DIR_PIN,!INVERT_Z_DIR);
else digitalWrite(Z_DIR_PIN,INVERT_Z_DIR);
- if (destination_e > current_e) digitalWrite(E_DIR_PIN,!INVERT_E_DIR);
+ if (destination[3] > current_position[3]) digitalWrite(E_DIR_PIN,!INVERT_E_DIR);
else digitalWrite(E_DIR_PIN,INVERT_E_DIR);
- if(X_MIN_PIN > -1) if(!direction_x) if(digitalRead(X_MIN_PIN) != ENDSTOPS_INVERTING) x_steps_remaining=0;
- if(Y_MIN_PIN > -1) if(!direction_y) if(digitalRead(Y_MIN_PIN) != ENDSTOPS_INVERTING) y_steps_remaining=0;
- if(Z_MIN_PIN > -1) if(!direction_z) if(digitalRead(Z_MIN_PIN) != ENDSTOPS_INVERTING) z_steps_remaining=0;
- if(X_MAX_PIN > -1) if(direction_x) if(digitalRead(X_MAX_PIN) != ENDSTOPS_INVERTING) x_steps_remaining=0;
- if(Y_MAX_PIN > -1) if(direction_y) if(digitalRead(Y_MAX_PIN) != ENDSTOPS_INVERTING) y_steps_remaining=0;
- if(Z_MAX_PIN > -1) if(direction_z) if(digitalRead(Z_MAX_PIN) != ENDSTOPS_INVERTING) z_steps_remaining=0;
+ if(X_MIN_PIN > -1) if(!move_direction[0]) if(digitalRead(X_MIN_PIN) != ENDSTOPS_INVERTING) axis_steps_remaining[0]=0;
+ if(Y_MIN_PIN > -1) if(!move_direction[1]) if(digitalRead(Y_MIN_PIN) != ENDSTOPS_INVERTING) axis_steps_remaining[1]=0;
+ if(Z_MIN_PIN > -1) if(!move_direction[2]) if(digitalRead(Z_MIN_PIN) != ENDSTOPS_INVERTING) axis_steps_remaining[2]=0;
+ if(X_MAX_PIN > -1) if(move_direction[0]) if(digitalRead(X_MAX_PIN) != ENDSTOPS_INVERTING) axis_steps_remaining[0]=0;
+ if(Y_MAX_PIN > -1) if(move_direction[1]) if(digitalRead(Y_MAX_PIN) != ENDSTOPS_INVERTING) axis_steps_remaining[1]=0;
+ if(Z_MAX_PIN > -1) if(move_direction[2]) if(digitalRead(Z_MAX_PIN) != ENDSTOPS_INVERTING) axis_steps_remaining[2]=0;
//Only enable axis that are moving. If the axis doesn't need to move then it can stay disabled depending on configuration.
- if(x_steps_remaining) enable_x();
- if(y_steps_remaining) enable_y();
- if(z_steps_remaining) { enable_z(); do_z_step(); z_steps_remaining--; }
- if(e_steps_remaining) { enable_e(); do_e_step(); e_steps_remaining--; }
+ // TODO: maybe it's better to refactor into a generic enable(int axis) function, that will probably take more ram,
+ // but will reduce code size
+ if(axis_steps_remaining[0]) enable_x();
+ if(axis_steps_remaining[1]) enable_y();
+ if(axis_steps_remaining[2]) enable_z();
+ if(axis_steps_remaining[3]) enable_e();
//Define variables that are needed for the Bresenham algorithm. Please note that Z is not currently included in the Bresenham algorithm.
- unsigned int delta_x = x_steps_remaining;
- unsigned long x_interval_nanos;
- unsigned int delta_y = y_steps_remaining;
- unsigned long y_interval_nanos;
- unsigned int delta_z = z_steps_remaining;
- unsigned long z_interval_nanos;
- boolean steep_y = delta_y > delta_x;// && delta_y > delta_e && delta_y > delta_z;
- boolean steep_x = delta_x >= delta_y;// && delta_x > delta_e && delta_x > delta_z;
- //boolean steep_z = delta_z > delta_x && delta_z > delta_y && delta_z > delta_e;
- int error_x;
- int error_y;
- int error_z;
- #ifdef RAMP_ACCELERATION
- long max_speed_steps_per_second;
- long min_speed_steps_per_second;
+ unsigned long delta[] = {axis_steps_remaining[0], axis_steps_remaining[1], axis_steps_remaining[2], axis_steps_remaining[3]}; //TODO: implement a "for" to support N axes
+ long axis_error[NUM_AXIS];
+ unsigned int primary_axis;
+ if(delta[1] > delta[0] && delta[1] > delta[2] && delta[1] > delta[3]) primary_axis = 1;
+ else if (delta[0] >= delta[1] && delta[0] > delta[2] && delta[0] > delta[3]) primary_axis = 0;
+ else if (delta[2] >= delta[0] && delta[2] >= delta[1] && delta[2] > delta[3]) primary_axis = 2;
+ else primary_axis = 3;
+ unsigned long steps_remaining = delta[primary_axis];
+ unsigned long steps_to_take = steps_remaining;
+ for(int i=0; i < NUM_AXIS; i++) if(i != primary_axis) axis_error[i] = delta[primary_axis] / 2;
+ interval = axis_interval[primary_axis];
+ bool is_print_move = delta[3] > 0;
+ #ifdef DEBUG_BRESENHAM
+ log_int("_BRESENHAM - Primary axis", primary_axis);
+ log_int("_BRESENHAM - Primary axis full speed interval", interval);
+ log_ulong_array("_BRESENHAM - Deltas", delta, NUM_AXIS);
+ log_long_array("_BRESENHAM - Errors", axis_error, NUM_AXIS);
#endif
- #ifdef EXP_ACCELERATION
- unsigned long virtual_full_velocity_steps;
- unsigned long full_velocity_steps;
+
+ //If acceleration is enabled, do some Bresenham calculations depending on which axis will lead it.
+ #ifdef RAMP_ACCELERATION
+ long max_speed_steps_per_second;
+ long min_speed_steps_per_second;
+ max_interval = axis_max_interval[primary_axis];
+ #ifdef DEBUG_RAMP_ACCELERATION
+ log_ulong_array("_RAMP_ACCELERATION - Teoric step intervals at move start", axis_max_interval, NUM_AXIS);
+ #endif
+ unsigned long new_axis_max_intervals[NUM_AXIS];
+ max_speed_steps_per_second = 100000000 / interval;
+ min_speed_steps_per_second = 100000000 / max_interval; //TODO: can this be deleted?
+ //Calculate start speeds based on moving axes max start speed constraints.
+ int slowest_start_axis = primary_axis;
+ unsigned long slowest_start_axis_max_interval = max_interval;
+ for(int i = 0; i < NUM_AXIS; i++)
+ if (axis_steps_remaining[i] >0 && i != primary_axis && axis_max_interval[i] * axis_steps_remaining[i]
+ / axis_steps_remaining[slowest_start_axis] > slowest_start_axis_max_interval) {
+ slowest_start_axis = i;
+ slowest_start_axis_max_interval = axis_max_interval[i];
+ }
+ for(int i = 0; i < NUM_AXIS; i++)
+ if(axis_steps_remaining[i] >0) {
+ new_axis_max_intervals[i] = slowest_start_axis_max_interval * axis_steps_remaining[slowest_start_axis] / axis_steps_remaining[i];
+ if(i == primary_axis) {
+ max_interval = new_axis_max_intervals[i];
+ min_speed_steps_per_second = 100000000 / max_interval;
+ }
+ }
+ //Calculate slowest axis plateau time
+ float slowest_axis_plateau_time = 0;
+ for(int i=0; i < NUM_AXIS ; i++) {
+ if(axis_steps_remaining[i] > 0) {
+ if(is_print_move && axis_steps_remaining[i] > 0) slowest_axis_plateau_time = max(slowest_axis_plateau_time,
+ (100000000.0 / axis_interval[i] - 100000000.0 / new_axis_max_intervals[i]) / (float) axis_steps_per_sqr_second[i]);
+ else if(axis_steps_remaining[i] > 0) slowest_axis_plateau_time = max(slowest_axis_plateau_time,
+ (100000000.0 / axis_interval[i] - 100000000.0 / new_axis_max_intervals[i]) / (float) axis_travel_steps_per_sqr_second[i]);
+ }
+ }
+ //Now we can calculate the new primary axis acceleration, so that the slowest axis max acceleration is not violated
+ steps_per_sqr_second = (100000000.0 / axis_interval[primary_axis] - 100000000.0 / new_axis_max_intervals[primary_axis]) / slowest_axis_plateau_time;
+ plateau_steps = (long) ((steps_per_sqr_second / 2.0 * slowest_axis_plateau_time + min_speed_steps_per_second) * slowest_axis_plateau_time);
+ #ifdef DEBUG_RAMP_ACCELERATION
+ log_int("_RAMP_ACCELERATION - Start speed limiting axis", slowest_start_axis);
+ log_ulong("_RAMP_ACCELERATION - Limiting axis start interval", slowest_start_axis_max_interval);
+ log_ulong_array("_RAMP_ACCELERATION - Actual step intervals at move start", new_axis_max_intervals, NUM_AXIS);
+ #endif
#endif
- unsigned long steps_remaining;
- unsigned long steps_to_take;
- //Do some Bresenham calculations depending on which axis will lead it.
- if(steep_y) {
- error_x = delta_y / 2;
- interval = y_interval;
- #ifdef RAMP_ACCELERATION
- max_interval = max_y_interval;
- if(e_steps_to_take > 0) steps_per_sqr_second = y_steps_per_sqr_second;
- else steps_per_sqr_second = y_travel_steps_per_sqr_second;
- max_speed_steps_per_second = 100000000 / interval;
- min_speed_steps_per_second = 100000000 / max_interval;
- float plateau_time = (max_speed_steps_per_second - min_speed_steps_per_second) / (float) steps_per_sqr_second;
- plateau_steps = (long) ((steps_per_sqr_second / 2.0 * plateau_time + min_speed_steps_per_second) * plateau_time);
- #endif
- #ifdef EXP_ACCELERATION
- if(e_steps_to_take > 0) virtual_full_velocity_steps = long_full_velocity_units * y_steps_per_unit /100;
- else virtual_full_velocity_steps = long_travel_move_full_velocity_units * y_steps_per_unit /100;
- full_velocity_steps = min(virtual_full_velocity_steps, (delta_y - y_min_constant_speed_steps) / 2);
- max_interval = max_y_interval;
- min_constant_speed_steps = y_min_constant_speed_steps;
- #endif
- steps_remaining = delta_y;
- steps_to_take = delta_y;
- } else if (steep_x) {
- error_y = delta_x / 2;
- interval = x_interval;
- #ifdef RAMP_ACCELERATION
- max_interval = max_x_interval;
- if(e_steps_to_take > 0) steps_per_sqr_second = x_steps_per_sqr_second;
- else steps_per_sqr_second = x_travel_steps_per_sqr_second;
- max_speed_steps_per_second = 100000000 / interval;
- min_speed_steps_per_second = 100000000 / max_interval;
- float plateau_time = (max_speed_steps_per_second - min_speed_steps_per_second) / (float) steps_per_sqr_second;
- plateau_steps = (long) ((steps_per_sqr_second / 2.0 * plateau_time + min_speed_steps_per_second) * plateau_time);
- #endif
- #ifdef EXP_ACCELERATION
- if(e_steps_to_take > 0) virtual_full_velocity_steps = long_full_velocity_units * x_steps_per_unit /100;
- else virtual_full_velocity_steps = long_travel_move_full_velocity_units * x_steps_per_unit /100;
- full_velocity_steps = min(virtual_full_velocity_steps, (delta_x - x_min_constant_speed_steps) / 2);
- max_interval = max_x_interval;
- min_constant_speed_steps = x_min_constant_speed_steps;
- #endif
- steps_remaining = delta_x;
- steps_to_take = delta_x;
- }
unsigned long steps_done = 0;
#ifdef RAMP_ACCELERATION
plateau_steps *= 1.01; // This is to compensate we use discrete intervals
@@ -1073,32 +1042,48 @@ void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remainin
if(interval > max_interval) acceleration_enabled = false;
boolean decelerating = false;
#endif
- #ifdef EXP_ACCELERATION
- acceleration_enabled = true;
- if(full_velocity_steps == 0) full_velocity_steps++;
- if(interval > max_interval) acceleration_enabled = false;
- unsigned long full_interval = interval;
- if(min_constant_speed_steps >= steps_to_take) {
- acceleration_enabled = false;
- full_interval = max(max_interval, interval); // choose the min speed between feedrate and acceleration start speed
- }
- if(full_velocity_steps < virtual_full_velocity_steps && acceleration_enabled) full_interval = max(interval,
- max_interval - ((max_interval - full_interval) * full_velocity_steps / virtual_full_velocity_steps)); // choose the min speed between feedrate and speed at full steps
- unsigned int steps_acceleration_check = 1;
- accelerating = acceleration_enabled;
- #endif
unsigned long start_move_micros = micros();
- previous_micros_x = start_move_micros*100;
- previous_micros_y = previous_micros_x;
- previous_micros_z = previous_micros_x;
- previous_micros_e = previous_micros_x;
+ for(int i = 0; i < NUM_AXIS; i++) {
+ axis_previous_micros[i] = start_move_micros * 100;
+ }
+
+ #ifdef DISABLE_CHECK_DURING_TRAVEL
+ //If the move time is more than allowed in DISABLE_CHECK_DURING_TRAVEL, let's
+ // consider this a print move and perform heat management during it
+ if(time_for_move / 1000 > DISABLE_CHECK_DURING_TRAVEL) is_print_move = true;
+ //else, if the move is a retract, consider it as a travel move for the sake of this feature
+ else if(delta[3]>0 && delta[0] + delta[1] + delta[2] == 0) is_print_move = false;
+ #ifdef DEBUG_DISABLE_CHECK_DURING_TRAVEL
+ log_bool("_DISABLE_CHECK_DURING_TRAVEL - is_print_move", is_print_move);
+ #endif
+ #endif
+
+ #ifdef DEBUG_MOVE_TIME
+ unsigned long startmove = micros();
+ #endif
//move until no more steps remain
- while(x_steps_remaining + y_steps_remaining + z_steps_remaining + e_steps_remaining > 0) {
- //If more that HEATER_CHECK_INTERVAL ms have passed since previous heating check, adjust temp
- manage_heater();
- manage_inactivity(2);
+ while(axis_steps_remaining[0] + axis_steps_remaining[1] + axis_steps_remaining[2] + axis_steps_remaining[3] > 0) {
+ #ifdef DISABLE_CHECK_DURING_ACC
+ if(!accelerating && !decelerating) {
+ //If more that HEATER_CHECK_INTERVAL ms have passed since previous heating check, adjust temp
+ #ifdef DISABLE_CHECK_DURING_TRAVEL
+ if(is_print_move)
+ #endif
+ manage_heater();
+ }
+ #else
+ #ifdef DISABLE_CHECK_DURING_MOVE
+ {} //Do nothing
+ #else
+ //If more that HEATER_CHECK_INTERVAL ms have passed since previous heating check, adjust temp
+ #ifdef DISABLE_CHECK_DURING_TRAVEL
+ if(is_print_move)
+ #endif
+ manage_heater();
+ #endif
+ #endif
#ifdef RAMP_ACCELERATION
//If acceleration is enabled on this move and we are in the acceleration segment, calculate the current interval
if (acceleration_enabled && steps_done == 0) {
@@ -1133,128 +1118,40 @@ void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remainin
accelerating = false;
}
#endif
- #ifdef EXP_ACCELERATION
- //If acceleration is enabled on this move and we are in the acceleration segment, calculate the current interval
- if (acceleration_enabled && steps_done < full_velocity_steps && steps_done / full_velocity_steps < 1 && (steps_done % steps_acceleration_check == 0)) {
- if(steps_done == 0) {
- interval = max_interval;
- } else {
- interval = max_interval - ((max_interval - full_interval) * steps_done / virtual_full_velocity_steps);
- }
- } else if (acceleration_enabled && steps_remaining < full_velocity_steps) {
- //Else, if acceleration is enabled on this move and we are in the deceleration segment, calculate the current interval
- if(steps_remaining == 0) {
- interval = max_interval;
- } else {
- interval = max_interval - ((max_interval - full_interval) * steps_remaining / virtual_full_velocity_steps);
- }
- accelerating = true;
- } else if (steps_done - full_velocity_steps >= 1 || !acceleration_enabled){
- //Else, we are just use the full speed interval as current interval
- interval = full_interval;
- accelerating = false;
- }
- #endif
//If there are x or y steps remaining, perform Bresenham algorithm
- if(x_steps_remaining || y_steps_remaining) {
- if(X_MIN_PIN > -1) if(!direction_x) if(digitalRead(X_MIN_PIN) != ENDSTOPS_INVERTING) break;
- if(Y_MIN_PIN > -1) if(!direction_y) if(digitalRead(Y_MIN_PIN) != ENDSTOPS_INVERTING) break;
- if(X_MAX_PIN > -1) if(direction_x) if(digitalRead(X_MAX_PIN) != ENDSTOPS_INVERTING) break;
- if(Y_MAX_PIN > -1) if(direction_y) if(digitalRead(Y_MAX_PIN) != ENDSTOPS_INVERTING) break;
- if(steep_y) {
- timediff = micros() * 100 - previous_micros_y;
- while(timediff >= interval && y_steps_remaining > 0) {
- steps_done++;
- steps_remaining--;
- y_steps_remaining--; timediff -= interval;
- error_x = error_x - delta_x;
- do_y_step();
- if(error_x < 0) {
- do_x_step(); x_steps_remaining--;
- error_x = error_x + delta_y;
- }
- #ifdef RAMP_ACCELERATION
- if (steps_remaining == plateau_steps || (steps_done >= steps_to_take / 2 && accelerating && !decelerating)) break;
- #endif
- #ifdef STEP_DELAY_RATIO
- if(timediff >= interval) delayMicroseconds(long_step_delay_ratio * interval / 10000);
- #endif
- #ifdef STEP_DELAY_MICROS
- if(timediff >= interval) delayMicroseconds(STEP_DELAY_MICROS);
- #endif
- }
- } else if (steep_x) {
- timediff=micros() * 100 - previous_micros_x;
- while(timediff >= interval && x_steps_remaining>0) {
- steps_done++;
- steps_remaining--;
- x_steps_remaining--; timediff -= interval;
- error_y = error_y - delta_y;
- do_x_step();
- if(error_y < 0) {
- do_y_step(); y_steps_remaining--;
- error_y = error_y + delta_x;
+ if(axis_steps_remaining[primary_axis]) {
+ if(X_MIN_PIN > -1) if(!move_direction[0]) if(digitalRead(X_MIN_PIN) != ENDSTOPS_INVERTING) break;
+ if(Y_MIN_PIN > -1) if(!move_direction[1]) if(digitalRead(Y_MIN_PIN) != ENDSTOPS_INVERTING) break;
+ if(X_MAX_PIN > -1) if(move_direction[0]) if(digitalRead(X_MAX_PIN) != ENDSTOPS_INVERTING) break;
+ if(Y_MAX_PIN > -1) if(move_direction[1]) if(digitalRead(Y_MAX_PIN) != ENDSTOPS_INVERTING) break;
+ if(Z_MIN_PIN > -1) if(!move_direction[2]) if(digitalRead(Z_MIN_PIN) != ENDSTOPS_INVERTING) break;
+ if(Z_MAX_PIN > -1) if(move_direction[2]) if(digitalRead(Z_MAX_PIN) != ENDSTOPS_INVERTING) break;
+ timediff = micros() * 100 - axis_previous_micros[primary_axis];
+ while(timediff >= interval && axis_steps_remaining[primary_axis] > 0) {
+ steps_done++;
+ steps_remaining--;
+ axis_steps_remaining[primary_axis]--; timediff -= interval;
+ do_step_update_micros(primary_axis);
+ for(int i=0; i < NUM_AXIS; i++) if(i != primary_axis && axis_steps_remaining[i] > 0) {
+ axis_error[i] = axis_error[i] - delta[i];
+ if(axis_error[i] < 0) {
+ do_step(i); axis_steps_remaining[i]--;
+ axis_error[i] = axis_error[i] + delta[primary_axis];
}
- #ifdef RAMP_ACCELERATION
- if (steps_remaining == plateau_steps || (steps_done >= steps_to_take / 2 && accelerating && !decelerating)) break;
- #endif
- #ifdef STEP_DELAY_RATIO
- if(timediff >= interval) delayMicroseconds(long_step_delay_ratio * interval / 10000);
- #endif
- #ifdef STEP_DELAY_MICROS
- if(timediff >= interval) delayMicroseconds(STEP_DELAY_MICROS);
- #endif
}
- }
- }
- #ifdef RAMP_ACCELERATION
- if((x_steps_remaining>0 || y_steps_remaining>0) &&
- steps_to_take > 0 &&
- (steps_remaining == plateau_steps || (steps_done >= steps_to_take / 2 && accelerating && !decelerating))) continue;
- #endif
-
- //If there are z steps remaining, check if z steps must be taken
- if(z_steps_remaining) {
- if(Z_MIN_PIN > -1) if(!direction_z) if(digitalRead(Z_MIN_PIN) != ENDSTOPS_INVERTING) break;
- if(Z_MAX_PIN > -1) if(direction_z) if(digitalRead(Z_MAX_PIN) != ENDSTOPS_INVERTING) break;
- timediff = micros() * 100-previous_micros_z;
- while(timediff >= z_interval && z_steps_remaining) {
- do_z_step();
- z_steps_remaining--;
- timediff -= z_interval;
- #ifdef STEP_DELAY_RATIO
- if(timediff >= z_interval) delayMicroseconds(long_step_delay_ratio * z_interval / 10000);
- #endif
- #ifdef STEP_DELAY_MICROS
- if(timediff >= z_interval) delayMicroseconds(STEP_DELAY_MICROS);
- #endif
- }
- }
-
- //If there are e steps remaining, check if e steps must be taken
- if(e_steps_remaining){
- if (x_steps_to_take + y_steps_to_take <= 0) timediff = micros()*100 - previous_micros_e;
- unsigned int final_e_steps_remaining = 0;
- if (steep_x && x_steps_to_take > 0) final_e_steps_remaining = e_steps_to_take * x_steps_remaining / x_steps_to_take;
- else if (steep_y && y_steps_to_take > 0) final_e_steps_remaining = e_steps_to_take * y_steps_remaining / y_steps_to_take;
- //If this move has X or Y steps, let E follow the Bresenham pace
- if (final_e_steps_remaining > 0) while(e_steps_remaining > final_e_steps_remaining) { do_e_step(); e_steps_remaining--;}
- else if (x_steps_to_take + y_steps_to_take > 0) while(e_steps_remaining) { do_e_step(); e_steps_remaining--;}
- //Else, normally check if e steps must be taken
- else while (timediff >= e_interval && e_steps_remaining) {
- do_e_step();
- e_steps_remaining--;
- timediff -= e_interval;
#ifdef STEP_DELAY_RATIO
- if(timediff >= e_interval) delayMicroseconds(long_step_delay_ratio * e_interval / 10000);
+ if(timediff >= interval) delayMicroseconds(long_step_delay_ratio * interval / 10000);
#endif
#ifdef STEP_DELAY_MICROS
- if(timediff >= e_interval) delayMicroseconds(STEP_DELAY_MICROS);
+ if(timediff >= interval) delayMicroseconds(STEP_DELAY_MICROS);
#endif
}
}
}
+ #ifdef DEBUG_MOVE_TIME
+ log_ulong("_MOVE_TIME - This move took", micros()-startmove);
+ #endif
if(DISABLE_X) disable_x();
if(DISABLE_Y) disable_y();
@@ -1262,47 +1159,21 @@ void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remainin
if(DISABLE_E) disable_e();
// Update current position partly based on direction, we probably can combine this with the direction code above...
- if (destination_x > current_x) current_x = current_x + x_steps_to_take / x_steps_per_unit;
- else current_x = current_x - x_steps_to_take / x_steps_per_unit;
- if (destination_y > current_y) current_y = current_y + y_steps_to_take / y_steps_per_unit;
- else current_y = current_y - y_steps_to_take / y_steps_per_unit;
- if (destination_z > current_z) current_z = current_z + z_steps_to_take / z_steps_per_unit;
- else current_z = current_z - z_steps_to_take / z_steps_per_unit;
- if (destination_e > current_e) current_e = current_e + e_steps_to_take / e_steps_per_unit;
- else current_e = current_e - e_steps_to_take / e_steps_per_unit;
-}
-
-
-inline void do_x_step()
-{
- digitalWrite(X_STEP_PIN, HIGH);
- previous_micros_x += interval;
- //delayMicroseconds(3);
- digitalWrite(X_STEP_PIN, LOW);
-}
-
-inline void do_y_step()
-{
- digitalWrite(Y_STEP_PIN, HIGH);
- previous_micros_y += interval;
- //delayMicroseconds(3);
- digitalWrite(Y_STEP_PIN, LOW);
+ for(int i=0; i < NUM_AXIS; i++) {
+ if (destination[i] > current_position[i]) current_position[i] = current_position[i] + move_steps_to_take[i] / axis_steps_per_unit[i];
+ else current_position[i] = current_position[i] - move_steps_to_take[i] / axis_steps_per_unit[i];
+ }
}
-inline void do_z_step()
-{
- digitalWrite(Z_STEP_PIN, HIGH);
- previous_micros_z += z_interval;
- //delayMicroseconds(3);
- digitalWrite(Z_STEP_PIN, LOW);
+inline void do_step_update_micros(int axis) {
+ digitalWrite(STEP_PIN[axis], HIGH);
+ axis_previous_micros[axis] += interval;
+ digitalWrite(STEP_PIN[axis], LOW);
}
-inline void do_e_step()
-{
- digitalWrite(E_STEP_PIN, HIGH);
- previous_micros_e += e_interval;
- //delayMicroseconds(3);
- digitalWrite(E_STEP_PIN, LOW);
+inline void do_step(int axis) {
+ digitalWrite(STEP_PIN[axis], HIGH);
+ digitalWrite(STEP_PIN[axis], LOW);
}
inline void disable_x() { if(X_ENABLE_PIN > -1) digitalWrite(X_ENABLE_PIN,!X_ENABLE_ON); }
@@ -1378,6 +1249,10 @@ inline void manage_heater()
previous_millis_heater = millis();
#ifdef HEATER_USES_THERMISTOR
current_raw = analogRead(TEMP_0_PIN);
+ #ifdef DEBUG_HEAT_MGMT
+ log_int("_HEAT_MGMT - analogRead(TEMP_0_PIN)", current_raw);
+ log_int("_HEAT_MGMT - NUMTEMPS", NUMTEMPS);
+ #endif
// When using thermistor, when the heater is colder than targer temp, we get a higher analog reading than target,
// this switches it up so that the reading appears lower than target for the control logic.
current_raw = 1023 - current_raw;
@@ -1440,7 +1315,11 @@ inline void manage_heater()
#ifdef BED_USES_THERMISTOR
- current_bed_raw = analogRead(TEMP_1_PIN);
+ current_bed_raw = analogRead(TEMP_1_PIN);
+ #ifdef DEBUG_HEAT_MGMT
+ log_int("_HEAT_MGMT - analogRead(TEMP_1_PIN)", current_bed_raw);
+ log_int("_HEAT_MGMT - BNUMTEMPS", BNUMTEMPS);
+ #endif
// If using thermistor, when the heater is colder than targer temp, we get a higher analog reading than target,
// this switches it up so that the reading appears lower than target for the control logic.
@@ -1616,3 +1495,78 @@ inline void manage_inactivity(byte debug) {
if( (millis()-previous_millis_cmd) > max_inactive_time ) if(max_inactive_time) kill();
if( (millis()-previous_millis_cmd) > stepper_inactive_time ) if(stepper_inactive_time) { disable_x(); disable_y(); disable_z(); disable_e(); }
}
+
+#ifdef DEBUG
+void log_message(char* message) {
+ Serial.print("DEBUG"); Serial.println(message);
+}
+
+void log_bool(char* message, bool value) {
+ Serial.print("DEBUG"); Serial.print(message); Serial.print(": "); Serial.println(value);
+}
+
+void log_int(char* message, int value) {
+ Serial.print("DEBUG"); Serial.print(message); Serial.print(": "); Serial.println(value);
+}
+
+void log_long(char* message, long value) {
+ Serial.print("DEBUG"); Serial.print(message); Serial.print(": "); Serial.println(value);
+}
+
+void log_float(char* message, float value) {
+ Serial.print("DEBUG"); Serial.print(message); Serial.print(": "); Serial.println(value);
+}
+
+void log_uint(char* message, unsigned int value) {
+ Serial.print("DEBUG"); Serial.print(message); Serial.print(": "); Serial.println(value);
+}
+
+void log_ulong(char* message, unsigned long value) {
+ Serial.print("DEBUG"); Serial.print(message); Serial.print(": "); Serial.println(value);
+}
+
+void log_int_array(char* message, int value[], int array_lenght) {
+ Serial.print("DEBUG"); Serial.print(message); Serial.print(": {");
+ for(int i=0; i < array_lenght; i++){
+ Serial.print(value[i]);
+ if(i != array_lenght-1) Serial.print(", ");
+ }
+ Serial.println("}");
+}
+
+void log_long_array(char* message, long value[], int array_lenght) {
+ Serial.print("DEBUG"); Serial.print(message); Serial.print(": {");
+ for(int i=0; i < array_lenght; i++){
+ Serial.print(value[i]);
+ if(i != array_lenght-1) Serial.print(", ");
+ }
+ Serial.println("}");
+}
+
+void log_float_array(char* message, float value[], int array_lenght) {
+ Serial.print("DEBUG"); Serial.print(message); Serial.print(": {");
+ for(int i=0; i < array_lenght; i++){
+ Serial.print(value[i]);
+ if(i != array_lenght-1) Serial.print(", ");
+ }
+ Serial.println("}");
+}
+
+void log_uint_array(char* message, unsigned int value[], int array_lenght) {
+ Serial.print("DEBUG"); Serial.print(message); Serial.print(": {");
+ for(int i=0; i < array_lenght; i++){
+ Serial.print(value[i]);
+ if(i != array_lenght-1) Serial.print(", ");
+ }
+ Serial.println("}");
+}
+
+void log_ulong_array(char* message, unsigned long value[], int array_lenght) {
+ Serial.print("DEBUG"); Serial.print(message); Serial.print(": {");
+ for(int i=0; i < array_lenght; i++){
+ Serial.print(value[i]);
+ if(i != array_lenght-1) Serial.print(", ");
+ }
+ Serial.println("}");
+}
+#endif
diff --git a/Tonokip_Firmware/createTemperatureLookup.py b/Sprinter/createTemperatureLookup.py
index e60a490..e60a490 100644
--- a/Tonokip_Firmware/createTemperatureLookup.py
+++ b/Sprinter/createTemperatureLookup.py
diff --git a/Tonokip_Firmware/pins.h b/Sprinter/pins.h
index eee78e8..1bd6702 100644
--- a/Tonokip_Firmware/pins.h
+++ b/Sprinter/pins.h
@@ -23,6 +23,8 @@
* +----+
****************************************************************************************/
#if MOTHERBOARD == 0
+#define KNOWN_BOARD 1
+
#ifndef __AVR_ATmega168__
#error Oops! Make sure you have 'Arduino Diecimila' selected from the boards menu.
#endif
@@ -60,7 +62,7 @@
#define TEMP_0_PIN 0 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
-
+#endif
@@ -93,7 +95,9 @@
* +--------+
*
****************************************************************************************/
-#elif MOTHERBOARD == 1
+#if MOTHERBOARD == 1
+#define KNOWN_BOARD 1
+
#ifndef __AVR_ATmega644P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif
@@ -134,14 +138,16 @@
-
+#endif
/****************************************************************************************
* RepRap Motherboard ****---NOOOOOO RS485/EXTRUDER CONTROLLER!!!!!!!!!!!!!!!!!---*******
*
****************************************************************************************/
-#elif MOTHERBOARD == 2
+#if MOTHERBOARD == 2
+#define KNOWN_BOARD 1
+
#ifndef __AVR_ATmega644P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif
@@ -192,13 +198,19 @@
-
+#endif
/****************************************************************************************
* Arduino Mega pin assignment
*
****************************************************************************************/
-#elif MOTHERBOARD == 3
+#if MOTHERBOARD == 33
+#define MOTHERBOARD 3
+#define RAMPS_V_1_3
+#endif
+#if MOTHERBOARD == 3
+#define KNOWN_BOARD 1
+
//////////////////FIX THIS//////////////
#ifndef __AVR_ATmega1280__
#ifndef __AVR_ATmega2560__
@@ -210,7 +222,6 @@
// #define RAMPS_V_1_3
// #define RAMPS_V_1_0
-
#ifdef RAMPS_V_1_3
#define X_STEP_PIN 54
@@ -307,12 +318,14 @@
#endif
-
+#endif
/****************************************************************************************
* Duemilanove w/ ATMega328P pin assignment
*
****************************************************************************************/
-#elif MOTHERBOARD == 4
+#if MOTHERBOARD == 4
+#define KNOWN_BOARD 1
+
#ifndef __AVR_ATmega328P__
#error Oops! Make sure you have 'Arduino Duemilanove w/ ATMega328' selected from the 'Tools -> Boards' menu.
#endif
@@ -350,13 +363,14 @@
#define TEMP_0_PIN 0 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
-
+#endif
/****************************************************************************************
* Gen6 pin assignment
*
****************************************************************************************/
-#elif MOTHERBOARD == 5
+#if MOTHERBOARD == 5
+#define KNOWN_BOARD 1
#ifndef __AVR_ATmega644P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
@@ -393,7 +407,7 @@
#define SDPOWER -1
- #define SDSS -1
+ #define SDSS 17
#define LED_PIN -1 //changed @ rkoeppl 20110410
#define TEMP_1_PIN -1 //changed @ rkoeppl 20110410
#define FAN_PIN -1 //changed @ rkoeppl 20110410
@@ -406,60 +420,63 @@
#define TX_ENABLE_PIN 12
#define RX_ENABLE_PIN 13
-
+#endif
/****************************************************************************************
* Sanguinololu pin assignment
*
****************************************************************************************/
-#elif MOTHERBOARD == 6
+#if MOTHERBOARD == 62
+#define MOTHERBOARD 6
+#define SANGUINOLOLU_V_1_2
+#endif
+#if MOTHERBOARD == 6
+#define KNOWN_BOARD 1
#ifndef __AVR_ATmega644P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif
-// uncomment the following line for Sanguinololu v1.2, comment for 1.1 or earlier.
-// #define SANGUINOLOLU_V_1_2
-
-
#define X_STEP_PIN 15
#define X_DIR_PIN 21
-#define X_ENABLE_PIN -1
#define X_MIN_PIN 18
-#define X_MAX_PIN -2 //2
+#define X_MAX_PIN -2
#define Y_STEP_PIN 22
#define Y_DIR_PIN 23
-#define Y_ENABLE_PIN -1
#define Y_MIN_PIN 19
-#define Y_MAX_PIN -1 //17
+#define Y_MAX_PIN -1
#define Z_STEP_PIN 3
#define Z_DIR_PIN 2
-// zenable defined by platform below
#define Z_MIN_PIN 20
-#define Z_MAX_PIN -1 //19
+#define Z_MAX_PIN -1
#define E_STEP_PIN 1
#define E_DIR_PIN 0
-#define E_ENABLE_PIN -1
#define LED_PIN -1
-#define FAN_PIN -1 // THIS LINE FOR V1.0
+#define FAN_PIN -1
#define PS_ON_PIN -1
#define KILL_PIN -1
-#define HEATER_0_PIN 13 // THIS LINE FOR V1.0+ (extruder)
+#define HEATER_0_PIN 13 // (extruder)
#ifdef SANGUINOLOLU_V_1_2
#define HEATER_1_PIN 12 // (bed)
+#define X_ENABLE_PIN 14
+#define Y_ENABLE_PIN 14
#define Z_ENABLE_PIN 26
+#define E_ENABLE_PIN 14
#else
#define HEATER_1_PIN 14 // (bed)
+#define X_ENABLE_PIN -1
+#define Y_ENABLE_PIN -1
#define Z_ENABLE_PIN -1
+#define E_ENABLE_PIN -1
#endif
@@ -468,9 +485,9 @@
#define SDPOWER -1
#define SDSS 31
-#else
-
+#ifndef KNOWN_BOARD
#error Unknown MOTHERBOARD value in configuration.h
+#endif
#endif
diff --git a/Sprinter/thermistortables.h b/Sprinter/thermistortables.h
new file mode 100644
index 0000000..6c583af
--- /dev/null
+++ b/Sprinter/thermistortables.h
@@ -0,0 +1,159 @@
+#ifndef THERMISTORTABLES_H_
+#define THERMISTORTABLES_H_
+
+#if (THERMISTORHEATER == 1) || (THERMISTORBED == 1) //100k bed thermistor
+
+
+#define NUMTEMPS_1 61
+const short temptable_1[NUMTEMPS_1][2] = {
+{ 23 , 300 },
+{ 25 , 295 },
+{ 27 , 290 },
+{ 28 , 285 },
+{ 31 , 280 },
+{ 33 , 275 },
+{ 35 , 270 },
+{ 38 , 265 },
+{ 41 , 260 },
+{ 44 , 255 },
+{ 48 , 250 },
+{ 52 , 245 },
+{ 56 , 240 },
+{ 61 , 235 },
+{ 66 , 230 },
+{ 71 , 225 },
+{ 78 , 220 },
+{ 84 , 215 },
+{ 92 , 210 },
+{ 100 , 205 },
+{ 109 , 200 },
+{ 120 , 195 },
+{ 131 , 190 },
+{ 143 , 185 },
+{ 156 , 180 },
+{ 171 , 175 },
+{ 187 , 170 },
+{ 205 , 165 },
+{ 224 , 160 },
+{ 245 , 155 },
+{ 268 , 150 },
+{ 293 , 145 },
+{ 320 , 140 },
+{ 348 , 135 },
+{ 379 , 130 },
+{ 411 , 125 },
+{ 445 , 120 },
+{ 480 , 115 },
+{ 516 , 110 },
+{ 553 , 105 },
+{ 591 , 100 },
+{ 628 , 95 },
+{ 665 , 90 },
+{ 702 , 85 },
+{ 737 , 80 },
+{ 770 , 75 },
+{ 801 , 70 },
+{ 830 , 65 },
+{ 857 , 60 },
+{ 881 , 55 },
+{ 903 , 50 },
+{ 922 , 45 },
+{ 939 , 40 },
+{ 954 , 35 },
+{ 966 , 30 },
+{ 977 , 25 },
+{ 985 , 20 },
+{ 993 , 15 },
+{ 999 , 10 },
+{ 1004 , 5 },
+{ 1008 , 0 } //safety
+};
+#endif
+#if (THERMISTORHEATER == 2) || (THERMISTORBED == 2) //200k bed thermistor
+#define NUMTEMPS_2 21
+const short temptable_2[NUMTEMPS_2][2] = {
+ {1, 848},
+ {54, 275},
+ {107, 228},
+ {160, 202},
+ {213, 185},
+ {266, 171},
+ {319, 160},
+ {372, 150},
+ {425, 141},
+ {478, 133},
+ {531, 125},
+ {584, 118},
+ {637, 110},
+ {690, 103},
+ {743, 95},
+ {796, 86},
+ {849, 77},
+ {902, 65},
+ {955, 49},
+ {1008, 17},
+ {1020, 0} //safety
+};
+
+#endif
+#if (THERMISTORHEATER == 3) || (THERMISTORBED == 3) //mendel-parts
+#define NUMTEMPS_3 28
+const short temptable_3[NUMTEMPS_3][2] = {
+ {1,864},
+ {21,300},
+ {25,290},
+ {29,280},
+ {33,270},
+ {39,260},
+ {46,250},
+ {54,240},
+ {64,230},
+ {75,220},
+ {90,210},
+ {107,200},
+ {128,190},
+ {154,180},
+ {184,170},
+ {221,160},
+ {265,150},
+ {316,140},
+ {375,130},
+ {441,120},
+ {513,110},
+ {588,100},
+ {734,80},
+ {856,60},
+ {938,40},
+ {986,20},
+ {1008,0},
+ {1018,-20}
+ };
+
+#endif
+
+#if THERMISTORHEATER == 1
+#define NUMTEMPS NUMTEMPS_1
+#define temptable temptable_1
+#elif THERMISTORHEATER == 2
+#define NUMTEMPS NUMTEMPS_2
+#define temptable temptable_2
+#elif THERMISTORHEATER == 3
+#define NUMTEMPS NUMTEMPS_3
+#define temptable temptable_3
+#elif defined HEATER_USES_THERMISTOR
+#error No heater thermistor table specified
+#endif
+#if THERMISTORBED == 1
+#define BNUMTEMPS NUMTEMPS_1
+#define bedtemptable temptable_1
+#elif THERMISTORBED == 2
+#define BNUMTEMPS NUMTEMPS_2
+#define bedtemptable temptable_2
+#elif THERMISTORBED == 3
+#define BNUMTEMPS NUMTEMPS_3
+#define bedtemptable temptable_3
+#elif defined BED_USES_THERMISTOR
+#error No bed thermistor table specified
+#endif
+
+#endif //THERMISTORTABLES_H_
diff --git a/Tonokip_Firmware/BedThermistorTable_100k.h b/Tonokip_Firmware/BedThermistorTable_100k.h
deleted file mode 100644
index 84bc607..0000000
--- a/Tonokip_Firmware/BedThermistorTable_100k.h
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef THERMISTORTABLE_H_
-#define THERMISTORTABLE_H_
-
-// Thermistor lookup table for RepRap Temperature Sensor Boards (http://make.rrrf.org/ts)
-// See this page:
-// http://dev.www.reprap.org/bin/view/Main/Thermistor
-// for details of what goes in this table.
-// Made with createTemperatureLookup.py (http://svn.reprap.org/trunk/reprap/firmware/Arduino/utilities/createTemperatureLookup.py)
-// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=4066 --max-adc=1023
-// r0: 100000
-// t0: 25
-// r1: 0
-// r2: 4700
-// beta: 4066
-// max adc: 1023
-
-#define BNUMTEMPS 61
-const short bedtemptable[BNUMTEMPS][2] = {
-{ 23 , 300 },
-{ 25 , 295 },
-{ 27 , 290 },
-{ 28 , 285 },
-{ 31 , 280 },
-{ 33 , 275 },
-{ 35 , 270 },
-{ 38 , 265 },
-{ 41 , 260 },
-{ 44 , 255 },
-{ 48 , 250 },
-{ 52 , 245 },
-{ 56 , 240 },
-{ 61 , 235 },
-{ 66 , 230 },
-{ 71 , 225 },
-{ 78 , 220 },
-{ 84 , 215 },
-{ 92 , 210 },
-{ 100 , 205 },
-{ 109 , 200 },
-{ 120 , 195 },
-{ 131 , 190 },
-{ 143 , 185 },
-{ 156 , 180 },
-{ 171 , 175 },
-{ 187 , 170 },
-{ 205 , 165 },
-{ 224 , 160 },
-{ 245 , 155 },
-{ 268 , 150 },
-{ 293 , 145 },
-{ 320 , 140 },
-{ 348 , 135 },
-{ 379 , 130 },
-{ 411 , 125 },
-{ 445 , 120 },
-{ 480 , 115 },
-{ 516 , 110 },
-{ 553 , 105 },
-{ 591 , 100 },
-{ 628 , 95 },
-{ 665 , 90 },
-{ 702 , 85 },
-{ 737 , 80 },
-{ 770 , 75 },
-{ 801 , 70 },
-{ 830 , 65 },
-{ 857 , 60 },
-{ 881 , 55 },
-{ 903 , 50 },
-{ 922 , 45 },
-{ 939 , 40 },
-{ 954 , 35 },
-{ 966 , 30 },
-{ 977 , 25 },
-{ 985 , 20 },
-{ 993 , 15 },
-{ 999 , 10 },
-{ 1004 , 5 },
-{ 1008 , 0 },
-
-};
-
-
-#endif
-
diff --git a/Tonokip_Firmware/BedThermistorTable_200k.h b/Tonokip_Firmware/BedThermistorTable_200k.h
deleted file mode 100644
index 3d96aa3..0000000
--- a/Tonokip_Firmware/BedThermistorTable_200k.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef THERMISTORTABLE_H_
-#define THERMISTORTABLE_H_
-
-// Thermistor lookup table for RepRap Temperature Sensor Boards (http://make.rrrf.org/ts)
-// See this page:
-// http://dev.www.reprap.org/bin/view/Main/Thermistor
-// for details of what goes in this table.
-// Made with createTemperatureLookup.py (http://svn.reprap.org/trunk/reprap/firmware/Arduino/utilities/createTemperatureLookup.py)
-// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=4066 --max-adc=1023
-// r0: 100000
-// t0: 25
-// r1: 0
-// r2: 4700
-// beta: 4066
-// max adc: 1023
-
-#define BNUMTEMPS 20
-const short bedtemptable[BNUMTEMPS][2] = {
- {1, 848},
- {54, 275},
- {107, 228},
- {160, 202},
- {213, 185},
- {266, 171},
- {319, 160},
- {372, 150},
- {425, 141},
- {478, 133},
- {531, 125},
- {584, 118},
- {637, 110},
- {690, 103},
- {743, 95},
- {796, 86},
- {849, 77},
- {902, 65},
- {955, 49},
- {1008, 17}
-};
-
-
-#endif
diff --git a/Tonokip_Firmware/ThermistorTable_100k.h b/Tonokip_Firmware/ThermistorTable_100k.h
deleted file mode 100644
index d0698b2..0000000
--- a/Tonokip_Firmware/ThermistorTable_100k.h
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef THERMISTORTABLE_H_
-#define THERMISTORTABLE_H_
-
-// Thermistor lookup table for RepRap Temperature Sensor Boards (http://make.rrrf.org/ts)
-// See this page:
-// http://dev.www.reprap.org/bin/view/Main/Thermistor
-// for details of what goes in this table.
-// Made with createTemperatureLookup.py (http://svn.reprap.org/trunk/reprap/firmware/Arduino/utilities/createTemperatureLookup.py)
-// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=4066 --max-adc=1023
-// r0: 100000
-// t0: 25
-// r1: 0
-// r2: 4700
-// beta: 4066
-// max adc: 1023
-
-#define NUMTEMPS 61
-const short temptable[NUMTEMPS][2] = {
-{ 23 , 300 },
-{ 25 , 295 },
-{ 27 , 290 },
-{ 28 , 285 },
-{ 31 , 280 },
-{ 33 , 275 },
-{ 35 , 270 },
-{ 38 , 265 },
-{ 41 , 260 },
-{ 44 , 255 },
-{ 48 , 250 },
-{ 52 , 245 },
-{ 56 , 240 },
-{ 61 , 235 },
-{ 66 , 230 },
-{ 71 , 225 },
-{ 78 , 220 },
-{ 84 , 215 },
-{ 92 , 210 },
-{ 100 , 205 },
-{ 109 , 200 },
-{ 120 , 195 },
-{ 131 , 190 },
-{ 143 , 185 },
-{ 156 , 180 },
-{ 171 , 175 },
-{ 187 , 170 },
-{ 205 , 165 },
-{ 224 , 160 },
-{ 245 , 155 },
-{ 268 , 150 },
-{ 293 , 145 },
-{ 320 , 140 },
-{ 348 , 135 },
-{ 379 , 130 },
-{ 411 , 125 },
-{ 445 , 120 },
-{ 480 , 115 },
-{ 516 , 110 },
-{ 553 , 105 },
-{ 591 , 100 },
-{ 628 , 95 },
-{ 665 , 90 },
-{ 702 , 85 },
-{ 737 , 80 },
-{ 770 , 75 },
-{ 801 , 70 },
-{ 830 , 65 },
-{ 857 , 60 },
-{ 881 , 55 },
-{ 903 , 50 },
-{ 922 , 45 },
-{ 939 , 40 },
-{ 954 , 35 },
-{ 966 , 30 },
-{ 977 , 25 },
-{ 985 , 20 },
-{ 993 , 15 },
-{ 999 , 10 },
-{ 1004 , 5 },
-{ 1008 , 0 },
-
-};
-
-
-#endif
-
diff --git a/Tonokip_Firmware/ThermistorTable_200k.h b/Tonokip_Firmware/ThermistorTable_200k.h
deleted file mode 100644
index 4142eb2..0000000
--- a/Tonokip_Firmware/ThermistorTable_200k.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef THERMISTORTABLE_H_
-#define THERMISTORTABLE_H_
-
-// Thermistor lookup table for RepRap Temperature Sensor Boards (http://make.rrrf.org/ts)
-// See this page:
-// http://dev.www.reprap.org/bin/view/Main/Thermistor
-// for details of what goes in this table.
-// Made with createTemperatureLookup.py (http://svn.reprap.org/trunk/reprap/firmware/Arduino/utilities/createTemperatureLookup.py)
-// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=4066 --max-adc=1023
-// r0: 100000
-// t0: 25
-// r1: 0
-// r2: 4700
-// beta: 4066
-// max adc: 1023
-
-#define NUMTEMPS 20
-const short temptable[NUMTEMPS][2] = {
- {1, 848},
- {54, 275},
- {107, 228},
- {160, 202},
- {213, 185},
- {266, 171},
- {319, 160},
- {372, 150},
- {425, 141},
- {478, 133},
- {531, 125},
- {584, 118},
- {637, 110},
- {690, 103},
- {743, 95},
- {796, 86},
- {849, 77},
- {902, 65},
- {955, 49},
- {1008, 17}
-};
-
-
-#endif
diff --git a/Tonokip_Firmware/ThermistorTable_mendelparts.h b/Tonokip_Firmware/ThermistorTable_mendelparts.h
deleted file mode 100644
index 9e65b85..0000000
--- a/Tonokip_Firmware/ThermistorTable_mendelparts.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef THERMISTORTABLE_H_
-#define THERMISTORTABLE_H_
-
-//thermistor table for mendel-parts thermistor
-// Standardized R/T characteristic no. 8404
- // RS thermistor 484-0183; EPCOS NTC
- // Mendel-Parts thermistor G540 / G550
- // Optimized for 100...300C working range.
- // Max range: -20...300C
- // Max reading error on Gen 6 electronics: ~+5%, -3% in 100 - 300C range.
-
-#define NUMTEMPS 28
-const short temptable[NUMTEMPS][2] = {
- {1,864},
- {21,300},
- {25,290},
- {29,280},
- {33,270},
- {39,260},
- {46,250},
- {54,240},
- {64,230},
- {75,220},
- {90,210},
- {107,200},
- {128,190},
- {154,180},
- {184,170},
- {221,160},
- {265,150},
- {316,140},
- {375,130},
- {441,120},
- {513,110},
- {588,100},
- {734,80},
- {856,60},
- {938,40},
- {986,20},
- {1008,0},
- {1018,-20}
- };
-
-
-#endif
diff --git a/Tonokip_Firmware/configuration.h b/Tonokip_Firmware/configuration.h
deleted file mode 100644
index 2bd4e6a..0000000
--- a/Tonokip_Firmware/configuration.h
+++ /dev/null
@@ -1,156 +0,0 @@
-#ifndef PARAMETERS_H
-#define PARAMETERS_H
-
-// NO RS485/EXTRUDER CONTROLLER SUPPORT
-// PLEASE VERIFY PIN ASSIGNMENTS FOR YOUR CONFIGURATION!!!!!!!
-#define MOTHERBOARD 3 // ATMEGA168 = 0, SANGUINO = 1, MOTHERBOARD = 2, MEGA/RAMPS = 3, ATMEGA328 = 4, Gen6 = 5, Sanguinololu = 6
-
-//Comment out to disable SD support
-#define SDSUPPORT 1
-
-//Min step delay in microseconds. If you are experiencing missing steps, try to raise the delay microseconds, but be aware this
-// If you enable this, make sure STEP_DELAY_RATIO is disabled.
-#define STEP_DELAY_MICROS 1
-
-//Step delay over interval ratio. If you are still experiencing missing steps, try to uncomment the following line, but be aware this
-//If you enable this, make sure STEP_DELAY_MICROS is disabled.
-//#define STEP_DELAY_RATIO 0.25
-
-//Comment this to disable ramp acceleration
-#define RAMP_ACCELERATION 1
-
-//Uncomment this to enable exponential acceleration
-//#define EXP_ACCELERATION 1
-
-//Acceleration settings
-#ifdef RAMP_ACCELERATION
-float min_units_per_second = 35.0; // the minimum feedrate
-long max_acceleration_units_per_sq_second = 750; // Max acceleration in mm/s^2 for printing moves
-long max_travel_acceleration_units_per_sq_second = 1500; // Max acceleration in mm/s^2 for travel moves
-#endif
-#ifdef EXP_ACCELERATION
-float full_velocity_units = 10; // the units between minimum and G1 move feedrate
-float travel_move_full_velocity_units = 10; // used for travel moves
-float min_units_per_second = 35.0; // the minimum feedrate
-float min_constant_speed_units = 2; // the minimum units of an accelerated move that must be done at constant speed
- // Note that if the move is shorter than this value, acceleration won't be perfomed,
- // but will be done at the minimum between min_units_per_seconds and move feedrate speeds.
-#endif
-
-// AD595 THERMOCOUPLE SUPPORT UNTESTED... USE WITH CAUTION!!!!
-
-//PID settings:
-//Uncomment the following line to enable PID support. This is untested and could be disastrous. Be careful.
-//#define PIDTEMP 1
-#ifdef PIDTEMP
-#define PID_MAX 255 // limits current to nozzle
-#define PID_INTEGRAL_DRIVE_MAX 220
-#define PID_PGAIN 180 //100 is 1.0
-#define PID_IGAIN 2 //100 is 1.0
-#define PID_DGAIN 100 //100 is 1.0
-#endif
-
-//How often should the heater check for new temp readings, in milliseconds
-#define HEATER_CHECK_INTERVAL 50
-#define BED_CHECK_INTERVAL 5000
-
-//Experimental temperature smoothing - only uncomment this if your temp readings are noisy
-//#define SMOOTHING 1
-//#define SMOOTHFACTOR 16 //best to use a power of two here - determines how many values are averaged together by the smoothing algorithm
-
-//Experimental watchdog and minimal temp
-//The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
-//If the temperature has not increased at the end of that period, the target temperature is set to zero. It can be reset with another M104/M109
-//#define WATCHPERIOD 5000 //5 seconds
-//The minimal temperature defines the temperature below which the heater will not be enabled
-//#define MINTEMP
-
-//Experimental max temp
-//When temperature exceeds max temp, your bot will halt.
-//This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure!
-//You should use MINTEMP for thermistor short/failure protection.
-//#define MAXTEMP 275
-
-// Select one of these only to define how the nozzle temp is read.
-#define HEATER_USES_THERMISTOR
-//#define HEATER_USES_AD595
-//#define HEATER_USES_MAX6675
-
-// Select one of these only to define how the bed temp is read.
-#define BED_USES_THERMISTOR
-//#define BED_USES_AD595
-
-// Calibration formulas
-// e_extruded_steps_per_mm = e_feedstock_steps_per_mm * (desired_extrusion_diameter^2 / feedstock_diameter^2)
-// new_axis_steps_per_mm = previous_axis_steps_per_mm * (test_distance_instructed/test_distance_traveled)
-// units are in millimeters or whatever length unit you prefer: inches,football-fields,parsecs etc
-
-//Calibration variables
-float x_steps_per_unit = 80.376;
-float y_steps_per_unit = 80.376;
-float z_steps_per_unit = 3200/1.25;
-float e_steps_per_unit = 16;
-float max_feedrate = 200000; //mmm, acceleration!
-float max_z_feedrate = 120;
-
-//For SAE Prusa mendeel float z_steps_per_unit = should be 3200/1.411 for 5/16-18 rod and 3200/1.058 for 5/16-24
-//float x_steps_per_unit = 10.047;
-//float y_steps_per_unit = 10.047;
-//float z_steps_per_unit = 833.398;
-//float e_steps_per_unit = 0.706;
-//float max_feedrate = 3000;
-
-//For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
-const bool X_ENABLE_ON = 0;
-const bool Y_ENABLE_ON = 0;
-const bool Z_ENABLE_ON = 0;
-const bool E_ENABLE_ON = 0;
-
-//Disables axis when it's not being used.
-const bool DISABLE_X = false;
-const bool DISABLE_Y = false;
-const bool DISABLE_Z = true;
-const bool DISABLE_E = false;
-
-const bool INVERT_X_DIR = false;
-const bool INVERT_Y_DIR = false;
-const bool INVERT_Z_DIR = true;
-const bool INVERT_E_DIR = false;
-
-// Sets direction of endstops when homing; 1=MAX, -1=MIN
-const int X_HOME_DIR = -1;
-const int Y_HOME_DIR = -1;
-const int Z_HOME_DIR = -1;
-
-
-//Thermistor settings:
-
-//Uncomment for 100k thermistor
-//#include "ThermistorTable_100k.h"
-//#include "BedThermistorTable_100k.h"
-
-//Uncomment for 200k thermistor
-//#include "ThermistorTable_200k.h"
-//#include "BedThermistorTable_200k.h"
-
-//Identical thermistors on heater and bed - use this if you have no heated bed or if the thermistors are the same on both:
-#include "ThermistorTable_200k.h"
-//#include "ThermistorTable_100k.h"
-//#include "ThermistorTable_mendelparts.h"
-#define BNUMTEMPS NUMTEMPS
-#define bedtemptable temptable
-
-//Endstop Settings
-#define ENDSTOPPULLUPS 1
-const bool ENDSTOPS_INVERTING = false;
-const bool min_software_endstops = false; //If true, axis won't move to coordinates less than zero.
-const bool max_software_endstops = true; //If true, axis won't move to coordinates greater than the defined lengths below.
-const int X_MAX_LENGTH = 220;
-const int Y_MAX_LENGTH = 220;
-const int Z_MAX_LENGTH = 100;
-
-#define BAUDRATE 115200
-
-
-
-#endif