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
......
This diff is collapsed.
......@@ -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