Преглед на файлове

Merge pull request #1555 from C-o-r-E/solenoids

Add support for solenoid articulated extruders
Scott Lahteine преди 9 години
родител
ревизия
08b722b635
променени са 8 файла, в които са добавени 114 реда и са изтрити 85 реда
  1. 74
    25
      Marlin/Marlin_main.cpp
  2. 1
    2
      Marlin/cardreader.cpp
  3. 3
    0
      Marlin/fastio.h
  4. 1
    0
      Marlin/language.h
  5. 11
    21
      Marlin/stepper.cpp
  6. 4
    10
      Marlin/temperature.cpp
  7. 17
    21
      Marlin/ultralcd_implementation_hitachi_HD44780.h
  8. 3
    6
      Marlin/ultralcd_st7920_u8glib_rrd.h

+ 74
- 25
Marlin/Marlin_main.cpp Целия файл

@@ -154,6 +154,8 @@
154 154
 // M302 - Allow cold extrudes, or set the minimum extrude S<temperature>.
155 155
 // M303 - PID relay autotune S<temperature> sets the target temperature. (default target temperature = 150C)
156 156
 // M304 - Set bed PID parameters P I and D
157
+// M380 - Activate solenoid on active extruder
158
+// M381 - Disable all solenoids
157 159
 // M400 - Finish all moves
158 160
 // M401 - Lower z-probe if present
159 161
 // M402 - Raise z-probe if present
@@ -529,32 +531,28 @@ void setup_homepin(void)
529 531
 void setup_photpin()
530 532
 {
531 533
   #if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
532
-    SET_OUTPUT(PHOTOGRAPH_PIN);
533
-    WRITE(PHOTOGRAPH_PIN, LOW);
534
+    OUT_WRITE(PHOTOGRAPH_PIN, LOW);
534 535
   #endif
535 536
 }
536 537
 
537 538
 void setup_powerhold()
538 539
 {
539 540
   #if defined(SUICIDE_PIN) && SUICIDE_PIN > -1
540
-    SET_OUTPUT(SUICIDE_PIN);
541
-    WRITE(SUICIDE_PIN, HIGH);
541
+    OUT_WRITE(SUICIDE_PIN, HIGH);
542 542
   #endif
543 543
   #if defined(PS_ON_PIN) && PS_ON_PIN > -1
544
-    SET_OUTPUT(PS_ON_PIN);
545
-	#if defined(PS_DEFAULT_OFF)
546
-	  WRITE(PS_ON_PIN, PS_ON_ASLEEP);
547
-    #else
548
-	  WRITE(PS_ON_PIN, PS_ON_AWAKE);
549
-	#endif
544
+    #if defined(PS_DEFAULT_OFF)
545
+      OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP);
546
+      #else
547
+      OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE);
548
+    #endif
550 549
   #endif
551 550
 }
552 551
 
553 552
 void suicide()
554 553
 {
555 554
   #if defined(SUICIDE_PIN) && SUICIDE_PIN > -1
556
-    SET_OUTPUT(SUICIDE_PIN);
557
-    WRITE(SUICIDE_PIN, LOW);
555
+    OUT_WRITE(SUICIDE_PIN, LOW);
558 556
   #endif
559 557
 }
560 558
 
@@ -2723,15 +2721,13 @@ Sigma_Exit:
2723 2721
 
2724 2722
     #if defined(PS_ON_PIN) && PS_ON_PIN > -1
2725 2723
       case 80: // M80 - Turn on Power Supply
2726
-        SET_OUTPUT(PS_ON_PIN); //GND
2727
-        WRITE(PS_ON_PIN, PS_ON_AWAKE);
2724
+        OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); // GND
2728 2725
 
2729 2726
         // If you have a switch on suicide pin, this is useful
2730 2727
         // if you want to start another print with suicide feature after
2731 2728
         // a print without suicide...
2732 2729
         #if defined SUICIDE_PIN && SUICIDE_PIN > -1
2733
-            SET_OUTPUT(SUICIDE_PIN);
2734
-            WRITE(SUICIDE_PIN, HIGH);
2730
+            OUT_WRITE(SUICIDE_PIN, HIGH);
2735 2731
         #endif
2736 2732
 
2737 2733
         #ifdef ULTIPANEL
@@ -2755,8 +2751,7 @@ Sigma_Exit:
2755 2751
         st_synchronize();
2756 2752
         suicide();
2757 2753
       #elif defined(PS_ON_PIN) && PS_ON_PIN > -1
2758
-        SET_OUTPUT(PS_ON_PIN);
2759
-        WRITE(PS_ON_PIN, PS_ON_ASLEEP);
2754
+        OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP);
2760 2755
       #endif
2761 2756
       #ifdef ULTIPANEL
2762 2757
         powersupply = false;
@@ -3118,7 +3113,7 @@ Sigma_Exit:
3118 3113
          SERIAL_ECHO(extruder_offset[Z_AXIS][tmp_extruder]);
3119 3114
       #endif
3120 3115
       }
3121
-      SERIAL_ECHOLN("");
3116
+      SERIAL_EOL;
3122 3117
     }break;
3123 3118
     #endif
3124 3119
     case 220: // M220 S<factor in percent>- set speed factor override percentage
@@ -3337,8 +3332,7 @@ Sigma_Exit:
3337 3332
      {
3338 3333
      	#ifdef CHDK
3339 3334
        
3340
-         SET_OUTPUT(CHDK);
3341
-         WRITE(CHDK, HIGH);
3335
+         OUT_WRITE(CHDK, HIGH);
3342 3336
          chdkHigh = millis();
3343 3337
          chdkActive = true;
3344 3338
        
@@ -3497,6 +3491,17 @@ Sigma_Exit:
3497 3491
       }
3498 3492
       break;
3499 3493
 	#endif
3494
+    
3495
+#ifdef EXT_SOLENOID
3496
+    case 380:
3497
+        enable_solenoid_on_active_extruder();
3498
+        break;
3499
+
3500
+    case 381:
3501
+        disable_all_solenoids();
3502
+        break;
3503
+#endif //EXT_SOLENOID
3504
+
3500 3505
     case 400: // M400 finish all moves
3501 3506
     {
3502 3507
       st_synchronize();
@@ -3737,9 +3742,7 @@ case 404:  //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
3737 3742
           if(cnt==0)
3738 3743
           {
3739 3744
           #if BEEPER > 0
3740
-            SET_OUTPUT(BEEPER);
3741
-
3742
-            WRITE(BEEPER,HIGH);
3745
+            OUT_WRITE(BEEPER,HIGH);
3743 3746
             delay(3);
3744 3747
             WRITE(BEEPER,LOW);
3745 3748
             delay(3);
@@ -4000,6 +4003,13 @@ case 404:  //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
4000 4003
            prepare_move();
4001 4004
         }
4002 4005
       }
4006
+
4007
+#ifdef EXT_SOLENOID
4008
+      st_synchronize();
4009
+      disable_all_solenoids();
4010
+      enable_solenoid_on_active_extruder();
4011
+#endif //EXT_SOLENOID
4012
+
4003 4013
       #endif
4004 4014
       SERIAL_ECHO_START;
4005 4015
       SERIAL_ECHO(MSG_ACTIVE_EXTRUDER);
@@ -4707,7 +4717,6 @@ bool setTargetedHotend(int code){
4707 4717
   return false;
4708 4718
 }
4709 4719
 
4710
-
4711 4720
 float calculate_volumetric_multiplier(float diameter) {
4712 4721
   if (!volumetric_enabled || diameter == 0) return 1.0;
4713 4722
   float d2 = diameter * 0.5;
@@ -4718,3 +4727,43 @@ void calculate_volumetric_multipliers() {
4718 4727
   for (int i=0; i<EXTRUDERS; i++)
4719 4728
     volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
4720 4729
 }
4730
+
4731
+#ifdef EXT_SOLENOID
4732
+
4733
+void enable_solenoid(uint8_t num) {
4734
+  switch(num) {
4735
+    case 0:
4736
+      OUT_WRITE(SOL0_PIN, HIGH);
4737
+      break;
4738
+      #if defined(SOL1_PIN) && SOL1_PIN > -1
4739
+        case 1:
4740
+          OUT_WRITE(SOL1_PIN, HIGH);
4741
+          break;
4742
+      #endif
4743
+      #if defined(SOL2_PIN) && SOL2_PIN > -1
4744
+        case 2:
4745
+          OUT_WRITE(SOL2_PIN, HIGH);
4746
+          break;
4747
+      #endif
4748
+      #if defined(SOL3_PIN) && SOL3_PIN > -1
4749
+        case 3:
4750
+          OUT_WRITE(SOL3_PIN, HIGH);
4751
+          break;
4752
+      #endif
4753
+    default:
4754
+      SERIAL_ECHO_START;
4755
+      SERIAL_ECHOLNPGM(MSG_INVALID_SOLENOID);
4756
+      break;
4757
+  }
4758
+}
4759
+
4760
+void enable_solenoid_on_active_extruder() { enable_solenoid(active_extruder); }
4761
+
4762
+void disable_all_solenoids() {
4763
+  OUT_WRITE(SOL0_PIN, LOW);
4764
+  OUT_WRITE(SOL1_PIN, LOW);
4765
+  OUT_WRITE(SOL2_PIN, LOW);
4766
+  OUT_WRITE(SOL3_PIN, LOW);
4767
+}
4768
+
4769
+#endif //EXT_SOLENOID

+ 1
- 2
Marlin/cardreader.cpp Целия файл

@@ -22,8 +22,7 @@ CardReader::CardReader() {
22 22
   autostart_index = 0;
23 23
   //power to SD reader
24 24
   #if SDPOWER > -1
25
-    SET_OUTPUT(SDPOWER);
26
-    WRITE(SDPOWER, HIGH);
25
+    OUT_WRITE(SDPOWER, HIGH);
27 26
   #endif //SDPOWER
28 27
 
29 28
   autostart_atmillis = millis() + 5000;

+ 3
- 0
Marlin/fastio.h Целия файл

@@ -83,6 +83,9 @@
83 83
 /// check if pin is an timer wrapper
84 84
 #define GET_TIMER(IO)  _GET_TIMER(IO)
85 85
 
86
+// Shorthand
87
+#define OUT_WRITE(IO, v) { SET_OUTPUT(IO); WRITE(IO, v); }
88
+
86 89
 /*
87 90
 	ports and functions
88 91
 

+ 1
- 0
Marlin/language.h Целия файл

@@ -121,6 +121,7 @@
121 121
 #define MSG_UNKNOWN_COMMAND                 "Unknown command: \""
122 122
 #define MSG_ACTIVE_EXTRUDER                 "Active Extruder: "
123 123
 #define MSG_INVALID_EXTRUDER                "Invalid extruder"
124
+#define MSG_INVALID_SOLENOID                "Invalid solenoid"
124 125
 #define MSG_X_MIN                           "x_min: "
125 126
 #define MSG_X_MAX                           "x_max: "
126 127
 #define MSG_Y_MIN                           "y_min: "

+ 11
- 21
Marlin/stepper.cpp Целия файл

@@ -187,7 +187,7 @@ void checkHitEndstops()
187 187
      SERIAL_ECHOPAIR(" Z:",(float)endstops_trigsteps[Z_AXIS]/axis_steps_per_unit[Z_AXIS]);
188 188
      LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Z");
189 189
    }
190
-   SERIAL_ECHOLN("");
190
+   SERIAL_EOL;
191 191
    endstop_x_hit=false;
192 192
    endstop_y_hit=false;
193 193
    endstop_z_hit=false;
@@ -959,51 +959,41 @@ void st_init()
959 959
 
960 960
   //Initialize Step Pins
961 961
   #if defined(X_STEP_PIN) && (X_STEP_PIN > -1)
962
-    SET_OUTPUT(X_STEP_PIN);
963
-    WRITE(X_STEP_PIN,INVERT_X_STEP_PIN);
962
+    OUT_WRITE(X_STEP_PIN,INVERT_X_STEP_PIN);
964 963
     disable_x();
965 964
   #endif
966 965
   #if defined(X2_STEP_PIN) && (X2_STEP_PIN > -1)
967
-    SET_OUTPUT(X2_STEP_PIN);
968
-    WRITE(X2_STEP_PIN,INVERT_X_STEP_PIN);
966
+    OUT_WRITE(X2_STEP_PIN,INVERT_X_STEP_PIN);
969 967
     disable_x();
970 968
   #endif
971 969
   #if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1)
972
-    SET_OUTPUT(Y_STEP_PIN);
973
-    WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
970
+    OUT_WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
974 971
     #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_STEP_PIN) && (Y2_STEP_PIN > -1)
975
-      SET_OUTPUT(Y2_STEP_PIN);
976
-      WRITE(Y2_STEP_PIN,INVERT_Y_STEP_PIN);
972
+      OUT_WRITE(Y2_STEP_PIN,INVERT_Y_STEP_PIN);
977 973
     #endif
978 974
     disable_y();
979 975
   #endif
980 976
   #if defined(Z_STEP_PIN) && (Z_STEP_PIN > -1)
981
-    SET_OUTPUT(Z_STEP_PIN);
982
-    WRITE(Z_STEP_PIN,INVERT_Z_STEP_PIN);
977
+    OUT_WRITE(Z_STEP_PIN,INVERT_Z_STEP_PIN);
983 978
     #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_STEP_PIN) && (Z2_STEP_PIN > -1)
984
-      SET_OUTPUT(Z2_STEP_PIN);
985
-      WRITE(Z2_STEP_PIN,INVERT_Z_STEP_PIN);
979
+      OUT_WRITE(Z2_STEP_PIN,INVERT_Z_STEP_PIN);
986 980
     #endif
987 981
     disable_z();
988 982
   #endif
989 983
   #if defined(E0_STEP_PIN) && (E0_STEP_PIN > -1)
990
-    SET_OUTPUT(E0_STEP_PIN);
991
-    WRITE(E0_STEP_PIN,INVERT_E_STEP_PIN);
984
+    OUT_WRITE(E0_STEP_PIN,INVERT_E_STEP_PIN);
992 985
     disable_e0();
993 986
   #endif
994 987
   #if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1)
995
-    SET_OUTPUT(E1_STEP_PIN);
996
-    WRITE(E1_STEP_PIN,INVERT_E_STEP_PIN);
988
+    OUT_WRITE(E1_STEP_PIN,INVERT_E_STEP_PIN);
997 989
     disable_e1();
998 990
   #endif
999 991
   #if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1)
1000
-    SET_OUTPUT(E2_STEP_PIN);
1001
-    WRITE(E2_STEP_PIN,INVERT_E_STEP_PIN);
992
+    OUT_WRITE(E2_STEP_PIN,INVERT_E_STEP_PIN);
1002 993
     disable_e2();
1003 994
   #endif
1004 995
   #if defined(E3_STEP_PIN) && (E3_STEP_PIN > -1)
1005
-    SET_OUTPUT(E3_STEP_PIN);
1006
-    WRITE(E3_STEP_PIN,INVERT_E_STEP_PIN);
996
+    OUT_WRITE(E3_STEP_PIN,INVERT_E_STEP_PIN);
1007 997
     disable_e3();
1008 998
   #endif
1009 999
 

+ 4
- 10
Marlin/temperature.cpp Целия файл

@@ -901,21 +901,15 @@ void tp_init()
901 901
   #ifdef HEATER_0_USES_MAX6675
902 902
 
903 903
     #ifndef SDSUPPORT
904
-      SET_OUTPUT(SCK_PIN);
905
-      WRITE(SCK_PIN,0);
906
-    
907
-      SET_OUTPUT(MOSI_PIN);
908
-      WRITE(MOSI_PIN,1);
909
-    
910
-      SET_INPUT(MISO_PIN);
911
-      WRITE(MISO_PIN,1);
904
+      OUT_WRITE(SCK_PIN, LOW);
905
+      OUT_WRITE(MOSI_PIN, HIGH);
906
+      OUT_WRITE(MISO_PIN, HIGH);
912 907
     #else
913 908
       pinMode(SS_PIN, OUTPUT);
914 909
       digitalWrite(SS_PIN, HIGH);
915 910
     #endif
916 911
     
917
-    SET_OUTPUT(MAX6675_SS);
918
-    WRITE(MAX6675_SS,1);
912
+    OUT_WRITE(MAX6675_SS,HIGH);
919 913
 
920 914
   #endif //HEATER_0_USES_MAX6675
921 915
 

+ 17
- 21
Marlin/ultralcd_implementation_hitachi_HD44780.h Целия файл

@@ -821,32 +821,28 @@ static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pst
821 821
 
822 822
 static void lcd_implementation_quick_feedback()
823 823
 {
824
-#ifdef LCD_USE_I2C_BUZZER
825
-	#if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS)
826
-	  lcd_buzz(1000/6,100);
827
-	#else
828
-	  lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS,LCD_FEEDBACK_FREQUENCY_HZ);
829
-	#endif
830
-#elif defined(BEEPER) && BEEPER > -1
824
+  #ifdef LCD_USE_I2C_BUZZER
825
+    #if defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS) && defined(LCD_FEEDBACK_FREQUENCY_HZ)
826
+      lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
827
+    #else
828
+      lcd_buzz(1000/6, 100);
829
+    #endif
830
+  #elif defined(BEEPER) && BEEPER > -1
831 831
     SET_OUTPUT(BEEPER);
832
-	#if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS)
833
-    for(int8_t i=0;i<10;i++)
834
-    {
835
-      WRITE(BEEPER,HIGH);
836
-      delayMicroseconds(100);
837
-      WRITE(BEEPER,LOW);
838
-      delayMicroseconds(100);
839
-    }
832
+    #if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS)
833
+      const unsigned int delay = 100;
834
+      uint8_t i = 10;
840 835
     #else
841
-    for(int8_t i=0;i<(LCD_FEEDBACK_FREQUENCY_DURATION_MS / (1000 / LCD_FEEDBACK_FREQUENCY_HZ));i++)
842
-    {
836
+      const unsigned int delay = 1000000 / LCD_FEEDBACK_FREQUENCY_HZ / 2;
837
+      int8_t i = LCD_FEEDBACK_FREQUENCY_DURATION_MS * LCD_FEEDBACK_FREQUENCY_HZ / 1000;
838
+    #endif
839
+    while (i--) {
843 840
       WRITE(BEEPER,HIGH);
844
-      delayMicroseconds(1000000 / LCD_FEEDBACK_FREQUENCY_HZ / 2);
841
+      delayMicroseconds(delay);
845 842
       WRITE(BEEPER,LOW);
846
-      delayMicroseconds(1000000 / LCD_FEEDBACK_FREQUENCY_HZ / 2);
843
+      delayMicroseconds(delay);
847 844
     }
848
-    #endif
849
-#endif
845
+  #endif
850 846
 }
851 847
 
852 848
 #ifdef LCD_HAS_STATUS_INDICATORS

+ 3
- 6
Marlin/ultralcd_st7920_u8glib_rrd.h Целия файл

@@ -47,12 +47,9 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
47 47
   {
48 48
     case U8G_DEV_MSG_INIT:
49 49
       {
50
-        SET_OUTPUT(ST7920_CS_PIN);
51
-        WRITE(ST7920_CS_PIN,0);
52
-        SET_OUTPUT(ST7920_DAT_PIN);
53
-        WRITE(ST7920_DAT_PIN,0);
54
-        SET_OUTPUT(ST7920_CLK_PIN);
55
-        WRITE(ST7920_CLK_PIN,1);
50
+        OUT_WRITE(ST7920_CS_PIN,LOW);
51
+        OUT_WRITE(ST7920_DAT_PIN,LOW);
52
+        OUT_WRITE(ST7920_CLK_PIN,HIGH);
56 53
 
57 54
         ST7920_CS();
58 55
         u8g_Delay(120);                 //initial delay for boot up

Loading…
Отказ
Запис