summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Tonokip_Firmware/Tonokip_Firmware.h34
-rw-r--r--Tonokip_Firmware/Tonokip_Firmware.pde67
2 files changed, 59 insertions, 42 deletions
diff --git a/Tonokip_Firmware/Tonokip_Firmware.h b/Tonokip_Firmware/Tonokip_Firmware.h
new file mode 100644
index 0000000..151937c
--- /dev/null
+++ b/Tonokip_Firmware/Tonokip_Firmware.h
@@ -0,0 +1,34 @@
+// Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
+// Licence: GPL
+
+void get_command();
+void process_commands();
+
+void manage_inactivity(byte debug);
+
+void manage_heater();
+float temp2analog(int celsius);
+float temp2analogBed(int celsius);
+float analog2temp(int raw);
+float analog2tempBed(int raw);
+
+void FlushSerialRequestResend();
+void ClearToSend();
+
+void get_coordinates();
+void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remaining, unsigned long z_steps_remaining, unsigned long e_steps_remaining);
+void disable_x();
+void disable_y();
+void disable_z();
+void disable_e();
+void enable_x();
+void enable_y();
+void enable_z();
+void enable_e();
+void do_x_step();
+void do_y_step();
+void do_z_step();
+void do_e_step();
+
+void kill(byte debug);
+
diff --git a/Tonokip_Firmware/Tonokip_Firmware.pde b/Tonokip_Firmware/Tonokip_Firmware.pde
index bb77f7e..33c4297 100644
--- a/Tonokip_Firmware/Tonokip_Firmware.pde
+++ b/Tonokip_Firmware/Tonokip_Firmware.pde
@@ -1,6 +1,7 @@
// Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
// Licence: GPL
+#include "Tonokip_Firmware.h"
#include "configuration.h"
#include "pins.h"
@@ -8,39 +9,6 @@
#include "SdFat.h"
#endif
-void get_command();
-void process_commands();
-
-void manage_inactivity(byte debug);
-
-void manage_heater();
-float temp2analog(int celsius);
-float temp2analogBed(int celsius);
-float analog2temp(int raw);
-float analog2tempBed(int raw);
-
-void FlushSerialRequestResend();
-void ClearToSend();
-
-void get_coordinates();
-void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remaining, unsigned long z_steps_remaining, unsigned long e_steps_remaining);
-void disable_x();
-void disable_y();
-void disable_z();
-void disable_e();
-void enable_x();
-void enable_y();
-void enable_z();
-void enable_e();
-void do_x_step();
-void do_y_step();
-void do_z_step();
-void do_e_step();
-
-void kill(byte debug);
-
-
-
// look here for descriptions of gcodes: http://linuxcnc.org/handbook/gcode/g-code.html
// http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes
@@ -76,14 +44,16 @@ void kill(byte debug);
// M81 - Turn off Power Supply
// M82 - Set E codes absolute (default)
// M83 - Set E codes relative while in Absolute Coordinates (G90) mode
-// M84 - Disable steppers until next move
+// M84 - Disable steppers until next move,
+// or use S<seconds> to specify an inactivity timeout, after which the steppers will be disabled. S0 to disable the timeout.
// M85 - Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
// M86 - If Endstop is Not Activated then Abort Print. Specify X and/or Y
// M92 - Set axis_steps_per_unit - same syntax as G92
// M115 - Capabilities string
// M140 - Set bed target temp
// M190 - Wait for bed current temp to reach target temp.
-
+// M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
+// M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000)
//Stepper Movement Variables
@@ -173,6 +143,7 @@ int minttemp=temp2analog(MINTEMP);
//Inactivity shutdown variables
unsigned long previous_millis_cmd=0;
unsigned long max_inactive_time = 0;
+unsigned long stepper_inactive_time = 0;
#ifdef SDSUPPORT
Sd2Card card;
@@ -312,9 +283,9 @@ void loop()
if(savetosd){
if(strstr(cmdbuffer[bufindr],"M29")==NULL){
write_command(cmdbuffer[bufindr]);
- file.sync();
Serial.println("ok");
}else{
+ file.sync(); // maybe this call is not needed
file.close();
savetosd=false;
Serial.println("Done saving file.");
@@ -494,7 +465,8 @@ inline void process_commands()
e_steps_to_take = abs(ediff)*e_steps_per_unit;
if(feedrate<10)
feedrate=10;
- /*//experimental feedrate calc
+ /*
+ //experimental feedrate calc
if(abs(xdiff)>0.1 && abs(ydiff)>0.1)
d=sqrt(xdiff*xdiff+ydiff*ydiff);
else if(abs(xdiff)>0.1)
@@ -780,10 +752,8 @@ inline void process_commands()
relative_mode_e = true;
break;
case 84:
- disable_x();
- disable_y();
- disable_z();
- disable_e();
+ if(code_seen('S')){ stepper_inactive_time = code_value()*1000; }
+ else{ disable_x(); disable_y(); disable_z(); disable_e(); }
break;
case 85: // M85
code_seen('S');
@@ -813,6 +783,16 @@ inline void process_commands()
Serial.print("E:");
Serial.println(current_e);
break;
+ #ifdef RAMP_ACCELERATION
+ case 201: // M201
+ if(code_seen('X')) x_steps_per_sqr_second = code_value() * x_steps_per_unit;
+ if(code_seen('Y')) x_steps_per_sqr_second = code_value() * y_steps_per_unit;
+ break;
+ case 202: // M202
+ if(code_seen('X')) x_travel_steps_per_sqr_second = code_value() * x_steps_per_unit;
+ if(code_seen('Y')) x_travel_steps_per_sqr_second = code_value() * y_steps_per_unit;
+ break;
+ #endif
}
}
@@ -1534,4 +1514,7 @@ inline void kill(byte debug)
}
}
-inline void manage_inactivity(byte debug) { if( (millis()-previous_millis_cmd) > max_inactive_time ) if(max_inactive_time) kill(debug); }
+inline void manage_inactivity(byte debug) {
+if( (millis()-previous_millis_cmd) > max_inactive_time ) if(max_inactive_time) kill(debug);
+if( (millis()-previous_millis_cmd) > stepper_inactive_time ) if(stepper_inactive_time) { disable_x(); disable_y(); disable_z(); disable_e(); }
+}