My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Marlin.pde 36KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178
  1. /*
  2. Reprap firmware based on Sprinter and grbl.
  3. Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. /*
  16. This firmware is a mashup between Sprinter and grbl.
  17. (https://github.com/kliment/Sprinter)
  18. (https://github.com/simen/grbl/tree)
  19. It has preliminary support for Matthew Roberts advance algorithm
  20. http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
  21. */
  22. #include <math.h>
  23. #include <EEPROM.h>
  24. #include "EEPROMwrite.h"
  25. #include "fastio.h"
  26. #include "Configuration.h"
  27. #include "pins.h"
  28. #include "Marlin.h"
  29. #include "ultralcd.h"
  30. #include "planner.h"
  31. #include "stepper.h"
  32. #include "temperature.h"
  33. #include "motion_control.h"
  34. #include "cardreader.h"
  35. #include "watchdog.h"
  36. #include <stdio.h>
  37. #define VERSION_STRING "1.0.0 Beta 1"
  38. // look here for descriptions of gcodes: http://linuxcnc.org/handbook/gcode/g-code.html
  39. // http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes
  40. //Implemented Codes
  41. //-------------------
  42. // G0 -> G1
  43. // G1 - Coordinated Movement X Y Z E
  44. // G2 - CW ARC
  45. // G3 - CCW ARC
  46. // G4 - Dwell S<seconds> or P<milliseconds>
  47. // G28 - Home all Axis
  48. // G90 - Use Absolute Coordinates
  49. // G91 - Use Relative Coordinates
  50. // G92 - Set current position to cordinates given
  51. //RepRap M Codes
  52. // M104 - Set extruder target temp
  53. // M105 - Read current temp
  54. // M106 - Fan on
  55. // M107 - Fan off
  56. // M109 - Wait for extruder current temp to reach target temp.
  57. // M114 - Display current position
  58. //Custom M Codes
  59. // M17 - Enable/Power all stepper motors
  60. // M18 - Disable all stepper motors; same as M84
  61. // M20 - List SD card
  62. // M21 - Init SD card
  63. // M22 - Release SD card
  64. // M23 - Select SD file (M23 filename.g)
  65. // M24 - Start/resume SD print
  66. // M25 - Pause SD print
  67. // M26 - Set SD position in bytes (M26 S12345)
  68. // M27 - Report SD print status
  69. // M28 - Start SD write (M28 filename.g)
  70. // M29 - Stop SD write
  71. // M30 - Output time since last M109 or SD card start to serial
  72. // M42 - Change pin status via gcode
  73. // M80 - Turn on Power Supply
  74. // M81 - Turn off Power Supply
  75. // M82 - Set E codes absolute (default)
  76. // M83 - Set E codes relative while in Absolute Coordinates (G90) mode
  77. // M84 - Disable steppers until next move,
  78. // or use S<seconds> to specify an inactivity timeout, after which the steppers will be disabled. S0 to disable the timeout.
  79. // M85 - Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
  80. // M92 - Set axis_steps_per_unit - same syntax as G92
  81. // M114 - Output current position to serial port
  82. // M115 - Capabilities string
  83. // M117 - display message
  84. // M119 - Output Endstop status to serial port
  85. // M140 - Set bed target temp
  86. // M190 - Wait for bed current temp to reach target temp.
  87. // M200 - Set filament diameter
  88. // M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
  89. // M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!!
  90. // M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec
  91. // 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
  92. // M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk
  93. // M206 - set additional homeing offset
  94. // M220 - set speed factor override percentage S:factor in percent
  95. // M301 - Set PID parameters P I and D
  96. // M400 - Finish all moves
  97. // M500 - stores paramters in EEPROM
  98. // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
  99. // M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
  100. //Stepper Movement Variables
  101. //===========================================================================
  102. //=============================imported variables============================
  103. //===========================================================================
  104. extern float HeaterPower;
  105. //===========================================================================
  106. //=============================public variables=============================
  107. //===========================================================================
  108. #ifdef SDSUPPORT
  109. CardReader card;
  110. #endif
  111. float homing_feedrate[] = HOMING_FEEDRATE;
  112. bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
  113. volatile int feedmultiply=100; //100->1 200->2
  114. int saved_feedmultiply;
  115. volatile bool feedmultiplychanged=false;
  116. float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
  117. float add_homeing[3]={0,0,0};
  118. //===========================================================================
  119. //=============================private variables=============================
  120. //===========================================================================
  121. const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
  122. static float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
  123. static float offset[3] = {0.0, 0.0, 0.0};
  124. static bool home_all_axis = true;
  125. static float feedrate = 1500.0, next_feedrate, saved_feedrate;
  126. static long gcode_N, gcode_LastN;
  127. static bool relative_mode = false; //Determines Absolute or Relative Coordinates
  128. static bool relative_mode_e = false; //Determines Absolute or Relative E Codes while in Absolute Coordinates mode. E is always relative in Relative Coordinates mode.
  129. static uint8_t fanpwm=0;
  130. static char cmdbuffer[BUFSIZE][MAX_CMD_SIZE];
  131. static bool fromsd[BUFSIZE];
  132. static int bufindr = 0;
  133. static int bufindw = 0;
  134. static int buflen = 0;
  135. static int i = 0;
  136. static char serial_char;
  137. static int serial_count = 0;
  138. static boolean comment_mode = false;
  139. static char *strchr_pointer; // just a pointer to find chars in the cmd string like X, Y, Z, E, etc
  140. const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42
  141. static float tt = 0, bt = 0;
  142. //Inactivity shutdown variables
  143. static unsigned long previous_millis_cmd = 0;
  144. static unsigned long max_inactive_time = 0;
  145. static unsigned long stepper_inactive_time = 0;
  146. static unsigned long starttime=0;
  147. static unsigned long stoptime=0;
  148. static uint8_t tmp_extruder;
  149. //===========================================================================
  150. //=============================ROUTINES=============================
  151. //===========================================================================
  152. void get_arc_coordinates();
  153. extern "C"{
  154. extern unsigned int __bss_end;
  155. extern unsigned int __heap_start;
  156. extern void *__brkval;
  157. int freeMemory() {
  158. int free_memory;
  159. if((int)__brkval == 0)
  160. free_memory = ((int)&free_memory) - ((int)&__bss_end);
  161. else
  162. free_memory = ((int)&free_memory) - ((int)__brkval);
  163. return free_memory;
  164. }
  165. }
  166. //adds an command to the main command buffer
  167. //thats really done in a non-safe way.
  168. //needs overworking someday
  169. void enquecommand(const char *cmd)
  170. {
  171. if(buflen < BUFSIZE)
  172. {
  173. //this is dangerous if a mixing of serial and this happsens
  174. strcpy(&(cmdbuffer[bufindw][0]),cmd);
  175. SERIAL_ECHO_START;
  176. SERIAL_ECHOPGM("enqueing \"");
  177. SERIAL_ECHO(cmdbuffer[bufindw]);
  178. SERIAL_ECHOLNPGM("\"");
  179. bufindw= (bufindw + 1)%BUFSIZE;
  180. buflen += 1;
  181. }
  182. }
  183. void setup()
  184. {
  185. MSerial.begin(BAUDRATE);
  186. SERIAL_ECHO_START;
  187. SERIAL_ECHOLNPGM(VERSION_STRING);
  188. SERIAL_PROTOCOLLNPGM("start");
  189. SERIAL_ECHO_START;
  190. SERIAL_ECHOPGM("Free Memory:");
  191. SERIAL_ECHOLN(freeMemory());
  192. for(int8_t i = 0; i < BUFSIZE; i++)
  193. {
  194. fromsd[i] = false;
  195. }
  196. RetrieveSettings(); // loads data from EEPROM if available
  197. for(int8_t i=0; i < NUM_AXIS; i++)
  198. {
  199. axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i];
  200. }
  201. tp_init(); // Initialize temperature loop
  202. plan_init(); // Initialize planner;
  203. st_init(); // Initialize stepper;
  204. wd_init();
  205. }
  206. void loop()
  207. {
  208. if(buflen<3)
  209. get_command();
  210. #ifdef SDSUPPORT
  211. card.checkautostart(false);
  212. #endif
  213. if(buflen)
  214. {
  215. #ifdef SDSUPPORT
  216. if(card.saving)
  217. {
  218. if(strstr(cmdbuffer[bufindr],"M29") == NULL)
  219. {
  220. card.write_command(cmdbuffer[bufindr]);
  221. SERIAL_PROTOCOLLNPGM("ok");
  222. }
  223. else
  224. {
  225. card.closefile();
  226. SERIAL_PROTOCOLLNPGM("Done saving file.");
  227. }
  228. }
  229. else
  230. {
  231. process_commands();
  232. }
  233. #else
  234. process_commands();
  235. #endif //SDSUPPORT
  236. buflen = (buflen-1);
  237. bufindr = (bufindr + 1)%BUFSIZE;
  238. }
  239. //check heater every n milliseconds
  240. manage_heater();
  241. manage_inactivity(1);
  242. checkHitEndstops();
  243. LCD_STATUS;
  244. }
  245. FORCE_INLINE void get_command()
  246. {
  247. while( MSerial.available() > 0 && buflen < BUFSIZE) {
  248. serial_char = MSerial.read();
  249. if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1) )
  250. {
  251. if(!serial_count) return; //if empty line
  252. cmdbuffer[bufindw][serial_count] = 0; //terminate string
  253. if(!comment_mode){
  254. fromsd[bufindw] = false;
  255. if(strstr(cmdbuffer[bufindw], "N") != NULL)
  256. {
  257. strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
  258. gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10));
  259. if(gcode_N != gcode_LastN+1 && (strstr(cmdbuffer[bufindw], "M110") == NULL) ) {
  260. SERIAL_ERROR_START;
  261. SERIAL_ERRORPGM("Line Number is not Last Line Number+1, Last Line:");
  262. SERIAL_ERRORLN(gcode_LastN);
  263. //Serial.println(gcode_N);
  264. FlushSerialRequestResend();
  265. serial_count = 0;
  266. return;
  267. }
  268. if(strstr(cmdbuffer[bufindw], "*") != NULL)
  269. {
  270. byte checksum = 0;
  271. byte count = 0;
  272. while(cmdbuffer[bufindw][count] != '*') checksum = checksum^cmdbuffer[bufindw][count++];
  273. strchr_pointer = strchr(cmdbuffer[bufindw], '*');
  274. if( (int)(strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)) != checksum) {
  275. SERIAL_ERROR_START;
  276. SERIAL_ERRORPGM("checksum mismatch, Last Line:");
  277. SERIAL_ERRORLN(gcode_LastN);
  278. FlushSerialRequestResend();
  279. serial_count = 0;
  280. return;
  281. }
  282. //if no errors, continue parsing
  283. }
  284. else
  285. {
  286. SERIAL_ERROR_START;
  287. SERIAL_ERRORPGM("No Checksum with line number, Last Line:");
  288. SERIAL_ERRORLN(gcode_LastN);
  289. FlushSerialRequestResend();
  290. serial_count = 0;
  291. return;
  292. }
  293. gcode_LastN = gcode_N;
  294. //if no errors, continue parsing
  295. }
  296. else // if we don't receive 'N' but still see '*'
  297. {
  298. if((strstr(cmdbuffer[bufindw], "*") != NULL))
  299. {
  300. SERIAL_ERROR_START;
  301. SERIAL_ERRORPGM("No Line Number with checksum, Last Line:");
  302. SERIAL_ERRORLN(gcode_LastN);
  303. serial_count = 0;
  304. return;
  305. }
  306. }
  307. if((strstr(cmdbuffer[bufindw], "G") != NULL)){
  308. strchr_pointer = strchr(cmdbuffer[bufindw], 'G');
  309. switch((int)((strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)))){
  310. case 0:
  311. case 1:
  312. case 2:
  313. case 3:
  314. #ifdef SDSUPPORT
  315. if(card.saving)
  316. break;
  317. #endif //SDSUPPORT
  318. SERIAL_PROTOCOLLNPGM("ok");
  319. break;
  320. default:
  321. break;
  322. }
  323. }
  324. bufindw = (bufindw + 1)%BUFSIZE;
  325. buflen += 1;
  326. }
  327. comment_mode = false; //for new command
  328. serial_count = 0; //clear buffer
  329. }
  330. else
  331. {
  332. if(serial_char == ';') comment_mode = true;
  333. if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
  334. }
  335. }
  336. #ifdef SDSUPPORT
  337. if(!card.sdprinting || serial_count!=0){
  338. return;
  339. }
  340. while( !card.eof() && buflen < BUFSIZE) {
  341. int16_t n=card.get();
  342. serial_char = (char)n;
  343. if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1)||n==-1)
  344. {
  345. if(card.eof()){
  346. SERIAL_PROTOCOLLNPGM("Done printing file");
  347. stoptime=millis();
  348. char time[30];
  349. unsigned long t=(stoptime-starttime)/1000;
  350. int sec,min;
  351. min=t/60;
  352. sec=t%60;
  353. sprintf(time,"%i min, %i sec",min,sec);
  354. SERIAL_ECHO_START;
  355. SERIAL_ECHOLN(time);
  356. LCD_MESSAGE(time);
  357. card.printingHasFinished();
  358. card.checkautostart(true);
  359. }
  360. if(serial_char=='\n')
  361. comment_mode = false; //for new command
  362. if(!serial_count)
  363. {
  364. return; //if empty line
  365. }
  366. cmdbuffer[bufindw][serial_count] = 0; //terminate string
  367. if(!comment_mode){
  368. fromsd[bufindw] = true;
  369. buflen += 1;
  370. bufindw = (bufindw + 1)%BUFSIZE;
  371. }
  372. serial_count = 0; //clear buffer
  373. }
  374. else
  375. {
  376. if(serial_char == ';') comment_mode = true;
  377. if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
  378. }
  379. }
  380. #endif //SDSUPPORT
  381. }
  382. FORCE_INLINE float code_value()
  383. {
  384. return (strtod(&cmdbuffer[bufindr][strchr_pointer - cmdbuffer[bufindr] + 1], NULL));
  385. }
  386. FORCE_INLINE long code_value_long()
  387. {
  388. return (strtol(&cmdbuffer[bufindr][strchr_pointer - cmdbuffer[bufindr] + 1], NULL, 10));
  389. }
  390. FORCE_INLINE bool code_seen(char code_string[]) //Return True if the string was found
  391. {
  392. return (strstr(cmdbuffer[bufindr], code_string) != NULL);
  393. }
  394. FORCE_INLINE bool code_seen(char code)
  395. {
  396. strchr_pointer = strchr(cmdbuffer[bufindr], code);
  397. return (strchr_pointer != NULL); //Return True if a character was found
  398. }
  399. #define HOMEAXIS(LETTER) \
  400. if ((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))\
  401. { \
  402. current_position[LETTER##_AXIS] = 0; \
  403. plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); \
  404. destination[LETTER##_AXIS] = 1.5 * LETTER##_MAX_LENGTH * LETTER##_HOME_DIR; \
  405. feedrate = homing_feedrate[LETTER##_AXIS]; \
  406. prepare_move(); \
  407. \
  408. current_position[LETTER##_AXIS] = 0;\
  409. plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
  410. destination[LETTER##_AXIS] = -LETTER##_HOME_RETRACT_MM * LETTER##_HOME_DIR;\
  411. prepare_move(); \
  412. \
  413. destination[LETTER##_AXIS] = 2*LETTER##_HOME_RETRACT_MM * LETTER##_HOME_DIR;\
  414. feedrate = homing_feedrate[LETTER##_AXIS]/2 ; \
  415. prepare_move(); \
  416. \
  417. current_position[LETTER##_AXIS] = (LETTER##_HOME_DIR == -1) ? 0 : LETTER##_MAX_LENGTH;\
  418. plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
  419. destination[LETTER##_AXIS] = current_position[LETTER##_AXIS];\
  420. feedrate = 0.0;\
  421. st_synchronize();\
  422. plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
  423. endstops_hit_on_purpose();\
  424. }
  425. FORCE_INLINE void process_commands()
  426. {
  427. unsigned long codenum; //throw away variable
  428. char *starpos = NULL;
  429. if(code_seen('G'))
  430. {
  431. switch((int)code_value())
  432. {
  433. case 0: // G0 -> G1
  434. case 1: // G1
  435. get_coordinates(); // For X Y Z E F
  436. prepare_move();
  437. previous_millis_cmd = millis();
  438. //ClearToSend();
  439. return;
  440. //break;
  441. case 2: // G2 - CW ARC
  442. get_arc_coordinates();
  443. prepare_arc_move(true);
  444. previous_millis_cmd = millis();
  445. return;
  446. case 3: // G3 - CCW ARC
  447. get_arc_coordinates();
  448. prepare_arc_move(false);
  449. previous_millis_cmd = millis();
  450. return;
  451. case 4: // G4 dwell
  452. LCD_MESSAGEPGM("DWELL...");
  453. codenum = 0;
  454. if(code_seen('P')) codenum = code_value(); // milliseconds to wait
  455. if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
  456. st_synchronize();
  457. codenum += millis(); // keep track of when we started waiting
  458. while(millis() < codenum ){
  459. manage_heater();
  460. }
  461. break;
  462. case 28: //G28 Home all Axis one at a time
  463. saved_feedrate = feedrate;
  464. saved_feedmultiply = feedmultiply;
  465. feedmultiply = 100;
  466. for(int8_t i=0; i < NUM_AXIS; i++) {
  467. destination[i] = current_position[i];
  468. }
  469. feedrate = 0.0;
  470. home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])));
  471. #ifdef QUICK_HOME
  472. if( code_seen(axis_codes[0]) && code_seen(axis_codes[1]) ) //first diagonal move
  473. {
  474. current_position[X_AXIS] = 0; current_position[Y_AXIS] = 0;
  475. plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
  476. destination[X_AXIS] = 1.5 * X_MAX_LENGTH * X_HOME_DIR;
  477. destination[Y_AXIS] = 1.5 * Y_MAX_LENGTH * Y_HOME_DIR;
  478. feedrate =homing_feedrate[X_AXIS];
  479. if(homing_feedrate[Y_AXIS]<feedrate)
  480. feedrate =homing_feedrate[Y_AXIS];
  481. prepare_move();
  482. current_position[X_AXIS] = 0; current_position[Y_AXIS] = 0;
  483. }
  484. #endif
  485. if((home_all_axis) || (code_seen(axis_codes[X_AXIS])))
  486. {
  487. HOMEAXIS(X);
  488. current_position[0]=code_value()+add_homeing[0];
  489. }
  490. if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
  491. HOMEAXIS(Y);
  492. current_position[1]=code_value()+add_homeing[1];
  493. }
  494. if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
  495. HOMEAXIS(Z);
  496. current_position[2]=code_value()+add_homeing[2];
  497. }
  498. feedrate = saved_feedrate;
  499. feedmultiply = saved_feedmultiply;
  500. previous_millis_cmd = millis();
  501. endstops_hit_on_purpose();
  502. break;
  503. case 90: // G90
  504. relative_mode = false;
  505. break;
  506. case 91: // G91
  507. relative_mode = true;
  508. break;
  509. case 92: // G92
  510. if(!code_seen(axis_codes[E_AXIS]))
  511. st_synchronize();
  512. for(int8_t i=0; i < NUM_AXIS; i++) {
  513. if(code_seen(axis_codes[i])) {
  514. current_position[i] = code_value()+add_homeing[i];
  515. if(i == E_AXIS) {
  516. plan_set_e_position(current_position[E_AXIS]);
  517. }
  518. else {
  519. plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
  520. }
  521. }
  522. }
  523. break;
  524. }
  525. }
  526. else if(code_seen('M'))
  527. {
  528. switch( (int)code_value() )
  529. {
  530. case 17:
  531. LCD_MESSAGEPGM("No move.");
  532. enable_x();
  533. enable_y();
  534. enable_z();
  535. enable_e();
  536. break;
  537. #ifdef SDSUPPORT
  538. case 20: // M20 - list SD card
  539. SERIAL_PROTOCOLLNPGM("Begin file list");
  540. card.ls();
  541. SERIAL_PROTOCOLLNPGM("End file list");
  542. break;
  543. case 21: // M21 - init SD card
  544. card.initsd();
  545. break;
  546. case 22: //M22 - release SD card
  547. card.release();
  548. break;
  549. case 23: //M23 - Select file
  550. starpos = (strchr(strchr_pointer + 4,'*'));
  551. if(starpos!=NULL)
  552. *(starpos-1)='\0';
  553. card.openFile(strchr_pointer + 4,true);
  554. break;
  555. case 24: //M24 - Start SD print
  556. card.startFileprint();
  557. starttime=millis();
  558. break;
  559. case 25: //M25 - Pause SD print
  560. card.pauseSDPrint();
  561. break;
  562. case 26: //M26 - Set SD index
  563. if(card.cardOK && code_seen('S')){
  564. card.setIndex(code_value_long());
  565. }
  566. break;
  567. case 27: //M27 - Get SD status
  568. card.getStatus();
  569. break;
  570. case 28: //M28 - Start SD write
  571. starpos = (strchr(strchr_pointer + 4,'*'));
  572. if(starpos != NULL){
  573. char* npos = strchr(cmdbuffer[bufindr], 'N');
  574. strchr_pointer = strchr(npos,' ') + 1;
  575. *(starpos-1) = '\0';
  576. }
  577. card.openFile(strchr_pointer+4,false);
  578. break;
  579. case 29: //M29 - Stop SD write
  580. //processed in write to file routine above
  581. //card,saving = false;
  582. break;
  583. #endif //SDSUPPORT
  584. case 30: //M30 take time since the start of the SD print or an M109 command
  585. {
  586. stoptime=millis();
  587. char time[30];
  588. unsigned long t=(stoptime-starttime)/1000;
  589. int sec,min;
  590. min=t/60;
  591. sec=t%60;
  592. sprintf(time,"%i min, %i sec",min,sec);
  593. SERIAL_ECHO_START;
  594. SERIAL_ECHOLN(time);
  595. LCD_MESSAGE(time);
  596. }
  597. break;
  598. case 42: //M42 -Change pin status via gcode
  599. if (code_seen('S'))
  600. {
  601. int pin_status = code_value();
  602. if (code_seen('P') && pin_status >= 0 && pin_status <= 255)
  603. {
  604. int pin_number = code_value();
  605. for(int8_t i = 0; i < (int8_t)sizeof(sensitive_pins); i++)
  606. {
  607. if (sensitive_pins[i] == pin_number)
  608. {
  609. pin_number = -1;
  610. break;
  611. }
  612. }
  613. if (pin_number > -1)
  614. {
  615. pinMode(pin_number, OUTPUT);
  616. digitalWrite(pin_number, pin_status);
  617. analogWrite(pin_number, pin_status);
  618. }
  619. }
  620. }
  621. break;
  622. case 104: // M104
  623. tmp_extruder = active_extruder;
  624. if(code_seen('T')) {
  625. tmp_extruder = code_value();
  626. if(tmp_extruder >= EXTRUDERS) {
  627. SERIAL_ECHO_START;
  628. SERIAL_ECHO("M104 Invalid extruder ");
  629. SERIAL_ECHOLN(tmp_extruder);
  630. break;
  631. }
  632. }
  633. if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
  634. setWatch();
  635. break;
  636. case 140: // M140 set bed temp
  637. if (code_seen('S')) setTargetBed(code_value());
  638. break;
  639. case 105 : // M105
  640. tmp_extruder = active_extruder;
  641. if(code_seen('T')) {
  642. tmp_extruder = code_value();
  643. if(tmp_extruder >= EXTRUDERS) {
  644. SERIAL_ECHO_START;
  645. SERIAL_ECHO("M105 Invalid extruder ");
  646. SERIAL_ECHOLN(tmp_extruder);
  647. break;
  648. }
  649. }
  650. #if (TEMP_0_PIN > -1) || (TEMP_2_PIN > -1)
  651. SERIAL_PROTOCOLPGM("ok T:");
  652. SERIAL_PROTOCOL( degHotend(tmp_extruder));
  653. #if TEMP_1_PIN > -1
  654. SERIAL_PROTOCOLPGM(" B:");
  655. SERIAL_PROTOCOL(degBed());
  656. #endif //TEMP_1_PIN
  657. #else
  658. SERIAL_ERROR_START;
  659. SERIAL_ERRORLNPGM("No thermistors - no temp");
  660. #endif
  661. #ifdef PIDTEMP
  662. SERIAL_PROTOCOLPGM(" @:");
  663. SERIAL_PROTOCOL( HeaterPower);
  664. #endif
  665. SERIAL_PROTOCOLLN("");
  666. return;
  667. break;
  668. case 109:
  669. {// M109 - Wait for extruder heater to reach target.
  670. tmp_extruder = active_extruder;
  671. if(code_seen('T')) {
  672. tmp_extruder = code_value();
  673. if(tmp_extruder >= EXTRUDERS) {
  674. SERIAL_ECHO_START;
  675. SERIAL_ECHO("M109 Invalid extruder ");
  676. SERIAL_ECHOLN(tmp_extruder);
  677. break;
  678. }
  679. }
  680. LCD_MESSAGEPGM("Heating...");
  681. #ifdef AUTOTEMP
  682. autotemp_enabled=false;
  683. #endif
  684. if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
  685. #ifdef AUTOTEMP
  686. if (code_seen('S')) autotemp_min=code_value();
  687. if (code_seen('G')) autotemp_max=code_value();
  688. if (code_seen('F'))
  689. {
  690. autotemp_factor=code_value();
  691. autotemp_enabled=true;
  692. }
  693. #endif
  694. setWatch();
  695. codenum = millis();
  696. /* See if we are heating up or cooling down */
  697. bool target_direction = isHeatingHotend(tmp_extruder); // true if heating, false if cooling
  698. #ifdef TEMP_RESIDENCY_TIME
  699. long residencyStart;
  700. residencyStart = -1;
  701. /* continue to loop until we have reached the target temp
  702. _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
  703. while((target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder))) ||
  704. (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
  705. #else
  706. while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) ) {
  707. #endif //TEMP_RESIDENCY_TIME
  708. if( (millis() - codenum) > 1000 )
  709. { //Print Temp Reading every 1 second while heating up/cooling down
  710. SERIAL_PROTOCOLPGM("T:");
  711. SERIAL_PROTOCOLLN( degHotend(tmp_extruder) );
  712. codenum = millis();
  713. }
  714. manage_heater();
  715. LCD_STATUS;
  716. #ifdef TEMP_RESIDENCY_TIME
  717. /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
  718. or when current temp falls outside the hysteresis after target temp was reached */
  719. if ((residencyStart == -1 && target_direction && !isHeatingHotend(tmp_extruder)) ||
  720. (residencyStart == -1 && !target_direction && !isCoolingHotend(tmp_extruder)) ||
  721. (residencyStart > -1 && labs(degHotend(tmp_extruder) - degTargetHotend(tmp_extruder)) > TEMP_HYSTERESIS) )
  722. {
  723. residencyStart = millis();
  724. }
  725. #endif //TEMP_RESIDENCY_TIME
  726. }
  727. LCD_MESSAGEPGM("Heating done.");
  728. starttime=millis();
  729. }
  730. break;
  731. case 190: // M190 - Wait bed for heater to reach target.
  732. #if TEMP_1_PIN > -1
  733. LCD_MESSAGEPGM("Bed Heating.");
  734. if (code_seen('S')) setTargetBed(code_value());
  735. codenum = millis();
  736. while(isHeatingBed())
  737. {
  738. if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
  739. {
  740. float tt=degHotend0();
  741. SERIAL_PROTOCOLPGM("T:");
  742. SERIAL_PROTOCOLLN(tt );
  743. SERIAL_PROTOCOLPGM("ok T:");
  744. SERIAL_PROTOCOL(tt );
  745. SERIAL_PROTOCOLPGM(" B:");
  746. SERIAL_PROTOCOLLN(degBed() );
  747. codenum = millis();
  748. }
  749. manage_heater();
  750. }
  751. LCD_MESSAGEPGM("Bed done.");
  752. #endif
  753. break;
  754. #if FAN_PIN > -1
  755. case 106: //M106 Fan On
  756. if (code_seen('S')){
  757. WRITE(FAN_PIN,HIGH);
  758. fanpwm=constrain(code_value(),0,255);
  759. analogWrite(FAN_PIN, fanpwm);
  760. }
  761. else {
  762. WRITE(FAN_PIN,HIGH);
  763. fanpwm=255;
  764. analogWrite(FAN_PIN, fanpwm);
  765. }
  766. break;
  767. case 107: //M107 Fan Off
  768. WRITE(FAN_PIN,LOW);
  769. analogWrite(FAN_PIN, 0);
  770. break;
  771. #endif //FAN_PIN
  772. #if (PS_ON_PIN > -1)
  773. case 80: // M80 - ATX Power On
  774. SET_OUTPUT(PS_ON_PIN); //GND
  775. break;
  776. case 81: // M81 - ATX Power Off
  777. SET_INPUT(PS_ON_PIN); //Floating
  778. break;
  779. #endif
  780. case 82:
  781. axis_relative_modes[3] = false;
  782. break;
  783. case 83:
  784. axis_relative_modes[3] = true;
  785. break;
  786. case 18: //compatibility
  787. case 84: // M84
  788. if(code_seen('S')){
  789. stepper_inactive_time = code_value() * 1000;
  790. }
  791. else
  792. {
  793. #if ((E_ENABLE_PIN != X_ENABLE_PIN) && (E_ENABLE_PIN != Y_ENABLE_PIN)) // Only enable on boards that have seperate ENABLE_PINS
  794. if(code_seen('E')) {
  795. st_synchronize();
  796. LCD_MESSAGEPGM("Free Move");
  797. disable_e();
  798. }
  799. else {
  800. finishAndDisableSteppers();
  801. }
  802. #else
  803. finishAndDisableSteppers();
  804. #endif
  805. }
  806. break;
  807. case 85: // M85
  808. code_seen('S');
  809. max_inactive_time = code_value() * 1000;
  810. break;
  811. case 92: // M92
  812. for(int8_t i=0; i < NUM_AXIS; i++)
  813. {
  814. if(code_seen(axis_codes[i]))
  815. axis_steps_per_unit[i] = code_value();
  816. }
  817. break;
  818. case 115: // M115
  819. 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");
  820. break;
  821. case 117: // M117 display message
  822. LCD_MESSAGE(cmdbuffer[bufindr]+5);
  823. break;
  824. case 114: // M114
  825. SERIAL_PROTOCOLPGM("X:");
  826. SERIAL_PROTOCOL(current_position[X_AXIS]);
  827. SERIAL_PROTOCOLPGM("Y:");
  828. SERIAL_PROTOCOL(current_position[Y_AXIS]);
  829. SERIAL_PROTOCOLPGM("Z:");
  830. SERIAL_PROTOCOL(current_position[Z_AXIS]);
  831. SERIAL_PROTOCOLPGM("E:");
  832. SERIAL_PROTOCOL(current_position[E_AXIS]);
  833. SERIAL_PROTOCOLPGM(" Count X:");
  834. SERIAL_PROTOCOL(float(st_get_position(X_AXIS))/axis_steps_per_unit[X_AXIS]);
  835. SERIAL_PROTOCOLPGM("Y:");
  836. SERIAL_PROTOCOL(float(st_get_position(Y_AXIS))/axis_steps_per_unit[Y_AXIS]);
  837. SERIAL_PROTOCOLPGM("Z:");
  838. SERIAL_PROTOCOL(float(st_get_position(Z_AXIS))/axis_steps_per_unit[Z_AXIS]);
  839. SERIAL_PROTOCOLLN("");
  840. break;
  841. case 119: // M119
  842. #if (X_MIN_PIN > -1)
  843. SERIAL_PROTOCOLPGM("x_min:");
  844. SERIAL_PROTOCOL(((READ(X_MIN_PIN)^X_ENDSTOPS_INVERTING)?"H ":"L "));
  845. #endif
  846. #if (X_MAX_PIN > -1)
  847. SERIAL_PROTOCOLPGM("x_max:");
  848. SERIAL_PROTOCOL(((READ(X_MAX_PIN)^X_ENDSTOPS_INVERTING)?"H ":"L "));
  849. #endif
  850. #if (Y_MIN_PIN > -1)
  851. SERIAL_PROTOCOLPGM("y_min:");
  852. SERIAL_PROTOCOL(((READ(Y_MIN_PIN)^Y_ENDSTOPS_INVERTING)?"H ":"L "));
  853. #endif
  854. #if (Y_MAX_PIN > -1)
  855. SERIAL_PROTOCOLPGM("y_max:");
  856. SERIAL_PROTOCOL(((READ(Y_MAX_PIN)^Y_ENDSTOPS_INVERTING)?"H ":"L "));
  857. #endif
  858. #if (Z_MIN_PIN > -1)
  859. SERIAL_PROTOCOLPGM("z_min:");
  860. SERIAL_PROTOCOL(((READ(Z_MIN_PIN)^Z_ENDSTOPS_INVERTING)?"H ":"L "));
  861. #endif
  862. #if (Z_MAX_PIN > -1)
  863. SERIAL_PROTOCOLPGM("z_max:");
  864. SERIAL_PROTOCOL(((READ(Z_MAX_PIN)^Z_ENDSTOPS_INVERTING)?"H ":"L "));
  865. #endif
  866. SERIAL_PROTOCOLLN("");
  867. break;
  868. //TODO: update for all axis, use for loop
  869. case 201: // M201
  870. for(int8_t i=0; i < NUM_AXIS; i++)
  871. {
  872. if(code_seen(axis_codes[i])) axis_steps_per_sqr_second[i] = code_value() * axis_steps_per_unit[i];
  873. }
  874. break;
  875. #if 0 // Not used for Sprinter/grbl gen6
  876. case 202: // M202
  877. for(int8_t i=0; i < NUM_AXIS; i++) {
  878. if(code_seen(axis_codes[i])) axis_travel_steps_per_sqr_second[i] = code_value() * axis_steps_per_unit[i];
  879. }
  880. break;
  881. #endif
  882. case 203: // M203 max feedrate mm/sec
  883. for(int8_t i=0; i < NUM_AXIS; i++) {
  884. if(code_seen(axis_codes[i])) max_feedrate[i] = code_value();
  885. }
  886. break;
  887. case 204: // M204 acclereration S normal moves T filmanent only moves
  888. {
  889. if(code_seen('S')) acceleration = code_value() ;
  890. if(code_seen('T')) retract_acceleration = code_value() ;
  891. }
  892. break;
  893. case 205: //M205 advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk
  894. {
  895. if(code_seen('S')) minimumfeedrate = code_value();
  896. if(code_seen('T')) mintravelfeedrate = code_value();
  897. if(code_seen('B')) minsegmenttime = code_value() ;
  898. if(code_seen('X')) max_xy_jerk = code_value() ;
  899. if(code_seen('Z')) max_z_jerk = code_value() ;
  900. }
  901. break;
  902. case 206: // M206 additional homeing offset
  903. for(int8_t i=0; i < 3; i++)
  904. {
  905. if(code_seen(axis_codes[i])) add_homeing[i] = code_value();
  906. }
  907. break;
  908. case 220: // M220 S<factor in percent>- set speed factor override percentage
  909. {
  910. if(code_seen('S'))
  911. {
  912. feedmultiply = code_value() ;
  913. feedmultiplychanged=true;
  914. }
  915. }
  916. break;
  917. #ifdef PIDTEMP
  918. case 301: // M301
  919. {
  920. if(code_seen('P')) Kp = code_value();
  921. if(code_seen('I')) Ki = code_value()*PID_dT;
  922. if(code_seen('D')) Kd = code_value()/PID_dT;
  923. #ifdef PID_ADD_EXTRUSION_RATE
  924. if(code_seen('C')) Kc = code_value();
  925. #endif
  926. updatePID();
  927. SERIAL_PROTOCOL("ok p:");
  928. SERIAL_PROTOCOL(Kp);
  929. SERIAL_PROTOCOL(" i:");
  930. SERIAL_PROTOCOL(Ki/PID_dT);
  931. SERIAL_PROTOCOL(" d:");
  932. SERIAL_PROTOCOL(Kd*PID_dT);
  933. #ifdef PID_ADD_EXTRUSION_RATE
  934. SERIAL_PROTOCOL(" c:");
  935. SERIAL_PROTOCOL(Kc*PID_dT);
  936. #endif
  937. SERIAL_PROTOCOLLN("");
  938. }
  939. break;
  940. #endif //PIDTEMP
  941. case 400: // finish all moves
  942. {
  943. st_synchronize();
  944. }
  945. break;
  946. case 500: // Store settings in EEPROM
  947. {
  948. StoreSettings();
  949. }
  950. break;
  951. case 501: // Read settings from EEPROM
  952. {
  953. RetrieveSettings();
  954. }
  955. break;
  956. case 502: // Revert to default settings
  957. {
  958. RetrieveSettings(true);
  959. }
  960. break;
  961. }
  962. }
  963. else if(code_seen('T')) {
  964. tmp_extruder = code_value();
  965. if(tmp_extruder >= EXTRUDERS) {
  966. SERIAL_ECHO_START;
  967. SERIAL_ECHO("T");
  968. SERIAL_ECHO(tmp_extruder);
  969. SERIAL_ECHOLN("Invalid extruder");
  970. }
  971. else {
  972. active_extruder = tmp_extruder;
  973. }
  974. }
  975. else
  976. {
  977. SERIAL_ECHO_START;
  978. SERIAL_ECHOPGM("Unknown command:\"");
  979. SERIAL_ECHO(cmdbuffer[bufindr]);
  980. SERIAL_ECHOLNPGM("\"");
  981. }
  982. ClearToSend();
  983. }
  984. void FlushSerialRequestResend()
  985. {
  986. //char cmdbuffer[bufindr][100]="Resend:";
  987. MSerial.flush();
  988. SERIAL_PROTOCOLPGM("Resend:");
  989. SERIAL_PROTOCOLLN(gcode_LastN + 1);
  990. ClearToSend();
  991. }
  992. void ClearToSend()
  993. {
  994. previous_millis_cmd = millis();
  995. #ifdef SDSUPPORT
  996. if(fromsd[bufindr])
  997. return;
  998. #endif //SDSUPPORT
  999. SERIAL_PROTOCOLLNPGM("ok");
  1000. }
  1001. FORCE_INLINE void get_coordinates()
  1002. {
  1003. for(int8_t i=0; i < NUM_AXIS; i++) {
  1004. if(code_seen(axis_codes[i])) destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i];
  1005. else destination[i] = current_position[i]; //Are these else lines really needed?
  1006. }
  1007. if(code_seen('F')) {
  1008. next_feedrate = code_value();
  1009. if(next_feedrate > 0.0) feedrate = next_feedrate;
  1010. }
  1011. }
  1012. FORCE_INLINE void get_arc_coordinates()
  1013. {
  1014. get_coordinates();
  1015. if(code_seen('I')) offset[0] = code_value();
  1016. if(code_seen('J')) offset[1] = code_value();
  1017. }
  1018. void prepare_move()
  1019. {
  1020. if (min_software_endstops) {
  1021. if (destination[X_AXIS] < 0) destination[X_AXIS] = 0.0;
  1022. if (destination[Y_AXIS] < 0) destination[Y_AXIS] = 0.0;
  1023. if (destination[Z_AXIS] < 0) destination[Z_AXIS] = 0.0;
  1024. }
  1025. if (max_software_endstops) {
  1026. if (destination[X_AXIS] > X_MAX_LENGTH) destination[X_AXIS] = X_MAX_LENGTH;
  1027. if (destination[Y_AXIS] > Y_MAX_LENGTH) destination[Y_AXIS] = Y_MAX_LENGTH;
  1028. if (destination[Z_AXIS] > Z_MAX_LENGTH) destination[Z_AXIS] = Z_MAX_LENGTH;
  1029. }
  1030. plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
  1031. for(int8_t i=0; i < NUM_AXIS; i++) {
  1032. current_position[i] = destination[i];
  1033. }
  1034. }
  1035. void prepare_arc_move(char isclockwise) {
  1036. float r = hypot(offset[X_AXIS], offset[Y_AXIS]); // Compute arc radius for mc_arc
  1037. // Trace the arc
  1038. mc_arc(current_position, destination, offset, X_AXIS, Y_AXIS, Z_AXIS, feedrate*feedmultiply/60/100.0, r, isclockwise, active_extruder);
  1039. // As far as the parser is concerned, the position is now == target. In reality the
  1040. // motion control system might still be processing the action and the real tool position
  1041. // in any intermediate location.
  1042. for(int8_t i=0; i < NUM_AXIS; i++) {
  1043. current_position[i] = destination[i];
  1044. }
  1045. }
  1046. void manage_inactivity(byte debug)
  1047. {
  1048. if( (millis()-previous_millis_cmd) > max_inactive_time )
  1049. if(max_inactive_time)
  1050. kill();
  1051. if( (millis()-previous_millis_cmd) > stepper_inactive_time )
  1052. if(stepper_inactive_time)
  1053. {
  1054. disable_x();
  1055. disable_y();
  1056. disable_z();
  1057. disable_e();
  1058. }
  1059. check_axes_activity();
  1060. }
  1061. void kill()
  1062. {
  1063. disable_heater();
  1064. disable_x();
  1065. disable_y();
  1066. disable_z();
  1067. disable_e();
  1068. if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT);
  1069. SERIAL_ERROR_START;
  1070. SERIAL_ERRORLNPGM("Printer halted. kill() called !!");
  1071. LCD_MESSAGEPGM("KILLED. ");
  1072. while(1); // Wait for reset
  1073. }