Merge pull request #133 from midopple/experimental
Experimental new Planner Code
This commit is contained in:
commit
5a41980404
5 changed files with 941 additions and 510 deletions
|
|
@ -56,8 +56,13 @@ const bool Z_ENDSTOP_INVERT = false;
|
|||
// Uncomment to make run init.g from SD on boot
|
||||
//#define SDINITFILE
|
||||
|
||||
//Only work with Atmega1284 you need +1 kb ram
|
||||
//#define SD_FAST_XFER_AKTIV
|
||||
|
||||
//Uncomment to aktivate the arc (circle) function (G2/G3 Command)
|
||||
//Without SD function an ARC function the used Flash is smaller 31 kb
|
||||
#define USE_ARC_FUNCTION
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
//// ADVANCED SETTINGS - to tweak parameters
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
@ -69,8 +74,9 @@ const bool Z_ENDSTOP_INVERT = false;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
|
||||
//-----------------------------------------------------------------------
|
||||
#define X_ENABLE_ON 0
|
||||
#define Y_ENABLE_ON 0
|
||||
#define Z_ENABLE_ON 0
|
||||
|
|
@ -79,40 +85,57 @@ const bool Z_ENDSTOP_INVERT = false;
|
|||
//Uncomment if you have problems with a stepper driver enabeling too late, this will also set how many microseconds delay there will be after enabeling the driver
|
||||
//#define DELAY_ENABLE 15
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// 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
|
||||
#define X_HOME_DIR -1
|
||||
#define Y_HOME_DIR -1
|
||||
#define Z_HOME_DIR -1
|
||||
|
||||
//#define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing
|
||||
|
||||
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.
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
//Max Length for Prusa Mendel, check the ways of your axis and set this Values
|
||||
//-----------------------------------------------------------------------
|
||||
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
|
||||
#define _MAX_FEEDRATE {200000, 200000, 240, 500000}
|
||||
#define _HOMING_FEEDRATE {1500,1500,120}
|
||||
#define _MAX_FEEDRATE {400, 400, 4, 45} // (mm/sec)
|
||||
#define _HOMING_FEEDRATE {1500,1500,120} // (mm/min) !!
|
||||
#define _AXIS_RELATIVE_MODES {false, false, false, false}
|
||||
|
||||
#define MAX_STEP_FREQUENCY 30000 // Max step frequency
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
//// Not used at the Moment
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
// 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.
|
||||
|
|
@ -128,23 +151,35 @@ const int NUM_AXIS = 4; // The axis order in all axis related arrays is X, Y, Z,
|
|||
long min_time_before_dir_change = 30; //milliseconds
|
||||
#endif
|
||||
|
||||
// Comment this to disable ramp acceleration
|
||||
#define RAMP_ACCELERATION
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
//// 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.
|
||||
#define _ACCELERATION 2000 // Normal acceleration mm/s^2
|
||||
#define _RETRACT_ACCELERATION 7000 // Normal acceleration mm/s^2
|
||||
#define _MAX_XY_JERK (20.0*60)
|
||||
#define _MAX_Z_JERK (0.4*60)
|
||||
#define _MAX_START_SPEED_UNITS_PER_SECOND {25.0,25.0,0.2,10.0}
|
||||
#define _MAX_ACCELERATION_UNITS_PER_SQ_SECOND {500,500,50,500} // X, Y, Z and E max acceleration in mm/s^2 for printing moves or retracts
|
||||
#define _MAX_TRAVEL_ACCELERATION_UNITS_PER_SQ_SECOND {500,500,50,500} // X, Y, Z max acceleration in mm/s^2 for travel moves
|
||||
#endif
|
||||
#define _ACCELERATION 1000 // Axis Normal acceleration mm/s^2
|
||||
#define _RETRACT_ACCELERATION 2000 // Extruder Normal acceleration mm/s^2
|
||||
#define _MAX_XY_JERK 20.0
|
||||
#define _MAX_Z_JERK 0.4
|
||||
//#define _MAX_START_SPEED_UNITS_PER_SECOND {25.0,25.0,0.2,10.0}
|
||||
#define _MAX_ACCELERATION_UNITS_PER_SQ_SECOND {5000,5000,50,5000} // X, Y, Z and E max acceleration in mm/s^2 for printing moves or retracts
|
||||
|
||||
|
||||
// Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end
|
||||
// of the buffer and all stops. This should not be much greater than zero and should only be changed
|
||||
// if unwanted behavior is observed on a user's machine when running at very slow speeds.
|
||||
#define MINIMUM_PLANNER_SPEED 2.0 // (mm/sec)
|
||||
|
||||
#define DEFAULT_MINIMUMFEEDRATE 0.0 // minimum feedrate
|
||||
#define DEFAULT_MINTRAVELFEEDRATE 0.0
|
||||
|
||||
// If defined the movements slow down when the look ahead buffer is only half full
|
||||
#define SLOWDOWN
|
||||
|
||||
|
||||
const int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Machine UUID
|
||||
//-----------------------------------------------------------------------
|
||||
// This may be useful if you have multiple machines and wish to identify them by using the M115 command.
|
||||
// By default we set it to zeros.
|
||||
#define _DEF_CHAR_UUID "00000000-0000-0000-0000-000000000000"
|
||||
|
|
@ -290,7 +325,6 @@ long min_time_before_dir_change = 30; //milliseconds
|
|||
//#define DEBUG
|
||||
#ifdef DEBUG
|
||||
//#define DEBUG_PREPARE_MOVE //Enable this to debug prepare_move() function
|
||||
//#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
|
||||
|
|
|
|||
|
|
@ -1,10 +1,18 @@
|
|||
// Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
|
||||
// Licence: GPL
|
||||
#include <WProgram.h>
|
||||
|
||||
//Check Version of Arduino and then include the right libraries
|
||||
#if defined(ARDUINO) && ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include <WProgram.h>
|
||||
#endif
|
||||
|
||||
#include "fastio.h"
|
||||
|
||||
extern "C" void __cxa_pure_virtual();
|
||||
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
|
||||
#if X_ENABLE_PIN > -1
|
||||
#define enable_x() WRITE(X_ENABLE_PIN, X_ENABLE_ON)
|
||||
|
|
@ -47,10 +55,10 @@ typedef struct {
|
|||
// Fields used by the bresenham algorithm for tracing the line
|
||||
long steps_x, steps_y, steps_z, steps_e; // Step count along each axis
|
||||
|
||||
long step_event_count; // The number of step events required to complete this block
|
||||
volatile long accelerate_until; // The index of the step event on which to stop acceleration
|
||||
volatile long decelerate_after; // The index of the step event on which to start decelerating
|
||||
volatile long acceleration_rate; // The acceleration rate used for acceleration calculation
|
||||
unsigned long step_event_count; // The number of step events required to complete this block
|
||||
long accelerate_until; // The index of the step event on which to stop acceleration
|
||||
long decelerate_after; // The index of the step event on which to start decelerating
|
||||
long acceleration_rate; // The acceleration rate used for acceleration calculation
|
||||
unsigned char direction_bits; // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
|
||||
|
||||
#ifdef ADVANCE
|
||||
|
|
@ -61,16 +69,20 @@ typedef struct {
|
|||
#endif
|
||||
|
||||
// Fields used by the motion planner to manage acceleration
|
||||
float speed_x, speed_y, speed_z, speed_e; // Nominal mm/minute for each axis
|
||||
// float speed_x, speed_y, speed_z, speed_e; // Nominal mm/minute for each axis
|
||||
float nominal_speed; // The nominal speed for this block in mm/min
|
||||
float entry_speed; // Entry speed at previous-current junction in mm/min
|
||||
float max_entry_speed; // Maximum allowable junction entry speed in mm/min
|
||||
float millimeters; // The total travel of this block in mm
|
||||
float entry_speed;
|
||||
float acceleration; // acceleration mm/sec^2
|
||||
unsigned char recalculate_flag; // Planner flag to recalculate trapezoids on entry junction
|
||||
unsigned char nominal_length_flag; // Planner flag for nominal speed always reached
|
||||
|
||||
|
||||
// Settings for the trapezoid generator
|
||||
long nominal_rate; // The nominal step rate for this block in step_events/sec
|
||||
volatile long initial_rate; // The jerk-adjusted step rate at start of block
|
||||
volatile long final_rate; // The minimal rate at exit
|
||||
long initial_rate; // The jerk-adjusted step rate at start of block
|
||||
long final_rate; // The minimal rate at exit
|
||||
long acceleration_st; // acceleration steps/sec^2
|
||||
volatile char busy;
|
||||
} block_t;
|
||||
|
|
@ -87,7 +99,6 @@ void manage_inactivity(byte debug);
|
|||
void get_coordinates();
|
||||
void prepare_move();
|
||||
void prepare_arc_move(char isclockwise);
|
||||
void plan_buffer_line(float x, float y, float z, float e, float feed_rate);
|
||||
|
||||
void kill(byte debug);
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -25,6 +25,7 @@
|
|||
#include "Configuration.h"
|
||||
#include "Sprinter.h"
|
||||
|
||||
#ifdef USE_ARC_FUNCTION
|
||||
// The arc is approximated by generating a huge number of tiny, linear segments. The length of each
|
||||
// segment is configured in settings.mm_per_arc_segment.
|
||||
void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1,
|
||||
|
|
@ -104,6 +105,12 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8
|
|||
for (i = 1; i<segments; i++)
|
||||
{ // Increment (segments-1)
|
||||
|
||||
if((count == 10) || (count == 15))
|
||||
{
|
||||
//Read the next two Commands while arc is calculating
|
||||
check_buffer_while_arc();
|
||||
}
|
||||
|
||||
if (count < N_ARC_CORRECTION) //25 pieces
|
||||
{
|
||||
// Apply vector rotation matrix
|
||||
|
|
@ -129,15 +136,12 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8
|
|||
arc_target[axis_linear] += linear_per_segment;
|
||||
arc_target[E_AXIS] += extruder_per_segment;
|
||||
|
||||
//showString(PSTR("sec:"));
|
||||
//Serial.println(i);
|
||||
plan_buffer_line(arc_target[X_AXIS], arc_target[Y_AXIS], arc_target[Z_AXIS], arc_target[E_AXIS], feed_rate);
|
||||
|
||||
}
|
||||
// Ensure last segment arrives at target location.
|
||||
//showString(PSTR("Last sec\r\n"));
|
||||
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feed_rate);
|
||||
|
||||
// plan_set_acceleration_manager_enabled(acceleration_manager_was_enabled);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@
|
|||
#include "pins.h"
|
||||
#include "Sprinter.h"
|
||||
|
||||
|
||||
#ifdef CONTROLLERFAN_PIN
|
||||
void controllerFan(void);
|
||||
#endif
|
||||
|
||||
// Manage heater variables. For a thermistor or AD595 thermocouple, raw values refer to the
|
||||
// reading from the analog pin. For a MAX6675 thermocouple, the raw value is the temperature in 0.25
|
||||
|
|
@ -256,7 +258,18 @@ int read_max6675()
|
|||
showString(PSTR(" "));
|
||||
Serial.print(target_temp);
|
||||
showString(PSTR(" "));
|
||||
#ifdef PIDTEMP
|
||||
Serial.println(heater_duty);
|
||||
#else
|
||||
#if (HEATER_0_PIN > -1)
|
||||
if(READ(HEATER_0_PIN))
|
||||
Serial.println(255);
|
||||
else
|
||||
Serial.println(0);
|
||||
#else
|
||||
Serial.println(0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#if THERMISTORBED!=0
|
||||
else
|
||||
|
|
@ -266,10 +279,14 @@ int read_max6675()
|
|||
showString(PSTR(" "));
|
||||
Serial.print(analog2tempBed(target_bed_raw));
|
||||
showString(PSTR(" "));
|
||||
if(READ(HEATER_1_PIN))
|
||||
Serial.println(255);
|
||||
else
|
||||
#if (HEATER_1_PIN > -1)
|
||||
if(READ(HEATER_1_PIN))
|
||||
Serial.println(255);
|
||||
else
|
||||
Serial.println(0);
|
||||
#else
|
||||
Serial.println(0);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue