diff options
author | daid <daid303@gmail.com> | 2016-03-22 18:29:32 +0300 |
---|---|---|
committer | daid <daid303@gmail.com> | 2016-03-22 18:29:32 +0300 |
commit | aca2c17ebaf5722137568bc8aeadd2be001a7a34 (patch) | |
tree | 0042fa69d633798200fda134d7203f69d7e5ad63 /src | |
parent | 22b0d0fe6a65bb445f8ff2cf3f62a87c7db58e74 (diff) |
Allow the engine to use dynamic acceleration settings to get better time estimates.15.04.6-RC215.04.6-RC115.04.6
Diffstat (limited to 'src')
-rw-r--r-- | src/fffProcessor.h | 1 | ||||
-rw-r--r-- | src/gcodeExport.cpp | 6 | ||||
-rw-r--r-- | src/gcodeExport.h | 2 | ||||
-rw-r--r-- | src/settings.cpp | 11 | ||||
-rw-r--r-- | src/settings.h | 7 | ||||
-rw-r--r-- | src/timeEstimate.cpp | 24 | ||||
-rw-r--r-- | src/timeEstimate.h | 3 |
7 files changed, 47 insertions, 7 deletions
diff --git a/src/fffProcessor.h b/src/fffProcessor.h index 8f6855c293..9e0e9d0ebd 100644 --- a/src/fffProcessor.h +++ b/src/fffProcessor.h @@ -108,6 +108,7 @@ private: gcode.setSwitchExtruderCode(config.preSwitchExtruderCode, config.postSwitchExtruderCode); gcode.setFlavor(config.gcodeFlavor); gcode.setRetractionSettings(config.retractionAmount, config.retractionSpeed, config.retractionAmountExtruderSwitch, config.minimalExtrusionBeforeRetraction, config.retractionZHop, config.retractionAmountPrime); + gcode.applyAccelerationSettings(config); } bool prepareModel(SliceDataStorage& storage, const std::vector<std::string> &files) diff --git a/src/gcodeExport.cpp b/src/gcodeExport.cpp index 90ab5c2598..af6dc945f9 100644 --- a/src/gcodeExport.cpp +++ b/src/gcodeExport.cpp @@ -85,6 +85,7 @@ void GCodeExport::setFlavor(int flavor) for(int n=0; n<MAX_EXTRUDERS; n++) extruderCharacter[n] = 'E'; } + int GCodeExport::getFlavor() { return this->flavor; @@ -119,6 +120,11 @@ void GCodeExport::setRetractionSettings(int retractionAmount, int retractionSpee this->retractionZHop = zHop; } +void GCodeExport::applyAccelerationSettings(ConfigSettings& config) +{ + estimateCalculator.applyAccelerationSettings(config); +} + void GCodeExport::setZ(int z) { this->zPos = z; diff --git a/src/gcodeExport.h b/src/gcodeExport.h index c0a6ee6375..f9e334b5a5 100644 --- a/src/gcodeExport.h +++ b/src/gcodeExport.h @@ -64,6 +64,8 @@ public: void setRetractionSettings(int retractionAmount, int retractionSpeed, int extruderSwitchRetraction, int minimalExtrusionBeforeRetraction, int zHop, int retractionAmountPrime); + void applyAccelerationSettings(ConfigSettings& config); + void setZ(int z); Point getPositionXY(); diff --git a/src/settings.cpp b/src/settings.cpp index 1f8975fe9d..27f8d0869f 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -152,6 +152,17 @@ ConfigSettings::ConfigSettings() "G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way\n" "M84 ;steppers off\n" "G90 ;absolute positioning\n"; + + + //Time estimate settings + SETTING(acceleration, 3000 * 1000); + SETTING(max_acceleration[0], 9000 * 1000); + SETTING(max_acceleration[1], 9000 * 1000); + SETTING(max_acceleration[2], 100 * 1000); + SETTING(max_acceleration[3], 10000 * 1000); + SETTING(max_xy_jerk, 20.0 * 1000); + SETTING(max_z_jerk, 0.4 * 1000); + SETTING(max_e_jerk, 5.0 * 1000); } #undef STRINGIFY diff --git a/src/settings.h b/src/settings.h index bd48ddadc1..58c0cb7e82 100644 --- a/src/settings.h +++ b/src/settings.h @@ -219,6 +219,13 @@ public: std::string endCode; std::string preSwitchExtruderCode; std::string postSwitchExtruderCode; + + //Time estimate settings + int acceleration; + int max_acceleration[4]; + int max_xy_jerk; + int max_z_jerk; + int max_e_jerk; ConfigSettings(); bool setSetting(const char* key, const char* value); diff --git a/src/timeEstimate.cpp b/src/timeEstimate.cpp index c00b170833..6cec07a178 100644 --- a/src/timeEstimate.cpp +++ b/src/timeEstimate.cpp @@ -6,16 +6,26 @@ #define MINIMUM_PLANNER_SPEED 0.05// (mm/sec) -const double max_feedrate[TimeEstimateCalculator::NUM_AXIS] = {600, 600, 40, 25}; -const double minimumfeedrate = 0.01; -const double acceleration = 3000; -const double max_acceleration[TimeEstimateCalculator::NUM_AXIS] = {9000,9000,100,10000}; -const double max_xy_jerk = 20.0; -const double max_z_jerk = 0.4; -const double max_e_jerk = 5.0; +static double max_feedrate[TimeEstimateCalculator::NUM_AXIS] = {600, 600, 40, 25}; +static double minimumfeedrate = 0.01; +static double acceleration = 3000; +static double max_acceleration[TimeEstimateCalculator::NUM_AXIS] = {9000,9000,100,10000}; +static double max_xy_jerk = 20.0; +static double max_z_jerk = 0.4; +static double max_e_jerk = 5.0; template<typename T> const T square(const T& a) { return a * a; } +void TimeEstimateCalculator::applyAccelerationSettings(ConfigSettings& config) +{ + acceleration = float(config.acceleration) / 1000.0; + for(unsigned int n=0; n<TimeEstimateCalculator::NUM_AXIS; n++) + max_acceleration[n] = float(config.max_acceleration[n]) / 1000.0; + max_xy_jerk = float(config.max_xy_jerk) / 1000.0; + max_z_jerk = float(config.max_z_jerk) / 1000.0; + max_e_jerk = float(config.max_e_jerk) / 1000.0; +} + void TimeEstimateCalculator::setPosition(Position newPos) { currentPosition = newPos; diff --git a/src/timeEstimate.h b/src/timeEstimate.h index 2f80f8d7c6..cc1cf3cc22 100644 --- a/src/timeEstimate.h +++ b/src/timeEstimate.h @@ -1,6 +1,7 @@ #ifndef TIME_ESTIMATE_H #define TIME_ESTIMATE_H +#include "settings.h" #include <stdint.h> #include <vector> @@ -58,6 +59,8 @@ private: std::vector<Block> blocks; public: + void applyAccelerationSettings(ConfigSettings& config); + void setPosition(Position newPos); void plan(Position newPos, double feedRate); void reset(); |