Permalink
Browse files

Version 0.70

  • Loading branch information...
1 parent 2f9c693 commit 7f168120e7d690f786b0dcf084da37e13d67f262 @repetier committed Jun 16, 2012
View
77 Repetier/Commands.cpp
@@ -64,13 +64,13 @@ void printPosition() {
}
void print_temperatures() {
#if HEATED_BED_SENSOR_TYPE==0
- out.print_int_P(PSTR("T:"),extruder_get_temperature()>>CELSIUS_EXTRA_BITS);
+ out.print_int_P(PSTR("T:"),((1<<(CELSIUS_EXTRA_BITS-1))+extruder_get_temperature())>>CELSIUS_EXTRA_BITS);
#else
- out.print_int_P(PSTR("T:"),extruder_get_temperature()>>CELSIUS_EXTRA_BITS);
- out.print_int_P(PSTR(" B:"),heated_bed_get_temperature()>>CELSIUS_EXTRA_BITS);
+ out.print_int_P(PSTR("T:"),((1<<(CELSIUS_EXTRA_BITS-1))+extruder_get_temperature())>>CELSIUS_EXTRA_BITS);
+ out.print_int_P(PSTR(" B:"),((1<<(CELSIUS_EXTRA_BITS-1))+heated_bed_get_temperature())>>CELSIUS_EXTRA_BITS);
#endif
#ifdef TEMP_PID
- out.print_int_P(PSTR(" @:"),(int)current_extruder->output);
+ out.print_int_P(PSTR(" @:"),(int)pwm_pos[current_extruder->id]);
#endif
out.println();
}
@@ -86,24 +86,7 @@ void set_fan_speed(int speed,bool wait) {
speed = constrain(speed,0,255);
if(wait)
wait_until_end_of_move(); // use only if neededthis to change the speed exactly at that point, but it may cause blobs if you do!
- if(speed>0) {
-#ifdef SIMULATE_FAN_PWM
- fan_speed = speed<<4;
-#else
- if (speed<255){
- digitalWrite(FAN_PIN, HIGH);
- analogWrite(FAN_PIN, speed );
- } else
- digitalWrite(FAN_PIN, HIGH);
-#endif
- } else {
-#ifdef SIMULATE_FAN_PWM
- fan_speed=0;
-#else
- analogWrite(FAN_PIN, 0);
- digitalWrite(FAN_PIN, LOW);
-#endif
- }
+ pwm_pos[3] = speed;
#endif
}
void home_axis(bool xaxis,bool yaxis,bool zaxis) {
@@ -457,7 +440,7 @@ void process_command(GCode *com)
}
break;
case 115: // M115
- out.println_P(PSTR("FIRMWARE_NAME:Repetier FIRMWARE_URL:https://github.com/repetier/Repetier-Firmware/ PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1 REPETIER_PROTOCOL:1"));
+ out.println_P(PSTR("FIRMWARE_NAME:Repetier_" REPETIER_VERSION " FIRMWARE_URL:https://github.com/repetier/Repetier-Firmware/ PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1 REPETIER_PROTOCOL:1"));
break;
case 114: // M114
printPosition();
@@ -527,24 +510,47 @@ void process_command(GCode *com)
out.println_P(PSTR("Error: No EEPROM support compiled."));
#endif
break;
+ case 207: // M207 X<XY jerk> Z<Z Jerk>
+ if(GCODE_HAS_X(com))
+ printer_state.maxJerk = com->X;
+ if(GCODE_HAS_Z(com))
+ printer_state.maxZJerk = com->Z;
+ if(GCODE_HAS_E(com)) {
+ current_extruder->maxStartFeedrate = com->E;
+ extruder_select(current_extruder->id);
+ }
+ out.print_float_P(PSTR("Jerk:"),printer_state.maxJerk);
+ out.println_float_P(PSTR(" ZJerk:"),printer_state.maxZJerk);
+ break;
case 220: // M220 S<Feedrate multiplier in percent>
if(GCODE_HAS_S(com))
change_feedrate_multiply(com->S);
else
change_feedrate_multiply(100);
break;
+ case 221: // M221 S<Extrusion flow multiplier in percent>
+ if(GCODE_HAS_S(com))
+ printer_state.extrudeMultiply = com->S;
+ break;
case 222: //M222 F_CPU / S
if(GCODE_HAS_S(com))
out.println_long_P(PSTR("F_CPU/x="),CPUDivU2(com->S));
break;
-#ifdef USE_ADVANCE
- case 232:
- out.print_int_P(PSTR("Max advance="),maxadv);
- if(maxadv>0)
- out.println_float_P(PSTR(", speed="),maxadvspeed);
- else
- out.println();
+ #ifdef USE_ADVANCE
+ case 223: // Extruder interrupt test
+ if(GCODE_HAS_S(com))
+ printer_state.extruderStepsNeeded+=com->S;
+ break;
+ case 232:
+ out.print_int_P(PSTR(" linear steps:"),maxadv2);
+ #ifdef ENABLE_QUADRATIC_ADVANCE
+ out.print_int_P(PSTR(" quadratic steps:"),maxadv);
+ #endif
+ out.println_float_P(PSTR(", speed="),maxadvspeed);
+#ifdef ENABLE_QUADRATIC_ADVANCE
maxadv=0;
+#endif
+ maxadv2=0;
maxadvspeed=0;
break;
#endif
@@ -577,7 +583,6 @@ void process_command(GCode *com)
out.println();
}
#ifdef DEBUG_OPS
- out.println_int_P(PSTR("Timer diff"),printer_state.timer0Interval);
out.println_int_P(PSTR("Ret. steps:"),printer_state.opsRetractSteps);
out.println_int_P(PSTR("PushBack Steps:"),printer_state.opsPushbackSteps);
out.println_int_P(PSTR("Move after steps:"),printer_state.opsMoveAfterSteps);
@@ -586,9 +591,15 @@ void process_command(GCode *com)
#endif
#ifdef USE_ADVANCE
case 233:
- if(GCODE_HAS_X(com)) {
+ if(GCODE_HAS_Y(com))
+ current_extruder->advanceL = com->Y;
+ out.print_float_P(PSTR("linear L:"),current_extruder->advanceL);
+#ifdef ENABLE_QUADRATIC_ADVANCE
+ if(GCODE_HAS_X(com))
current_extruder->advanceK = com->X;
- }
+ out.print_float_P(PSTR(" quadratic K:"),current_extruder->advanceK);
+#endif
+ out.println();
break;
#endif
}
View
196 Repetier/Configuration.h
@@ -71,9 +71,9 @@
// for skeinforge 40 and later, steps to pull the plasic 1 mm inside the extruder, not out. Overridden if EEPROM activated.
#define EXT0_STEPS_PER_MM 373
// What type of sensor is used?
-// 1 is 100k thermistor
+// 1 is 100k thermistor (Epcos B57560G0107F000 - RepRap-Fab.org and many other)
// 2 is 200k thermistor
-// 3 is mendel-parts thermistor
+// 3 is mendel-parts thermistor (EPCOS G550)
// 4 is 10k thermistor
// 5 is userdefined thermistor table 0
// 6 is userdefined thermistor table 1
@@ -84,7 +84,7 @@
// 99 Generic thermistor table
// 100 is AD595
// 101 is MAX6675
-#define EXT0_TEMPSENSOR_TYPE 5
+#define EXT0_TEMPSENSOR_TYPE 1
// Position in analog input table below for reading temperatures or pin enabling SS for MAX6675
#define EXT0_TEMPSENSOR_PIN 0
// WHich pin enables the heater
@@ -100,17 +100,16 @@
// length of filament pulled inside the heater. For repsnap or older
// skeinforge use hiher values.
// Overridden if EEPROM activated.
-#define EXT0_MAX_FEEDRATE 1200
+#define EXT0_MAX_FEEDRATE 1500
// Feedrate from halted extruder in mm/s
// Overridden if EEPROM activated.
-#define EXT0_MAX_START_FEEDRATE 10
+#define EXT0_MAX_START_FEEDRATE 18
// Acceleration in mm/s^2
// Overridden if EEPROM activated.
-#define EXT0_MAX_ACCELERATION 10000
+#define EXT0_MAX_ACCELERATION 6000
/** Type of heat manager for this extruder.
- 0 = Simply switch on/off if temperature is reached. Works always.
-- 1 = PID Temperature control. Is better, but needs an output with PWM, which doesn't
- use Timer 0 and 1
+- 1 = PID Temperature control. Is better but needs good PID values. Defaults are a good start for most extruder.
Overridden if EEPROM activated.
*/
#define EXT0_HEAT_MANAGER 1
@@ -120,11 +119,11 @@
/** \brief The maximum value, I-gain can contribute to the output.
A good value is slightly higher then the output needed for your temperature.
-Values for startes:
+Values for starts:
130 => PLA for temperatures from 170-180°C
180 => ABS for temperatures around 240°C
-The precice values may differ for different nozzle/resistor combination.
+The precise values may differ for different nozzle/resistor combination.
Overridden if EEPROM activated.
*/
#define EXT0_PID_INTEGRAL_DRIVE_MAX 130
@@ -148,8 +147,20 @@ WATCH OUT: This value was in 0,01 units in earlier versions!
#define EXT0_PID_DGAIN 3000
// maximum time the heater is can be switched on. Max = 255. Overridden if EEPROM activated.
#define EXT0_PID_MAX 255
-/** \brief Faktor for the advance algorithm. 0 disables the algorithm. Overridden if EEPROM activated.*/
+/** \brief Faktor for the advance algorithm. 0 disables the algorithm. Overridden if EEPROM activated.
+K is the factor for the quadratic term, which is normally disabled in newer versions. If you want to use
+the quadratic factor make sure ENABLE_QUADRATIC_ADVANCE is defined.
+L is the linear factor and seems to be working better then the quadratic dependency.
+*/
#define EXT0_ADVANCE_K 0.0f
+#define EXT0_ADVANCE_L 0.0f
+
+/** PID control only works target temperature +/- PID_CONTROL_RANGE.
+If you get much overshoot at the first temperature set, because the heater is going full power to long, you
+need to increase this value. For one 6.8 Ohm heater 10 is ok. With two 6.8 Ohm heater use 15.
+*/
+#define PID_CONTROL_RANGE 15
+
/** Number of entries in the user thermistortable 0. Set to 0 to disable it. */
#define NUM_TEMPS_USERTHERMISTOR0 28
/** Number of entries in the user thermistortable 1. Set to 0 to disable it. */
@@ -355,9 +366,17 @@ one extruder with heated bed, write:
// ## Endstop configuration ##
// ##########################################################################################
-//// Endstop Settings
-#define ENDSTOPPULLUPS // 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.
+/* By default all endstops are pulled up to high. You need a pullup if you
+use a mechanical endstop connected with gnd. Set value to false for no pullup
+on this endstop.
+*/
+#define ENDSTOP_PULLUP_X_MIN true
+#define ENDSTOP_PULLUP_Y_MIN true
+#define ENDSTOP_PULLUP_Z_MIN true
+#define ENDSTOP_PULLUP_X_MAX true
+#define ENDSTOP_PULLUP_Y_MAX true
+#define ENDSTOP_PULLUP_Z_MAX true
+
//set to true to invert the logic of the endstops
#define ENDSTOP_X_MIN_INVERTING false
#define ENDSTOP_Y_MIN_INVERTING false
@@ -450,9 +469,43 @@ one extruder with heated bed, write:
/** Speed in mm/min for finding the home position. Overridden if EEPROM activated. */
#define HOMING_FEEDRATE {2400,2400,100}
+/* If you have a backslash in both z-directions, you can use this. For most printer, the bed will be pushed down by it's
+own weight, so this is nearly never needed. */
+//#define Z_BACKSLASH 0.1
+
/** Comment this to disable ramp acceleration */
#define RAMP_ACCELERATION 1
+/** If your stepper needs a longer high signal then given, you can add a delay here.
+The delay is realized as a simple loop wasting time, which is not available for other
+computations. So make it as low as possible. For the most common drivers no delay is needed, as the
+included delay is already enough.
+*/
+#define STEPPER_HIGH_DELAY 0
+
+/** The firmware can only handle 16000Hz interrupt frequency cleanly. If you need higher speeds
+a faster solution is needed, and this is to double/quadruple the steps in one interrupt call.
+This is like reducing your 1/16th microstepping to 1/8 or 1/4. It is much cheaper then 1 or 3
+additional stepper interrupts with all it's overhead. As a result you can go as high as
+40000Hz.
+*/
+#define STEP_DOUBLER_FREQUENCY 10000
+/** If you need frequencies off more then 30000 you definitely need to enable this. If you have only 1/8 stepping
+enabling this may cause to stall your moves when 20000Hz is reached.
+*/
+#define ALLOW_QUADSTEPPING false
+/** If you reach STEP_DOUBLER_FREQUENCY the firmware will do 2 or 4 steps with nearly no delay. That can be too fast
+for some printers causing an early stall.
+
+*/
+#define DOUBLE_STEP_DELAY 1 // time in us
+
+/** The firmware supports trajectory smoothing. To acieve this, it divides the stepsize by 2, resulting in
+the double computation cost. For slow movements this is not an issue, but for really fast moves this is
+too much. The value specified here is the number of clock cycles between a step on the driving axis.
+If the interval at full speed is below this value, smoothing is disabled for that line.*/
+#define MAX_HALFSTEP_INTERVAL 1999
+
//// Acceleration settings
/** \brief Use RAMP acceleration for faster printing speed. */
@@ -491,6 +544,43 @@ Overridden if EEPROM activated.
#define MAX_JERK 40.0
#define MAX_ZJERK 0.3
+/* Define the type of axis movements needed for your printer. The typical case
+is a full cartesian system where x, y and z moves are handled by seperate motors.
+
+0 = full cartesian system, xyz have seperate motors.
+1 = z axis + xy H-gantry (x_motor = x+y, y_motor = x-y)
+2 = z axis + xy H-gantry (x_motor = x+y, y_motor = y-x)
+Cases 1 and 2 cover all needed xy H gantry systems. If you get results mirrored etc. you can swap motor connections for x and y. If a motor turns in
+the wrong direction change INVERT_X_DIR or INVERT_Y_DIR.
+*/
+#define DRIVE_SYSTEM 0
+
+/** \brief Number of moves we can cache in advance.
+
+This number of moves can be cached in advance. If you wan't to cache more, increase this. Especially on
+many very short moves the cache may go empty. The minimum value is 5.
+*/
+#define MOVE_CACHE_SIZE 16
+/* How many line segments can the path planner use for path optimization. The maximum possible
+value is MOVE_CACHE_SIZE-2. Higher values need more computation time, which can cause blocking for many
+short subsequent moves. If this happens you will see BLK messages in your log and then you now the
+value is to high for your printer settings.
+*/
+#define PATH_PLANNER_CHECK_SEGMENTS 12
+/** \brief Low filled cache size.
+
+If the cache contains less then MOVE_CACHE_LOW segments, the time per segment is limited to LOW_TICKS_PER_MOVE clock cycles.
+If a move would be shorter, the feedrate will be reduced. This should prevent buffer underflows. Set this to 0 if you
+don't care about empty buffers during print.
+*/
+#define MOVE_CACHE_LOW 12
+/** \brief Cycles per move, if move cache is low.
+
+This value must be high enough, that the buffer has time to fill up. The problem only occurs at the beginning of a print or
+if you are printing many very short segments at high speed. Higher delays here allow higher values in PATH_PLANNER_CHECK_SEGMENTS.
+*/
+#define LOW_TICKS_PER_MOVE 400000
+
// ##########################################################################################
// ## Extruder control ##
// ##########################################################################################
@@ -500,22 +590,6 @@ Overridden if EEPROM activated.
All known arduino boards use 64. This value is needed for the extruder timing. */
#define TIMER0_PRESCALE 64
-/** \brief speed of the extruder feeder
-
-This is the maximum speed, the filament can be moved forward and backward without acceleration.
-The value determines, how often we can update the extruder stepper, to come up with the desired
-extruder position. Higher values increase precision. If you set the value too high, you will
-lose steps. Only discrete values between 1 and 255 can be set for the timer. The effectife update
-frequency is computed as:
-
-f = floor(F_CPU/(TIMER0_PRESCALE*EXTRUDER_SPEED*STEPS_PER_MM))
-
-Important: This is the speed, filament is pushed inside the extruder not the speed at the nozzle!
-If you set the extruder steps_per_mm for 1mm pushed outside, cause skeinforge<40 needed it, you must
-decrease the value to reflect this. (*filament_diameter^2/nozzle_diameter^2)
-*/
-#define EXTRUDER_SPEED 20.0
-
/* \brief Minimum temperature for extruder operation
This is a saftey value. If your extruder temperature is below this temperature, no
@@ -588,11 +662,11 @@ For more informations, read the wiki.
*/
#define USE_ADVANCE
-/** The firmware supports trajectory smoothing. To acieve this, it divides the stepsize by 2, resulting in
-the double computation cost. For slow movements this is not an issue, but for really fast moves this is
-too much. The value specified here is the number of clock cycles between a step on the driving axis.
-If the interval at full speed is below this value, smoothing is disabled for that line.*/
-#define MAX_HALFSTEP_INTERVAL 1999
+/** \brief enables quadratic component.
+
+Uncomment to allow a quadratic advance dependency. Linear is the dominant value, so no real need
+to activate the quadratic term. Only adds lots of computations and storage usage. */
+//#define ENABLE_QUADRATIC_ADVANCE
// ##########################################################################################
// ## Communication configuration ##
@@ -633,31 +707,6 @@ the power will be turned on without the need to call M80 if initially started.
#if !defined(__AVR_AT90USB1286__) && !defined(__AVR_AT90USB1287__) // not needed for USB serial
#define USE_BUFFERED_OUTPUT
#endif
-/** \brief Number of moves we can cache in advance.
-
-This number of moves can be cached in advance. If you wan't to cache more, increase this. Especially on
-many very short moves the cache may go empty. The minimum value is 5.
-*/
-#define MOVE_CACHE_SIZE 16
-/* How many line segments can the path planner use for path optimization. The maximum possible
-value is MOVE_CACHE_SIZE-2. Higher values need more computation time, which can cause blocking for many
-short subsequent moves. If this happens you will see BLK messages in your log and then you now the
-value is to high for your printer settings.
-*/
-#define PATH_PLANNER_CHECK_SEGMENTS 7
-/** \brief Low filled cache size.
-
-If the cache contains less then MOVE_CACHE_LOW segments, the time per segment is limited to LOW_TICKS_PER_MOVE clock cycles.
-If a move would be shorter, the feedrate will be reduced. This should prevent buffer underflows. Set this to 0 if you
-don't care about empty buffers during print.
-*/
-#define MOVE_CACHE_LOW 12
-/** \brief Cycles per move, if move cache is low.
-
-This value must be high enough, that the buffer has time to fill up. The problem only occurs at the beginning of a print or
-if you are printing many very short segments at high speed. Higher delays here allow higher values in PATH_PLANNER_CHECK_SEGMENTS.
-*/
-#define LOW_TICKS_PER_MOVE 400000
/** \brief Cache size for incoming commands.
There should be no reason to increase this cache. Commands are nearly immediately send to
@@ -724,34 +773,7 @@ usage or for seraching for memory induced errors. Switch it off for production,
//#define DEBUG_STEPCOUNT
// Uncomment the following line to enable debugging. You can better control debugging below the following line
//#define DEBUG
-// ####################################################################################
-// # Below this line only for experts #
-// ####################################################################################
-
-// ####################################################################################
-// # No configuration below this line - just some errorchecking #
-// ####################################################################################
-#ifdef SUPPORT_MAX6675
-#if !defined SCK_PIN || !defined MOSI_PIN || !defined MISO_PIN
-#error For MAX6675 support, you need to define SCK_PIN, MISO_PIN and MOSI_PIN in pins.h
-#endif
-#endif
-#if X_STEP_PIN<0 || Y_STEP_PIN<0 || Z_STEP_PIN<0
-#error One of the following pins is not assigned: X_STEP_PIN,Y_STEP_PIN,Z_STEP_PIN
-#endif
-#if EXT0_STEP_PIN<0
-#error EXT0_STEP_PIN not set to a pin number.
-#endif
-#if EXT0_DIR_PIN<0
-#error EXT0_DIR_PIN not set to a pin number.
-#endif
-#if MOVE_CACHE_SIZE<4
-#error MOVE_CACHE_SIZE must be at least 5
-#endif
-#if OUTPUT_BUFFER_SIZE>250 || OUTPUT_BUFFER_SIZE<16
-#error OUTPUT_BUFFER_SIZE must be in range 16..250
-#endif
#endif
View
23 Repetier/Eeprom.cpp
@@ -132,9 +132,6 @@ void epr_data_to_eeprom() {
epr_set_float(EPR_Y_MAX_TRAVEL_ACCEL,max_travel_acceleration_units_per_sq_second[1]);
epr_set_float(EPR_Z_MAX_TRAVEL_ACCEL,max_travel_acceleration_units_per_sq_second[2]);
#endif
-#if USE_OPS==1 || defined(USE_ADVANCE)
- epr_set_float(EPR_EXTRUDER_SPEED,printer_state.extruderSpeed);
-#endif
#if USE_OPS==1
epr_set_float(EPR_OPS_MIN_DISTANCE,printer_state.opsMinDistance);
epr_set_byte(EPR_OPS_MODE,printer_state.opsMode);
@@ -163,7 +160,12 @@ void epr_data_to_eeprom() {
epr_set_long(o+EPR_EXTRUDER_X_OFFSET,e->yOffset);
epr_set_long(o+EPR_EXTRUDER_Y_OFFSET,e->xOffset);
epr_set_int(o+EPR_EXTRUDER_WATCH_PERIOD,e->watchPeriod);
+#ifdef USE_ADVANCE
+#ifdef ENABLE_QUADRATIC_ADVANCE
epr_set_float(o+EPR_EXTRUDER_ADVANCE_K,e->advanceK);
+#endif
+ epr_set_float(o+EPR_EXTRUDER_ADVANCE_L,e->advanceL);
+#endif
}
}
/** \brief Copy data from EEPROM to variables.
@@ -192,9 +194,6 @@ void epr_eeprom_to_data() {
max_travel_acceleration_units_per_sq_second[1] = epr_get_float(EPR_Y_MAX_TRAVEL_ACCEL);
max_travel_acceleration_units_per_sq_second[2] = epr_get_float(EPR_Z_MAX_TRAVEL_ACCEL);
#endif
-#if USE_OPS==1 || defined(USE_ADVANCE)
- printer_state.extruderSpeed = epr_get_float(EPR_EXTRUDER_SPEED);
-#endif
#if USE_OPS==1
printer_state.opsMode = epr_get_byte(EPR_OPS_MODE);
printer_state.opsMoveAfter = epr_get_float(EPR_OPS_MOVE_AFTER);
@@ -222,7 +221,12 @@ void epr_eeprom_to_data() {
e->yOffset = epr_get_long(o+EPR_EXTRUDER_X_OFFSET);
e->xOffset = epr_get_long(o+EPR_EXTRUDER_Y_OFFSET);
e->watchPeriod = epr_get_int(o+EPR_EXTRUDER_WATCH_PERIOD);
+ #ifdef USE_ADVANCE
+ #ifdef ENABLE_QUADRATIC_ADVANCE
e->advanceK = epr_get_float(o+EPR_EXTRUDER_ADVANCE_K);
+ #endif
+ e->advanceL = epr_get_float(o+EPR_EXTRUDER_ADVANCE_L);
+ #endif
}
extruder_select(current_extruder->id);
update_ramps_parameter();
@@ -287,7 +291,6 @@ void epr_output_settings() {
epr_out_float(EPR_Y_MAX_TRAVEL_ACCEL,PSTR("Y-axis travel acceleration [mm/s^2]"));
epr_out_float(EPR_Z_MAX_TRAVEL_ACCEL,PSTR("Z-axis travel acceleration [mm/s^2]"));
#endif
- epr_out_float(EPR_EXTRUDER_SPEED,PSTR("Max. extruder speed in [mm/s]"));
#if USE_OPS==1
epr_out_byte(EPR_OPS_MODE,PSTR("OPS operation mode [0=Off,1=Classic,2=Fast]"));
epr_out_float(EPR_OPS_MOVE_AFTER,PSTR("OPS move after x% retract [%]"));
@@ -315,8 +318,12 @@ void epr_output_settings() {
epr_out_long(o+EPR_EXTRUDER_X_OFFSET,PSTR("X-offset [steps]"));
epr_out_long(o+EPR_EXTRUDER_Y_OFFSET,PSTR("Y-offset [steps]"));
epr_out_int(o+EPR_EXTRUDER_WATCH_PERIOD,PSTR("Temp. stabilize time [s]"));
+#ifdef USE_ADVANCE
+#ifdef ENABLE_QUADRATIC_ADVANCE
epr_out_float(o+EPR_EXTRUDER_ADVANCE_K,PSTR("Advance K [0=off]"));
-
+#endif
+ epr_out_float(o+EPR_EXTRUDER_ADVANCE_L,PSTR("Advance L [0=off]"));
+#endif
}
#else
out.println_P(PSTR("No EEPROM support compiled."));
View
1 Repetier/Eeprom.h
@@ -75,6 +75,7 @@ have problems with other modules using the eeprom */
#define EPR_EXTRUDER_WATCH_PERIOD 39
#define EPR_EXTRUDER_ADVANCE_K 41
#define EPR_EXTRUDER_DRIVE_MIN 45
+#define EPR_EXTRUDER_ADVANCE_L 46
#if EEPROM_MODE!=0
extern inline byte epr_get_byte(uint pos);
View
128 Repetier/Extruder.cpp
@@ -25,23 +25,29 @@
Extruder *current_extruder;
Extruder extruder[NUM_EXTRUDER] = {
- {0,EXT0_X_OFFSET,EXT0_Y_OFFSET,EXT0_STEPS_PER_MM,EXT0_TEMPSENSOR_TYPE,EXT0_TEMPSENSOR_PIN,EXT0_HEATER_PIN,EXT0_ENABLE_PIN,EXT0_DIR_PIN,EXT0_STEP_PIN,EXT0_ENABLE_ON,EXT0_INVERSE,
- EXT0_MAX_FEEDRATE,EXT0_MAX_ACCELERATION,EXT0_MAX_START_FEEDRATE,0,0,0,0,0,0,EXT0_HEAT_MANAGER,EXT0_WATCHPERIOD,EXT0_ADVANCE_K,0
+ {0,EXT0_X_OFFSET,EXT0_Y_OFFSET,EXT0_STEPS_PER_MM,EXT0_TEMPSENSOR_TYPE,EXT0_TEMPSENSOR_PIN,EXT0_ENABLE_PIN,EXT0_ENABLE_ON,
+ EXT0_MAX_FEEDRATE,EXT0_MAX_ACCELERATION,EXT0_MAX_START_FEEDRATE,0,0,0,0,0,0,EXT0_HEAT_MANAGER,EXT0_WATCHPERIOD
+#ifdef USE_ADVANCE
+#ifdef ENABLE_QUADRATIC_ADVANCE
+ ,EXT0_ADVANCE_K
+#endif
+ ,EXT0_ADVANCE_L
+#endif
#ifdef TEMP_PID
,0,EXT0_PID_INTEGRAL_DRIVE_MAX,EXT0_PID_INTEGRAL_DRIVE_MIN,EXT0_PID_PGAIN,EXT0_PID_IGAIN,EXT0_PID_DGAIN,EXT0_PID_MAX,0,0,0,0,0,0,0,0,0,0,0
-#ifdef SIMULATE_PWM
- ,0,0
-#endif
#endif
}
#if NUM_EXTRUDER>1
- ,{1,EXT1_X_OFFSET,EXT1_Y_OFFSET,EXT1_STEPS_PER_MM,EXT1_TEMPSENSOR_TYPE,EXT1_TEMPSENSOR_PIN,EXT1_HEATER_PIN,EXT1_ENABLE_PIN,EXT1_DIR_PIN,EXT1_STEP_PIN,EXT1_ENABLE_ON,EXT1_INVERSE,
- EXT1_MAX_FEEDRATE,EXT1_MAX_ACCELERATION,EXT1_MAX_START_FEEDRATE,0,0,0,0,0,0,EXT1_HEAT_MANAGER,EXT1_WATCHPERIOD,EXT1_ADVANCE_K,0
+ ,{1,EXT1_X_OFFSET,EXT1_Y_OFFSET,EXT1_STEPS_PER_MM,EXT1_TEMPSENSOR_TYPE,EXT1_TEMPSENSOR_PIN,EXT1_ENABLE_PIN,EXT1_ENABLE_ON,
+ EXT1_MAX_FEEDRATE,EXT1_MAX_ACCELERATION,EXT1_MAX_START_FEEDRATE,0,0,0,0,0,0,EXT1_HEAT_MANAGER,EXT1_WATCHPERIOD
+#ifdef USE_ADVANCE
+#ifdef ENABLE_QUADRATIC_ADVANCE
+ ,EXT1_ADVANCE_K
+#endif
+ ,EXT1_ADVANCE_L
+#endif
#ifdef TEMP_PID
,0,EXT1_PID_INTEGRAL_DRIVE_MAX,EXT1_PID_INTEGRAL_DRIVE_MIN,EXT1_PID_PGAIN,EXT1_PID_IGAIN,EXT1_PID_DGAIN,EXT1_PID_MAX,0,0,0,0,0,0,0,0,0,0,0
-#ifdef SIMULATE_PWM
- ,0,0
-#endif
#endif
}
#endif
@@ -57,7 +63,7 @@ short temptable_generic[GENERIC_THERM_NUM_ENTRIES][2];
#endif
byte manage_monitor = 255; ///< Temp. we want to monitor with our host. 1+NUM_EXTRUDER is heated bed
-int counter_periodical=0;
+byte counter_periodical=0;
volatile byte execute_periodical=0;
byte counter_250ms=25;
byte heated_bed_output=0;
@@ -70,45 +76,11 @@ unsigned long last_bed_set = 0; ///< Time of last temperature setting for
extern int read_max6675(byte ss_pin);
#endif
-#if ANALOG_INPUTS>0
-const static uint8 osAnalogInputChannels[] PROGMEM = ANALOG_INPUT_CHANNELS;
-static uint8 osAnalogInputCounter[ANALOG_INPUTS];
-static uint osAnalogInputBuildup[ANALOG_INPUTS];
-static uint8 osAnalogInputPos=0; // Current sampling position
+const uint8 osAnalogInputChannels[] PROGMEM = ANALOG_INPUT_CHANNELS;
+uint8 osAnalogInputCounter[ANALOG_INPUTS];
+uint osAnalogInputBuildup[ANALOG_INPUTS];
+uint8 osAnalogInputPos=0; // Current sampling position
volatile uint osAnalogInputValues[ANALOG_INPUTS];
-ISR(ADC_vect) {
- osAnalogInputBuildup[osAnalogInputPos] += ADCW;
- if(++osAnalogInputCounter[osAnalogInputPos]>=_BV(ANALOG_INPUT_SAMPLE)) {
-#if ANALOG_INPUT_BITS+ANALOG_INPUT_SAMPLE<12
- osAnalogInputValues[osAnalogInputPos] =
- osAnalogInputBuildup[osAnalogInputPos] <<
- (12-ANALOG_INPUT_BITS-ANALOG_INPUT_SAMPLE);
-#endif
-#if ANALOG_INPUT_BITS+ANALOG_INPUT_SAMPLE>12
- osAnalogInputValues[osAnalogInputPos] =
- osAnalogInputBuildup[osAnalogInputPos] >>
- (ANALOG_INPUT_BITS+ANALOG_INPUT_SAMPLE-12);
-#endif
-#if ANALOG_INPUT_BITS+ANALOG_INPUT_SAMPLE==12
- osAnalogInputValues[osAnalogInputPos] =
- osAnalogInputBuildup[osAnalogInputPos];
-#endif
- osAnalogInputBuildup[osAnalogInputPos] = 0;
- osAnalogInputCounter[osAnalogInputPos] = 0;
- // Start next conversion
- if(++osAnalogInputPos>=ANALOG_INPUTS) osAnalogInputPos = 0;
- byte channel = pgm_read_byte(&osAnalogInputChannels[osAnalogInputPos]);
-#if defined(ADCSRB) && defined(MUX5)
- if(channel & 8) // Reading channel 0-7 or 8-15?
- ADCSRB |= _BV(MUX5);
- else
- ADCSRB &= ~_BV(MUX5);
-#endif
- ADMUX = (ADMUX & ~(0x1F)) | (channel & 7);
- }
- ADCSRA |= _BV(ADSC); // start next conversion
-}
-#endif
// ------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------- initExtruder ------------------------------------------------------
@@ -147,16 +119,23 @@ void initExtruder() {
#endif
}
#endif
+ SET_OUTPUT(EXT0_DIR_PIN);
+ SET_OUTPUT(EXT0_STEP_PIN);
+#ifdef EXT1_STEP_PIN
+ SET_OUTPUT(EXT1_DIR_PIN);
+ SET_OUTPUT(EXT1_STEP_PIN);
+#endif
+#ifdef EXT2_STEP_PIN
+ SET_OUTPUT(EXT2_DIR_PIN);
+ SET_OUTPUT(EXT2_STEP_PIN);
+#endif
for(i=0;i<NUM_EXTRUDER;++i) {
Extruder *act = &extruder[i];
- pinMode(act->directionPin,OUTPUT);
- pinMode(act->stepPin,OUTPUT);
if(act->enablePin > -1) {
pinMode(act->enablePin,OUTPUT);
if(!act->enableOn) digitalWrite(act->enablePin,HIGH);
}
- if(act->heaterPin > -1) pinMode(act->heaterPin,OUTPUT);
act->lastTemperatureUpdate = millis();
#ifdef SUPPORT_MAX6675
if(act->sensorType==101) {
@@ -197,7 +176,7 @@ void initExtruder() {
ADCSRB &= ~_BV(MUX5);
#endif
ADMUX = (ADMUX & ~(0x1F)) | (channel & 7);
- ADCSRA |= _BV(ADSC) | _BV(ADIE);
+ ADCSRA |= _BV(ADSC); // start conversion without interrupt!
#endif
}
@@ -227,10 +206,16 @@ void extruder_select(byte ext_num) {
max_acceleration_units_per_sq_second[3] = max_travel_acceleration_units_per_sq_second[3] = current_extruder->maxAcceleration;
axis_travel_steps_per_sqr_second[3] = axis_steps_per_sqr_second[3] = max_acceleration_units_per_sq_second[3] * axis_steps_per_unit[3];
#if USE_OPS==1 || defined(USE_ADVANCE)
- printer_state.timer0Interval = F_CPU/(TIMER0_PRESCALE*printer_state.extruderSpeed*current_extruder->stepsPerMM);
- if(printer_state.timer0Interval<15)
- printer_state.timer0Interval = 15; // Leave time for other work. Limit Interrupt to 16666 Hz
- float fmax=((float)F_CPU/((float)printer_state.timer0Interval*TIMER0_PRESCALE*axis_steps_per_unit[3]))*60.0; // Limit feedrate to interrupt speed
+ printer_state.minExtruderSpeed = (byte)(F_CPU/(TIMER0_PRESCALE*current_extruder->maxStartFeedrate*current_extruder->stepsPerMM));
+ printer_state.maxExtruderSpeed = (byte)(F_CPU/(TIMER0_PRESCALE*0.0166666*current_extruder->maxFeedrate*current_extruder->stepsPerMM));
+ if(printer_state.maxExtruderSpeed>=printer_state.minExtruderSpeed) {
+ printer_state.maxExtruderSpeed = printer_state.minExtruderSpeed;
+ } else {
+ float maxdist = current_extruder->maxStartFeedrate*current_extruder->maxStartFeedrate*0.00013888/current_extruder->maxAcceleration;
+ maxdist-= current_extruder->maxStartFeedrate*current_extruder->maxStartFeedrate*0.5/current_extruder->maxAcceleration;
+ printer_state.extruderAccelerateDelay = (byte)constrain(ceil(maxdist*current_extruder->stepsPerMM/(printer_state.minExtruderSpeed-printer_state.maxExtruderSpeed)),0,255);
+ }
+ float fmax=((float)F_CPU/((float)printer_state.maxExtruderSpeed*TIMER0_PRESCALE*axis_steps_per_unit[3]))*60.0; // Limit feedrate to interrupt speed
if(fmax<max_feedrate[3]) max_feedrate[3] = fmax;
#endif
#ifdef TEMP_PID
@@ -316,15 +301,20 @@ void extruder_disable() {
if(current_extruder->enablePin > -1)
digitalWrite(current_extruder->enablePin,!current_extruder->enableOn);
}
-#define NUMTEMPS_1 61
+#define NUMTEMPS_1 28
+// Epcos B57560G0107F000
const short temptable_1[NUMTEMPS_1][2] PROGMEM = {
+{0,4000},{92,2400},{105,2320},{121,2240},{140,2160},{162,2080},{189,2000},{222,1920},{261,1840},{308,1760},
+{365,1680},{434,1600},{519,1520},{621,1440},{744,1360},{891,1280},{1067,1200},{1272,1120},
+{1771,960},{2357,800},{2943,640},{3429,480},{3760,320},{3869,240},{3912,200},{3948,160},{4077,-160},{4094,-440}
+/* Old table for 100k unknown type 61 values
{23*4,300*8},{25*4,295*8},{27*4,290*8},{28*4,285*8},{31*4,280*8},{33*4,275*8},{35*4,270*8},{38*4,265*8},{41*4,260*8},{44*4,255*8},
{48*4,250*8},{52*4,245*8},{56*4,240*8},{61*4,235*8},{66*4,230*8},{71*4,225*8},{78*4,220*8},{84*4,215*8},{92*4,210*8},{100*4,205*8},
{109*4,200*8},{120*4,195*8},{131*4,190*8},{143*4,185*8},{156*4,180*8},{171*4,175*8},{187*4,170*8},{205*4,165*8},{224*4,160*8},
{245*4,155*8},{268*4,150*8},{293*4,145*8},{320*4,140*8},{348*4,135*8},{379*4,130*8},{411*4,125*8},{445*4,120*8},{480*4,115*8},
{516*4,110*8},{553*4,105*8},{591*4,100*8},{628*4,95*8},{665*4,90*8},{702*4,85*8},{737*4,80*8},{770*4,75*8},{801*4,70*8},{830*4,65*8},
{857*4,60*8},{881*4,55*8},{903*4,50*8},{922*4,45*8},{939*4,40*8},{954*4,35*8},{966*4,30*8},{977*4,25*8},{985*4,20*8},{993*4,15*8},
-{999*4,10*8},{1004*4,5*8},{1008*4,0*8} //safety
+{999*4,10*8},{1004*4,5*8},{1008*4,0*8} //safety*/
};
#define NUMTEMPS_2 21
const short temptable_2[NUMTEMPS_2][2] PROGMEM = {
@@ -398,7 +388,7 @@ int read_raw_temperature(byte type,byte pin) {
return read_max6675(pin);
#endif
}
- return 2000; // unknown method, return high value to switch heater off for safety
+ return 4095; // unknown method, return high value to switch heater off for safety
}
// ------------------------------------------------------------------------------------------------------------------
@@ -581,12 +571,12 @@ void write_monitor() {
Extruder *e = &extruder[manage_monitor];
out.print_int_P(PSTR(" "),e->currentTemperatureC>>CELSIUS_EXTRA_BITS);
out.print_int_P(PSTR(" "),e->targetTemperatureC>>CELSIUS_EXTRA_BITS);
- out.println_int_P(PSTR(" "),(int)e->output);
+ out.println_int_P(PSTR(" "),(int)pwm_pos[e->id]);
}
#if HEATED_BED_SENSOR_TYPE!=0
else {
out.print_int_P(PSTR(" "),conv_raw_temp(HEATED_BED_SENSOR_TYPE,current_bed_raw)>>CELSIUS_EXTRA_BITS);
- out.print_int_P(PSTR(" "),conv_raw_temp(HEATED_BED_SENSOR_TYPE,target_bed_raw)>>CELSIUS_EXTRA_BITS);
+ out.print_int_P(PSTR(" "),target_bed_celsius>>CELSIUS_EXTRA_BITS);
out.println_int_P(PSTR(" "),(int)heated_bed_output);
}
#endif
@@ -618,9 +608,9 @@ void manage_temperatures() {
byte output;
int error = act->targetTemperatureC - act->currentTemperatureC;
if(act->targetTemperatureC<(20<<CELSIUS_EXTRA_BITS)) output = 0; // off is off, even if damping term wants a heat peak!
- else if(error>(10<<CELSIUS_EXTRA_BITS))
+ else if(error>(PID_CONTROL_RANGE<<CELSIUS_EXTRA_BITS))
output = act->pidMax;
- else if(error<(-10<<CELSIUS_EXTRA_BITS))
+ else if(error<(-PID_CONTROL_RANGE<<CELSIUS_EXTRA_BITS))
output = 0;
else {
long pidTerm = act->pidPGain * error; // *100
@@ -639,21 +629,15 @@ void manage_temperatures() {
out.println_long_P(PSTR(" "),dgain);
} */
}
- act->output = output;
-#ifdef SIMULATE_PWM
- act->pwm = output<<3;
-#else
- analogWrite(act->heaterPin, output);
-#endif
+ pwm_pos[act->id] = output;
}
#endif
if(act->heatManager == 0
#ifndef TEMP_PID
|| true
#endif
) {
- act->output = (on?255:0);
- digitalWrite(act->heaterPin,on);
+ pwm_pos[act->id] = (on?255:0);
}
#if LED_PIN>-1
if(act == current_extruder)
View
697 Repetier/Repetier.pde
@@ -93,6 +93,7 @@ Custom M Codes
- M205 - Output EEPROM settings
- M206 - Set EEPROM value
- M220 S<Feedrate multiplier in percent> - Increase/decrease given feedrate
+- M221 S<Extrusion flow multiplier in percent> - Increase/decrease given flow rate
- M231 S<OPS_MODE> X<Min_Distance> Y<Retract> Z<Backslash> F<ReatrctMove> - Set OPS parameter
- M232 - Read and reset max. advance values
- M233 X<AdvanceK> - Set temporary advance K-value to X
@@ -114,6 +115,48 @@ Custom M Codes
//#include <LiquidCrystal.h> // Uncomment this if you are using liquid crystal library
#endif
+// ================ Sanity checks ================
+#ifndef STEP_DOUBLER_FREQUENCY
+#error Please add new parameter STEP_DOUBLER_FREQUENCY to your configuration.
+#else
+#if STEP_DOUBLER_FREQUENCY<10000 || STEP_DOUBLER_FREQUENCY>20000
+#error STEP_DOUBLER_FREQUENCY should be in range 10000-16000.
+#endif
+#endif
+#ifdef EXTRUDER_SPEED
+#error EXTRUDER_SPEED is not used any more. Values are now taken from extruder definition.
+#endif
+#if MAX_HALFSTEP_INTERVAL<=1900
+#error MAX_HALFSTEP_INTERVAL must be greater then 1900
+#endif
+#ifdef ENDSTOPPULLUPS
+#error ENDSTOPPULLUPS is now replaced by individual pullup configuration!
+#endif
+// ####################################################################################
+// # No configuration below this line - just some errorchecking #
+// ####################################################################################
+#ifdef SUPPORT_MAX6675
+#if !defined SCK_PIN || !defined MOSI_PIN || !defined MISO_PIN
+#error For MAX6675 support, you need to define SCK_PIN, MISO_PIN and MOSI_PIN in pins.h
+#endif
+#endif
+#if X_STEP_PIN<0 || Y_STEP_PIN<0 || Z_STEP_PIN<0
+#error One of the following pins is not assigned: X_STEP_PIN,Y_STEP_PIN,Z_STEP_PIN
+#endif
+#if EXT0_STEP_PIN<0
+#error EXT0_STEP_PIN not set to a pin number.
+#endif
+#if EXT0_DIR_PIN<0
+#error EXT0_DIR_PIN not set to a pin number.
+#endif
+#if MOVE_CACHE_SIZE<4
+#error MOVE_CACHE_SIZE must be at least 5
+#endif
+#if OUTPUT_BUFFER_SIZE>250 || OUTPUT_BUFFER_SIZE<16
+#error OUTPUT_BUFFER_SIZE must be in range 16..250
+#endif
+
+
#define OVERFLOW_PERIODICAL (int)(F_CPU/(TIMER0_PRESCALE*40))
// RAM usage of variables: Non RAMPS 114+MOVE_CACHE_SIZE*59+printer_state(32) = 382 Byte with MOVE_CACHE_SIZE=4
// RAM usage RAMPS adds: 96
@@ -150,9 +193,14 @@ byte lines_pos=0; ///< Position for executing line movement.
volatile byte lines_count=0; ///< Number of lines cached 0 = nothing to do.
long baudrate = BAUDRATE; ///< Communication speed rate.
#ifdef USE_ADVANCE
+#ifdef ENABLE_QUADRATIC_ADVANCE
int maxadv=0;
+#endif
+int maxadv2=0;
float maxadvspeed=0;
#endif
+byte pwm_pos[4] = {0,0,0,0}; // 0-2 = Heater 0-2 of extruder, 3 = Fan
+
#ifdef SIMULATE_FAN_PWM
int fan_speed=0;
int fan_pwm_pos=0;
@@ -316,35 +364,57 @@ void setup()
#endif
//endstop pullups
-#ifdef ENDSTOPPULLUPS
#if X_MIN_PIN>-1
- SET_INPUT(X_MIN_PIN); WRITE(X_MIN_PIN,HIGH);
+ SET_INPUT(X_MIN_PIN);
+#if ENDSTOP_PULLUP_X_MIN
+ WRITE(X_MIN_PIN,HIGH);
+#endif
#endif
#if Y_MIN_PIN>-1
- SET_INPUT(Y_MIN_PIN); WRITE(Y_MIN_PIN,HIGH);
+ SET_INPUT(Y_MIN_PIN);
+#if ENDSTOP_PULLUP_Y_MIN
+ WRITE(Y_MIN_PIN,HIGH);
+#endif
#endif
#if Z_MIN_PIN>-1
- SET_INPUT(Z_MIN_PIN); WRITE(Z_MIN_PIN,HIGH);
+ SET_INPUT(Z_MIN_PIN);
+#if ENDSTOP_PULLUP_Z_MIN
+ WRITE(Z_MIN_PIN,HIGH);
+#endif
#endif
#if X_MAX_PIN>-1
- SET_INPUT(X_MAX_PIN); WRITE(X_MAX_PIN,HIGH);
+ SET_INPUT(X_MAX_PIN);
+#if ENDSTOP_PULLUP_X_MAX
+ WRITE(X_MAX_PIN,HIGH);
+#endif
#endif
#if Y_MAX_PIN>-1
- SET_INPUT(Y_MAX_PIN); WRITE(Y_MAX_PIN,HIGH);
+ SET_INPUT(Y_MAX_PIN);
+#if ENDSTOP_PULLUP_Y_MAX
+ WRITE(Y_MAX_PIN,HIGH);
+#endif
#endif
#if Z_MAX_PIN>-1
- SET_INPUT(Z_MAX_PIN); WRITE(Z_MAX_PIN,HIGH);
+ SET_INPUT(Z_MAX_PIN);
+#if ENDSTOP_PULLUP_Z_MAX
+ WRITE(Z_MAX_PIN,HIGH);
#endif
#endif
#if FAN_PIN>-1
SET_OUTPUT(FAN_PIN);
WRITE(FAN_PIN,LOW);
#endif
-#if USE_OPS==1 || defined(USE_ADVANCE)
- printer_state.timer0Interval = 50;
- printer_state.extruderSpeed = EXTRUDER_SPEED;
-#else
- printer_state.timer0Interval = 100;
+#if EXT0_HEATER_PIN>-1
+ SET_OUTPUT(EXT0_HEATER_PIN);
+ WRITE(EXT0_HEATER_PIN,LOW);
+#endif
+#if defined(EXT1_HEATER_PIN) && EXT1_HEATER_PIN>-1
+ SET_OUTPUT(EXT1_HEATER_PIN);
+ WRITE(EXT1_HEATER_PIN,LOW);
+#endif
+#if defined(EXT2_HEATER_PIN) && EXT2_HEATER_PIN>-1
+ SET_OUTPUT(EXT2_HEATER_PIN);
+ WRITE(EXT2_HEATER_PIN,LOW);
#endif
#if USE_OPS==1
printer_state.opsMode = OPS_MODE;
@@ -355,13 +425,19 @@ void setup()
#endif
printer_state.feedrate = 3000; ///< Current feedrate in mm/min.
printer_state.feedrateMultiply = 100;
+ printer_state.extrudeMultiply = 100; // Is 10.24 * value here 100 percent)
#ifdef USE_ADVANCE
+#ifdef ENABLE_QUADRATIC_ADVANCE
printer_state.advance_executed = 0;
+#endif
printer_state.advance_steps_set = 0;
+ printer_state.advance_lin_set = 0;
#endif
printer_state.currentPositionSteps[0] = printer_state.currentPositionSteps[1] = printer_state.currentPositionSteps[2] = printer_state.currentPositionSteps[3] = 0;
printer_state.maxJerk = MAX_JERK;
printer_state.maxZJerk = MAX_ZJERK;
+ printer_state.interval = 5000;
+ printer_state.stepper_loops = 1;
printer_state.flag0 = 1;
epr_init_baudrate();
Serial.begin(baudrate);
@@ -391,8 +467,14 @@ void setup()
initsd();
#endif
+#if USE_OPS==1 || defined(USE_ADVANCE)
EXTRUDER_TCCR = 0; // need Normal not fastPWM set by arduino init
EXTRUDER_TIMSK |= (1<<EXTRUDER_OCIE); // Activate compa interrupt on timer 0
+#endif
+ PWM_TCCR = 0; // Setup PWM interrupt
+ PWM_OCR = 64;
+ PWM_TIMSK |= (1<<PWM_OCIE);
+
TCCR1A = 0; // Steup timer 1 interrupt to no prescale CTC mode
TCCR1C = 0;
TIMSK1 = 0;
@@ -479,9 +561,11 @@ void log_printLine(PrintLine *p) {
//out.println_long_P(PSTR("Acceleration Timer:"),p->facceleration);
out.println_long_P(PSTR("Remaining steps:"),p->stepsRemaining);
#ifdef USE_ADVANCE
+#ifdef ENABLE_QUADRATIC_ADVANCE
out.println_long_P(PSTR("advanceFull:"),p->advanceFull>>16);
out.println_long_P(PSTR("advanceRate:"),p->advanceRate);
#endif
+#endif
}
/** \brief Disable stepper motor for x direction. */
inline void disable_x() {
@@ -742,6 +826,9 @@ long CPUDivU2(unsigned int divisor) {
return y0-(((long)gain*(divisor & 4095))>>12);*/
}
}
+#ifdef Z_BACKSLASH
+char lastzdir=0;
+#endif
/**
\brief Sets the destination coordinates to values stored in com.
@@ -786,10 +873,29 @@ byte get_coordinates(GCode *com)
p = com->Z*25.4*axis_steps_per_unit[2];
else
p = com->Z*axis_steps_per_unit[2];
- if(relative_mode)
+ if(relative_mode) {
printer_state.destinationSteps[2] = printer_state.currentPositionSteps[2]+p;
- else
+#ifdef Z_BACKSLASH
+ if(p>0 && lastzdir!=1) {
+ lastzdir = 1;
+ printer_state.currentPositionSteps[2]-=Z_BACKSLASH*axis_steps_per_unit[2];
+ } else if(p<0 && lastzdir!=-1) {
+ lastzdir=-1;
+ printer_state.currentPositionSteps[2]+=Z_BACKSLASH*axis_steps_per_unit[2];
+ }
+#endif
+ } else {
+#ifdef Z_BACKSLASH
+ if(p>printer_state.destinationSteps[2] && lastzdir!=1) {
+ lastzdir = 1;
+ printer_state.currentPositionSteps[2]-=Z_BACKSLASH*axis_steps_per_unit[2];
+ } else if(p<printer_state.destinationSteps[2] && lastzdir!=-1) {
+ lastzdir=-1;
+ printer_state.currentPositionSteps[2]+=Z_BACKSLASH*axis_steps_per_unit[2];
+ }
+#endif
printer_state.destinationSteps[2] = p;
+ }
} else printer_state.destinationSteps[2] = printer_state.currentPositionSteps[2];
if(GCODE_HAS_E(com) && !DEBUG_DRYRUN) {
if(unit_inches)
@@ -822,8 +928,12 @@ inline float computeJerk(PrintLine *p1,PrintLine *p2) {
}
inline float safeSpeed(PrintLine *p) {
float safe = printer_state.maxJerk*0.5;
- if(p->dir & 64)
- if(abs(p->speedZ)>printer_state.maxZJerk*0.5) safe = printer_state.maxZJerk*0.5*p->fullSpeed/abs(p->speedZ);
+ if(p->dir & 64) {
+ if(abs(p->speedZ)>printer_state.maxZJerk*0.5) {
+ float safe2 = printer_state.maxZJerk*0.5*p->fullSpeed/abs(p->speedZ);
+ if(safe2<safe) safe = safe2;
+ }
+ }
return (safe<p->fullSpeed?safe:p->fullSpeed);
}
inline unsigned long U16SquaredToU32(unsigned int val) {
@@ -849,17 +959,19 @@ inline unsigned long U16SquaredToU32(unsigned int val) {
}
/** Update parameter used by
*/
-void updateStepsParameter(PrintLine *p,byte caller) {
+void updateStepsParameter(PrintLine *p/*,byte caller*/) {
if(p->flags & FLAG_WARMUP) return;
p->vStart = p->vMax*p->startFactor; //starting speed
p->vEnd = p->vMax*p->endFactor;
unsigned long vmax2 = U16SquaredToU32(p->vMax);
p->accelSteps = ((vmax2-U16SquaredToU32(p->vStart))/(p->accelerationPrim<<1))+1; // Always add 1 for missing precision
p->decelSteps = ((vmax2-U16SquaredToU32(p->vEnd))/(p->accelerationPrim<<1))+1;
#ifdef USE_ADVANCE
+#ifdef ENABLE_QUADRATIC_ADVANCE
p->advanceStart = (float)p->advanceFull*p->startFactor*p->startFactor;
p->advanceEnd = (float)p->advanceFull*p->endFactor*p->endFactor;
#endif
+#endif
if(p->accelSteps+p->decelSteps>=p->stepsRemaining) { // can't reach limit speed
unsigned int red = (p->accelSteps+p->decelSteps+2-p->stepsRemaining)>>1;
if(red<p->accelSteps)
@@ -875,7 +987,7 @@ void updateStepsParameter(PrintLine *p,byte caller) {
#ifdef DEBUG_QUEUE_MOVE
if(DEBUG_ECHO) {
out.print_int_P(PSTR("ID:"),(int)p);
- out.println_int_P(PSTR("/"),(int)caller);
+ // out.println_int_P(PSTR("/"),(int)caller);
out.print_int_P(PSTR("vStart/End:"),p->vStart);
out.println_int_P(PSTR("/"),p->vEnd);
out.print_int_P(PSTR("accel/decel steps:"),p->accelSteps);
@@ -903,7 +1015,7 @@ void finishNextSegment() {
BEGIN_INTERRUPT_PROTECTED;
p->flags |= FLAG_BLOCKED;
END_INTERRUPT_PROTECTED;
- updateStepsParameter(p,1);
+ updateStepsParameter(p/*,1*/);
p->flags &= ~FLAG_BLOCKED;
}
@@ -912,7 +1024,7 @@ void updateTrapezoids(byte p) {
PrintLine *act = &lines[p],*prev;
if(lines_count<4) {
if(!(act->joinFlags & FLAG_JOIN_STEPPARAMS_COMPUTED))
- updateStepsParameter(act,2);
+ updateStepsParameter(act/*,2*/);
return;
}
byte n=lines_count-2; // ignore active segment and following segment
@@ -925,42 +1037,45 @@ void updateTrapezoids(byte p) {
END_INTERRUPT_PROTECTED;
#if USE_OPS==1
if(printer_state.opsMode && printmoveSeen) {
- if((prev->dir & 136)==136 && (act->dir & 136)!=136) { // Switch printing - travel
- act->joinFlags |= FLAG_JOIN_START_RETRACT | FLAG_JOIN_START_FIXED; // enable retract for this point
- prev->joinFlags |= FLAG_JOIN_END_FIXED;
- updateStepsParameter(prev,4);
- updateStepsParameter(act,4);
- act->flags &= ~FLAG_BLOCKED;
- prev->flags &= ~FLAG_BLOCKED;
- return;
- }
+ if((prev->dir & 136)==136 && (act->dir & 136)!=136) {
+ if((act->dir & 64)!=0 || act->distance>printer_state.opsMinDistance) { // Switch printing - travel
+ act->joinFlags |= FLAG_JOIN_START_RETRACT | FLAG_JOIN_START_FIXED; // enable retract for this point
+ prev->joinFlags |= FLAG_JOIN_END_FIXED;
+ updateStepsParameter(prev/*,4*/);
+ updateStepsParameter(act/*,4*/);
+ act->flags &= ~FLAG_BLOCKED;
+ prev->flags &= ~FLAG_BLOCKED;
+ return;
+ } else {
+ act->joinFlags |= FLAG_JOIN_NO_RETRACT;
+ }
+ } else
if((prev->dir & 136)!=136 && (act->dir & 136)==136) { // Switch travel - print
- prev->joinFlags |= FLAG_JOIN_END_RETRACT; // reverse retract for this point
+ prev->joinFlags |= FLAG_JOIN_END_RETRACT | FLAG_JOIN_END_FIXED; // reverse retract for this point
if(printer_state.opsMode==2) {
- prev->opsReverseSteps = ((long)printer_state.opsPushbackSteps*(long)printer_state.timer0Interval*TIMER0_PRESCALE)/prev->fullInterval;
+ prev->opsReverseSteps = ((long)printer_state.opsPushbackSteps*(long)printer_state.maxExtruderSpeed*TIMER0_PRESCALE)/prev->fullInterval;
long ponr = prev->stepsRemaining/(1.0+0.01*printer_state.opsMoveAfter);
if(prev->opsReverseSteps>ponr)
prev->opsReverseSteps = ponr;
}
- if((prev->joinFlags & FLAG_JOIN_START_RETRACT) && (prev->distance<printer_state.opsMinDistance)) {
- prev->joinFlags &= ~(FLAG_JOIN_END_RETRACT | FLAG_JOIN_START_RETRACT); // Disable retract, because the distance is short
+ //if((prev->joinFlags & FLAG_JOIN_START_RETRACT) /*&& (prev->distance<printer_state.opsMinDistance)*/) {
+ /* prev->joinFlags &= ~(FLAG_JOIN_END_RETRACT | FLAG_JOIN_START_RETRACT); // Disable retract, because the distance is short
prev->joinFlags |= FLAG_JOIN_NO_RETRACT;
- } else {
+ } else {*/
act->joinFlags |= FLAG_JOIN_START_FIXED; // Wait only with safe speeds!
- prev->joinFlags |= FLAG_JOIN_END_FIXED; // Wait only with safe speeds!
- updateStepsParameter(prev,5);
- updateStepsParameter(act,5);
+ updateStepsParameter(prev/*,5*/);
+ updateStepsParameter(act/*,5*/);
act->flags &= ~FLAG_BLOCKED;
prev->flags &= ~FLAG_BLOCKED;
return;
- }
+ // }
}
}
#endif
if(prev->joinFlags & FLAG_JOIN_END_FIXED) { // Nothing to update from here on
act->joinFlags |= FLAG_JOIN_START_FIXED; // Wait only with safe speeds!
prev->flags &= ~FLAG_BLOCKED;
- updateStepsParameter(act,3);
+ updateStepsParameter(act/*,3*/);
act->flags &= ~FLAG_BLOCKED;
return;
}
@@ -980,30 +1095,34 @@ void updateTrapezoids(byte p) {
act->startFactor *= jerk;
prev->joinFlags |= FLAG_JOIN_END_FIXED;
act->joinFlags |= FLAG_JOIN_START_FIXED;
- updateStepsParameter(prev,6);
- updateStepsParameter(act,6);
+ updateStepsParameter(prev/*,6*/);
+ updateStepsParameter(act/*,6*/);
act->flags &= ~FLAG_BLOCKED;
prev->flags &= ~FLAG_BLOCKED;
return;
}
if(prev->endFactor>0.999 || act->startFactor>0.999) { // speed fixed by limit
prev->joinFlags |= FLAG_JOIN_END_FIXED;
act->joinFlags |= FLAG_JOIN_START_FIXED;
- updateStepsParameter(act,7);
- updateStepsParameter(prev,7);
+ updateStepsParameter(act/*,7*/);
+ updateStepsParameter(prev/*,7*/);
act->flags &= ~FLAG_BLOCKED;
prev->flags &= ~FLAG_BLOCKED;
return;
}
// here prev is blocked
- updateStepsParameter(act,7);
+ updateStepsParameter(act/*,7*/);
act->flags &= ~FLAG_BLOCKED; // unblock for interrupt routine
prev->joinFlags &= ~FLAG_JOIN_STEPPARAMS_COMPUTED;
act = prev;
n--;
+ if(lines_count>=MOVE_CACHE_LOW) { // we have time for checks
+ UI_MEDIUM; // do check encoder
+ check_periodical(); // Temperature update
+ }
}
if(!(act->joinFlags & FLAG_JOIN_STEPPARAMS_COMPUTED)) // Always stop with computed segments
- updateStepsParameter(act,13);
+ updateStepsParameter(act/*,13*/);
act->flags &= ~FLAG_BLOCKED;
}
void move_steps(long x,long y,long z,long e,float feedrate,bool waitEnd) {
@@ -1014,6 +1133,15 @@ void move_steps(long x,long y,long z,long e,float feedrate,bool waitEnd) {
printer_state.destinationSteps[0]+=x;
printer_state.destinationSteps[1]+=y;
printer_state.destinationSteps[2]+=z;
+#ifdef Z_BACKSLASH
+ if(z>0 && lastzdir!=1) {
+ lastzdir = 1;
+ printer_state.currentPositionSteps[2]-=Z_BACKSLASH*axis_steps_per_unit[2];
+ } else if(z<0 && lastzdir!=-1) {
+ lastzdir=-1;
+ printer_state.currentPositionSteps[2]+=Z_BACKSLASH*axis_steps_per_unit[2];
+ }
+#endif
printer_state.destinationSteps[3]+=e;
printer_state.feedrate = feedrate;
queue_move(true,false);
@@ -1086,6 +1214,7 @@ END_INTERRUPT_PROTECTED
if (printer_state.destinationSteps[2] > printer_state.zMaxSteps) printer_state.destinationSteps[2] = printer_state.zMaxSteps;
#endif
//Find direction
+#if DRIVE_SYSTEM==0
for(byte i=0; i < 4; i++) {
if((p->delta[i]=printer_state.destinationSteps[i]-printer_state.currentPositionSteps[i])>=0) {
p->dir |= 1<<i;
@@ -1097,6 +1226,37 @@ END_INTERRUPT_PROTECTED
if(p->delta[i]) p->dir |= 16<<i;
printer_state.currentPositionSteps[i] = printer_state.destinationSteps[i];
}
+#else
+ long deltax = printer_state.destinationSteps[0]-printer_state.currentPositionSteps[0];
+ long deltay = printer_state.destinationSteps[1]-printer_state.currentPositionSteps[1];
+#if DRIVE_SYSTEM==1
+ p->delta[2] = printer_state.destinationSteps[2]-printer_state.currentPositionSteps[2];
+ p->delta[3] = printer_state.destinationSteps[3]-printer_state.currentPositionSteps[3];
+ p->delta[0] = deltax+deltay;
+ p->delta[1] = deltax-deltay;
+#endif
+#if DRIVE_SYSTEM==2
+p->delta[2] = printer_state.destinationSteps[2]-printer_state.currentPositionSteps[2];
+p->delta[3] = printer_state.destinationSteps[3]-printer_state.currentPositionSteps[3];
+p->delta[0] = deltay+deltax;
+p->delta[1] = deltay-deltax;
+#endif
+ //Find direction
+ for(byte i=0; i < 4; i++) {
+ if(p->delta[i]>=0) {
+ p->dir |= 1<<i;
+ axis_diff[i] = p->delta[i]*inv_axis_steps_per_unit[i];
+ } else {
+ axis_diff[i] = p->delta[i]*inv_axis_steps_per_unit[i];
+ p->delta[i] = -p->delta[i];
+ }
+ if(p->delta[i]) p->dir |= 16<<i;
+ printer_state.currentPositionSteps[i] = printer_state.destinationSteps[i];
+ }
+#endif
+ if(printer_state.extrudeMultiply!=100) {
+ p->delta[3]=(p->delta[3]*printer_state.extrudeMultiply)/100;
+ }
if(!(p->dir & 240)) {
if(newPath) { // need to delete dummy elements, otherwise commands can get locked.
lines_count = 0;
@@ -1133,6 +1293,7 @@ END_INTERRUPT_PROTECTED
time_for_move = LOW_TICKS_PER_MOVE;
critical=true;
}
+ UI_MEDIUM; // do check encoder
// Compute the solwest allowed interval (ticks/step), so maximum feedrate is not violated
long limitInterval = time_for_move/p->stepsRemaining; // until not violated by other constraints it is your target speed
axis_interval[0] = 60.0*abs(axis_diff[0])*F_CPU/(max_feedrate[0]*p->stepsRemaining); // mm*ticks/s/(mm/s*steps) = ticks/step
@@ -1196,17 +1357,28 @@ END_INTERRUPT_PROTECTED
//p->plateauN = (p->vMax*p->vMax/p->accelerationPrim)>>1;
#ifdef USE_ADVANCE
if((p->dir & 112)==0 || (p->dir & 128)==0 || (p->dir & 8)==0) {
+#ifdef ENABLE_QUADRATIC_ADVANCE
p->advanceRate = 0; // No head move or E move only or sucking filament back
p->advanceFull = 0;
+#endif
+ p->advanceL = 0;
} else {
float speedE = axis_diff[3]*inv_time_s; // [mm/s]
+ float advlin = speedE*current_extruder->advanceL*0.001*axis_steps_per_unit[3];
+ p->advanceL = (65536*advlin)/p->vMax; //advanceLscaled = (65536*vE*k2)/vMax
+ #ifdef ENABLE_QUADRATIC_ADVANCE;
p->advanceFull = 65536*current_extruder->advanceK*speedE*speedE; // Steps*65536 at full speed
long steps = (U16SquaredToU32(p->vMax))/(p->accelerationPrim<<1); // v^2/(2*a) = steps needed to accelerate from 0-vMax
p->advanceRate = p->advanceFull/steps;
if((p->advanceFull>>16)>maxadv) {
maxadv = (p->advanceFull>>16);
maxadvspeed = speedE;
- }
+ }
+ #endif
+ if(advlin>maxadv2) {
+ maxadv2 = advlin;
+ maxadvspeed = speedE;
+ }
}
#endif
UI_MEDIUM; // do check encoder
@@ -1216,10 +1388,12 @@ END_INTERRUPT_PROTECTED
//p->plateauSteps = (long) (((float)p->acceleration *0.5f / slowest_axis_plateau_time_repro + p->vMin) *1.01f/slowest_axis_plateau_time_repro);
#else
#ifdef USE_ADVANCE
+ #ifdef ENABLE_QUADRATIC_ADVANCE
p->advanceRate = 0; // No advance for constant speeds
p->advanceFull = 0;
#endif
#endif
+ #endif
// Correct integers for fixed point math used in bresenham_step
if(p->fullInterval<MAX_HALFSTEP_INTERVAL || critical)
@@ -1294,6 +1468,59 @@ inline unsigned int ComputeV(long timer,long accel) {
// unsigned int v = ((timer>>8)*cur->accel)>>10;
return res;
}
+// Multiply two 16 bit values and return 32 bit result
+inline unsigned long mulu6xu16to32(unsigned int a,unsigned int b) {
+ unsigned long res;
+ // 18 Ticks = 1.125 us
+ __asm__ __volatile__ ( // 0 = res, 1 = timer, 2 = accel %D2=0 ,%A1 are unused is free
+ // Result LSB first: %A0, %B0, %A1
+ "clr r18 \n\t"
+ "mul %B2,%B1 \n\t" // mul hig bytes
+ "movw %C0,r0 \n\t"
+ "mul %A1,%A2 \n\t" // mul low bytes
+ "movw %A0,r0 \n\t"
+ "mul %A1,%B2 \n\t"
+ "add %B0,r0 \n\t"
+ "adc %C0,r1 \n\t"
+ "adc %D0,r18 \n\t"
+ "mul %B1,%A2 \n\t"
+ "add %B0,r0 \n\t"
+ "adc %C0,r1 \n\t"
+ "adc %D0,r18 \n\t"
+ "clr r1 \n\t"
+ :"=&r"(res),"=r"(a),"=r"(b)
+ :"1"(a),"2"(b)
+ :"r18" );
+ // return (long)a*b;
+ return res;
+}
+// Multiply two 16 bit values and return 32 bit result
+inline unsigned int mulu6xu16shift16(unsigned int a,unsigned int b) {
+ unsigned int res;
+ // 18 Ticks = 1.125 us
+ __asm__ __volatile__ ( // 0 = res, 1 = timer, 2 = accel %D2=0 ,%A1 are unused is free
+ // Result LSB first: %A0, %B0, %A1
+ "clr r18 \n\t"
+ "mul %B2,%B1 \n\t" // mul hig bytes
+ "movw %A0,r0 \n\t"
+ "mul %A1,%A2 \n\t" // mul low bytes
+ "mov r19,r1 \n\t"
+ "mul %A1,%B2 \n\t"
+ "add r19,r0 \n\t"
+ "adc %A0,r1 \n\t"
+ "adc %B0,r18 \n\t"
+ "mul %B1,%A2 \n\t"
+ "add r19,r0 \n\t"
+ "adc %A0,r1 \n\t"
+ "adc %B0,r18 \n\t"
+ "clr r1 \n\t"
+ :"=&r"(res),"=r"(a),"=r"(b)
+ :"1"(a),"2"(b)
+ :"r18","r19" );
+ // return ((long)a*b)>>16;
+ return res;
+}
+
/**
Moves the stepper motors one step. If the last step is reached, the next movement is started.
The function must be called from a timer loop. It returns the time for the next call.
@@ -1390,7 +1617,7 @@ inline long bresenham_step() {
// If path optimizer ran out of samples, he might miss some retractions. Solve them before printing
else if((cur->joinFlags & FLAG_JOIN_NO_RETRACT)==0 && printmoveSeen) {
if((cur->dir & 136)==136) {
- if(printer_state.filamentRetracted) { // Printmove and filament is up!
+ if(printer_state.filamentRetracted) { // Printmove and filament is still up!
#ifdef DEBUG_OPS
out.println_P(PSTR("DownA"));
#endif
@@ -1399,15 +1626,15 @@ inline long bresenham_step() {
printer_state.extruderStepsNeeded+=printer_state.opsPushbackSteps;
cur->joinFlags |= FLAG_JOIN_WAIT_EXTRUDER_DOWN;
}
- } else if(!printer_state.filamentRetracted) {
+ } /*else if(!printer_state.filamentRetracted) {
#ifdef DEBUG_OPS
out.println_P(PSTR("UpA"));
#endif
printer_state.filamentRetracted = true;
cli();
printer_state.extruderStepsNeeded-=printer_state.opsRetractSteps;
cur->joinFlags |= FLAG_JOIN_WAIT_EXTRUDER_UP;
- }
+ }*/
}
if(cur->joinFlags & FLAG_JOIN_WAIT_EXTRUDER_UP) { // Wait for filament pushback
cli();
@@ -1431,7 +1658,7 @@ inline long bresenham_step() {
} else
cur_errupd = cur->delta[cur->primaryAxis];
if(!(cur->joinFlags & FLAG_JOIN_STEPPARAMS_COMPUTED)) {// should never happen, but with bad timings???
- updateStepsParameter(cur,8);
+ updateStepsParameter(cur/*,8*/);
}
printer_state.vMaxReached = cur->vStart;
printer_state.stepNumber=0;
@@ -1461,11 +1688,17 @@ inline long bresenham_step() {
}
#endif
#ifdef USE_ADVANCE
- int tred = cur->advanceStart>>16;
- printer_state.extruderStepsNeeded+=tred-printer_state.advance_steps_set;
+ long h = mulu6xu16to32(cur->vStart,cur->advanceL);
+ int tred = ((
+#ifdef ENABLE_QUADRATIC_ADVANCE
printer_state.advance_executed = cur->advanceStart;
+ cur->advanceStart+
+#endif
+ h)>>16);
+ printer_state.extruderStepsNeeded+=tred-printer_state.advance_steps_set;
printer_state.advance_steps_set = tred;
#endif
+ return printer_state.interval; // Wait an other 50% fro last step to make the 100% full
} // End cur=0
sei();
/* For halfstepping, we divide the actions into even and odd actions to split
@@ -1484,16 +1717,40 @@ inline long bresenham_step() {
if(do_even) {
if(cur->flags & FLAG_CHECK_ENDSTOPS) {
#if X_MIN_PIN>-1
- if((cur->dir & 17)==16) if(READ(X_MIN_PIN) != ENDSTOP_X_MIN_INVERTING) {cur->dir&=~16;}
+ if((cur->dir & 17)==16) if(READ(X_MIN_PIN) != ENDSTOP_X_MIN_INVERTING) {
+#if DRIVE_SYSTEM==0
+ cur->dir&=~16;
+#else
+ cur->dir&=~48;
+#endif
+ }
#endif
#if Y_MIN_PIN>-1
- if((cur->dir & 34)==32) if(READ(Y_MIN_PIN) != ENDSTOP_Y_MIN_INVERTING) {cur->dir&=~32;}
+ if((cur->dir & 34)==32) if(READ(Y_MIN_PIN) != ENDSTOP_Y_MIN_INVERTING) {
+#if DRIVE_SYSTEM==0
+ cur->dir&=~32;
+#else
+ cur->dir&=~48;
+#endif
+ }
#endif
#if X_MAX_PIN>-1
- if((cur->dir & 17)==17) if(READ(X_MAX_PIN) != ENDSTOP_X_MAX_INVERTING) {cur->dir&=~16;}
+ if((cur->dir & 17)==17) if(READ(X_MAX_PIN) != ENDSTOP_X_MAX_INVERTING) {
+#if DRIVE_SYSTEM==0
+ cur->dir&=~16;
+#else
+ cur->dir&=~48;
+#endif
+ }
#endif
#if Y_MAX_PIN>-1
- if((cur->dir & 34)==34) if(READ(Y_MAX_PIN) != ENDSTOP_Y_MAX_INVERTING) {cur->dir&=~32;}
+ if((cur->dir & 34)==34) if(READ(Y_MAX_PIN) != ENDSTOP_Y_MAX_INVERTING) {
+#if DRIVE_SYSTEM==0
+ cur->dir&=~32;
+#else
+ cur->dir&=~48;
+#endif
+ }
#endif
}
// Test Z-Axis every step if necessary, otherwise it could easyly ruin your printer!
@@ -1504,8 +1761,16 @@ inline long bresenham_step() {
if((cur->dir & 68)==68) if(READ(Z_MAX_PIN)!= ENDSTOP_Z_MAX_INVERTING) {cur->dir&=~64;}
#endif
}
+ byte max_loops = (printer_state.stepper_loops<=cur->stepsRemaining ? printer_state.stepper_loops : cur->stepsRemaining);
if(cur->stepsRemaining>0) {
- if(cur->dir & 128) {
+ for(byte loop=0;loop<max_loops;loop++) {
+ if(loop>0)
+#if STEPPER_HIGH_DELAY>0
+ delayMicroseconds(STEPPER_HIGH_DELAY+DOUBLE_STEP_DELAY);
+#else
+ delayMicroseconds(DOUBLE_STEP_DELAY);
+#endif
+ if(cur->dir & 128) {
if((cur->error[3] -= cur->delta[3]) < 0) {
#if USE_OPS==1 || defined(USE_ADVANCE)
if(cur->dir & 8)
@@ -1542,31 +1807,62 @@ inline long bresenham_step() {
cur->error[2] += cur_errupd;
}
}
- WRITE(X_STEP_PIN,LOW);
- WRITE(Y_STEP_PIN,LOW);
- WRITE(Z_STEP_PIN,LOW);
+#if STEPPER_HIGH_DELAY>0
+ delayMicroseconds(STEPPER_HIGH_DELAY);
+#endif
#if USE_OPS==0 && !defined(USE_ADVANCE)
extruder_unstep();
#endif
+ WRITE(X_STEP_PIN,LOW);
+ WRITE(Y_STEP_PIN,LOW);
+ WRITE(Z_STEP_PIN,LOW);
+ } // for loop
if(do_odd) {
sei(); // Allow interrupts for other types, timer1 is still disabled
#ifdef RAMP_ACCELERATION
//If acceleration is enabled on this move and we are in the acceleration segment, calculate the current interval
if (printer_state.stepNumber <= cur->accelSteps) { // we are accelerating
printer_state.vMaxReached = ComputeV(printer_state.timer,cur->facceleration)+cur->vStart;
if(printer_state.vMaxReached>cur->vMax) printer_state.vMaxReached = cur->vMax;
- printer_state.interval = CPUDivU2(printer_state.vMaxReached);
+ unsigned int v;
+ if(printer_state.vMaxReached>STEP_DOUBLER_FREQUENCY) {
+ #if ALLOW_QUADSTEPPING
+ if(printer_state.vMaxReached>STEP_DOUBLER_FREQUENCY*2) {
+ printer_state.stepper_loops = 4;
+ v = printer_state.vMaxReached>>2;
+ } else {
+ printer_state.stepper_loops = 2;
+ v = printer_state.vMaxReached>>1;
+ }
+ #else
+ printer_state.stepper_loops = 2;
+ v = printer_state.vMaxReached>>1;
+ #endif
+ } else {
+ printer_state.stepper_loops = 1;
+ v = printer_state.vMaxReached;
+ }
+ printer_state.interval = CPUDivU2(v);
printer_state.timer+=printer_state.interval;
#ifdef USE_ADVANCE
+#ifdef ENABLE_QUADRATIC_ADVANCE
long advance_target =printer_state.advance_executed+cur->advanceRate;
+ for(byte loop=1;loop<max_loops;loop++) advance_target+=cur->advanceRate;
if(advance_target>cur->advanceFull)
advance_target = cur->advanceFull;
cli();
- int tred = (advance_target>>16);
+ long h = mulu6xu16to32(printer_state.vMaxReached,cur->advanceL);
+ int tred = ((advance_target+h)>>16);
printer_state.extruderStepsNeeded+=tred-printer_state.advance_steps_set;
printer_state.advance_steps_set = tred;
sei();
printer_state.advance_executed = advance_target;
+#else
+ int tred = mulu6xu16shift16(printer_state.vMaxReached,cur->advanceL);
+ printer_state.extruderStepsNeeded+=tred-printer_state.advance_steps_set;
+ printer_state.advance_steps_set = tred;
+ sei();
+#endif
#endif
} else if (cur->stepsRemaining <= cur->decelSteps) { // time to slow down
if (!(cur->flags & FLAG_DECELERATING)) {
@@ -1575,34 +1871,102 @@ inline long bresenham_step() {
}
unsigned int v = ComputeV(printer_state.timer,cur->facceleration);
if (v > printer_state.vMaxReached) // if deceleration goes too far it can become too large
- printer_state.interval = CPUDivU2(cur->vEnd);
+ v = cur->vEnd;
else{
v=printer_state.vMaxReached-v;
if (v<cur->vEnd) v = cur->vEnd; // extra steps at the end of desceleration due to rounding erros
- printer_state.interval = CPUDivU2(v);
}
+ if(v>STEP_DOUBLER_FREQUENCY) {
+#if ALLOW_QUADSTEPPING
+ if(v>STEP_DOUBLER_FREQUENCY*2) {
+ printer_state.stepper_loops = 4;
+ v = v>>2;
+ } else {
+ printer_state.stepper_loops = 2;
+ v = v>>1;
+ }
+#else
+ printer_state.stepper_loops = 2;
+ v = v>>1;
+#endif
+ } else {
+ printer_state.stepper_loops = 1;
+ }
+ printer_state.interval = CPUDivU2(v);
printer_state.timer+=printer_state.interval;
#ifdef USE_ADVANCE
+#ifdef ENABLE_QUADRATIC_ADVANCE
long advance_target =printer_state.advance_executed-cur->advanceRate;
+ for(byte loop=1;loop<max_loops;loop++) advance_target-=cur->advanceRate;
if(advance_target<cur->advanceEnd)
advance_target = cur->advanceEnd;
- int tred = (advance_target>>16);
+ long h=mulu6xu16to32(cur->advanceL,v);
+ int tred = ((advance_target+h)>>16);
cli();
printer_state.extruderStepsNeeded+=tred-printer_state.advance_steps_set;
printer_state.advance_steps_set = tred;
sei();
printer_state.advance_executed = advance_target;
+#else
+ int tred=mulu6xu16shift16(cur->advanceL,v);
+ cli();
+ printer_state.extruderStepsNeeded+=tred-printer_state.advance_steps_set;
+ printer_state.advance_steps_set = tred;
+ sei();
+#endif
#endif
} else {
- printer_state.interval = cur->fullInterval;
+ // If we had acceleration, we need to use the latest vMaxReached and interval
+ // If we started full speed, we need to use cur->fullInterval and vMax
+#ifdef USE_ADVANCE
+ unsigned int v;
+ if(!cur->accelSteps) {
+ v = cur->vMax;
+ } else {
+ v = printer_state.vMaxReached;
+ }
+#ifdef ENABLE_QUADRATIC_ADVANCE
+ long h=mulu6xu16to32(cur->advanceL,v);
+ int tred = ((advance_target+h)>>16);
+ cli();
+ printer_state.extruderStepsNeeded+=tred-printer_state.advance_steps_set;
+ printer_state.advance_steps_set = tred;
+ sei();
+#else
+ int tred=mulu6xu16shift16(cur->advanceL,v);
+ cli();
+ printer_state.extruderStepsNeeded+=tred-printer_state.advance_steps_set;
+ printer_state.advance_steps_set = tred;
+ sei();
+#endif
+#endif
+ if(!cur->accelSteps) {
+ if(cur->vMax>STEP_DOUBLER_FREQUENCY) {
+#if ALLOW_QUADSTEPPING
+ if(cur->vMax>STEP_DOUBLER_FREQUENCY*2) {
+ printer_state.stepper_loops = 4;
+ printer_state.interval = cur->fullInterval>>2;
+ } else {
+ printer_state.stepper_loops = 2;
+ printer_state.interval = cur->fullInterval>>1;
+ }
+#else
+ printer_state.stepper_loops = 2;
+ printer_state.interval = cur->fullInterval>>1;
+#endif
+ } else {
+ printer_state.stepper_loops = 1;
+ printer_state.interval = cur->fullInterval;
+ }
+ }
}
#else
printer_state.interval = cur->fullInterval; // without RAMPS always use full speed
#endif
} // do_odd
if(do_even) {
- printer_state.stepNumber++;
- cur->stepsRemaining--;
+ printer_state.stepNumber+=max_loops;
+ cur->stepsRemaining-=max_loops;
}
#if USE_OPS==1
@@ -1664,6 +2028,7 @@ inline long bresenham_step() {
if(DISABLE_Y) disable_y();
if(DISABLE_Z) disable_z();
if(lines_count==0) UI_STATUS(UI_TEXT_IDLE);
+ interval = printer_state.interval = interval>>1; // 50% of time to next call to do cur=0
}
#ifdef DEBUG_FREE_MEMORY
check_mem();
@@ -1688,6 +2053,9 @@ void kill(byte only_steppers)
#if NUM_EXTRUDER>1
extruder_set_temperature(0,1);
#endif
+ #if NUM_EXTRUDER>2
+ extruder_set_temperature(0,2);
+ #endif
heated_bed_set_temperature(0);
UI_STATUS_UPD(UI_TEXT_KILLED);
if(PS_ON_PIN > -1) {
@@ -1804,9 +2172,11 @@ ISR(TIMER1_COMPA_vect)
printmoveSeen = 0;
#endif
#ifdef USE_ADVANCE
- if(printer_state.advance_executed>0) {
+ if(printer_state.advance_steps_set) {
printer_state.extruderStepsNeeded-=printer_state.advance_steps_set;
+#ifdef ENABLE_QUADRATIC_ADVANCE
printer_state.advance_executed = 0;
+#endif
printer_state.advance_steps_set = 0;
}
#endif
@@ -1828,7 +2198,10 @@ ISR(TIMER1_COMPA_vect)
#if USE_OPS==1 || defined(USE_ADVANCE)
byte extruder_wait_dirchange=0; ///< Wait cycles, if direction changes. Prevents stepper from loosing steps.
char extruder_last_dir = 0;
+byte extruder_speed = 0;
#endif
+
+
/** \brief Timer routine for extruder stepper.
Several methods need to move the extruder. To get a optima result,
@@ -1840,13 +2213,44 @@ allowable speed for the extruder.
*/
ISR(EXTRUDER_TIMER_VECTOR)
{
- EXTRUDER_OCR += printer_state.timer0Interval; // time to come back
- counter_periodical+= printer_state.timer0Interval; // Appxoimate a 10ms timer
- if(counter_periodical>OVERFLOW_PERIODICAL) {
- counter_periodical-=OVERFLOW_PERIODICAL;
- execute_periodical=1;
- }
#if USE_OPS==1 || defined(USE_ADVANCE)
+ static byte extruder_mode=1;
+ static byte accdelay=10;
+ byte timer = EXTRUDER_OCR;
+ byte wait; // Time to wait until next interrupt
+ bool increasing = printer_state.extruderStepsNeeded>0;
+ if(printer_state.extruderStepsNeeded==0) {
+ extruder_last_dir = 0;
+ extruder_mode = 1;
+ extruder_speed=printer_state.minExtruderSpeed;
+ accdelay =printer_state.extruderAccelerateDelay;
+ EXTRUDER_OCR = timer+50; // 5000 Hz wait timer
+ } else if((increasing>0 && extruder_last_dir<0) || (!increasing && extruder_last_dir>0)) {
+ extruder_mode = 1;
+ EXTRUDER_OCR = timer+150; // Little delay to accomodate to reversed direction
+ extruder_last_dir = (increasing ? 1 : -1);
+ extruder_set_direction(increasing ? 1 : 0);
+ } else {
+ if(extruder_last_dir==0) {
+ extruder_last_dir = (increasing ? 1 : -1);
+ extruder_set_direction(increasing ? 1 : 0);
+ }
+ extruder_step();
+ printer_state.extruderStepsNeeded-=extruder_last_dir;
+ if(extruder_speed>printer_state.maxExtruderSpeed) { // We can accelerate
+ if(--accdelay==0) {
+ accdelay = printer_state.extruderAccelerateDelay;
+ extruder_speed--;
+ }
+ }
+#if STEPPER_HIGH_DELAY>0
+ delayMicroseconds(STEPPER_HIGH_DELAY);
+#endif
+ EXTRUDER_OCR = timer+extruder_speed;
+ extruder_unstep();
+ }
+/*
+ EXTRUDER_OCR += printer_state.timer0Interval; // time to come back
// The stepper signals are in strategical positions for optimal timing. If you
// still have timing issues, add dummy commands between.
if(printer_state.extruderStepsNeeded) {
@@ -1875,79 +2279,88 @@ ISR(EXTRUDER_TIMER_VECTOR)
} else {
if(extruder_wait_dirchange)
extruder_wait_dirchange--;
- }
+ }*/
+#endif
+}
+
+/**
+This timer is called 1953 timer per second. It is used to update pwm values for heater and some other frequent jobs.
+*/
+ISR(PWM_TIMER_VECTOR)
+{
+ static byte pwm_count = 0;
+ static byte pwm_pos_set[4];
+ PWM_OCR += 128;
+ if(pwm_count==0) {
+#if EXT0_HEATER_PIN>-1
+ if((pwm_pos_set[0] = pwm_pos[0])>0) WRITE(EXT0_HEATER_PIN,1);
+#endif
+#if defined(EXT1_HEATER_PIN) && EXT1_HEATER_PIN>-1
+ if((pwm_pos_set[1] = pwm_pos[1])>0) WRITE(EXT1_HEATER_PIN,1);
+#endif
+#if defined(EXT2_HEATER_PIN) && EXT2_HEATER_PIN>-1
+ if((pwm_pos_set[2] = pwm_pos[2])>0) WRITE(EXT2_HEATER_PIN,1);
+#endif
+#if FAN_PIN>-1
+ if((pwm_pos_set[3] = pwm_pos[3])>0) WRITE(FAN_PIN,1);
#endif
-#ifdef SIMULATE_PWM
- // Sanguino boards have the heater output on a pin with PWM for
- // timer 1. This software pwm solves the problem with the timer
- // already in use.
-#if NUM_EXTRUDER==1
- Extruder *ext = &extruder[0];
- if(ext->heatManager) { // Extruder with pid control found
- if(ext->pwmState<=ext->pwm) {
- ext->pwmState+=printer_state.timer0Interval;
- if(ext->pwmState>=2040) {
- ext->pwmState=0;
- WRITE(EXT0_HEATER_PIN,1 );
- } else if(ext->pwmState>ext->pwm) {
- WRITE(EXT0_HEATER_PIN,0 );
- }
- } else {
- ext->pwmState+=printer_state.timer0Interval;
- if(ext->pwmState>=2040) {
- ext->pwmState=0;
- if(ext->pwm>0) { // Turn only on for values > 0
- WRITE(EXT0_HEATER_PIN,1 );
- }
- }
- }
}
-#else
- for(byte e=0;e<NUM_EXTRUDER;e++) {
- Extruder *ext = &extruder[e];
- if(ext->heatManager) { // Extruder with pid control found
- if(ext->pwmState<=ext->pwm) {
- ext->pwmState+=printer_state.timer0Interval;
- if(ext->pwmState>=2040) {
- ext->pwmState=0;
- digitalWrite(ext->heaterPin,on);
- } else if(ext->pwmState>ext->pwm) {
- digitalWrite(ext->heaterPin,off);
- }
- } else {
- ext->pwmState+=printer_state.timer0Interval;
- if(ext->pwmState>=2040) {
- ext->pwmState=0;
- if(ext->pwm) { // Turn only on for values > 0
- digitalWrite(ext->heaterPin,on);
- }
- }
- }
- }
+#if EXT0_HEATER_PIN>-1
+ if(pwm_pos_set[0] == pwm_count) WRITE(EXT0_HEATER_PIN,0);
+#endif
+#if defined(EXT1_HEATER_PIN) && EXT1_HEATER_PIN>-1
+ if(pwm_pos_set[1] == pwm_count) WRITE(EXT1_HEATER_PIN,0);
+#endif
+#if defined(EXT2_HEATER_PIN) && EXT2_HEATER_PIN>-1
+ if(pwm_pos_set[2] == pwm_count) WRITE(EXT2_HEATER_PIN,0);
+#endif
+#if FAN_PIN>-1
+ if(pwm_pos_set[3] == pwm_count) WRITE(FAN_PIN,0);
+#endif
+ sei();
+ counter_periodical++; // Appxoimate a 25ms timer
+ if(counter_periodical>=49) {
+ counter_periodical=0;
+ execute_periodical=1;
}
+// read analog values
+#if ANALOG_INPUTS>0
+if((ADCSRA & _BV(ADSC))==0) { // Conversion finished?
+ osAnalogInputBuildup[osAnalogInputPos] += ADCW;
+ if(++osAnalogInputCounter[osAnalogInputPos]>=_BV(ANALOG_INPUT_SAMPLE)) {
+#if ANALOG_INPUT_BITS+ANALOG_INPUT_SAMPLE<12
+ osAnalogInputValues[osAnalogInputPos] =
+ osAnalogInputBuildup[osAnalogInputPos] <<
+ (12-ANALOG_INPUT_BITS-ANALOG_INPUT_SAMPLE);
+#endif
+#if ANALOG_INPUT_BITS+ANALOG_INPUT_SAMPLE>12
+ osAnalogInputValues[osAnalogInputPos] =
+ osAnalogInputBuildup[osAnalogInputPos] >>
+ (ANALOG_INPUT_BITS+ANALOG_INPUT_SAMPLE-12);
+#endif
+#if ANALOG_INPUT_BITS+ANALOG_INPUT_SAMPLE==12
+ osAnalogInputValues[osAnalogInputPos] =
+ osAnalogInputBuildup[osAnalogInputPos];
+#endif
+ osAnalogInputBuildup[osAnalogInputPos] = 0;
+ osAnalogInputCounter[osAnalogInputPos] = 0;
+ // Start next conversion
+ if(++osAnalogInputPos>=ANALOG_INPUTS) osAnalogInputPos = 0;
+ byte channel = pgm_read_byte(&osAnalogInputChannels[osAnalogInputPos]);
+#if defined(ADCSRB) && defined(MUX5)
+ if(channel & 8) // Reading channel 0-7 or 8-15?
+ ADCSRB |= _BV(MUX5);
+ else
+ ADCSRB &= ~_BV(MUX5);
#endif
-#endif // SIMULATE_PWM
-#ifdef SIMULATE_FAN_PWM
- // If your fan output has no pwm or pwm is blocked by this interrupt routine
- if(fan_pwm_pos<=fan_speed) {
- fan_pwm_pos+=printer_state.timer0Interval;
- if(fan_pwm_pos>=4080) {
- fan_pwm_pos=0;
- WRITE(FAN_PIN,1 );
- } else if(fan_pwm_pos>fan_speed) {
- WRITE(FAN_PIN,0 );
- }
- } else {
- fan_pwm_pos+=printer_state.timer0Interval;
- if(fan_pwm_pos>=4080) {
- fan_pwm_pos=0;
- if(fan_speed>0) { // Turn only on for values > 0
- WRITE(FAN_PIN,1 );
- }
- }
+ ADMUX = (ADMUX & ~(0x1F)) | (channel & 7);
+ }
+ ADCSRA |= _BV(ADSC); // start next conversion
}
#endif
+
UI_FAST; // Short timed user interface action
+ pwm_count++;
}
-
+
View
118 Repetier/Reptier.h
@@ -32,14 +32,15 @@
#include "SdFat.h"
extern void initsd();
#endif
+#define REPETIER_VERSION "0.70"
#define uint uint16_t
#define uint8 uint8_t
#define int8 int8_t
#define uint32 uint32_t
#define int32 int32_t
-#if MOTHERBOARD==6 || MOTHERBOARD==62 || MOTHERBOARD==7
+/*#if MOTHERBOARD==6 || MOTHERBOARD==62 || MOTHERBOARD==7
#if MOTHERBOARD!=7
#define SIMULATE_PWM
#endif
@@ -48,13 +49,23 @@ extern void initsd();
#define EXTRUDER_TCCR TCCR2A
#define EXTRUDER_TIMSK TIMSK2
#define EXTRUDER_OCIE OCIE2A
-#else
+#define PWM_TIMER_VECTOR TIMER2_COMPB_vect
+#define PWM_OCR OCR2B
+#define PWM_TCCR TCCR2B
+#define PWM_TIMSK TIMSK2
+#define PWM_OCIE OCIE2B
+#else*/
#define EXTRUDER_TIMER_VECTOR TIMER0_COMPA_vect
#define EXTRUDER_OCR OCR0A
#define EXTRUDER_TCCR TCCR0A
#define EXTRUDER_TIMSK TIMSK0
#define EXTRUDER_OCIE OCIE0A
-#endif
+#define PWM_TIMER_VECTOR TIMER0_COMPB_vect
+#define PWM_OCR OCR0B
+#define PWM_TCCR TCCR0A
+#define PWM_TIMSK TIMSK0
+#define PWM_OCIE OCIE0B
+//#endif
/** \brief Data to drive one extruder.
@@ -68,12 +79,11 @@ typedef struct { // Size: 12*1 Byte+12*4 Byte+4*2Byte = 68 Byte
float stepsPerMM; ///< Steps per mm.
byte sensorType; ///< Type of temperature sensor.
byte sensorPin; ///< Pin to read extruder temperature.
- byte heaterPin; ///< Pin to enable the heater.
byte enablePin; ///< Pin to enable extruder stepper motor.
- byte directionPin; ///< Pin number to assign the direction.
- byte stepPin; ///< Pin number for a step.
+// byte directionPin; ///< Pin number to assign the direction.
+// byte stepPin; ///< Pin number for a step.
byte enableOn;
- byte invertDir; ///< 1 if the direction of the extruder should be inverted.
+// byte invertDir; ///< 1 if the direction of the extruder should be inverted.
float maxFeedrate;
float maxAcceleration; ///< Maximum acceleration in mm/s^2.
float maxStartFeedrate; ///< Maximum start feedrate in mm/s.
@@ -85,8 +95,13 @@ typedef struct { // Size: 12*1 Byte+12*4 Byte+4*2Byte = 68 Byte
long lastTemperatureUpdate; ///< Time in millis of the last temperature update.
char heatManager; ///< How is temperature controled. 0 = on/off, 1 = PID-Control
int watchPeriod; ///< Time in seconds, a M109 command will wait to stabalize temperature
+#ifdef USE_ADVANCE
+#ifdef ENABLE_QUADRATIC_ADVANCE
float advanceK; ///< Koefficient for advance algorithm. 0 = off
- byte output; ///< Output value 0 = off, 255=MAX
+#endif
+ float advanceL;
+#endif
+ // byte output; ///< Output value 0 = off, 255=MAX
#ifdef TEMP_PID
long tempIState; ///< Temp. var. for PID computation.
byte pidDriveMax; ///< Used for windup in PID calculation.
@@ -99,21 +114,25 @@ typedef struct { // Size: 12*1 Byte+12*4 Byte+4*2Byte = 68 Byte
long tempIStateLimitMin;
byte tempPointer;
int tempArray[8];
-#ifdef SIMULATE_PWM
- int pwm; // Switch of at this timing
- int pwmState; // Current timing
-#endif
#endif
} Extruder;
-
+extern const uint8 osAnalogInputChannels[] PROGMEM;
+extern uint8 osAnalogInputCounter[ANALOG_INPUTS];
+extern uint osAnalogInputBuildup[ANALOG_INPUTS];
+extern uint8 osAnalogInputPos; // Current sampling position
+extern volatile uint osAnalogInputValues[ANALOG_INPUTS];
+extern byte pwm_pos[4]; // 0-2 = Heater 0-2 of extruder, 3 = Fan
extern int target_bed_celsius;
#if HEATED_BED_SENSOR_TYPE!=0
extern int current_bed_raw;
extern int target_bed_raw;
#endif
#ifdef USE_ADVANCE
+#ifdef ENABLE_QUADRATIC_ADVANCE
extern int maxadv;
+#endif
+extern int maxadv2;
extern float maxadvspeed;
#endif
@@ -145,7 +164,21 @@ inline void extruder_step() {
#if NUM_EXTRUDER==1
WRITE(EXT0_STEP_PIN,HIGH);
#else
- digitalWrite(current_extruder->stepPin,HIGH);
+ switch(current_extruder->id) {
+ case 0:
+ WRITE(EXT0_STEP_PIN,HIGH);
+ break;
+#ifdef EXT1_STEP_PIN
+ case 1:
+ WRITE(EXT1_STEP_PIN,HIGH);
+ break;
+#endif
+#ifdef EXT2_STEP_PIN
+ case 2:
+ WRITE(EXT2_STEP_PIN,HIGH);
+ break;
+#endif
+ }
#endif
}
/** \brief Sets stepper signal to low for current extruder.
@@ -156,7 +189,21 @@ inline void extruder_unstep() {
#if NUM_EXTRUDER==1
WRITE(EXT0_STEP_PIN,LOW);
#else
- digitalWrite(current_extruder->stepPin,LOW);
+ switch(current_extruder->id) {
+ case 0:
+ WRITE(EXT0_STEP_PIN,LOW);
+ break;
+#ifdef EXT1_STEP_PIN
+ case 1:
+ WRITE(EXT1_STEP_PIN,LOW);
+ break;
+#endif
+#ifdef EXT2_STEP_PIN
+ case 2:
+ WRITE(EXT2_STEP_PIN,LOW);
+ break;
+#endif
+ }
#endif
}
/** \brief Activates the extruder stepper and sets the direction. */
@@ -167,6 +214,31 @@ inline void extruder_set_direction(byte dir) {
else
WRITE(EXT0_DIR_PIN,EXT0_INVERSE);
#else
+ switch(current_extruder->id) {
+ case 0:
+ if(dir)
+ WRITE(EXT0_DIR_PIN,!EXT0_INVERSE);
+ else
+ WRITE(EXT0_DIR_PIN,EXT0_INVERSE);