Skip to content

Commit

Permalink
Merge branch 'Marlin_v1' of https://github.com/ErikZalm/Marlin into M…
Browse files Browse the repository at this point in the history
…arlin_v1

Conflicts:
	Marlin/Configuration.h
  • Loading branch information
markfinn committed Jul 31, 2012
2 parents 1d4f31b + 538189c commit 1cd06d1
Show file tree
Hide file tree
Showing 14 changed files with 1,242 additions and 637 deletions.
44 changes: 38 additions & 6 deletions Marlin/Configuration.h
@@ -1,5 +1,5 @@
#ifndef __CONFIGURATION_H
#define __CONFIGURATION_H
#ifndef CONFIGURATION_H
#define CONFIGURATION_H

// This configurtion file contains the basic settings.
// Advanced settings can be found in Configuration_adv.h
Expand Down Expand Up @@ -35,6 +35,8 @@
#define MOTHERBOARD 33
#endif



//===========================================================================
//=============================Thermal Settings ============================
//===========================================================================
Expand Down Expand Up @@ -128,9 +130,31 @@
//=============================Mechanical Settings===========================
//===========================================================================

// Endstop Settings
// Uncomment the following line to enable CoreXY kinematics
// #define COREXY

// corse Endstop Settings
#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors

#ifndef ENDSTOPPULLUPS
// fine Enstop settings: Individual Pullups. will be ignord if ENDSTOPPULLUPS is defined
#define ENDSTOPPULLUP_XMAX
#define ENDSTOPPULLUP_YMAX
#define ENDSTOPPULLUP_ZMAX
#define ENDSTOPPULLUP_XMIN
#define ENDSTOPPULLUP_YMIN
//#define ENDSTOPPULLUP_ZMIN
#endif

#ifdef ENDSTOPPULLUPS
#define ENDSTOPPULLUP_XMAX
#define ENDSTOPPULLUP_YMAX
#define ENDSTOPPULLUP_ZMAX
#define ENDSTOPPULLUP_XMIN
#define ENDSTOPPULLUP_YMIN
#define ENDSTOPPULLUP_ZMIN
#endif

// The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
const bool X_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
Expand Down Expand Up @@ -164,9 +188,17 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th

#define min_software_endstops true //If true, axis won't move to coordinates less than HOME_POS.
#define max_software_endstops true //If true, axis won't move to coordinates greater than the defined lengths below.
#define X_MAX_LENGTH 200
#define Y_MAX_LENGTH 198
#define Z_MAX_LENGTH 86
// Travel limits after homing
#define X_MAX_POS 200
#define X_MIN_POS 0
#define Y_MAX_POS 198
#define Y_MIN_POS 0
#define Z_MAX_POS 86
#define Z_MIN_POS 0

#define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS)
#define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
#define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS)

// The position of the homing switches. Use MAX_LENGTH * -0.5 if the center should be 0, 0, 0
#define X_HOME_POS 0
Expand Down
20 changes: 18 additions & 2 deletions Marlin/Configuration_adv.h
@@ -1,5 +1,5 @@
#ifndef __CONFIGURATION_ADV_H
#define __CONFIGURATION_ADV_H
#ifndef CONFIGURATION_ADV_H
#define CONFIGURATION_ADV_H

//===========================================================================
//=============================Thermal Settings ============================
Expand Down Expand Up @@ -88,6 +88,12 @@

#define MAX_STEP_FREQUENCY 40000 // Max step frequency for Ultimaker (5000 pps / half step)

//By default pololu step drivers require an active high signal. However, some high power drivers require an active low signal as step.
#define INVERT_X_STEP_PIN false
#define INVERT_Y_STEP_PIN false
#define INVERT_Z_STEP_PIN false
#define INVERT_E_STEP_PIN false

//default stepper release if idle
#define DEFAULT_STEPPER_DEACTIVE_TIME 60

Expand Down Expand Up @@ -182,6 +188,16 @@ const int dropsegments=1; //everything with less than this number of steps will
#define MAX_CMD_SIZE 96
#define BUFSIZE 4


// Firmware based and LCD controled retract
// M207 and M208 can be used to define parameters for the retraction.
// The retraction can be called by the slicer using G10 and G11
// until then, intended retractions can be detected by moves that only extrude and the direction.
// the moves are than replaced by the firmware controlled ones.

// #define FWRETRACT //ONLY PARTIALLY TESTED
#define MIN_RETRACT 0.1 //minimum extruded mm to accept a automatic gcode retraction attempt

//===========================================================================
//============================= Define Defines ============================
//===========================================================================
Expand Down
4 changes: 2 additions & 2 deletions Marlin/EEPROMwrite.h
@@ -1,5 +1,5 @@
#ifndef __EEPROMH
#define __EEPROMH
#ifndef EEPROM_H
#define EEPROM_H

#include "Marlin.h"
#include "planner.h"
Expand Down
4 changes: 2 additions & 2 deletions Marlin/Marlin.h
@@ -1,8 +1,8 @@
// Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
// Licence: GPL

#ifndef __MARLINH
#define __MARLINH
#ifndef MARLIN_H
#define MARLIN_H

#define HardwareSerial_h // trick to disable the standard HWserial

Expand Down
161 changes: 150 additions & 11 deletions Marlin/Marlin.pde
Expand Up @@ -50,6 +50,8 @@
// G2 - CW ARC
// G3 - CCW ARC
// G4 - Dwell S<seconds> or P<milliseconds>
// G10 - retract filament according to settings of M207
// G11 - retract recover filament according to settings of M208
// G28 - Home all Axis
// G90 - Use Absolute Coordinates
// G91 - Use Relative Coordinates
Expand Down Expand Up @@ -102,6 +104,9 @@
// M204 - Set default acceleration: S normal moves T filament only moves (M204 S3000 T7000) im mm/sec^2 also sets minimum segment time in ms (B20000) to prevent buffer underruns and M20 minimum feedrate
// M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk, E=maximum E jerk
// M206 - set additional homeing offset
// M207 - set retract length S[positive mm] F[feedrate mm/sec] Z[additional zlift/hop]
// M208 - set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec]
// M209 - S<1=true/0=false> enable automatic retract detect if the slicer did not support G10/11: every normal extrude-only move will be classified as retract depending on the direction.
// M220 S<factor in percent>- set speed factor override percentage
// M221 S<factor in percent>- set extrude factor override percentage
// M240 - Trigger a camera to take a photograph
Expand Down Expand Up @@ -139,6 +144,12 @@ float add_homeing[3]={0,0,0};
uint8_t active_extruder = 0;
unsigned char FanSpeed=0;

#ifdef FWRETRACT
bool autoretract_enabled=true;
bool retracted=false;
float retract_length=3, retract_feedrate=17*60, retract_zlift=0.8;
float retract_recover_length=0, retract_recover_feedrate=8*60;
#endif

//===========================================================================
//=============================private variables=============================
Expand Down Expand Up @@ -179,6 +190,7 @@ static unsigned long stoptime=0;

static uint8_t tmp_extruder;


bool Stopped=false;

//===========================================================================
Expand Down Expand Up @@ -550,7 +562,7 @@ bool code_seen(char code)
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
st_synchronize();\
\
current_position[LETTER##_AXIS] = (LETTER##_HOME_DIR == -1) ? LETTER##_HOME_POS : LETTER##_MAX_LENGTH;\
current_position[LETTER##_AXIS] = LETTER##_HOME_POS;\
destination[LETTER##_AXIS] = current_position[LETTER##_AXIS];\
feedrate = 0.0;\
endstops_hit_on_purpose();\
Expand Down Expand Up @@ -601,6 +613,36 @@ void process_commands()
LCD_STATUS;
}
break;
#ifdef FWRETRACT
case 10: // G10 retract
if(!retracted)
{
destination[X_AXIS]=current_position[X_AXIS];
destination[Y_AXIS]=current_position[Y_AXIS];
destination[Z_AXIS]=current_position[Z_AXIS];
current_position[Z_AXIS]+=-retract_zlift;
destination[E_AXIS]=current_position[E_AXIS]-retract_length;
feedrate=retract_feedrate;
retracted=true;
prepare_move();
}

break;
case 11: // G10 retract_recover
if(!retracted)
{
destination[X_AXIS]=current_position[X_AXIS];
destination[Y_AXIS]=current_position[Y_AXIS];
destination[Z_AXIS]=current_position[Z_AXIS];

current_position[Z_AXIS]+=retract_zlift;
current_position[E_AXIS]+=-retract_recover_length;
feedrate=retract_recover_feedrate;
retracted=false;
prepare_move();
}
break;
#endif //FWRETRACT
case 28: //G28 Home all Axis one at a time
saved_feedrate = feedrate;
saved_feedmultiply = feedmultiply;
Expand All @@ -614,6 +656,13 @@ void process_commands()
}
feedrate = 0.0;
home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])));

#if Z_HOME_DIR > 0 // If homing away from BED do Z first
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
HOMEAXIS(Z);
}
#endif

#ifdef QUICK_HOME
if((home_all_axis)||( code_seen(axis_codes[X_AXIS]) && code_seen(axis_codes[Y_AXIS])) ) //first diagonal move
{
Expand All @@ -627,8 +676,8 @@ void process_commands()
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
st_synchronize();

current_position[X_AXIS] = (X_HOME_DIR == -1) ? X_HOME_POS : X_MAX_LENGTH;
current_position[Y_AXIS] = (Y_HOME_DIR == -1) ? Y_HOME_POS : Y_MAX_LENGTH;
current_position[X_AXIS] = X_HOME_POS;
current_position[Y_AXIS] = Y_HOME_POS;
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
destination[X_AXIS] = current_position[X_AXIS];
destination[Y_AXIS] = current_position[Y_AXIS];
Expand All @@ -645,12 +694,14 @@ void process_commands()
}

if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
HOMEAXIS(Y);
HOMEAXIS(Y);
}

#if Z_HOME_DIR < 0 // If homing towards BED do Z last
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
HOMEAXIS(Z);
}
#endif

if(code_seen(axis_codes[X_AXIS]))
{
Expand Down Expand Up @@ -1212,6 +1263,53 @@ void process_commands()
if(code_seen(axis_codes[i])) add_homeing[i] = code_value();
}
break;
#ifdef FWRETRACT
case 207: //M207 - set retract length S[positive mm] F[feedrate mm/sec] Z[additional zlift/hop]
{
if(code_seen('S'))
{
retract_length = code_value() ;
}
if(code_seen('F'))
{
retract_feedrate = code_value() ;
}
if(code_seen('Z'))
{
retract_zlift = code_value() ;
}
}break;
case 208: // M208 - set retract recover length S[positive mm surplus to the M207 S*] F[feedrate mm/sec]
{
if(code_seen('S'))
{
retract_recover_length = code_value() ;
}
if(code_seen('F'))
{
retract_recover_feedrate = code_value() ;
}
}break;

case 209: // M209 - S<1=true/0=false> enable automatic retract detect if the slicer did not support G10/11: every normal extrude-only move will be classified as retract depending on the direction.
{
if(code_seen('S'))
{
int t= code_value() ;
switch(t)
{
case 0: autoretract_enabled=false;retracted=false;break;
case 1: autoretract_enabled=true;retracted=false;break;
default:
SERIAL_ECHO_START;
SERIAL_ECHOPGM(MSG_UNKNOWN_COMMAND);
SERIAL_ECHO(cmdbuffer[bufindr]);
SERIAL_ECHOLNPGM("\"");
}
}

}break;
#endif
case 220: // M220 S<factor in percent>- set speed factor override percentage
{
if(code_seen('S'))
Expand Down Expand Up @@ -1373,14 +1471,55 @@ void ClearToSend()

void get_coordinates()
{
bool seen[4]={false,false,false,false};
for(int8_t i=0; i < NUM_AXIS; i++) {
if(code_seen(axis_codes[i])) destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i];
if(code_seen(axis_codes[i]))
{
destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i];
seen[i]=true;
}
else destination[i] = current_position[i]; //Are these else lines really needed?
}
if(code_seen('F')) {
next_feedrate = code_value();
if(next_feedrate > 0.0) feedrate = next_feedrate;
}
#ifdef FWRETRACT
if(autoretract_enabled)
if( !(seen[X_AXIS] || seen[Y_AXIS] || seen[Z_AXIS]) && seen[E_AXIS])
{
float echange=destination[E_AXIS]-current_position[E_AXIS];
if(echange<-MIN_RETRACT) //retract
{
if(!retracted)
{

destination[Z_AXIS]+=retract_zlift; //not sure why chaninging current_position negatively does not work.
//if slicer retracted by echange=-1mm and you want to retract 3mm, corrrectede=-2mm additionally
float correctede=-echange-retract_length;
//to generate the additional steps, not the destination is changed, but inversely the current position
current_position[E_AXIS]+=-correctede;
feedrate=retract_feedrate;
retracted=true;
}

}
else
if(echange>MIN_RETRACT) //retract_recover
{
if(retracted)
{
//current_position[Z_AXIS]+=-retract_zlift;
//if slicer retracted_recovered by echange=+1mm and you want to retract_recover 3mm, corrrectede=2mm additionally
float correctede=-echange+1*retract_length+retract_recover_length; //total unretract=retract_length+retract_recover_length[surplus]
current_position[E_AXIS]+=correctede; //to generate the additional steps, not the destination is changed, but inversely the current position
feedrate=retract_recover_feedrate;
retracted=false;
}
}

}
#endif //FWRETRACT
}

void get_arc_coordinates()
Expand All @@ -1403,15 +1542,15 @@ void get_arc_coordinates()
void prepare_move()
{
if (min_software_endstops) {
if (destination[X_AXIS] < X_HOME_POS) destination[X_AXIS] = X_HOME_POS;
if (destination[Y_AXIS] < Y_HOME_POS) destination[Y_AXIS] = Y_HOME_POS;
if (destination[Z_AXIS] < Z_HOME_POS) destination[Z_AXIS] = Z_HOME_POS;
if (destination[X_AXIS] < X_MIN_POS) destination[X_AXIS] = X_MIN_POS;
if (destination[Y_AXIS] < Y_MIN_POS) destination[Y_AXIS] = Y_MIN_POS;
if (destination[Z_AXIS] < Z_MIN_POS) destination[Z_AXIS] = Z_MIN_POS;
}

if (max_software_endstops) {
if (destination[X_AXIS] > X_MAX_LENGTH) destination[X_AXIS] = X_MAX_LENGTH;
if (destination[Y_AXIS] > Y_MAX_LENGTH) destination[Y_AXIS] = Y_MAX_LENGTH;
if (destination[Z_AXIS] > Z_MAX_LENGTH) destination[Z_AXIS] = Z_MAX_LENGTH;
if (destination[X_AXIS] > X_MAX_POS) destination[X_AXIS] = X_MAX_POS;
if (destination[Y_AXIS] > Y_MAX_POS) destination[Y_AXIS] = Y_MAX_POS;
if (destination[Z_AXIS] > Z_MAX_POS) destination[Z_AXIS] = Z_MAX_POS;
}
previous_millis_cmd = millis();
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
Expand Down
4 changes: 2 additions & 2 deletions Marlin/cardreader.h
@@ -1,5 +1,5 @@
#ifndef __CARDREADERH
#define __CARDREADERH
#ifndef CARDREADER_H
#define CARDREADER_H

#ifdef SDSUPPORT

Expand Down

0 comments on commit 1cd06d1

Please sign in to comment.