Browse Source

Laser Test Fire (#20452)

Mike La Spina 3 years ago
parent
commit
cf1f8aff77
No account linked to committer's email address

+ 4
- 0
Marlin/Configuration_adv.h View File

@@ -3055,6 +3055,10 @@
3055 3055
     #define SPEED_POWER_MAX             100    // (%) 0-100
3056 3056
     #define SPEED_POWER_STARTUP          80    // (%) M3/M4 speed/power default (with no arguments)
3057 3057
 
3058
+    // Define the minimum and maximum test pulse time values for a laser test fire function
3059
+    #define LASER_TEST_PULSE_MIN           1   // Used with Laser Control Menu
3060
+    #define LASER_TEST_PULSE_MAX         999   // Caution: Menu may not show more than 3 characters
3061
+
3058 3062
     /**
3059 3063
      * Enable inline laser power to be handled in the planner / stepper routines.
3060 3064
      * Inline power is specified by the I (inline) flag in an M3 command (e.g., M3 S20 I)

+ 3
- 0
Marlin/src/feature/spindle_laser.cpp View File

@@ -36,6 +36,9 @@
36 36
 
37 37
 SpindleLaser cutter;
38 38
 uint8_t SpindleLaser::power;
39
+#if ENABLED(LASER_FEATURE)
40
+  cutter_test_pulse_t SpindleLaser::testPulse = 50;                   // Test fire Pulse time ms value.
41
+#endif
39 42
 bool SpindleLaser::isReady;                                           // Ready to apply power setting from the UI to OCR
40 43
 cutter_power_t SpindleLaser::menuPower,                               // Power set via LCD menu in PWM, PERCENT, or RPM
41 44
                SpindleLaser::unitPower;                               // LCD status power in PWM, PERCENT, or RPM

+ 23
- 1
Marlin/src/feature/spindle_laser.h View File

@@ -30,6 +30,10 @@
30 30
 
31 31
 #include "spindle_laser_types.h"
32 32
 
33
+#if USE_BEEPER
34
+  #include "../libs/buzzer.h"
35
+#endif
36
+
33 37
 #if ENABLED(LASER_POWER_INLINE)
34 38
   #include "../module/planner.h"
35 39
 #endif
@@ -90,6 +94,10 @@ public:
90 94
   static const cutter_power_t mpower_min() { return cpwr_to_upwr(SPEED_POWER_MIN); }
91 95
   static const cutter_power_t mpower_max() { return cpwr_to_upwr(SPEED_POWER_MAX); }
92 96
 
97
+  #if ENABLED(LASER_FEATURE)
98
+    static cutter_test_pulse_t testPulse; // Test fire Pulse ms value
99
+  #endif
100
+
93 101
   static bool isReady;                    // Ready to apply power setting from the UI to OCR
94 102
   static uint8_t power;
95 103
 
@@ -230,7 +238,21 @@ public:
230 238
       }
231 239
     #endif
232 240
 
233
-  #endif
241
+    #if ENABLED(LASER_FEATURE)
242
+      /**
243
+       * Test fire the laser using the testPulse ms duration
244
+       * Also fires with any PWM power that was previous set
245
+       * If not set defaults to 80% power
246
+       */
247
+      static inline void test_fire_pulse() {
248
+        enable_forward();                  // Turn Laser on (Spindle speak but same funct)
249
+        TERN_(USE_BEEPER, buzzer.tone(30, 3000));
250
+        delay(testPulse);                  // Delay for time set by user in pulse ms menu screen.
251
+        disable();                         // Turn laser off
252
+      }
253
+    #endif
254
+
255
+  #endif // HAS_LCD_MENU
234 256
 
235 257
   #if ENABLED(LASER_POWER_INLINE)
236 258
     /**

+ 5
- 0
Marlin/src/feature/spindle_laser_types.h View File

@@ -52,6 +52,11 @@ typedef IF<(SPEED_POWER_MAX > 255), uint16_t, uint8_t>::type cutter_cpower_t;
52 52
   #endif
53 53
 #endif
54 54
 
55
+#if ENABLED(LASER_FEATURE)
56
+  typedef uint16_t cutter_test_pulse_t;
57
+  #define CUTTER_MENU_PULSE_TYPE uint16_3
58
+#endif
59
+
55 60
 #if ENABLED(MARLIN_DEV_MODE)
56 61
   typedef uint16_t cutter_frequency_t;
57 62
   #define CUTTER_MENU_FREQUENCY_TYPE uint16_5

+ 2
- 0
Marlin/src/lcd/language/language_en.h View File

@@ -114,6 +114,8 @@ namespace Language_en {
114 114
   PROGMEM Language_Str MSG_LASER_POWER                     = _UxGT("Laser Power");
115 115
   PROGMEM Language_Str MSG_SPINDLE_POWER                   = _UxGT("Spindle Pwr");
116 116
   PROGMEM Language_Str MSG_LASER_TOGGLE                    = _UxGT("Toggle Laser");
117
+  PROGMEM Language_Str MSG_LASER_PULSE_MS                  = _UxGT("Test Pulse ms");
118
+  PROGMEM Language_Str MSG_LASER_FIRE_PULSE                = _UxGT("Fire Pulse");
117 119
   PROGMEM Language_Str MSG_SPINDLE_TOGGLE                  = _UxGT("Toggle Spindle");
118 120
   PROGMEM Language_Str MSG_SPINDLE_FORWARD                 = _UxGT("Spindle Forward");
119 121
   PROGMEM Language_Str MSG_SPINDLE_REVERSE                 = _UxGT("Spindle Reverse");

+ 6
- 0
Marlin/src/lcd/menu/menu_spindle_laser.cpp View File

@@ -58,6 +58,12 @@
58 58
       }
59 59
     #endif
60 60
 
61
+    #if ENABLED(LASER_FEATURE)
62
+      // Setup and fire a test pulse using the current PWM power level for for a duration of test_pulse_min to test_pulse_max ms.
63
+      EDIT_ITEM_FAST(CUTTER_MENU_PULSE_TYPE, MSG_LASER_PULSE_MS, &cutter.testPulse, LASER_TEST_PULSE_MIN, LASER_TEST_PULSE_MAX);
64
+      ACTION_ITEM(MSG_LASER_FIRE_PULSE, cutter.test_fire_pulse);
65
+    #endif
66
+
61 67
     #if BOTH(MARLIN_DEV_MODE, HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY)
62 68
       EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 80000, cutter.refresh_frequency);
63 69
     #endif

Loading…
Cancel
Save