Commit 8d8c62d8 authored by MagoKimbra's avatar MagoKimbra

Fix Laser beam width PWM modulation

parent 769d1ec6
...@@ -288,6 +288,10 @@ extern float retract_length, retract_length_swap, retract_feedrate, retract_zlif ...@@ -288,6 +288,10 @@ extern float retract_length, retract_length_swap, retract_feedrate, retract_zlif
extern float retract_recover_length, retract_recover_length_swap, retract_recover_feedrate; extern float retract_recover_length, retract_recover_length_swap, retract_recover_feedrate;
#endif #endif
#ifdef LASERBEAM
extern int laser_ttl_modulation;
#endif
extern unsigned long starttime; extern unsigned long starttime;
extern unsigned long stoptime; extern unsigned long stoptime;
......
...@@ -90,6 +90,7 @@ ...@@ -90,6 +90,7 @@
// M0 - Unconditional stop - Wait for user to press a button on the LCD (Only if ULTRA_LCD is enabled) // M0 - Unconditional stop - Wait for user to press a button on the LCD (Only if ULTRA_LCD is enabled)
// M1 - Same as M0 // M1 - Same as M0
// M03 - Put S<value> in laser beam control // M03 - Put S<value> in laser beam control
// M04 - Turn on laser beam
// M05 - Turn off laser beam // M05 - Turn off laser beam
// M17 - Enable/Power all stepper motors // M17 - Enable/Power all stepper motors
// M18 - Disable all stepper motors; same as M84 // M18 - Disable all stepper motors; same as M84
...@@ -379,6 +380,10 @@ bool cancel_heatup = false ; ...@@ -379,6 +380,10 @@ bool cancel_heatup = false ;
int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting
#endif #endif
#ifdef LASERBEAM
int laser_ttl_modulation = 0;
#endif
//=========================================================================== //===========================================================================
//=============================Private Variables============================= //=============================Private Variables=============================
//=========================================================================== //===========================================================================
...@@ -661,9 +666,11 @@ void setup() ...@@ -661,9 +666,11 @@ void setup()
#if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1 #if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
setup_photpin(); setup_photpin();
#endif #endif
#if defined(LASERBEAM_PIN) && LASERBEAM_PIN > -1 #ifdef LASERBEAM // Initialize Laser beam
pinMode(LASERBEAM_PIN, OUTPUT); SET_OUTPUT(LASER_PWR_PIN);
digitalWrite(LASERBEAM_PIN, LOW); // turn it off digitalWrite(LASER_PWR_PIN, LOW);
SET_OUTPUT(LASER_TTL_PIN);
digitalWrite(LASER_TTL_PIN, LOW);
#endif #endif
#if defined(NUM_SERVOS) #if defined(NUM_SERVOS)
servo_init(); servo_init();
...@@ -3026,12 +3033,20 @@ void process_commands() ...@@ -3026,12 +3033,20 @@ void process_commands()
case 03: // M03 S - Setting laser beam case 03: // M03 S - Setting laser beam
{ {
if(code_seen('S')) { if(code_seen('S')) {
digitalWrite(LASERBEAM_PIN, code_value()); laser_ttl_modulation=constrain(code_value(),0,255);
}
else {
laser_ttl_modulation=0;
} }
} }
break; break;
case 05: // M05 - Setting laser beam off case 04: // M04 - Turn on laser beam
digitalWrite(LASERBEAM_PIN, 0); digitalWrite(LASER_PWR_PIN, HIGH);
laser_ttl_modulation = 0;
break;
case 05: // M05 - Turn off laser beam
digitalWrite(LASER_PWR_PIN, LOW);
laser_ttl_modulation=0;
break; break;
#endif // LASERBEAM #endif // LASERBEAM
......
...@@ -282,6 +282,7 @@ ...@@ -282,6 +282,7 @@
#define MSG_BABYSTEP_Y "Babystep Y" #define MSG_BABYSTEP_Y "Babystep Y"
#define MSG_BABYSTEP_Z "Babystep Z" #define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort" #define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_LASER "Laser Preset"
#endif #endif
...@@ -411,6 +412,7 @@ ...@@ -411,6 +412,7 @@
#define MSG_BABYSTEP_Z "Babystep Z" #define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Blad wyl. kranc." #define MSG_ENDSTOP_ABORT "Blad wyl. kranc."
#define MSG_CONTRAST "Kontrast" #define MSG_CONTRAST "Kontrast"
#define MSG_LASER "Laser Preset"
#endif #endif
...@@ -540,6 +542,7 @@ ...@@ -540,6 +542,7 @@
#define MSG_BABYSTEP_Z "Babystep Z" #define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Butee abandon" #define MSG_ENDSTOP_ABORT "Butee abandon"
#define MSG_CONTRAST "Contrast" #define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#endif #endif
...@@ -670,6 +673,7 @@ ...@@ -670,6 +673,7 @@
#define MSG_BABYSTEP_Z "Babystep Z" #define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort" #define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast" #define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#endif #endif
...@@ -805,6 +809,7 @@ ...@@ -805,6 +809,7 @@
#define MSG_BABYSTEP_Z "Babystep Z" #define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort" #define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast" #define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#endif #endif
...@@ -932,6 +937,7 @@ ...@@ -932,6 +937,7 @@
#define MSG_BABYSTEP_Z "Babystep Z" #define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort" #define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast" #define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#endif #endif
...@@ -1071,6 +1077,7 @@ ...@@ -1071,6 +1077,7 @@
#define MSG_BABYSTEP_Z "Babystep Z" #define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort" #define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast" #define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#endif #endif
...@@ -1203,6 +1210,7 @@ ...@@ -1203,6 +1210,7 @@
#define MSG_BABYSTEP_Z "Babystep Z" #define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort" #define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast" #define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#endif #endif
...@@ -1329,6 +1337,7 @@ ...@@ -1329,6 +1337,7 @@
#define MSG_BABYSTEP_Y "Babystep Y" #define MSG_BABYSTEP_Y "Babystep Y"
#define MSG_BABYSTEP_Z "Babystep Z" #define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort" #define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_LASER "Laser Preset"
#endif #endif
...@@ -1462,6 +1471,7 @@ ...@@ -1462,6 +1471,7 @@
#define MSG_BABYSTEP_Z "Babystep Z" #define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort" #define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast" #define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#endif #endif
...@@ -1586,6 +1596,7 @@ ...@@ -1586,6 +1596,7 @@
#define MSG_BABYSTEP_Y "Babystap Y" #define MSG_BABYSTEP_Y "Babystap Y"
#define MSG_BABYSTEP_Z "Babystap Z" #define MSG_BABYSTEP_Z "Babystap Z"
#define MSG_ENDSTOP_ABORT "Endstop afbr." #define MSG_ENDSTOP_ABORT "Endstop afbr."
#define MSG_LASER "Laser Preset"
#endif #endif
...@@ -1711,6 +1722,7 @@ ...@@ -1711,6 +1722,7 @@
#define MSG_BABYSTEP_Y "Babystep Y" #define MSG_BABYSTEP_Y "Babystep Y"
#define MSG_BABYSTEP_Z "Babystep Z" #define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort" #define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_LASER "Laser Preset"
#endif #endif
...@@ -1835,8 +1847,8 @@ ...@@ -1835,8 +1847,8 @@
#define MSG_BABYSTEP_Y "Babystep Y" #define MSG_BABYSTEP_Y "Babystep Y"
#define MSG_BABYSTEP_Z "Babystep Z" #define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop deuseztat" #define MSG_ENDSTOP_ABORT "Endstop deuseztat"
#define MSG_LASER "Laser Preset"
#endif #endif
#endif // ifndef LANGUAGE_H #endif // ifndef LANGUAGE_H
\ No newline at end of file
...@@ -3057,7 +3057,8 @@ DaveX plan for Teensylu/printrboard-type pinouts (ref teensylu & sprinter) for a ...@@ -3057,7 +3057,8 @@ DaveX plan for Teensylu/printrboard-type pinouts (ref teensylu & sprinter) for a
#endif // END NPR2 #endif // END NPR2
#ifdef LASERBEAM #ifdef LASERBEAM
#define LASERBEAM_PIN 6 #define LASER_PWR_PIN 42
#define LASER_TTL_PIN 44
#endif #endif
#ifdef FILAMENT_END_SWITCH #ifdef FILAMENT_END_SWITCH
......
...@@ -459,6 +459,9 @@ void check_axes_activity() ...@@ -459,6 +459,9 @@ void check_axes_activity()
unsigned char tail_valve_pressure = ValvePressure; unsigned char tail_valve_pressure = ValvePressure;
unsigned char tail_e_to_p_pressure = EtoPPressure; unsigned char tail_e_to_p_pressure = EtoPPressure;
#endif #endif
#ifdef LASERBEAM
unsigned char tail_laser_ttl_modulation = laser_ttl_modulation;
#endif
block_t *block; block_t *block;
if(block_buffer_tail != block_buffer_head) if(block_buffer_tail != block_buffer_head)
...@@ -469,6 +472,10 @@ void check_axes_activity() ...@@ -469,6 +472,10 @@ void check_axes_activity()
tail_valve_pressure = block_buffer[block_index].valve_pressure; tail_valve_pressure = block_buffer[block_index].valve_pressure;
tail_e_to_p_pressure = block_buffer[block_index].e_to_p_pressure; tail_e_to_p_pressure = block_buffer[block_index].e_to_p_pressure;
#endif #endif
#ifdef LASERBEAM
tail_laser_ttl_modulation = block_buffer[block_index].laser_ttlmodulation;
#endif
while(block_index != block_buffer_head) while(block_index != block_buffer_head)
{ {
block = &block_buffer[block_index]; block = &block_buffer[block_index];
...@@ -523,6 +530,12 @@ void check_axes_activity() ...@@ -523,6 +530,12 @@ void check_axes_activity()
analogWrite(HEATER_2_PIN,tail_e_to_p_pressure); analogWrite(HEATER_2_PIN,tail_e_to_p_pressure);
#endif #endif
#endif #endif
// add Laser TTL Modulation(PWM) Control
#ifdef LASERBEAM
analogWrite(LASER_TTL_PIN, tail_laser_ttl_modulation);
#endif
} }
...@@ -633,6 +646,11 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi ...@@ -633,6 +646,11 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi
block->e_to_p_pressure = EtoPPressure; block->e_to_p_pressure = EtoPPressure;
#endif #endif
// Add update block variables for LASER BEAM control
#ifdef LASERBEAM
block->laser_ttlmodulation = laser_ttl_modulation;
#endif
// Compute direction bits for this block // Compute direction bits for this block
block->direction_bits = 0; block->direction_bits = 0;
#ifndef COREXY #ifndef COREXY
......
...@@ -67,6 +67,9 @@ typedef struct { ...@@ -67,6 +67,9 @@ typedef struct {
#ifdef BARICUDA #ifdef BARICUDA
unsigned long valve_pressure; unsigned long valve_pressure;
unsigned long e_to_p_pressure; unsigned long e_to_p_pressure;
#endif
#ifdef LASERBEAM
unsigned long laser_ttlmodulation;
#endif #endif
volatile char busy; volatile char busy;
} }
......
...@@ -716,6 +716,15 @@ static void lcd_prepare_menu() ...@@ -716,6 +716,15 @@ static void lcd_prepare_menu()
MENU_ITEM(gcode, MSG_BED_SETTING, PSTR("G28 M")); MENU_ITEM(gcode, MSG_BED_SETTING, PSTR("G28 M"));
MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets); MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets);
//MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0")); //MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0"));
//Add Preset menu for LASER setting '14. 7. 22
#ifdef LASERBEAM
MENU_ITEM_EDIT(int3, MSG_LASER, &laser_ttl_modulation, 0, 255);
if(laser_ttl_modulation == 0) {
digitalWrite(LASER_PWR_PIN, LOW);
} else {
digitalWrite(LASER_PWR_PIN, HIGH);
}
#endif
#if TEMP_SENSOR_0 != 0 #if TEMP_SENSOR_0 != 0
#if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_BED != 0
MENU_ITEM(submenu, MSG_PREHEAT_PLA, lcd_preheat_pla_menu); MENU_ITEM(submenu, MSG_PREHEAT_PLA, lcd_preheat_pla_menu);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment