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
extern float retract_recover_length, retract_recover_length_swap, retract_recover_feedrate;
#endif
#ifdef LASERBEAM
extern int laser_ttl_modulation;
#endif
extern unsigned long starttime;
extern unsigned long stoptime;
......
......@@ -90,6 +90,7 @@
// M0 - Unconditional stop - Wait for user to press a button on the LCD (Only if ULTRA_LCD is enabled)
// M1 - Same as M0
// M03 - Put S<value> in laser beam control
// M04 - Turn on laser beam
// M05 - Turn off laser beam
// M17 - Enable/Power all stepper motors
// M18 - Disable all stepper motors; same as M84
......@@ -379,6 +380,10 @@ bool cancel_heatup = false ;
int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting
#endif
#ifdef LASERBEAM
int laser_ttl_modulation = 0;
#endif
//===========================================================================
//=============================Private Variables=============================
//===========================================================================
......@@ -661,9 +666,11 @@ void setup()
#if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
setup_photpin();
#endif
#if defined(LASERBEAM_PIN) && LASERBEAM_PIN > -1
pinMode(LASERBEAM_PIN, OUTPUT);
digitalWrite(LASERBEAM_PIN, LOW); // turn it off
#ifdef LASERBEAM // Initialize Laser beam
SET_OUTPUT(LASER_PWR_PIN);
digitalWrite(LASER_PWR_PIN, LOW);
SET_OUTPUT(LASER_TTL_PIN);
digitalWrite(LASER_TTL_PIN, LOW);
#endif
#if defined(NUM_SERVOS)
servo_init();
......@@ -3026,12 +3033,20 @@ void process_commands()
case 03: // M03 S - Setting laser beam
{
if(code_seen('S')) {
digitalWrite(LASERBEAM_PIN, code_value());
laser_ttl_modulation=constrain(code_value(),0,255);
}
else {
laser_ttl_modulation=0;
}
}
break;
case 05: // M05 - Setting laser beam off
digitalWrite(LASERBEAM_PIN, 0);
case 04: // M04 - Turn on laser beam
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;
#endif // LASERBEAM
......
......@@ -282,6 +282,7 @@
#define MSG_BABYSTEP_Y "Babystep Y"
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_LASER "Laser Preset"
#endif
......@@ -411,6 +412,7 @@
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Blad wyl. kranc."
#define MSG_CONTRAST "Kontrast"
#define MSG_LASER "Laser Preset"
#endif
......@@ -420,126 +422,127 @@
// LCD Menu Messages
// Please note these are limited to 17 characters!
#define WELCOME_MSG MACHINE_NAME " prete."
#define MSG_SD_INSERTED "Carte inseree"
#define MSG_SD_REMOVED "Carte retiree"
#define MSG_MAIN "Menu principal"
#define MSG_AUTOSTART "Demarrage auto"
#define MSG_DISABLE_STEPPERS "Arreter moteurs"
#define MSG_AUTO_HOME "Home auto."
#define MSG_BED_SETTING "Bed Setting"
#define MSG_SET_HOME_OFFSETS "Set home offsets"
#define MSG_SET_ORIGIN "Regler origine"
#define MSG_PREHEAT_PLA " Prechauffage PLA"
#define MSG_PREHEAT_PLA0 "Prechauff. PLA 1"
#define MSG_PREHEAT_PLA1 "Prechauff. PLA 2"
#define MSG_PREHEAT_PLA2 "Prechauff. PLA 3"
#define MSG_PREHEAT_PLA012 "Prech. PLA Tout"
#define MSG_PREHEAT_PLA_BEDONLY "Prech. PLA Plateau"
#define MSG_PREHEAT_PLA_SETTINGS "Regl. prech. PLA"
#define MSG_PREHEAT_ABS "Prechauffage ABS"
#define MSG_PREHEAT_ABS0 "Prechauff. ABS 1"
#define MSG_PREHEAT_ABS1 "Prechauff. ABS 2"
#define MSG_PREHEAT_ABS2 "Prechauff. ABS 3"
#define MSG_PREHEAT_ABS012 "Prech. ABS Tout"
#define MSG_PREHEAT_ABS_BEDONLY "Prech. ABS Plateau"
#define MSG_PREHEAT_ABS_SETTINGS "Regl. prech. ABS"
#define MSG_COOLDOWN "Refroidir"
#define MSG_SWITCH_PS_ON "Allumer alim."
#define MSG_SWITCH_PS_OFF "Eteindre alim."
#define MSG_EXTRUDE "Extrusion"
#define MSG_RETRACT "Retraction"
#define MSG_PREHEAT_PLA "Prechauffage PLA"
#define MSG_PREHEAT_ABS "Prechauffage ABS"
#define MSG_MOVE_AXIS "Deplacer un axe"
#define MSG_MOVE_X "Move X"
#define MSG_MOVE_Y "Move Y"
#define MSG_MOVE_Z "Move Z"
#define MSG_MOVE_E "Extruder"
#define MSG_MOVE_E1 "Extruder2"
#define MSG_MOVE_E2 "Extruder3"
#define MSG_MOVE_01MM "Move 0.1mm"
#define MSG_MOVE_1MM "Move 1mm"
#define MSG_MOVE_10MM "Move 10mm"
#define MSG_SPEED " Vitesse"
#define MSG_NOZZLE "Buse"
#define MSG_NOZZLE1 "Buse2"
#define MSG_NOZZLE2 "Buse3"
#define MSG_BED "Plateau"
#define MSG_FAN_SPEED "Vite. ventilateur"
#define MSG_FLOW "Flux"
#define MSG_FLOW0 "Flux 0"
#define MSG_FLOW1 "Flux 1"
#define MSG_FLOW2 "Flux 2"
#define MSG_CONTROL "Controler"
#define MSG_MIN " \002 Min"
#define MSG_MAX " \002 Max"
#define MSG_FACTOR " \002 Facteur"
#define MSG_AUTOTEMP "Temp. Auto."
#define MSG_ON "Marche "
#define MSG_OFF "Arret"
#define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_ACC "Accel"
#define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk"
#define MSG_VE_JERK "Ve-jerk"
#define MSG_VMAX "Vmax"
#define MSG_X "x"
#define MSG_Y "y"
#define MSG_Z "z"
#define MSG_E "e"
#define MSG_VMIN "Vmin"
#define MSG_VTRAV_MIN "Vdepl min"
#define MSG_AMAX "Amax "
#define MSG_A_RETRACT "A-retract"
#define MSG_XSTEPS "Xpas/mm"
#define MSG_YSTEPS "Ypas/mm"
#define MSG_ZSTEPS "Zpas/mm"
#define MSG_ESTEPS "Epas/mm"
#define MSG_TEMPERATURE "Temperature"
#define MSG_MOTION "Mouvement"
#define MSG_CONTRAST "Contraste LCD"
#define MSG_STORE_EPROM "Sauver config"
#define MSG_LOAD_EPROM "Lire config"
#define MSG_RESTORE_FAILSAFE "Restaurer defauts"
#define MSG_REFRESH "Actualiser"
#define MSG_WATCH "Surveiller"
#define MSG_PREPARE "Preparer"
#define MSG_TUNE "Regler"
#define MSG_PAUSE_PRINT "Interrompre impr."
#define MSG_RESUME_PRINT "Reprendre impr."
#define MSG_STOP_PRINT "Arreter impr."
#define MSG_CARD_MENU "Impr. depuis SD"
#define MSG_NO_CARD "Pas de carte"
#define MSG_DWELL "Repos..."
#define MSG_USERWAIT "Atten. de l'util."
#define MSG_RESUMING "Repri. de l'impr."
#define MSG_NO_MOVE "Aucun mouvement."
#define MSG_KILLED "MORT."
#define MSG_STOPPED "STOPPE."
#define MSG_STEPPER_RELEASED "RELACHE."
#define MSG_CONTROL_RETRACT "Retraction mm"
#define MSG_CONTROL_RETRACT_SWAP "Ech. Retr. mm"
#define MSG_CONTROL_RETRACTF "Retraction V"
#define MSG_CONTROL_RETRACT_ZLIFT "Hop mm"
#define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm"
#define MSG_CONTROL_RETRACT_RECOVER_SWAP "Ech. UnRet +mm"
#define MSG_CONTROL_RETRACT_RECOVERF "UnRet V"
#define MSG_AUTORETRACT "Retract. Auto."
#define MSG_FILAMENTCHANGE "Changer filament"
#define MSG_INIT_SDCARD "Init. la carte SD"
#define MSG_CNG_SDCARD "Changer de carte"
#define MSG_ZPROBE_OUT "Z sonde exte. lit"
#define MSG_POSITION_UNKNOWN "Rev. dans XY av.Z"
#define MSG_ZPROBE_ZOFFSET "Offset Z"
#define MSG_BABYSTEP_X "Babystep X"
#define MSG_BABYSTEP_Y "Babystep Y"
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Butee abandon"
#define MSG_CONTRAST "Contrast"
#define WELCOME_MSG MACHINE_NAME " prete."
#define MSG_SD_INSERTED "Carte inseree"
#define MSG_SD_REMOVED "Carte retiree"
#define MSG_MAIN "Menu principal"
#define MSG_AUTOSTART "Demarrage auto"
#define MSG_DISABLE_STEPPERS "Arreter moteurs"
#define MSG_AUTO_HOME "Home auto."
#define MSG_BED_SETTING "Bed Setting"
#define MSG_SET_HOME_OFFSETS "Set home offsets"
#define MSG_SET_ORIGIN "Regler origine"
#define MSG_PREHEAT_PLA " Prechauffage PLA"
#define MSG_PREHEAT_PLA0 "Prechauff. PLA 1"
#define MSG_PREHEAT_PLA1 "Prechauff. PLA 2"
#define MSG_PREHEAT_PLA2 "Prechauff. PLA 3"
#define MSG_PREHEAT_PLA012 "Prech. PLA Tout"
#define MSG_PREHEAT_PLA_BEDONLY "Prech. PLA Plateau"
#define MSG_PREHEAT_PLA_SETTINGS "Regl. prech. PLA"
#define MSG_PREHEAT_ABS "Prechauffage ABS"
#define MSG_PREHEAT_ABS0 "Prechauff. ABS 1"
#define MSG_PREHEAT_ABS1 "Prechauff. ABS 2"
#define MSG_PREHEAT_ABS2 "Prechauff. ABS 3"
#define MSG_PREHEAT_ABS012 "Prech. ABS Tout"
#define MSG_PREHEAT_ABS_BEDONLY "Prech. ABS Plateau"
#define MSG_PREHEAT_ABS_SETTINGS "Regl. prech. ABS"
#define MSG_COOLDOWN "Refroidir"
#define MSG_SWITCH_PS_ON "Allumer alim."
#define MSG_SWITCH_PS_OFF "Eteindre alim."
#define MSG_EXTRUDE "Extrusion"
#define MSG_RETRACT "Retraction"
#define MSG_PREHEAT_PLA "Prechauffage PLA"
#define MSG_PREHEAT_ABS "Prechauffage ABS"
#define MSG_MOVE_AXIS "Deplacer un axe"
#define MSG_MOVE_X "Move X"
#define MSG_MOVE_Y "Move Y"
#define MSG_MOVE_Z "Move Z"
#define MSG_MOVE_E "Extruder"
#define MSG_MOVE_E1 "Extruder2"
#define MSG_MOVE_E2 "Extruder3"
#define MSG_MOVE_01MM "Move 0.1mm"
#define MSG_MOVE_1MM "Move 1mm"
#define MSG_MOVE_10MM "Move 10mm"
#define MSG_SPEED " Vitesse"
#define MSG_NOZZLE "Buse"
#define MSG_NOZZLE1 "Buse2"
#define MSG_NOZZLE2 "Buse3"
#define MSG_BED "Plateau"
#define MSG_FAN_SPEED "Vite. ventilateur"
#define MSG_FLOW "Flux"
#define MSG_FLOW0 "Flux 0"
#define MSG_FLOW1 "Flux 1"
#define MSG_FLOW2 "Flux 2"
#define MSG_CONTROL "Controler"
#define MSG_MIN " \002 Min"
#define MSG_MAX " \002 Max"
#define MSG_FACTOR " \002 Facteur"
#define MSG_AUTOTEMP "Temp. Auto."
#define MSG_ON "Marche "
#define MSG_OFF "Arret"
#define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_ACC "Accel"
#define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk"
#define MSG_VE_JERK "Ve-jerk"
#define MSG_VMAX "Vmax"
#define MSG_X "x"
#define MSG_Y "y"
#define MSG_Z "z"
#define MSG_E "e"
#define MSG_VMIN "Vmin"
#define MSG_VTRAV_MIN "Vdepl min"
#define MSG_AMAX "Amax "
#define MSG_A_RETRACT "A-retract"
#define MSG_XSTEPS "Xpas/mm"
#define MSG_YSTEPS "Ypas/mm"
#define MSG_ZSTEPS "Zpas/mm"
#define MSG_ESTEPS "Epas/mm"
#define MSG_TEMPERATURE "Temperature"
#define MSG_MOTION "Mouvement"
#define MSG_CONTRAST "Contraste LCD"
#define MSG_STORE_EPROM "Sauver config"
#define MSG_LOAD_EPROM "Lire config"
#define MSG_RESTORE_FAILSAFE "Restaurer defauts"
#define MSG_REFRESH "Actualiser"
#define MSG_WATCH "Surveiller"
#define MSG_PREPARE "Preparer"
#define MSG_TUNE "Regler"
#define MSG_PAUSE_PRINT "Interrompre impr."
#define MSG_RESUME_PRINT "Reprendre impr."
#define MSG_STOP_PRINT "Arreter impr."
#define MSG_CARD_MENU "Impr. depuis SD"
#define MSG_NO_CARD "Pas de carte"
#define MSG_DWELL "Repos..."
#define MSG_USERWAIT "Atten. de l'util."
#define MSG_RESUMING "Repri. de l'impr."
#define MSG_NO_MOVE "Aucun mouvement."
#define MSG_KILLED "MORT."
#define MSG_STOPPED "STOPPE."
#define MSG_STEPPER_RELEASED "RELACHE."
#define MSG_CONTROL_RETRACT "Retraction mm"
#define MSG_CONTROL_RETRACT_SWAP "Ech. Retr. mm"
#define MSG_CONTROL_RETRACTF "Retraction V"
#define MSG_CONTROL_RETRACT_ZLIFT "Hop mm"
#define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm"
#define MSG_CONTROL_RETRACT_RECOVER_SWAP "Ech. UnRet +mm"
#define MSG_CONTROL_RETRACT_RECOVERF "UnRet V"
#define MSG_AUTORETRACT "Retract. Auto."
#define MSG_FILAMENTCHANGE "Changer filament"
#define MSG_INIT_SDCARD "Init. la carte SD"
#define MSG_CNG_SDCARD "Changer de carte"
#define MSG_ZPROBE_OUT "Z sonde exte. lit"
#define MSG_POSITION_UNKNOWN "Rev. dans XY av.Z"
#define MSG_ZPROBE_ZOFFSET "Offset Z"
#define MSG_BABYSTEP_X "Babystep X"
#define MSG_BABYSTEP_Y "Babystep Y"
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Butee abandon"
#define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#endif
......@@ -670,6 +673,7 @@
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#endif
......@@ -686,7 +690,7 @@
#define MSG_AUTOSTART " Autostart"
#define MSG_DISABLE_STEPPERS "Apagar motores"
#define MSG_AUTO_HOME "Llevar al origen"
#define MSG_BED_SETTING "Bed Setting"
#define MSG_BED_SETTING "Bed Setting"
#define MSG_SET_HOME_OFFSETS "Set home offsets"
#define MSG_SET_ORIGIN "Establecer cero"
#define MSG_PREHEAT_PLA "Precalentar PLA"
......@@ -805,6 +809,7 @@
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#endif
......@@ -821,7 +826,7 @@
#define MSG_AUTOSTART "Автостарт"
#define MSG_DISABLE_STEPPERS "Выкл. двигатели"
#define MSG_AUTO_HOME "Парковка"
#define MSG_BED_SETTING "Bed Setting"
#define MSG_BED_SETTING "Bed Setting"
#define MSG_SET_HOME_OFFSETS "Set home offsets"
#define MSG_SET_ORIGIN "Запомнить ноль"
#define MSG_PREHEAT_PLA "Преднагрев PLA"
......@@ -932,6 +937,7 @@
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#endif
......@@ -1071,6 +1077,7 @@
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#endif
......@@ -1203,6 +1210,7 @@
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#endif
......@@ -1329,6 +1337,7 @@
#define MSG_BABYSTEP_Y "Babystep Y"
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_LASER "Laser Preset"
#endif
......@@ -1462,6 +1471,7 @@
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#endif
......@@ -1586,6 +1596,7 @@
#define MSG_BABYSTEP_Y "Babystap Y"
#define MSG_BABYSTEP_Z "Babystap Z"
#define MSG_ENDSTOP_ABORT "Endstop afbr."
#define MSG_LASER "Laser Preset"
#endif
......@@ -1711,6 +1722,7 @@
#define MSG_BABYSTEP_Y "Babystep Y"
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_LASER "Laser Preset"
#endif
......@@ -1835,8 +1847,8 @@
#define MSG_BABYSTEP_Y "Babystep Y"
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop deuseztat"
#define MSG_LASER "Laser Preset"
#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
#endif // END NPR2
#ifdef LASERBEAM
#define LASERBEAM_PIN 6
#define LASER_PWR_PIN 42
#define LASER_TTL_PIN 44
#endif
#ifdef FILAMENT_END_SWITCH
......
......@@ -459,6 +459,9 @@ void check_axes_activity()
unsigned char tail_valve_pressure = ValvePressure;
unsigned char tail_e_to_p_pressure = EtoPPressure;
#endif
#ifdef LASERBEAM
unsigned char tail_laser_ttl_modulation = laser_ttl_modulation;
#endif
block_t *block;
if(block_buffer_tail != block_buffer_head)
......@@ -469,6 +472,10 @@ void check_axes_activity()
tail_valve_pressure = block_buffer[block_index].valve_pressure;
tail_e_to_p_pressure = block_buffer[block_index].e_to_p_pressure;
#endif
#ifdef LASERBEAM
tail_laser_ttl_modulation = block_buffer[block_index].laser_ttlmodulation;
#endif
while(block_index != block_buffer_head)
{
block = &block_buffer[block_index];
......@@ -523,6 +530,12 @@ void check_axes_activity()
analogWrite(HEATER_2_PIN,tail_e_to_p_pressure);
#endif
#endif
// add Laser TTL Modulation(PWM) Control
#ifdef LASERBEAM
analogWrite(LASER_TTL_PIN, tail_laser_ttl_modulation);
#endif
}
......@@ -632,6 +645,11 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi
block->valve_pressure = ValvePressure;
block->e_to_p_pressure = EtoPPressure;
#endif
// Add update block variables for LASER BEAM control
#ifdef LASERBEAM
block->laser_ttlmodulation = laser_ttl_modulation;
#endif
// Compute direction bits for this block
block->direction_bits = 0;
......
......@@ -67,6 +67,9 @@ typedef struct {
#ifdef BARICUDA
unsigned long valve_pressure;
unsigned long e_to_p_pressure;
#endif
#ifdef LASERBEAM
unsigned long laser_ttlmodulation;
#endif
volatile char busy;
}
......
......@@ -716,6 +716,15 @@ static void lcd_prepare_menu()
MENU_ITEM(gcode, MSG_BED_SETTING, PSTR("G28 M"));
MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets);
//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_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_BED != 0
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