Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what am I doing wrong #11

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Marlin/Base64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int base64_encode(char *output, char *input, int inputLen) {
return encLen;
}

int base64_decode(char * output, char * input, int inputLen) {
int base64_decode(unsigned char * output, char * input, int inputLen) {
int i = 0, j = 0;
int decLen = 0;
unsigned char a3[3];
Expand Down
2 changes: 1 addition & 1 deletion Marlin/Base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int base64_encode(char *output, char *input, int inputLen);
* 2. input must not be null
* 3. inputLen must be greater than or equal to 0
*/
int base64_decode(char *output, char *input, int inputLen);
int base64_decode(unsigned char *output, char *input, int inputLen);

/* base64_enc_len:
* Description:
Expand Down
40 changes: 27 additions & 13 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
// 2 = Two pin control - A firing pin for which LOW = off, HIGH = on, and a seperate intensity pin which carries a constant PWM signal and adjusts duty cycle to control intensity
#define LASER_CONTROL 2

// Uncomment the following if your laser firing pin (not the PWM pin) for two pin control requires a HIGH signal to fire rather than a low (eg Red Sail M300 RS 3040)
/// #define HIGH_TO_FIRE

//// The following defines select which G codes tell the laser to fire. It's OK to uncomment more than one.
#define LASER_FIRE_G1 10 // fire the laser on a G1 move, extinguish when the move ends
#define LASER_FIRE_SPINDLE 11 // fire the laser on M3, extinguish on M5
Expand All @@ -91,13 +94,13 @@
//// Raster mode enables the laser to etch bitmap data at high speeds. Increases command buffer size substantially.
#define LASER_RASTER
#define LASER_MAX_RASTER_LINE 68 // maximum number of base64 encoded pixels per raster gcode command
#define LASER_RASTER_ASPECT_RATIO 1.33 // pixels aren't square on most displays, 1.33 == 4:3 aspect ratio
#define LASER_RASTER_MM_PER_PULSE 0.2
#define LASER_RASTER_ASPECT_RATIO 1 // pixels aren't square on most displays, 1.33 == 4:3 aspect ratio
#define LASER_RASTER_MM_PER_PULSE 0.2 //Can be overridden by providing an R value in M649 command : M649 S17 B2 D0 R0.1 F4000

//// Uncomment the following if the laser cutter is equipped with a peripheral relay board
//// to control power to an exhaust fan, water pump, laser power supply, etc.
#define LASER_PERIPHERALS
#define LASER_PERIPHERALS_TIMEOUT 30000 // Number of milliseconds to wait for status signal from peripheral control board
//#define LASER_PERIPHERALS
//#define LASER_PERIPHERALS_TIMEOUT 30000 // Number of milliseconds to wait for status signal from peripheral control board

//// Uncomment the following line to enable cubic bezier curve movement with the G5 code
// #define G5_BEZIER
Expand All @@ -113,7 +116,7 @@
#define CUSTOM_MENDEL_NAME "Laser Cutter"
#define LASER_WATTS 40.0
#define LASER_DIAMETER 0.1 // milimeters
#define LASER_PWM 25000 // hertz
#define LASER_PWM 50000 // hertz
#define LASER_FOCAL_HEIGHT 74.50 // z axis position at which the laser is focused

//===========================================================================
Expand Down Expand Up @@ -145,6 +148,9 @@
// 52 is 200k thermistor - ATC Semitec 204GT-2 (1k pullup)
// 55 is 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan) (1k pullup)


// changes made in ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780.H line 473 to allow temperature display
// instead of Z position, set to 1 for temperature, 0 for no temperature.
#define TEMP_SENSOR_0 0
#define TEMP_SENSOR_1 0
#define TEMP_SENSOR_2 0
Expand Down Expand Up @@ -294,7 +300,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
const bool X_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Y_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
#define DISABLE_MAX_ENDSTOPS
//#define DISABLE_MAX_ENDSTOPS
//#define DISABLE_MIN_ENDSTOPS

// Disable max endstops for compatibility with endstop checking routine
Expand Down Expand Up @@ -343,11 +349,19 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o
//#define Z_MIN_POS 0

// Lansing Makers Netowrk Laser Cutter
#define X_MAX_POS 531
//#define X_MAX_POS 531
//#define X_MIN_POS 0
//#define Y_MAX_POS 558
//#define Y_MIN_POS 0
//#define Z_MAX_POS 95
//#define Z_MIN_POS 0

// China Town K40 CO2 Laser Engraver/Cutter
#define X_MAX_POS 337
#define X_MIN_POS 0
#define Y_MAX_POS 558
#define Y_MAX_POS 230
#define Y_MIN_POS 0
#define Z_MAX_POS 95
#define Z_MAX_POS 75
#define Z_MIN_POS 0

#define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS)
Expand All @@ -367,7 +381,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o

//// MOVEMENT SETTINGS
#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
#define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0} // set the homing speeds (mm/min)
#define HOMING_FEEDRATE {7600, 7600, 0, 0} // set the homing speeds (mm/min)

// default settings

Expand All @@ -380,7 +394,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o

// Lansing Makers Netowork Laser Cutter
#define DEFAULT_AXIS_STEPS_PER_UNIT {157.4802,157.4802,6047.2440} // default steps per unit for Ultimaker
#define DEFAULT_MAX_FEEDRATE {500, 500, 10, 25} // (mm/sec)
#define DEFAULT_MAX_FEEDRATE {7600, 7600, 10, 25} // (mm/sec)
#define DEFAULT_MAX_ACCELERATION {2600,2600,2.5,2.5} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.

#define DEFAULT_ACCELERATION 2000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
Expand Down Expand Up @@ -436,7 +450,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o

// The RepRapDiscount Smart Controller (white PCB)
// http://reprap.org/wiki/RepRapDiscount_Smart_Controller
//#define REPRAP_DISCOUNT_SMART_CONTROLLER
#define REPRAP_DISCOUNT_SMART_CONTROLLER

// The GADGETS3D G3D LCD/SD Controller (blue PCB)
// http://reprap.org/wiki/RAMPS_1.3/1.4_GADGETS3D_Shield_with_Panel
Expand Down Expand Up @@ -609,4 +623,4 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#include "Configuration_adv.h"
#include "thermistortables.h"

#endif //__CONFIGURATION_H
#endif //__CONFIGURATION_H
74 changes: 62 additions & 12 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,14 @@ void get_command()
if(!comment_mode){
comment_mode = false; //for new command
fromsd[bufindw] = false;
if(strchr(cmdbuffer[bufindw], 'N') != NULL)

//Turnkey - Changed <=6 to <=8 to allow up to 999999 lines of raster data to be transmitted per raster node
//This area needs improving for stability.
if( (strstr_P(cmdbuffer[bufindw], PSTR("G7")) == NULL && strchr(cmdbuffer[bufindw], 'N') != NULL) || //For non G7 commands, run as normal.
((strstr_P(cmdbuffer[bufindw], PSTR("G7")) != NULL) &&
((strstr_P(cmdbuffer[bufindw], PSTR("G7")) - strchr(cmdbuffer[bufindw], 'N') <=8 ) &&
(strstr_P(cmdbuffer[bufindw], PSTR("G7")) - strchr(cmdbuffer[bufindw], 'N') >0 )))
)
{
strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10));
Expand Down Expand Up @@ -792,12 +799,6 @@ static void homeaxis(int axis) {
has_axis_homed[axis] = true;
current_position[axis] = 0;
#ifdef MUVE_Z_PEEL

if (axis == Z_AXIS) {
has_axis_homed[E_AXIS] = true;
current_position[E_AXIS] = 0;
}

plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[Z_AXIS]);
destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
feedrate = homing_feedrate[axis];
Expand Down Expand Up @@ -907,13 +908,47 @@ void process_commands()
case 2: // G2 - CW ARC
if(Stopped == false) {
get_arc_coordinates();

#ifdef LASER_FIRE_G1
if (code_seen('S') && !IsStopped()) laser.intensity = (float) code_value();
if (code_seen('L') && !IsStopped()) laser.duration = (unsigned long) labs(code_value());
if (code_seen('P') && !IsStopped()) laser.ppm = (float) code_value();
if (code_seen('D') && !IsStopped()) laser.diagnostics = (bool) code_value();
if (code_seen('B') && !IsStopped()) laser_set_mode((int) code_value());

laser.status = LASER_ON;
laser.fired = LASER_FIRE_G1;
#endif // LASER_FIRE_G1

prepare_arc_move(true);

#ifdef LASER_FIRE_G1
laser.status = LASER_OFF;
#endif // LASER_FIRE_G1

return;
}
case 3: // G3 - CCW ARC
if(Stopped == false) {
get_arc_coordinates();

#ifdef LASER_FIRE_G1
if (code_seen('S') && !IsStopped()) laser.intensity = (float) code_value();
if (code_seen('L') && !IsStopped()) laser.duration = (unsigned long) labs(code_value());
if (code_seen('P') && !IsStopped()) laser.ppm = (float) code_value();
if (code_seen('D') && !IsStopped()) laser.diagnostics = (bool) code_value();
if (code_seen('B') && !IsStopped()) laser_set_mode((int) code_value());

laser.status = LASER_ON;
laser.fired = LASER_FIRE_G1;
#endif // LASER_FIRE_G1

prepare_arc_move(false);

#ifdef LASER_FIRE_G1
laser.status = LASER_OFF;
#endif // LASER_FIRE_G1

return;
}
case 4: // G4 dwell
Expand Down Expand Up @@ -1035,7 +1070,7 @@ void process_commands()
#ifdef LASER_RASTER
case 7: //G7 Execute raster line
if (code_seen('L')) laser.raster_raw_length = int(code_value());
if (code_seen('N')) {
if (code_seen('$')) {
laser.raster_direction = (bool)code_value();
destination[Y_AXIS] = current_position[Y_AXIS] + (laser.raster_mm_per_pulse * laser.raster_aspect_ratio); // increment Y axis
}
Expand All @@ -1053,8 +1088,10 @@ void process_commands()
SERIAL_ECHOLN("Positive Raster Line");
}
}
laser.ppm = 1 / laser.raster_mm_per_pulse;
laser.duration = labs(1 / (feedrate * laser.ppm) * 1000000);

laser.ppm = 1 / laser.raster_mm_per_pulse; //number of pulses per millimetre
laser.duration = (1000000 / ( feedrate / 60)) / laser.ppm; // (1 second in microseconds / (time to move 1mm in microseconds)) / (pulses per mm) = Duration of pulse, taking into account feedrate as speed and ppm

laser.mode = RASTER;
laser.status = LASER_ON;
laser.fired = RASTER;
Expand All @@ -1078,7 +1115,7 @@ void process_commands()
}

break;
case 11: // G10 retract_recover
case 11: // G11 retract_recover
if(!retracted)
{
destination[X_AXIS]=current_position[X_AXIS];
Expand Down Expand Up @@ -1319,10 +1356,14 @@ void process_commands()

laser.status = LASER_ON;
laser.fired = LASER_FIRE_SPINDLE;
//*=*=*=*=*=*
lcd_update();

prepare_move();
break;
case 5: //M5 stop firing laser
laser.status = LASER_OFF;
lcd_update();
prepare_move();
break;
#endif // LASER_FIRE_SPINDLE
Expand Down Expand Up @@ -2381,11 +2422,20 @@ void process_commands()
#ifdef LASER
case 649: // M649 set laser options
{
if (code_seen('S') && !IsStopped()) laser.intensity = (float) code_value();
if (code_seen('S') && !IsStopped()) {
laser.intensity = (float) code_value();
laser.rasterlaserpower = laser.intensity;
}
if (code_seen('L') && !IsStopped()) laser.duration = (unsigned long) labs(code_value());
if (code_seen('P') && !IsStopped()) laser.ppm = (float) code_value();
if (code_seen('D') && !IsStopped()) laser.diagnostics = (bool) code_value();
if (code_seen('B') && !IsStopped()) laser_set_mode((int) code_value());
if (code_seen('R') && !IsStopped()) laser.raster_mm_per_pulse = ((float) code_value());
if (code_seen('F')) {
next_feedrate = code_value();
if(next_feedrate > 0.0) feedrate = next_feedrate;
}

}
break;
#endif // LASER
Expand Down
Loading