|
|
@ -32,7 +32,6 @@
|
|
|
|
#include "pins.h"
|
|
|
|
#include "pins.h"
|
|
|
|
#include "Marlin.h"
|
|
|
|
#include "Marlin.h"
|
|
|
|
#include "ultralcd.h"
|
|
|
|
#include "ultralcd.h"
|
|
|
|
#include "streaming.h"
|
|
|
|
|
|
|
|
#include "planner.h"
|
|
|
|
#include "planner.h"
|
|
|
|
#include "stepper.h"
|
|
|
|
#include "stepper.h"
|
|
|
|
#include "temperature.h"
|
|
|
|
#include "temperature.h"
|
|
|
@ -40,7 +39,8 @@
|
|
|
|
#include "cardreader.h"
|
|
|
|
#include "cardreader.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char version_string[] = "1.0.0 Alpha 1";
|
|
|
|
#define VERSION_STRING "1.0.0 Alpha 1"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -99,8 +99,9 @@ char version_string[] = "1.0.0 Alpha 1";
|
|
|
|
// M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk
|
|
|
|
// M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk
|
|
|
|
// M220 - set speed factor override percentage S:factor in percent
|
|
|
|
// M220 - set speed factor override percentage S:factor in percent
|
|
|
|
// M301 - Set PID parameters P I and D
|
|
|
|
// M301 - Set PID parameters P I and D
|
|
|
|
|
|
|
|
// M400 - Finish all moves
|
|
|
|
// M500 - stores paramters in EEPROM
|
|
|
|
// M500 - stores paramters in EEPROM
|
|
|
|
// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). D
|
|
|
|
// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
|
|
|
|
// M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
|
|
|
|
// M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
|
|
|
|
|
|
|
|
|
|
|
|
//Stepper Movement Variables
|
|
|
|
//Stepper Movement Variables
|
|
|
@ -122,13 +123,14 @@ bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
|
|
|
|
volatile int feedmultiply=100; //100->1 200->2
|
|
|
|
volatile int feedmultiply=100; //100->1 200->2
|
|
|
|
int saved_feedmultiply;
|
|
|
|
int saved_feedmultiply;
|
|
|
|
volatile bool feedmultiplychanged=false;
|
|
|
|
volatile bool feedmultiplychanged=false;
|
|
|
|
|
|
|
|
float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//===========================================================================
|
|
|
|
//=============================private variables=============================
|
|
|
|
//=============================private variables=============================
|
|
|
|
//===========================================================================
|
|
|
|
//===========================================================================
|
|
|
|
const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
|
|
|
|
const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
|
|
|
|
static float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
|
|
|
|
static float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
|
|
|
|
static float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
|
|
|
|
|
|
|
|
static float offset[3] = {0.0, 0.0, 0.0};
|
|
|
|
static float offset[3] = {0.0, 0.0, 0.0};
|
|
|
|
static bool home_all_axis = true;
|
|
|
|
static bool home_all_axis = true;
|
|
|
|
static float feedrate = 1500.0, next_feedrate, saved_feedrate;
|
|
|
|
static float feedrate = 1500.0, next_feedrate, saved_feedrate;
|
|
|
@ -173,6 +175,23 @@ static unsigned long stoptime=0;
|
|
|
|
//===========================================================================
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern "C"{
|
|
|
|
|
|
|
|
extern unsigned int __bss_end;
|
|
|
|
|
|
|
|
extern unsigned int __heap_start;
|
|
|
|
|
|
|
|
extern void *__brkval;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int freeMemory() {
|
|
|
|
|
|
|
|
int free_memory;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if((int)__brkval == 0)
|
|
|
|
|
|
|
|
free_memory = ((int)&free_memory) - ((int)&__bss_end);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
free_memory = ((int)&free_memory) - ((int)__brkval);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return free_memory;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//adds an command to the main command buffer
|
|
|
|
//adds an command to the main command buffer
|
|
|
|
//thats really done in a non-safe way.
|
|
|
|
//thats really done in a non-safe way.
|
|
|
@ -183,7 +202,10 @@ void enquecommand(const char *cmd)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//this is dangerous if a mixing of serial and this happsens
|
|
|
|
//this is dangerous if a mixing of serial and this happsens
|
|
|
|
strcpy(&(cmdbuffer[bufindw][0]),cmd);
|
|
|
|
strcpy(&(cmdbuffer[bufindw][0]),cmd);
|
|
|
|
SERIAL_ECHOLN("enqueing \""<<cmdbuffer[bufindw]<<"\"");
|
|
|
|
SERIAL_ECHO_START;
|
|
|
|
|
|
|
|
SERIAL_ECHOPGM("enqueing \"");
|
|
|
|
|
|
|
|
SERIAL_ECHO(cmdbuffer[bufindw]);
|
|
|
|
|
|
|
|
SERIAL_ECHOLNPGM("\"");
|
|
|
|
bufindw= (bufindw + 1)%BUFSIZE;
|
|
|
|
bufindw= (bufindw + 1)%BUFSIZE;
|
|
|
|
buflen += 1;
|
|
|
|
buflen += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -192,8 +214,12 @@ void enquecommand(const char *cmd)
|
|
|
|
void setup()
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Serial.begin(BAUDRATE);
|
|
|
|
Serial.begin(BAUDRATE);
|
|
|
|
SERIAL_ECHOLN("Marlin "<<version_string);
|
|
|
|
SERIAL_ECHO_START;
|
|
|
|
Serial.println("start");
|
|
|
|
SERIAL_ECHOLNPGM(VERSION_STRING);
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLLNPGM("start");
|
|
|
|
|
|
|
|
SERIAL_ECHO_START;
|
|
|
|
|
|
|
|
SERIAL_ECHOPGM("Free Memory:");
|
|
|
|
|
|
|
|
SERIAL_ECHOLN(freeMemory());
|
|
|
|
for(int8_t i = 0; i < BUFSIZE; i++)
|
|
|
|
for(int8_t i = 0; i < BUFSIZE; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fromsd[i] = false;
|
|
|
|
fromsd[i] = false;
|
|
|
@ -228,12 +254,12 @@ void loop()
|
|
|
|
if(strstr(cmdbuffer[bufindr],"M29") == NULL)
|
|
|
|
if(strstr(cmdbuffer[bufindr],"M29") == NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
card.write_command(cmdbuffer[bufindr]);
|
|
|
|
card.write_command(cmdbuffer[bufindr]);
|
|
|
|
Serial.println("ok");
|
|
|
|
SERIAL_PROTOCOLLNPGM("ok");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
card.closefile();
|
|
|
|
card.closefile();
|
|
|
|
Serial.println("Done saving file.");
|
|
|
|
SERIAL_PROTOCOLLNPGM("Done saving file.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -249,6 +275,7 @@ void loop()
|
|
|
|
//check heater every n milliseconds
|
|
|
|
//check heater every n milliseconds
|
|
|
|
manage_heater();
|
|
|
|
manage_heater();
|
|
|
|
manage_inactivity(1);
|
|
|
|
manage_inactivity(1);
|
|
|
|
|
|
|
|
checkHitEndstops();
|
|
|
|
LCD_STATUS;
|
|
|
|
LCD_STATUS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -268,8 +295,9 @@ inline void get_command()
|
|
|
|
strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
|
|
|
|
strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
|
|
|
|
gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10));
|
|
|
|
gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10));
|
|
|
|
if(gcode_N != gcode_LastN+1 && (strstr(cmdbuffer[bufindw], "M110") == NULL) ) {
|
|
|
|
if(gcode_N != gcode_LastN+1 && (strstr(cmdbuffer[bufindw], "M110") == NULL) ) {
|
|
|
|
Serial.print("Serial Error: Line Number is not Last Line Number+1, Last Line:");
|
|
|
|
SERIAL_ERROR_START;
|
|
|
|
Serial.println(gcode_LastN);
|
|
|
|
SERIAL_ERRORPGM("Line Number is not Last Line Number+1, Last Line:");
|
|
|
|
|
|
|
|
SERIAL_ERRORLN(gcode_LastN);
|
|
|
|
//Serial.println(gcode_N);
|
|
|
|
//Serial.println(gcode_N);
|
|
|
|
FlushSerialRequestResend();
|
|
|
|
FlushSerialRequestResend();
|
|
|
|
serial_count = 0;
|
|
|
|
serial_count = 0;
|
|
|
@ -284,8 +312,9 @@ inline void get_command()
|
|
|
|
strchr_pointer = strchr(cmdbuffer[bufindw], '*');
|
|
|
|
strchr_pointer = strchr(cmdbuffer[bufindw], '*');
|
|
|
|
|
|
|
|
|
|
|
|
if( (int)(strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)) != checksum) {
|
|
|
|
if( (int)(strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)) != checksum) {
|
|
|
|
Serial.print("Error: checksum mismatch, Last Line:");
|
|
|
|
SERIAL_ERROR_START;
|
|
|
|
Serial.println(gcode_LastN);
|
|
|
|
SERIAL_ERRORPGM("checksum mismatch, Last Line:");
|
|
|
|
|
|
|
|
SERIAL_ERRORLN(gcode_LastN);
|
|
|
|
FlushSerialRequestResend();
|
|
|
|
FlushSerialRequestResend();
|
|
|
|
serial_count = 0;
|
|
|
|
serial_count = 0;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -294,8 +323,9 @@ inline void get_command()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Serial.print("Error: No Checksum with line number, Last Line:");
|
|
|
|
SERIAL_ERROR_START;
|
|
|
|
Serial.println(gcode_LastN);
|
|
|
|
SERIAL_ERRORPGM("No Checksum with line number, Last Line:");
|
|
|
|
|
|
|
|
SERIAL_ERRORLN(gcode_LastN);
|
|
|
|
FlushSerialRequestResend();
|
|
|
|
FlushSerialRequestResend();
|
|
|
|
serial_count = 0;
|
|
|
|
serial_count = 0;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -308,8 +338,9 @@ inline void get_command()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if((strstr(cmdbuffer[bufindw], "*") != NULL))
|
|
|
|
if((strstr(cmdbuffer[bufindw], "*") != NULL))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Serial.print("Error: No Line Number with checksum, Last Line:");
|
|
|
|
SERIAL_ERROR_START;
|
|
|
|
Serial.println(gcode_LastN);
|
|
|
|
SERIAL_ERRORPGM("No Line Number with checksum, Last Line:");
|
|
|
|
|
|
|
|
SERIAL_ERRORLN(gcode_LastN);
|
|
|
|
serial_count = 0;
|
|
|
|
serial_count = 0;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -325,7 +356,7 @@ inline void get_command()
|
|
|
|
if(card.saving)
|
|
|
|
if(card.saving)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
#endif //SDSUPPORT
|
|
|
|
#endif //SDSUPPORT
|
|
|
|
Serial.println("ok");
|
|
|
|
SERIAL_PROTOCOLLNPGM("ok");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -350,22 +381,23 @@ inline void get_command()
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while( !card.eof() && buflen < BUFSIZE) {
|
|
|
|
while( !card.eof() && buflen < BUFSIZE) {
|
|
|
|
|
|
|
|
int16_t n=card.get();
|
|
|
|
serial_char = card.get();
|
|
|
|
serial_char = (char)n;
|
|
|
|
if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1))
|
|
|
|
if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1)||n==-1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if(card.eof()){
|
|
|
|
if(card.eof()){
|
|
|
|
card.sdprinting = false;
|
|
|
|
card.sdprinting = false;
|
|
|
|
Serial.println("echo: Done printing file");
|
|
|
|
SERIAL_PROTOCOLLNPGM("Done printing file");
|
|
|
|
stoptime=millis();
|
|
|
|
stoptime=millis();
|
|
|
|
char time[30];
|
|
|
|
char time[30];
|
|
|
|
unsigned long t=(stoptime-starttime)/1000;
|
|
|
|
unsigned long t=(stoptime-starttime)/1000;
|
|
|
|
int sec,min;
|
|
|
|
int sec,min;
|
|
|
|
min=t/60;
|
|
|
|
min=t/60;
|
|
|
|
sec=t%60;
|
|
|
|
sec=t%60;
|
|
|
|
sprintf(time,"echo: %i min, %i sec",min,sec);
|
|
|
|
sprintf(time,"%i min, %i sec",min,sec);
|
|
|
|
Serial.println(time);
|
|
|
|
SERIAL_ECHO_START;
|
|
|
|
|
|
|
|
SERIAL_ECHOLN(time);
|
|
|
|
LCD_MESSAGE(time);
|
|
|
|
LCD_MESSAGE(time);
|
|
|
|
card.checkautostart(true);
|
|
|
|
card.checkautostart(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -386,6 +418,7 @@ inline void get_command()
|
|
|
|
if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
|
|
|
|
if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif //SDSUPPORT
|
|
|
|
#endif //SDSUPPORT
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -417,20 +450,25 @@ inline bool code_seen(char code)
|
|
|
|
destination[LETTER##_AXIS] = 1.5 * LETTER##_MAX_LENGTH * LETTER##_HOME_DIR; \
|
|
|
|
destination[LETTER##_AXIS] = 1.5 * LETTER##_MAX_LENGTH * LETTER##_HOME_DIR; \
|
|
|
|
feedrate = homing_feedrate[LETTER##_AXIS]; \
|
|
|
|
feedrate = homing_feedrate[LETTER##_AXIS]; \
|
|
|
|
prepare_move(); \
|
|
|
|
prepare_move(); \
|
|
|
|
|
|
|
|
st_synchronize();\
|
|
|
|
\
|
|
|
|
\
|
|
|
|
current_position[LETTER##_AXIS] = 0;\
|
|
|
|
current_position[LETTER##_AXIS] = 0;\
|
|
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
|
|
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
|
|
|
|
destination[LETTER##_AXIS] = -5 * LETTER##_HOME_DIR;\
|
|
|
|
destination[LETTER##_AXIS] = -5 * LETTER##_HOME_DIR;\
|
|
|
|
prepare_move(); \
|
|
|
|
prepare_move(); \
|
|
|
|
|
|
|
|
st_synchronize();\
|
|
|
|
\
|
|
|
|
\
|
|
|
|
destination[LETTER##_AXIS] = 10 * LETTER##_HOME_DIR;\
|
|
|
|
destination[LETTER##_AXIS] = 10 * LETTER##_HOME_DIR;\
|
|
|
|
feedrate = homing_feedrate[LETTER##_AXIS]/2 ; \
|
|
|
|
feedrate = homing_feedrate[LETTER##_AXIS]/2 ; \
|
|
|
|
prepare_move(); \
|
|
|
|
prepare_move(); \
|
|
|
|
|
|
|
|
st_synchronize();\
|
|
|
|
\
|
|
|
|
\
|
|
|
|
current_position[LETTER##_AXIS] = (LETTER##_HOME_DIR == -1) ? 0 : LETTER##_MAX_LENGTH;\
|
|
|
|
current_position[LETTER##_AXIS] = (LETTER##_HOME_DIR == -1) ? 0 : LETTER##_MAX_LENGTH;\
|
|
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
|
|
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
|
|
|
|
destination[LETTER##_AXIS] = current_position[LETTER##_AXIS];\
|
|
|
|
destination[LETTER##_AXIS] = current_position[LETTER##_AXIS];\
|
|
|
|
feedrate = 0.0;\
|
|
|
|
feedrate = 0.0;\
|
|
|
|
|
|
|
|
st_synchronize();\
|
|
|
|
|
|
|
|
endstops_hit_on_purpose();\
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void process_commands()
|
|
|
|
inline void process_commands()
|
|
|
@ -461,6 +499,7 @@ inline void process_commands()
|
|
|
|
previous_millis_cmd = millis();
|
|
|
|
previous_millis_cmd = millis();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
case 4: // G4 dwell
|
|
|
|
case 4: // G4 dwell
|
|
|
|
|
|
|
|
LCD_MESSAGEPGM("DWELL...");
|
|
|
|
codenum = 0;
|
|
|
|
codenum = 0;
|
|
|
|
if(code_seen('P')) codenum = code_value(); // milliseconds to wait
|
|
|
|
if(code_seen('P')) codenum = code_value(); // milliseconds to wait
|
|
|
|
if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
|
|
|
|
if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
|
|
|
@ -495,6 +534,7 @@ inline void process_commands()
|
|
|
|
feedrate = saved_feedrate;
|
|
|
|
feedrate = saved_feedrate;
|
|
|
|
feedmultiply = saved_feedmultiply;
|
|
|
|
feedmultiply = saved_feedmultiply;
|
|
|
|
previous_millis_cmd = millis();
|
|
|
|
previous_millis_cmd = millis();
|
|
|
|
|
|
|
|
endstops_hit_on_purpose();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 90: // G90
|
|
|
|
case 90: // G90
|
|
|
|
relative_mode = false;
|
|
|
|
relative_mode = false;
|
|
|
@ -521,13 +561,14 @@ inline void process_commands()
|
|
|
|
#ifdef SDSUPPORT
|
|
|
|
#ifdef SDSUPPORT
|
|
|
|
|
|
|
|
|
|
|
|
case 20: // M20 - list SD card
|
|
|
|
case 20: // M20 - list SD card
|
|
|
|
Serial.println("Begin file list");
|
|
|
|
SERIAL_PROTOCOLLNPGM("Begin file list");
|
|
|
|
card.ls();
|
|
|
|
card.ls();
|
|
|
|
Serial.println("End file list");
|
|
|
|
SERIAL_PROTOCOLLNPGM("End file list");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 21: // M21 - init SD card
|
|
|
|
case 21: // M21 - init SD card
|
|
|
|
|
|
|
|
|
|
|
|
card.initsd();
|
|
|
|
card.initsd();
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 22: //M22 - release SD card
|
|
|
|
case 22: //M22 - release SD card
|
|
|
|
card.release();
|
|
|
|
card.release();
|
|
|
@ -579,8 +620,9 @@ inline void process_commands()
|
|
|
|
int sec,min;
|
|
|
|
int sec,min;
|
|
|
|
min=t/60;
|
|
|
|
min=t/60;
|
|
|
|
sec=t%60;
|
|
|
|
sec=t%60;
|
|
|
|
sprintf(time,"echo: time needed %i min, %i sec",min,sec);
|
|
|
|
sprintf(time,"%i min, %i sec",min,sec);
|
|
|
|
Serial.println(time);
|
|
|
|
SERIAL_ECHO_START;
|
|
|
|
|
|
|
|
SERIAL_ECHOLN(time);
|
|
|
|
LCD_MESSAGE(time);
|
|
|
|
LCD_MESSAGE(time);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -617,37 +659,30 @@ inline void process_commands()
|
|
|
|
if (code_seen('S')) setTargetBed(code_value());
|
|
|
|
if (code_seen('S')) setTargetBed(code_value());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 105: // M105
|
|
|
|
case 105: // M105
|
|
|
|
|
|
|
|
//SERIAL_ECHOLN(freeMemory());
|
|
|
|
|
|
|
|
|
|
|
|
#if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
|
|
|
|
#if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
|
|
|
|
tt = degHotend0();
|
|
|
|
SERIAL_PROTOCOLPGM("ok T:");
|
|
|
|
#endif
|
|
|
|
SERIAL_PROTOCOL( degHotend0());
|
|
|
|
#if TEMP_1_PIN > -1
|
|
|
|
|
|
|
|
bt = degBed();
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
|
|
|
|
|
|
|
|
Serial.print("ok T:");
|
|
|
|
|
|
|
|
Serial.print(tt);
|
|
|
|
|
|
|
|
#if TEMP_1_PIN > -1
|
|
|
|
#if TEMP_1_PIN > -1
|
|
|
|
#ifdef PIDTEMP
|
|
|
|
SERIAL_PROTOCOLPGM(" B:");
|
|
|
|
Serial.print(" B:");
|
|
|
|
SERIAL_PROTOCOL(degBed());
|
|
|
|
#if TEMP_1_PIN > -1
|
|
|
|
|
|
|
|
Serial.println(bt);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
Serial.println(HeaterPower);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#else //not PIDTEMP
|
|
|
|
|
|
|
|
Serial.println();
|
|
|
|
|
|
|
|
#endif //PIDTEMP
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
Serial.println();
|
|
|
|
|
|
|
|
#endif //TEMP_1_PIN
|
|
|
|
#endif //TEMP_1_PIN
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
SERIAL_ERRORLN("No thermistors - no temp");
|
|
|
|
SERIAL_ERROR_START;
|
|
|
|
|
|
|
|
SERIAL_ERRORLNPGM("No thermistors - no temp");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PIDTEMP
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLPGM(" @:");
|
|
|
|
|
|
|
|
SERIAL_PROTOCOL( HeaterPower);
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLLN("");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 109:
|
|
|
|
case 109:
|
|
|
|
{// M109 - Wait for extruder heater to reach target.
|
|
|
|
{// M109 - Wait for extruder heater to reach target.
|
|
|
|
LCD_MESSAGE("Heating...");
|
|
|
|
LCD_MESSAGEPGM("Heating...");
|
|
|
|
if (code_seen('S')) setTargetHotend0(code_value());
|
|
|
|
if (code_seen('S')) setTargetHotend0(code_value());
|
|
|
|
|
|
|
|
|
|
|
|
setWatch();
|
|
|
|
setWatch();
|
|
|
@ -668,8 +703,8 @@ inline void process_commands()
|
|
|
|
#endif //TEMP_RESIDENCY_TIME
|
|
|
|
#endif //TEMP_RESIDENCY_TIME
|
|
|
|
if( (millis() - codenum) > 1000 )
|
|
|
|
if( (millis() - codenum) > 1000 )
|
|
|
|
{ //Print Temp Reading every 1 second while heating up/cooling down
|
|
|
|
{ //Print Temp Reading every 1 second while heating up/cooling down
|
|
|
|
Serial.print("T:");
|
|
|
|
SERIAL_PROTOCOLPGM("T:");
|
|
|
|
Serial.println( degHotend0() );
|
|
|
|
SERIAL_PROTOCOLLN( degHotend0() );
|
|
|
|
codenum = millis();
|
|
|
|
codenum = millis();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
manage_heater();
|
|
|
|
manage_heater();
|
|
|
@ -685,12 +720,13 @@ inline void process_commands()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif //TEMP_RESIDENCY_TIME
|
|
|
|
#endif //TEMP_RESIDENCY_TIME
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LCD_MESSAGE("Heating done.");
|
|
|
|
LCD_MESSAGEPGM("Heating done.");
|
|
|
|
starttime=millis();
|
|
|
|
starttime=millis();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 190: // M190 - Wait bed for heater to reach target.
|
|
|
|
case 190: // M190 - Wait bed for heater to reach target.
|
|
|
|
#if TEMP_1_PIN > -1
|
|
|
|
#if TEMP_1_PIN > -1
|
|
|
|
|
|
|
|
LCD_MESSAGEPGM("Bed Heating.");
|
|
|
|
if (code_seen('S')) setTargetBed(code_value());
|
|
|
|
if (code_seen('S')) setTargetBed(code_value());
|
|
|
|
codenum = millis();
|
|
|
|
codenum = millis();
|
|
|
|
while(isHeatingBed())
|
|
|
|
while(isHeatingBed())
|
|
|
@ -698,16 +734,17 @@ inline void process_commands()
|
|
|
|
if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
|
|
|
|
if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
|
|
|
|
{
|
|
|
|
{
|
|
|
|
float tt=degHotend0();
|
|
|
|
float tt=degHotend0();
|
|
|
|
Serial.print("T:");
|
|
|
|
SERIAL_PROTOCOLPGM("T:");
|
|
|
|
Serial.println( tt );
|
|
|
|
SERIAL_PROTOCOLLN(tt );
|
|
|
|
Serial.print("ok T:");
|
|
|
|
SERIAL_PROTOCOLPGM("ok T:");
|
|
|
|
Serial.print( tt );
|
|
|
|
SERIAL_PROTOCOL(tt );
|
|
|
|
Serial.print(" B:");
|
|
|
|
SERIAL_PROTOCOLPGM(" B:");
|
|
|
|
Serial.println( degBed() );
|
|
|
|
SERIAL_PROTOCOLLN(degBed() );
|
|
|
|
codenum = millis();
|
|
|
|
codenum = millis();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
manage_heater();
|
|
|
|
manage_heater();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LCD_MESSAGEPGM("Bed done.");
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
@ -752,6 +789,7 @@ inline void process_commands()
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
st_synchronize();
|
|
|
|
st_synchronize();
|
|
|
|
|
|
|
|
LCD_MESSAGEPGM("Free move.");
|
|
|
|
disable_x();
|
|
|
|
disable_x();
|
|
|
|
disable_y();
|
|
|
|
disable_y();
|
|
|
|
disable_z();
|
|
|
|
disable_z();
|
|
|
@ -770,53 +808,53 @@ inline void process_commands()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 115: // M115
|
|
|
|
case 115: // M115
|
|
|
|
Serial.println("FIRMWARE_NAME:Marlin; Sprinter/grbl mashup for gen6 FIRMWARE_URL:http://www.mendel-parts.com PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1");
|
|
|
|
SerialprintPGM("FIRMWARE_NAME:Marlin; Sprinter/grbl mashup for gen6 FIRMWARE_URL:http://www.mendel-parts.com PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 114: // M114
|
|
|
|
case 114: // M114
|
|
|
|
Serial.print("X:");
|
|
|
|
SERIAL_PROTOCOLPGM("X:");
|
|
|
|
Serial.print(current_position[X_AXIS]);
|
|
|
|
SERIAL_PROTOCOL(current_position[X_AXIS]);
|
|
|
|
Serial.print("Y:");
|
|
|
|
SERIAL_PROTOCOLPGM("Y:");
|
|
|
|
Serial.print(current_position[Y_AXIS]);
|
|
|
|
SERIAL_PROTOCOL(current_position[Y_AXIS]);
|
|
|
|
Serial.print("Z:");
|
|
|
|
SERIAL_PROTOCOLPGM("Z:");
|
|
|
|
Serial.print(current_position[Z_AXIS]);
|
|
|
|
SERIAL_PROTOCOL(current_position[Z_AXIS]);
|
|
|
|
Serial.print("E:");
|
|
|
|
SERIAL_PROTOCOLPGM("E:");
|
|
|
|
Serial.print(current_position[E_AXIS]);
|
|
|
|
SERIAL_PROTOCOL(current_position[E_AXIS]);
|
|
|
|
#ifdef DEBUG_STEPS
|
|
|
|
#ifdef DEBUG_STEPS
|
|
|
|
Serial.print(" Count X:");
|
|
|
|
SERIAL_PROTOCOLPGM(" Count X:");
|
|
|
|
Serial.print(float(count_position[X_AXIS])/axis_steps_per_unit[X_AXIS]);
|
|
|
|
SERIAL_PROTOCOL(float(count_position[X_AXIS])/axis_steps_per_unit[X_AXIS]);
|
|
|
|
Serial.print("Y:");
|
|
|
|
SERIAL_PROTOCOLPGM("Y:");
|
|
|
|
Serial.print(float(count_position[Y_AXIS])/axis_steps_per_unit[Y_AXIS]);
|
|
|
|
SERIAL_PROTOCOL(float(count_position[Y_AXIS])/axis_steps_per_unit[Y_AXIS]);
|
|
|
|
Serial.print("Z:");
|
|
|
|
SERIAL_PROTOCOLPGM("Z:");
|
|
|
|
Serial.println(float(count_position[Z_AXIS])/axis_steps_per_unit[Z_AXIS]);
|
|
|
|
SERIAL_PROTOCOL(float(count_position[Z_AXIS])/axis_steps_per_unit[Z_AXIS]);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
Serial.println("");
|
|
|
|
SERIAL_PROTOCOLLN("");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 119: // M119
|
|
|
|
case 119: // M119
|
|
|
|
#if (X_MIN_PIN > -1)
|
|
|
|
#if (X_MIN_PIN > -1)
|
|
|
|
Serial.print("x_min:");
|
|
|
|
SERIAL_PROTOCOLPGM("x_min:");
|
|
|
|
Serial.print((READ(X_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L ");
|
|
|
|
SERIAL_PROTOCOL(((READ(X_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if (X_MAX_PIN > -1)
|
|
|
|
#if (X_MAX_PIN > -1)
|
|
|
|
Serial.print("x_max:");
|
|
|
|
SERIAL_PROTOCOLPGM("x_max:");
|
|
|
|
Serial.print((READ(X_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L ");
|
|
|
|
SERIAL_PROTOCOL(((READ(X_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if (Y_MIN_PIN > -1)
|
|
|
|
#if (Y_MIN_PIN > -1)
|
|
|
|
Serial.print("y_min:");
|
|
|
|
SERIAL_PROTOCOLPGM("y_min:");
|
|
|
|
Serial.print((READ(Y_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L ");
|
|
|
|
SERIAL_PROTOCOL(((READ(Y_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if (Y_MAX_PIN > -1)
|
|
|
|
#if (Y_MAX_PIN > -1)
|
|
|
|
Serial.print("y_max:");
|
|
|
|
SERIAL_PROTOCOLPGM("y_max:");
|
|
|
|
Serial.print((READ(Y_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L ");
|
|
|
|
SERIAL_PROTOCOL(((READ(Y_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if (Z_MIN_PIN > -1)
|
|
|
|
#if (Z_MIN_PIN > -1)
|
|
|
|
Serial.print("z_min:");
|
|
|
|
SERIAL_PROTOCOLPGM("z_min:");
|
|
|
|
Serial.print((READ(Z_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L ");
|
|
|
|
SERIAL_PROTOCOL(((READ(Z_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if (Z_MAX_PIN > -1)
|
|
|
|
#if (Z_MAX_PIN > -1)
|
|
|
|
Serial.print("z_max:");
|
|
|
|
SERIAL_PROTOCOLPGM("z_max:");
|
|
|
|
Serial.print((READ(Z_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L ");
|
|
|
|
SERIAL_PROTOCOL(((READ(Z_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
Serial.println("");
|
|
|
|
SERIAL_PROTOCOLLN("");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
//TODO: update for all axis, use for loop
|
|
|
|
//TODO: update for all axis, use for loop
|
|
|
|
case 201: // M201
|
|
|
|
case 201: // M201
|
|
|
@ -867,8 +905,28 @@ inline void process_commands()
|
|
|
|
if(code_seen('P')) Kp = code_value();
|
|
|
|
if(code_seen('P')) Kp = code_value();
|
|
|
|
if(code_seen('I')) Ki = code_value()*PID_dT;
|
|
|
|
if(code_seen('I')) Ki = code_value()*PID_dT;
|
|
|
|
if(code_seen('D')) Kd = code_value()/PID_dT;
|
|
|
|
if(code_seen('D')) Kd = code_value()/PID_dT;
|
|
|
|
|
|
|
|
#ifdef PID_ADD_EXTRUSION_RATE
|
|
|
|
|
|
|
|
if(code_seen('C')) Kc = code_value();
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
SERIAL_PROTOCOL("ok p:");
|
|
|
|
|
|
|
|
SERIAL_PROTOCOL(Kp);
|
|
|
|
|
|
|
|
SERIAL_PROTOCOL(" i:");
|
|
|
|
|
|
|
|
SERIAL_PROTOCOL(Ki/PID_dT);
|
|
|
|
|
|
|
|
SERIAL_PROTOCOL(" d:");
|
|
|
|
|
|
|
|
SERIAL_PROTOCOL(Kd*PID_dT);
|
|
|
|
|
|
|
|
#ifdef PID_ADD_EXTRUSION_RATE
|
|
|
|
|
|
|
|
SERIAL_PROTOCOL(" c:");
|
|
|
|
|
|
|
|
SERIAL_PROTOCOL(Kc*PID_dT);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLLN("");
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
#endif //PIDTEMP
|
|
|
|
#endif //PIDTEMP
|
|
|
|
|
|
|
|
case 400: // finish all moves
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
st_synchronize();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 500: // Store settings in EEPROM
|
|
|
|
case 500: // Store settings in EEPROM
|
|
|
|
{
|
|
|
|
{
|
|
|
|
StoreSettings();
|
|
|
|
StoreSettings();
|
|
|
@ -889,9 +947,10 @@ inline void process_commands()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Serial.print("echo: Unknown command:\"");
|
|
|
|
SERIAL_ECHO_START;
|
|
|
|
Serial.print(cmdbuffer[bufindr]);
|
|
|
|
SERIAL_ECHOPGM("Unknown command:\"");
|
|
|
|
Serial.println("\"");
|
|
|
|
SERIAL_ECHO(cmdbuffer[bufindr]);
|
|
|
|
|
|
|
|
SERIAL_ECHOLNPGM("\"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ClearToSend();
|
|
|
|
ClearToSend();
|
|
|
@ -901,8 +960,8 @@ void FlushSerialRequestResend()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//char cmdbuffer[bufindr][100]="Resend:";
|
|
|
|
//char cmdbuffer[bufindr][100]="Resend:";
|
|
|
|
Serial.flush();
|
|
|
|
Serial.flush();
|
|
|
|
Serial.print("Resend:");
|
|
|
|
SERIAL_PROTOCOLPGM("Resend:");
|
|
|
|
Serial.println(gcode_LastN + 1);
|
|
|
|
SERIAL_PROTOCOLLN(gcode_LastN + 1);
|
|
|
|
ClearToSend();
|
|
|
|
ClearToSend();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -913,7 +972,7 @@ void ClearToSend()
|
|
|
|
if(fromsd[bufindr])
|
|
|
|
if(fromsd[bufindr])
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
#endif //SDSUPPORT
|
|
|
|
#endif //SDSUPPORT
|
|
|
|
Serial.println("ok");
|
|
|
|
SERIAL_PROTOCOLLNPGM("ok");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void get_coordinates()
|
|
|
|
inline void get_coordinates()
|
|
|
@ -987,7 +1046,9 @@ void kill()
|
|
|
|
disable_e();
|
|
|
|
disable_e();
|
|
|
|
|
|
|
|
|
|
|
|
if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT);
|
|
|
|
if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT);
|
|
|
|
SERIAL_ERRORLN("Printer halted. kill() called !!");
|
|
|
|
SERIAL_ERROR_START;
|
|
|
|
|
|
|
|
SERIAL_ERRORLNPGM("Printer halted. kill() called !!");
|
|
|
|
|
|
|
|
LCD_MESSAGEPGM("KILLED. ");
|
|
|
|
while(1); // Wait for reset
|
|
|
|
while(1); // Wait for reset
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|