Skip to content

Commit 24ea5d6

Browse files
author
Chris K.Y. FUNG
authored
Merge pull request #1 from Craftweeks/grbl-1.1f=lx
Customized-for-laser
2 parents 790c666 + f415d42 commit 24ea5d6

File tree

5 files changed

+68
-102
lines changed

5 files changed

+68
-102
lines changed

grbl/config.h

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@
172172
// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until
173173
// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the
174174
// previous tool path, as if nothing happened.
175-
// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.
175+
#define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.
176176

177177
// After the safety door switch has been toggled and restored, this setting sets the power-up delay
178178
// between restoring the spindle and coolant and resuming the cycle.
179-
#define SAFETY_DOOR_SPINDLE_DELAY 4.0 // Float (seconds)
180-
#define SAFETY_DOOR_COOLANT_DELAY 1.0 // Float (seconds)
179+
#define SAFETY_DOOR_SPINDLE_DELAY 1.0 // Float (seconds)
180+
#define SAFETY_DOOR_COOLANT_DELAY 0.0 // Float (seconds)
181181

182182
// Enable CoreXY kinematics. Use ONLY with CoreXY machines.
183183
// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to
@@ -586,31 +586,6 @@
586586
// to ensure the laser doesn't inadvertently remain powered while at a stop and cause a fire.
587587
#define DISABLE_LASER_DURING_HOLD // Default enabled. Comment to disable.
588588

589-
// Enables a piecewise linear model of the spindle PWM/speed output. Requires a solution by the
590-
// 'fit_nonlinear_spindle.py' script in the /doc/script folder of the repo. See file comments
591-
// on how to gather spindle data and run the script to generate a solution.
592-
// #define ENABLE_PIECEWISE_LINEAR_SPINDLE // Default disabled. Uncomment to enable.
593-
594-
// N_PIECES, RPM_MAX, RPM_MIN, RPM_POINTxx, and RPM_LINE_XX constants are all set and given by
595-
// the 'fit_nonlinear_spindle.py' script solution. Used only when ENABLE_PIECEWISE_LINEAR_SPINDLE
596-
// is enabled. Make sure the constant values are exactly the same as the script solution.
597-
// NOTE: When N_PIECES < 4, unused RPM_LINE and RPM_POINT defines are not required and omitted.
598-
#define N_PIECES 4 // Integer (1-4). Number of piecewise lines used in script solution.
599-
#define RPM_MAX 11686.4 // Max RPM of model. $30 > RPM_MAX will be limited to RPM_MAX.
600-
#define RPM_MIN 202.5 // Min RPM of model. $31 < RPM_MIN will be limited to RPM_MIN.
601-
#define RPM_POINT12 6145.4 // Used N_PIECES >=2. Junction point between lines 1 and 2.
602-
#define RPM_POINT23 9627.8 // Used N_PIECES >=3. Junction point between lines 2 and 3.
603-
#define RPM_POINT34 10813.9 // Used N_PIECES = 4. Junction point between lines 3 and 4.
604-
#define RPM_LINE_A1 3.197101e-03 // Used N_PIECES >=1. A and B constants of line 1.
605-
#define RPM_LINE_B1 -3.526076e-1
606-
#define RPM_LINE_A2 1.722950e-2 // Used N_PIECES >=2. A and B constants of line 2.
607-
#define RPM_LINE_B2 8.588176e+01
608-
#define RPM_LINE_A3 5.901518e-02 // Used N_PIECES >=3. A and B constants of line 3.
609-
#define RPM_LINE_B3 4.881851e+02
610-
#define RPM_LINE_A4 1.203413e-01 // Used N_PIECES = 4. A and B constants of line 4.
611-
#define RPM_LINE_B4 1.151360e+03
612-
613-
614589
/* ---------------------------------------------------------------------------------------
615590
OEM Single File Configuration Option
616591

grbl/defaults.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,4 +490,42 @@
490490
#define DEFAULT_HOMING_PULLOFF 1.0 // mm
491491
#endif
492492

493+
#ifdef DEFAULTS_LBV4S2125M
494+
// Description: LubanDIY Laser Engraver V4.
495+
#define DEFAULT_X_STEPS_PER_MM 80.0
496+
#define DEFAULT_Y_STEPS_PER_MM 80.0
497+
#define DEFAULT_Z_STEPS_PER_MM 250.0
498+
#define DEFAULT_X_MAX_RATE 3000.0 // mm/min
499+
#define DEFAULT_Y_MAX_RATE 3000.0 // mm/min
500+
#define DEFAULT_Z_MAX_RATE 500.0 // mm/min
501+
#define DEFAULT_X_ACCELERATION (500.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
502+
#define DEFAULT_Y_ACCELERATION (500.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
503+
#define DEFAULT_Z_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
504+
#define DEFAULT_X_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value.
505+
#define DEFAULT_Y_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value.
506+
#define DEFAULT_Z_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value.
507+
#define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm
508+
#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
509+
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
510+
#define DEFAULT_STEPPING_INVERT_MASK 0
511+
#define DEFAULT_DIRECTION_INVERT_MASK 2
512+
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-254, 255 keeps steppers enabled)
513+
#define DEFAULT_STATUS_REPORT_MASK 3 // MPos enabled
514+
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
515+
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
516+
#define DEFAULT_REPORT_INCHES 0 // false
517+
#define DEFAULT_INVERT_ST_ENABLE 0 // false
518+
#define DEFAULT_INVERT_LIMIT_PINS 0 // false
519+
#define DEFAULT_SOFT_LIMIT_ENABLE 1 // true
520+
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
521+
#define DEFAULT_INVERT_PROBE_PIN 0 // false
522+
#define DEFAULT_LASER_MODE 0 // false
523+
#define DEFAULT_HOMING_ENABLE 0 // false
524+
#define DEFAULT_HOMING_DIR_MASK 0 // move positive dir
525+
#define DEFAULT_HOMING_FEED_RATE 25.0 // mm/min
526+
#define DEFAULT_HOMING_SEEK_RATE 500.0 // mm/min
527+
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
528+
#define DEFAULT_HOMING_PULLOFF 1.0 // mm
529+
#endif
530+
493531
#endif

grbl/grbl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#define grbl_h
2323

2424
// Grbl versioning system
25-
#define GRBL_VERSION "1.1f"
26-
#define GRBL_VERSION_BUILD "20170531"
25+
#define GRBL_VERSION "1.1f-lx"
26+
#define GRBL_VERSION_BUILD "20170324"
2727

2828
// Define standard libraries used by Grbl.
2929
#include <avr/io.h>

grbl/serial.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ ISR(SERIAL_RX)
151151
case CMD_RESET: mc_reset(); break; // Call motion control reset routine.
152152
case CMD_STATUS_REPORT: system_set_exec_state_flag(EXEC_STATUS_REPORT); break; // Set as true
153153
case CMD_CYCLE_START: system_set_exec_state_flag(EXEC_CYCLE_START); break; // Set as true
154-
case CMD_FEED_HOLD: system_set_exec_state_flag(EXEC_FEED_HOLD); break; // Set as true
154+
case CMD_FEED_HOLD: system_set_exec_state_flag(EXEC_SAFETY_DOOR); break; // Set as true
155155
default :
156156
if (data > 0x7F) { // Real-time control characters are extended ACSII only.
157157
switch(data) {

grbl/spindle_control.c

Lines changed: 24 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
spindle_control.c - spindle control methods
33
Part of Grbl
44
5-
Copyright (c) 2012-2017 Sungeun K. Jeon for Gnea Research LLC
5+
Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC
66
Copyright (c) 2009-2011 Simen Svale Skogsrud
77
88
Grbl is free software: you can redistribute it and/or modify
@@ -137,79 +137,32 @@ void spindle_stop()
137137
}
138138

139139

140-
#ifdef ENABLE_PIECEWISE_LINEAR_SPINDLE
141-
142-
// Called by spindle_set_state() and step segment generator. Keep routine small and efficient.
143-
uint8_t spindle_compute_pwm_value(float rpm) // 328p PWM register is 8-bit.
144-
{
145-
uint8_t pwm_value;
146-
rpm *= (0.010*sys.spindle_speed_ovr); // Scale by spindle speed override value.
147-
// Calculate PWM register value based on rpm max/min settings and programmed rpm.
148-
if ((settings.rpm_min >= settings.rpm_max) || (rpm >= RPM_MAX)) {
149-
rpm = RPM_MAX;
150-
pwm_value = SPINDLE_PWM_MAX_VALUE;
151-
} else if (rpm <= RPM_MIN) {
152-
if (rpm == 0.0) { // S0 disables spindle
153-
pwm_value = SPINDLE_PWM_OFF_VALUE;
154-
} else {
155-
rpm = RPM_MIN;
156-
pwm_value = SPINDLE_PWM_MIN_VALUE;
157-
}
158-
} else {
159-
// Compute intermediate PWM value with linear spindle speed model via piecewise linear fit model.
160-
#if (N_PIECES > 3)
161-
if (rpm > RPM_POINT34) {
162-
pwm_value = floor(RPM_LINE_A4*rpm - RPM_LINE_B4);
163-
} else
164-
#endif
165-
#if (N_PIECES > 2)
166-
if (rpm > RPM_POINT23) {
167-
pwm_value = floor(RPM_LINE_A3*rpm - RPM_LINE_B3);
168-
} else
169-
#endif
170-
#if (N_PIECES > 1)
171-
if (rpm > RPM_POINT12) {
172-
pwm_value = floor(RPM_LINE_A2*rpm - RPM_LINE_B2);
173-
} else
174-
#endif
175-
{
176-
pwm_value = floor(RPM_LINE_A1*rpm - RPM_LINE_B1);
177-
}
140+
// Called by spindle_set_state() and step segment generator. Keep routine small and efficient.
141+
uint8_t spindle_compute_pwm_value(float rpm) // 328p PWM register is 8-bit.
142+
{
143+
uint8_t pwm_value;
144+
rpm *= (0.010*sys.spindle_speed_ovr); // Scale by spindle speed override value.
145+
// Calculate PWM register value based on rpm max/min settings and programmed rpm.
146+
if ((settings.rpm_min >= settings.rpm_max) || (rpm >= settings.rpm_max)) {
147+
// No PWM range possible. Set simple on/off spindle control pin state.
148+
sys.spindle_speed = settings.rpm_max;
149+
pwm_value = SPINDLE_PWM_MAX_VALUE;
150+
} else if (rpm <= settings.rpm_min) {
151+
if (rpm == 0.0) { // S0 disables spindle
152+
sys.spindle_speed = 0.0;
153+
pwm_value = SPINDLE_PWM_OFF_VALUE;
154+
} else { // Set minimum PWM output
155+
sys.spindle_speed = settings.rpm_min;
156+
pwm_value = SPINDLE_PWM_MIN_VALUE;
178157
}
158+
} else {
159+
// Compute intermediate PWM value with linear spindle speed model.
160+
// NOTE: A nonlinear model could be installed here, if required, but keep it VERY light-weight.
179161
sys.spindle_speed = rpm;
180-
return(pwm_value);
162+
pwm_value = floor((rpm-settings.rpm_min)*pwm_gradient) + SPINDLE_PWM_MIN_VALUE;
181163
}
182-
183-
#else
184-
185-
// Called by spindle_set_state() and step segment generator. Keep routine small and efficient.
186-
uint8_t spindle_compute_pwm_value(float rpm) // 328p PWM register is 8-bit.
187-
{
188-
uint8_t pwm_value;
189-
rpm *= (0.010*sys.spindle_speed_ovr); // Scale by spindle speed override value.
190-
// Calculate PWM register value based on rpm max/min settings and programmed rpm.
191-
if ((settings.rpm_min >= settings.rpm_max) || (rpm >= settings.rpm_max)) {
192-
// No PWM range possible. Set simple on/off spindle control pin state.
193-
sys.spindle_speed = settings.rpm_max;
194-
pwm_value = SPINDLE_PWM_MAX_VALUE;
195-
} else if (rpm <= settings.rpm_min) {
196-
if (rpm == 0.0) { // S0 disables spindle
197-
sys.spindle_speed = 0.0;
198-
pwm_value = SPINDLE_PWM_OFF_VALUE;
199-
} else { // Set minimum PWM output
200-
sys.spindle_speed = settings.rpm_min;
201-
pwm_value = SPINDLE_PWM_MIN_VALUE;
202-
}
203-
} else {
204-
// Compute intermediate PWM value with linear spindle speed model.
205-
// NOTE: A nonlinear model could be installed here, if required, but keep it VERY light-weight.
206-
sys.spindle_speed = rpm;
207-
pwm_value = floor((rpm-settings.rpm_min)*pwm_gradient) + SPINDLE_PWM_MIN_VALUE;
208-
}
209-
return(pwm_value);
210-
}
211-
212-
#endif
164+
return(pwm_value);
165+
}
213166
#endif
214167

215168

0 commit comments

Comments
 (0)