Skip to content
This repository
Browse code

made it possible to have an intermediate M92 command without the extr…

…uder motor running wild.
commit 81202a8d303a848fc99c29a1f817a727f84450b1 1 parent 259a5ac
Bernhard Kubicek authored

Showing 2 changed files with 64 additions and 21 deletions. Show diff stats Hide diff stats

  1. +16 10 Marlin/Marlin.pde
  2. +48 11 Marlin/ultralcd.pde
26 Marlin/Marlin.pde
@@ -178,6 +178,7 @@ float mintravelfeedrate;
178 178 // Manage heater variables.
179 179
180 180 #include "EEPROM.h"
  181 +static long position[4]; //in steps
181 182
182 183
183 184 static block_t *current_block; // A pointer to the block currently being traced
@@ -1073,7 +1074,12 @@ inline void process_commands()
1073 1074 break;
1074 1075 case 92: // M92
1075 1076 for(int i=0; i < NUM_AXIS; i++) {
1076   - if(code_seen(axis_codes[i])) axis_steps_per_unit[i] = code_value();
  1077 + if(code_seen(axis_codes[i]))
  1078 + {
  1079 + float factor=float(code_value())/float(axis_steps_per_unit[3]);
  1080 + position[E_AXIS]=lround(position[E_AXIS]*factor);
  1081 + axis_steps_per_unit[i] = code_value();
  1082 + }
1077 1083 }
1078 1084
1079 1085 break;
@@ -1729,7 +1735,6 @@ static volatile unsigned char block_buffer_head; // Index of the next
1729 1735 static volatile unsigned char block_buffer_tail; // Index of the block to process now
1730 1736
1731 1737 // The current position of the tool in absolute steps
1732   -static long position[4];
1733 1738
1734 1739 #define ONE_MINUTE_OF_MICROSECONDS 60000000.0
1735 1740
@@ -2032,14 +2037,7 @@ void check_axes_activity() {
2032 2037 // mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration
2033 2038 // calculation the caller must also provide the physical length of the line in millimeters.
2034 2039 void plan_buffer_line(float x, float y, float z, float e, float feed_rate) {
2035   -
2036   - // The target position of the tool in absolute steps
2037   - // Calculate target position in absolute steps
2038   - long target[4];
2039   - target[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]);
2040   - target[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]);
2041   - target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
2042   - target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);
  2040 +
2043 2041
2044 2042 // Calculate the buffer head after we push this byte
2045 2043 int next_buffer_head = (block_buffer_head + 1) %BLOCK_BUFFER_SIZE;
@@ -2051,6 +2049,14 @@ void plan_buffer_line(float x, float y, float z, float e, float feed_rate) {
2051 2049 manage_inactivity(1);
2052 2050 }
2053 2051
  2052 + // The target position of the tool in absolute steps
  2053 + // Calculate target position in absolute steps
  2054 + long target[4];
  2055 + target[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]);
  2056 + target[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]);
  2057 + target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
  2058 + target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);
  2059 +
2054 2060 // Prepare to set up new block
2055 2061 block_t *block = &block_buffer[block_buffer_head];
2056 2062
59 Marlin/ultralcd.pde
@@ -503,7 +503,7 @@ enum {
503 503 ItemC_fan,
504 504 ItemC_acc, ItemC_xyjerk,
505 505 ItemC_vmaxx, ItemC_vmaxy, ItemC_vmaxz, ItemC_vmaxe,
506   - ItemC_vmin,
  506 + ItemC_vtravmin,ItemC_vmin,
507 507 ItemC_amaxx, ItemC_amaxy, ItemC_amaxz, ItemC_amaxe,
508 508 ItemC_aret,ItemC_esteps, ItemC_store, ItemC_load,ItemC_failsafe
509 509 };
@@ -710,7 +710,7 @@ void MainMenu::showControl()
710 710 if(force_lcd_update)
711 711 {
712 712 lcd.setCursor(0,line);lcd.print(" PID-I: ");
713   - lcd.setCursor(13,line);lcd.print(itostr4(Ki));
  713 + lcd.setCursor(13,line);lcd.print(ftostr51(Ki));
714 714 }
715 715
716 716 if((activeline==line) )
@@ -720,11 +720,11 @@ void MainMenu::showControl()
720 720 linechanging=!linechanging;
721 721 if(linechanging)
722 722 {
723   - encoderpos=(int)Ki/5;
  723 + encoderpos=(int)(Ki*10);
724 724 }
725 725 else
726 726 {
727   - Ki= encoderpos*5;
  727 + Ki= encoderpos/10.;
728 728 encoderpos=activeline*lcdslow;
729 729
730 730 }
@@ -734,8 +734,8 @@ void MainMenu::showControl()
734 734 if(linechanging)
735 735 {
736 736 if(encoderpos<0) encoderpos=0;
737   - if(encoderpos>9990/5) encoderpos=9990/5;
738   - lcd.setCursor(13,line);lcd.print(itostr4(encoderpos*5));
  737 + if(encoderpos>9990) encoderpos=9990;
  738 + lcd.setCursor(13,line);lcd.print(ftostr51(encoderpos/10.));
739 739 }
740 740 }
741 741 }break;
@@ -867,7 +867,7 @@ void MainMenu::showControl()
867 867 linechanging=!linechanging;
868 868 if(linechanging)
869 869 {
870   - encoderpos=(int)minimumfeedrate/60;
  870 + encoderpos=(int)(minimumfeedrate/60.);
871 871 }
872 872 else
873 873 {
@@ -886,6 +886,40 @@ void MainMenu::showControl()
886 886 }
887 887 }
888 888 }break;
  889 + case ItemC_vtravmin:
  890 + {
  891 + if(force_lcd_update)
  892 + {
  893 + lcd.setCursor(0,line);lcd.print(" VTrav min:");
  894 + lcd.setCursor(13,line);lcd.print(itostr3(mintravelfeedrate/60));
  895 + }
  896 +
  897 + if((activeline==line) )
  898 + {
  899 + if(CLICKED)
  900 + {
  901 + linechanging=!linechanging;
  902 + if(linechanging)
  903 + {
  904 + encoderpos=(int)mintravelfeedrate/60;
  905 + }
  906 + else
  907 + {
  908 + mintravelfeedrate= encoderpos*60;
  909 + encoderpos=activeline*lcdslow;
  910 +
  911 + }
  912 + BLOCK;
  913 + beepshort();
  914 + }
  915 + if(linechanging)
  916 + {
  917 + if(encoderpos<0) encoderpos=0;
  918 + if(encoderpos>990) encoderpos=990;
  919 + lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  920 + }
  921 + }
  922 + }break;
889 923
890 924 case ItemC_amaxx:
891 925 case ItemC_amaxy:
@@ -966,7 +1000,7 @@ void MainMenu::showControl()
966 1000 if(force_lcd_update)
967 1001 {
968 1002 lcd.setCursor(0,line);lcd.print(" Esteps/mm:");
969   - lcd.setCursor(13,line);lcd.print(itostr3(axis_steps_per_unit[3]));
  1003 + lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3]));
970 1004 }
971 1005
972 1006 if((activeline==line) )
@@ -980,7 +1014,10 @@ void MainMenu::showControl()
980 1014 }
981 1015 else
982 1016 {
983   - axis_steps_per_unit[3]= encoderpos;
  1017 + float factor=float(encoderpos)/float(axis_steps_per_unit[3]);
  1018 + position[E_AXIS]=lround(position[E_AXIS]*factor);
  1019 + //current_position[3]*=factor;
  1020 + axis_steps_per_unit[E_AXIS]= encoderpos;
984 1021 encoderpos=activeline*lcdslow;
985 1022
986 1023 }
@@ -990,8 +1027,8 @@ void MainMenu::showControl()
990 1027 if(linechanging)
991 1028 {
992 1029 if(encoderpos<5) encoderpos=5;
993   - if(encoderpos>990) encoderpos=990;
994   - lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
  1030 + if(encoderpos>9999) encoderpos=9999;
  1031 + lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
995 1032 }
996 1033 }
997 1034 }break;

0 comments on commit 81202a8

Please sign in to comment.
Something went wrong with that request. Please try again.