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
     #define SPEED_POWER_MAX             100    // (%) 0-100
3055
     #define SPEED_POWER_MAX             100    // (%) 0-100
3056
     #define SPEED_POWER_STARTUP          80    // (%) M3/M4 speed/power default (with no arguments)
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
      * Enable inline laser power to be handled in the planner / stepper routines.
3063
      * Enable inline laser power to be handled in the planner / stepper routines.
3060
      * Inline power is specified by the I (inline) flag in an M3 command (e.g., M3 S20 I)
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
 
36
 
37
 SpindleLaser cutter;
37
 SpindleLaser cutter;
38
 uint8_t SpindleLaser::power;
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
 bool SpindleLaser::isReady;                                           // Ready to apply power setting from the UI to OCR
42
 bool SpindleLaser::isReady;                                           // Ready to apply power setting from the UI to OCR
40
 cutter_power_t SpindleLaser::menuPower,                               // Power set via LCD menu in PWM, PERCENT, or RPM
43
 cutter_power_t SpindleLaser::menuPower,                               // Power set via LCD menu in PWM, PERCENT, or RPM
41
                SpindleLaser::unitPower;                               // LCD status power in PWM, PERCENT, or RPM
44
                SpindleLaser::unitPower;                               // LCD status power in PWM, PERCENT, or RPM

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

30
 
30
 
31
 #include "spindle_laser_types.h"
31
 #include "spindle_laser_types.h"
32
 
32
 
33
+#if USE_BEEPER
34
+  #include "../libs/buzzer.h"
35
+#endif
36
+
33
 #if ENABLED(LASER_POWER_INLINE)
37
 #if ENABLED(LASER_POWER_INLINE)
34
   #include "../module/planner.h"
38
   #include "../module/planner.h"
35
 #endif
39
 #endif
90
   static const cutter_power_t mpower_min() { return cpwr_to_upwr(SPEED_POWER_MIN); }
94
   static const cutter_power_t mpower_min() { return cpwr_to_upwr(SPEED_POWER_MIN); }
91
   static const cutter_power_t mpower_max() { return cpwr_to_upwr(SPEED_POWER_MAX); }
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
   static bool isReady;                    // Ready to apply power setting from the UI to OCR
101
   static bool isReady;                    // Ready to apply power setting from the UI to OCR
94
   static uint8_t power;
102
   static uint8_t power;
95
 
103
 
230
       }
238
       }
231
     #endif
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
   #if ENABLED(LASER_POWER_INLINE)
257
   #if ENABLED(LASER_POWER_INLINE)
236
     /**
258
     /**

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

52
   #endif
52
   #endif
53
 #endif
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
 #if ENABLED(MARLIN_DEV_MODE)
60
 #if ENABLED(MARLIN_DEV_MODE)
56
   typedef uint16_t cutter_frequency_t;
61
   typedef uint16_t cutter_frequency_t;
57
   #define CUTTER_MENU_FREQUENCY_TYPE uint16_5
62
   #define CUTTER_MENU_FREQUENCY_TYPE uint16_5

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

114
   PROGMEM Language_Str MSG_LASER_POWER                     = _UxGT("Laser Power");
114
   PROGMEM Language_Str MSG_LASER_POWER                     = _UxGT("Laser Power");
115
   PROGMEM Language_Str MSG_SPINDLE_POWER                   = _UxGT("Spindle Pwr");
115
   PROGMEM Language_Str MSG_SPINDLE_POWER                   = _UxGT("Spindle Pwr");
116
   PROGMEM Language_Str MSG_LASER_TOGGLE                    = _UxGT("Toggle Laser");
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
   PROGMEM Language_Str MSG_SPINDLE_TOGGLE                  = _UxGT("Toggle Spindle");
119
   PROGMEM Language_Str MSG_SPINDLE_TOGGLE                  = _UxGT("Toggle Spindle");
118
   PROGMEM Language_Str MSG_SPINDLE_FORWARD                 = _UxGT("Spindle Forward");
120
   PROGMEM Language_Str MSG_SPINDLE_FORWARD                 = _UxGT("Spindle Forward");
119
   PROGMEM Language_Str MSG_SPINDLE_REVERSE                 = _UxGT("Spindle Reverse");
121
   PROGMEM Language_Str MSG_SPINDLE_REVERSE                 = _UxGT("Spindle Reverse");

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

58
       }
58
       }
59
     #endif
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
     #if BOTH(MARLIN_DEV_MODE, HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY)
67
     #if BOTH(MARLIN_DEV_MODE, HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY)
62
       EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 80000, cutter.refresh_frequency);
68
       EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 80000, cutter.refresh_frequency);
63
     #endif
69
     #endif

Loading…
Cancel
Save