diff --git a/doc/markdown/settings.md b/doc/markdown/settings.md index 4b54746..f653c8c 100644 --- a/doc/markdown/settings.md +++ b/doc/markdown/settings.md @@ -51,6 +51,7 @@ $27=1.000 $30=1000. $31=0. $32=0 +$33=5000 $100=250.000 $101=250.000 $102=250.000 @@ -63,6 +64,9 @@ $122=10.000 $130=200.000 $131=200.000 $132=200.000 +$140=0.000 +$141=0.000 +$142=0.000 ``` #### $x=val - Save Grbl setting @@ -227,6 +231,10 @@ When enabled, Grbl will move continuously through consecutive `G1`, `G2`, or `G3 When disabled, Grbl will operate as it always has, stopping motion with every `S` spindle speed command. This is the default operation of a milling machine to allow a pause to let the spindle change speeds. +#### $33 - Spindle/Laser PWM frequency + +This sets the PWM frequency. + #### $100, $101 and $102 – [X,Y,Z] steps/mm Grbl needs to know how far each step will take the tool in reality. To calculate steps/mm for an axis of your machine you need to know: diff --git a/doc/media/Thumbs.db b/doc/media/Thumbs.db new file mode 100644 index 0000000..4715c4b Binary files /dev/null and b/doc/media/Thumbs.db differ diff --git a/grbl-lpc/current_control.cpp b/grbl-lpc/current_control.cpp index ab8f0de..02fc675 100644 --- a/grbl-lpc/current_control.cpp +++ b/grbl-lpc/current_control.cpp @@ -55,7 +55,7 @@ void current_init() set_current(0, settings.current[0]); set_current(1, settings.current[1]); set_current(2, settings.current[2]); - set_current(3, DEFAULT_A_CURRENT); + set_current(3, settings.current[3]); #endif } diff --git a/grbl/config.h b/grbl/config.h index be9af41..4534b3e 100644 --- a/grbl/config.h +++ b/grbl/config.h @@ -35,8 +35,11 @@ // NOTE: OEMs can avoid the need to maintain/update the defaults.h and cpu_map.h files and use only // one configuration file by placing their specific defaults and pin map at the bottom of this file. // If doing so, simply comment out these two defines and see instructions below. -// #define DEFAULTS_GENERIC -// #define CPU_MAP_ATMEGA328P // Arduino Uno CPU +#define CPU_MAP_LPC1769 // NXP LPC1769 boards (like Smoothieboard, Cohesion3D, MKS SBase) +#define BOARD_C3D // For boards without i2c stepper current chip (like Cohesion3D). +//#define DEFAULTS_GENERIC +#define DEFAULTS_K40 +//#define DEFAULTS_FABKIT // Serial baud rate // #define BAUD_RATE 230400 @@ -359,6 +362,7 @@ // pwm = scaled value. settings.rpm_min scales to SPINDLE_PWM_MIN_VALUE. settings.rpm_max // scales to SPINDLE_PWM_MAX_VALUE. +// Not needed anymore, as spindle PWM frequency is set by $33 param //#define SPINDLE_PWM_PERIOD (SystemCoreClock / 40000) // SystemCoreClock / frequency #define SPINDLE_PWM_OFF_VALUE 0.0 // SPINDLE_PWM_PERIOD * fraction //#define SPINDLE_PWM_MIN_VALUE (SPINDLE_PWM_PERIOD * 0.0) // SPINDLE_PWM_PERIOD * fraction @@ -629,154 +633,5 @@ below. */ -// Paste CPU_MAP definitions here. -// Define serial port pins and interrupt vectors. -#define SERIAL_RX USART_RX_vect -#define SERIAL_UDRE USART_UDRE_vect - -// Define step pulse output pins. NOTE: All step bit pins must be on the same port. -#define STEP_DDR LPC_GPIO2->FIODIR -#define STEP_PORT LPC_GPIO2->FIOPIN -#define X_STEP_BIT 0 -#define Y_STEP_BIT 1 -#define Z_STEP_BIT 2 -#define STEP_MASK ((1<FIODIR -#define DIRECTION_PORT LPC_GPIO0->FIOPIN -#define X_DIRECTION_BIT 5 -#define Y_DIRECTION_BIT 11 -#define Z_DIRECTION_BIT 20 -#define DIRECTION_MASK ((1<FIODIR -#define STEPPERS_DISABLE_PORT LPC_GPIO0->FIOPIN -#define X_DISABLE_BIT 4 -#define Y_DISABLE_BIT 10 -#define Z_DISABLE_BIT 19 -#define STEPPERS_DISABLE_MASK ((1<FIODIR -#define LIMIT_PIN LPC_GPIO1->FIOPIN -#define LIMIT_PORT LPC_GPIO1->FIOPIN -#define X_LIMIT_BIT 24 // X-MIN=24, X-MAX=25 -#define Y_LIMIT_BIT 27 // Y-MIN=26, Y-MAX=27 -#define Z_LIMIT_BIT 29 // Z-MIN=28, Z-MAX=29 -#define LIMIT_MASK ((1<FIODIR + #define STEP_PORT LPC_GPIO2->FIOPIN + #define X_STEP_BIT 0 + #define Y_STEP_BIT 1 + #define Z_STEP_BIT 2 + #define A_STEP_BIT 3 + //#define B_STEP_BIT 8 + //#define C_STEP_BIT 9 + #define STEP_MASK ((1<FIODIR + #define DIRECTION_PORT LPC_GPIO0->FIOPIN + #define X_DIRECTION_BIT 5 + #define Y_DIRECTION_BIT 11 + #define Z_DIRECTION_BIT 20 + #define A_DIRECTION_BIT 22 + //#define B_DIRECTION_BIT 13 + //#define C_DIRECTION_BIT NotUsed + #define DIRECTION_MASK ((1<FIODIR + #define STEPPERS_DISABLE_PORT LPC_GPIO0->FIOPIN + #define X_DISABLE_BIT 4 + #define Y_DISABLE_BIT 10 + #define Z_DISABLE_BIT 19 + #define A_DISABLE_BIT 21 + //#define B_DISABLE_BIT 29 + //#define C_DISABLE_BIT NotUsed + #define STEPPERS_DISABLE_MASK ((1<FIODIR + #define LIMIT_PIN LPC_GPIO1->FIOPIN + #define LIMIT_PORT LPC_GPIO1->FIOPIN + #define X_LIMIT_BIT 24 // X-MIN=24, X-MAX=25 + #define Y_LIMIT_BIT 27 // Y-MIN=26, Y-MAX=27 + #define Z_LIMIT_BIT 29 // Z-MIN=28, Z-MAX=29 + #define A_LIMIT_BIT 28 // reuse p1.28, as z-min is not often used + //#define B_LIMIT_BIT NotUsed + //#define C_LIMIT_BIT NotUsed + #define LIMIT_MASK ((1< 62.5kHz + // #define SPINDLE_TCCRB_INIT_MASK (1< 7.8kHz (Used in v0.9) + // #define SPINDLE_TCCRB_INIT_MASK ((1< 1.96kHz + #define SPINDLE_TCCRB_INIT_MASK (1< 0.98kHz (J-tech laser) + + // NOTE: On the 328p, these must be the same as the SPINDLE_ENABLE settings. + #define SPINDLE_PWM_DDR DDRB + #define SPINDLE_PWM_PORT PORTB + #define SPINDLE_PWM_BIT 3 // Uno Digital Pin 11 + */ + +#endif + /* #ifdef CPU_MAP_CUSTOM_PROC // For a custom pin map or different processor, copy and edit one of the available cpu diff --git a/grbl/defaults.h b/grbl/defaults.h index ff30f8a..a3d12db 100644 --- a/grbl/defaults.h +++ b/grbl/defaults.h @@ -32,15 +32,33 @@ #define DEFAULT_X_STEPS_PER_MM 250.0 #define DEFAULT_Y_STEPS_PER_MM 250.0 #define DEFAULT_Z_STEPS_PER_MM 250.0 + #define DEFAULT_A_STEPS_PER_MM 160.0 + //#define DEFAULT_B_STEPS_PER_MM 160.0 + //#define DEFAULT_C_STEPS_PER_MM 160.0 #define DEFAULT_X_MAX_RATE 500.0 // mm/min #define DEFAULT_Y_MAX_RATE 500.0 // mm/min #define DEFAULT_Z_MAX_RATE 500.0 // mm/min + #define DEFAULT_A_MAX_RATE 500.0 // mm/min + //#define DEFAULT_B_MAX_RATE 500.0 // mm/min + //#define DEFAULT_C_MAX_RATE 500.0 // mm/min #define DEFAULT_X_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 #define DEFAULT_Y_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 #define DEFAULT_Z_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 + #define DEFAULT_A_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 + //#define DEFAULT_B_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 + //#define DEFAULT_C_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 + #define DEFAULT_X_CURRENT 0.6 // amps + #define DEFAULT_Y_CURRENT 0.6 // amps + #define DEFAULT_Z_CURRENT 0.0 // amps + #define DEFAULT_A_CURRENT 0.0 // amps + //#define DEFAULT_B_CURRENT 0.0 // amps + //#define DEFAULT_C_CURRENT 0.0 // amps #define DEFAULT_X_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value. #define DEFAULT_Y_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value. #define DEFAULT_Z_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value. + #define DEFAULT_A_MAX_TRAVEL 1.0 // mm NOTE: Must be a positive value. + //#define DEFAULT_B_MAX_TRAVEL 1.0 // mm NOTE: Must be a positive value. + //#define DEFAULT_C_MAX_TRAVEL 1.0 // mm NOTE: Must be a positive value. #define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz #define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm @@ -71,19 +89,33 @@ #define DEFAULT_X_STEPS_PER_MM 160.0 #define DEFAULT_Y_STEPS_PER_MM 160.0 #define DEFAULT_Z_STEPS_PER_MM 160.0 + #define DEFAULT_A_STEPS_PER_MM 160.0 + //#define DEFAULT_B_STEPS_PER_MM 160.0 + //#define DEFAULT_C_STEPS_PER_MM 160.0 #define DEFAULT_X_MAX_RATE 24000.0 // mm/min #define DEFAULT_Y_MAX_RATE 24000.0 // mm/min #define DEFAULT_Z_MAX_RATE 24000.0 // mm/min + #define DEFAULT_A_MAX_RATE 24000.0 // mm/min + //#define DEFAULT_B_MAX_RATE 24000.0 // mm/min + //#define DEFAULT_C_MAX_RATE 24000.0 // mm/min #define DEFAULT_X_ACCELERATION (2500.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 #define DEFAULT_Y_ACCELERATION (2500.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 #define DEFAULT_Z_ACCELERATION (2500.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 - #define DEFAULT_X_CURRENT 0.0 // amps - #define DEFAULT_Y_CURRENT 0.0 // amps + #define DEFAULT_A_ACCELERATION (2500.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 + //#define DEFAULT_B_ACCELERATION (2500.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 + //#define DEFAULT_C_ACCELERATION (2500.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 + #define DEFAULT_X_CURRENT 0.6 // amps + #define DEFAULT_Y_CURRENT 0.6 // amps #define DEFAULT_Z_CURRENT 0.0 // amps - #define DEFAULT_A_CURRENT 0.0 // amps + #define DEFAULT_A_CURRENT 0.0 // amps + //#define DEFAULT_B_CURRENT 0.0 // amps + //#define DEFAULT_C_CURRENT 0.0 // amps #define DEFAULT_X_MAX_TRAVEL 300.0 // mm NOTE: Must be a positive value. #define DEFAULT_Y_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value. - #define DEFAULT_Z_MAX_TRAVEL 50.0 // mm NOTE: Must be a positive value. + #define DEFAULT_Z_MAX_TRAVEL 1.0 // mm NOTE: Must be a positive value. + #define DEFAULT_A_MAX_TRAVEL 1.0 // mm NOTE: Must be a positive value. + //#define DEFAULT_B_MAX_TRAVEL 1.0 // mm NOTE: Must be a positive value. + //#define DEFAULT_C_MAX_TRAVEL 1.0 // mm NOTE: Must be a positive value. #define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz #define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm @@ -109,6 +141,49 @@ #define DEFAULT_HOMING_PULLOFF 1.0 // mm #endif +#ifdef DEFAULTS_FABKIT + // Paste default settings definitions here. + #define DEFAULT_X_STEPS_PER_MM 80.0 + #define DEFAULT_Y_STEPS_PER_MM 80.0 + #define DEFAULT_Z_STEPS_PER_MM 640.0 + #define DEFAULT_X_MAX_RATE 30000 // mm/min + #define DEFAULT_Y_MAX_RATE 4500 // mm/min + #define DEFAULT_Z_MAX_RATE 1200 // mm/min + #define DEFAULT_X_ACCELERATION (4000.0*60*60) // 5000*60*60 mm/min^2 = 5000 mm/sec^2 + #define DEFAULT_Y_ACCELERATION (250.0*60*60) // 5000*60*60 mm/min^2 = 5000 mm/sec^2 + #define DEFAULT_Z_ACCELERATION (150.0*60*60) // 5000*60*60 mm/min^2 = 5000 mm/sec^2 + #define DEFAULT_X_CURRENT 1.5 // amps + #define DEFAULT_Y_CURRENT 1.5 // amps + #define DEFAULT_Z_CURRENT 1.5 // amps + #define DEFAULT_A_CURRENT 0.0 // amps + #define DEFAULT_X_MAX_TRAVEL 680.0 // mm + #define DEFAULT_Y_MAX_TRAVEL 460.0 // mm + #define DEFAULT_Z_MAX_TRAVEL 150.0 // mm + #define DEFAULT_SPINDLE_PWM_FREQ 50000 // Hz + #define DEFAULT_SPINDLE_RPM_MAX 0.7 // rpm + #define DEFAULT_SPINDLE_RPM_MIN 0.08 // rpm + #define DEFAULT_STEP_PULSE_MICROSECONDS 1 + #define DEFAULT_STEPPING_INVERT_MASK 0 + #define DEFAULT_DIRECTION_INVERT_MASK 2 + #define DEFAULT_STEPPER_IDLE_LOCK_TIME 255 // msec (0-254, 255 keeps steppers enabled) + #define DEFAULT_STATUS_REPORT_MASK 0 // WPos enabled + #define DEFAULT_JUNCTION_DEVIATION 0.01 // mm + #define DEFAULT_ARC_TOLERANCE 0.002 // mm + #define DEFAULT_REPORT_INCHES 0 // false + #define DEFAULT_INVERT_ST_ENABLE 0 // false + #define DEFAULT_INVERT_LIMIT_PINS 1 // false + #define DEFAULT_SOFT_LIMIT_ENABLE 0 // false + #define DEFAULT_HARD_LIMIT_ENABLE 0 // false + #define DEFAULT_INVERT_PROBE_PIN 0 // false + #define DEFAULT_LASER_MODE 1 // true + #define DEFAULT_HOMING_ENABLE 1 // false + #define DEFAULT_HOMING_DIR_MASK 1 // move positive dir + #define DEFAULT_HOMING_FEED_RATE 60.0 // mm/min + #define DEFAULT_HOMING_SEEK_RATE 6000.0 // mm/min + #define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k) + #define DEFAULT_HOMING_PULLOFF 1.0 // mm +#endif + #ifdef DEFAULTS_SHERLINE_5400 // Description: Sherline 5400 mill with three NEMA 23 Keling KL23H256-21-8B 185 oz-in stepper motors, // driven by three Pololu A4988 stepper drivers with a 30V, 6A power supply at 1.5A per winding. @@ -127,6 +202,7 @@ #define DEFAULT_X_MAX_TRAVEL 225.0 // mm NOTE: Must be a positive value. #define DEFAULT_Y_MAX_TRAVEL 125.0 // mm NOTE: Must be a positive value. #define DEFAULT_Z_MAX_TRAVEL 170.0 // mm NOTE: Must be a positive value. + #define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz #define DEFAULT_SPINDLE_RPM_MAX 2800.0 // rpm #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm #define DEFAULT_STEP_PULSE_MICROSECONDS 10 @@ -172,6 +248,7 @@ #define DEFAULT_X_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value. #define DEFAULT_Y_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value. #define DEFAULT_Z_MAX_TRAVEL 200.0 // mm NOTE: Must be a positive value. + #define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz #define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm #define DEFAULT_STEP_PULSE_MICROSECONDS 10 @@ -217,6 +294,7 @@ #define DEFAULT_X_MAX_TRAVEL 290.0 // mm NOTE: Must be a positive value. #define DEFAULT_Y_MAX_TRAVEL 290.0 // mm NOTE: Must be a positive value. #define DEFAULT_Z_MAX_TRAVEL 100.0 // mm NOTE: Must be a positive value. + #define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz #define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm #define DEFAULT_STEP_PULSE_MICROSECONDS 10 @@ -261,6 +339,7 @@ #define DEFAULT_X_MAX_TRAVEL 425.0 // mm NOTE: Must be a positive value. #define DEFAULT_Y_MAX_TRAVEL 465.0 // mm NOTE: Must be a positive value. #define DEFAULT_Z_MAX_TRAVEL 80.0 // mm NOTE: Must be a positive value. + #define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz #define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm #define DEFAULT_STEP_PULSE_MICROSECONDS 10 @@ -306,6 +385,7 @@ #define DEFAULT_X_MAX_TRAVEL 290.0 // mm NOTE: Must be a positive value. #define DEFAULT_Y_MAX_TRAVEL 290.0 // mm NOTE: Must be a positive value. #define DEFAULT_Z_MAX_TRAVEL 100.0 // mm NOTE: Must be a positive value. + #define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz #define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm #define DEFAULT_STEP_PULSE_MICROSECONDS 10 @@ -351,6 +431,7 @@ #define DEFAULT_X_MAX_TRAVEL 740.0 // mm NOTE: Must be a positive value. #define DEFAULT_Y_MAX_TRAVEL 790.0 // mm NOTE: Must be a positive value. #define DEFAULT_Z_MAX_TRAVEL 100.0 // mm NOTE: Must be a positive value. + #define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz #define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm #define DEFAULT_STEP_PULSE_MICROSECONDS 10 @@ -394,6 +475,7 @@ #define DEFAULT_X_MAX_TRAVEL 190.0 // mm NOTE: Must be a positive value. #define DEFAULT_Y_MAX_TRAVEL 180.0 // mm NOTE: Must be a positive value. #define DEFAULT_Z_MAX_TRAVEL 150.0 // mm NOTE: Must be a positive value. + #define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz #define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm #define DEFAULT_STEP_PULSE_MICROSECONDS 10 @@ -433,6 +515,7 @@ #define DEFAULT_X_MAX_TRAVEL 500.0 // mm NOTE: Must be a positive value. #define DEFAULT_Y_MAX_TRAVEL 750.0 // mm NOTE: Must be a positive value. #define DEFAULT_Z_MAX_TRAVEL 80.0 // mm NOTE: Must be a positive value. + #define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz #define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm #define DEFAULT_STEP_PULSE_MICROSECONDS 10 @@ -472,6 +555,7 @@ #define DEFAULT_X_MAX_TRAVEL 1000.0 // mm NOTE: Must be a positive value. #define DEFAULT_Y_MAX_TRAVEL 1000.0 // mm NOTE: Must be a positive value. #define DEFAULT_Z_MAX_TRAVEL 1000.0 // mm NOTE: Must be a positive value. + #define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz #define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm #define DEFAULT_STEP_PULSE_MICROSECONDS 10 diff --git a/grbl/gcode.c b/grbl/gcode.c index d4fd2c7..8290484 100644 --- a/grbl/gcode.c +++ b/grbl/gcode.c @@ -80,7 +80,7 @@ uint8_t gc_execute_line(char *line) uint8_t coord_select = 0; // Tracks G10 P coordinate selection for execution // Initialize bitflag tracking variables for axis indices compatible operations. - uint8_t axis_words = 0; // XYZ tracking + uint8_t axis_words = 0; // XYZA tracking uint8_t ijk_words = 0; // IJK tracking // Initialize command and value words and parser flags variables. @@ -296,7 +296,7 @@ uint8_t gc_execute_line(char *line) legal g-code words and stores their value. Error-checking is performed later since some words (I,J,K,L,P,R) have multiple connotations and/or depend on the issued commands. */ switch(letter){ - // case 'A': // Not supported + case 'A': word_bit = WORD_A; gc_block.values.xyza[A_AXIS] = value; axis_words |= (1< MAX_TOOL_NUMBER) { FAIL(STATUS_GCODE_MAX_VALUE_EXCEEDED); } gc_block.values.t = int_value; break; - case 'X': word_bit = WORD_X; gc_block.values.xyz[X_AXIS] = value; axis_words |= (1< WCS = MPos - G92 - TLO - WPos - gc_block.values.ijk[idx] = gc_state.position[idx]-gc_state.coord_offset[idx]-gc_block.values.xyz[idx]; + gc_block.values.ijk[idx] = gc_state.position[idx]-gc_state.coord_offset[idx]-gc_block.values.xyza[idx]; if (idx == TOOL_LENGTH_OFFSET_AXIS) { gc_block.values.ijk[idx] -= gc_state.tool_length_offset; } } else { // L2: Update coordinate system axis to programmed value. - gc_block.values.ijk[idx] = gc_block.values.xyz[idx]; + gc_block.values.ijk[idx] = gc_block.values.xyza[idx]; } } // Else, keep current stored value. } @@ -567,10 +567,10 @@ uint8_t gc_execute_line(char *line) for (idx=0; idx G92 = MPos - WCS - TLO - WPos - gc_block.values.xyz[idx] = gc_state.position[idx]-block_coord_system[idx]-gc_block.values.xyz[idx]; - if (idx == TOOL_LENGTH_OFFSET_AXIS) { gc_block.values.xyz[idx] -= gc_state.tool_length_offset; } + gc_block.values.xyza[idx] = gc_state.position[idx]-block_coord_system[idx]-gc_block.values.xyza[idx]; + if (idx == TOOL_LENGTH_OFFSET_AXIS) { gc_block.values.xyza[idx] -= gc_state.tool_length_offset; } } else { - gc_block.values.xyz[idx] = gc_state.coord_offset[idx]; + gc_block.values.xyza[idx] = gc_state.coord_offset[idx]; } } break; @@ -585,17 +585,17 @@ uint8_t gc_execute_line(char *line) if (axis_words) { for (idx=0; idxcondition |= PL_COND_FLAG_RAPID_MOTION; // Set rapid motion condition flag. - if (axis_command) { mc_line(gc_block.values.xyz, pl_data); } + if (axis_command) { mc_line(gc_block.values.xyza, pl_data); } mc_line(gc_block.values.ijk, pl_data); memcpy(gc_state.position, gc_block.values.ijk, N_AXIS*sizeof(float)); break; @@ -1033,7 +1033,7 @@ uint8_t gc_execute_line(char *line) settings_write_coord_data(SETTING_INDEX_G30,gc_state.position,false,true); break; case NON_MODAL_SET_COORDINATE_OFFSET: - memcpy(gc_state.coord_offset,gc_block.values.xyz,sizeof(gc_block.values.xyz)); + memcpy(gc_state.coord_offset,gc_block.values.xyza,sizeof(gc_block.values.xyza)); system_flag_wco_change(); break; case NON_MODAL_RESET_COORDINATE_OFFSET: @@ -1051,27 +1051,27 @@ uint8_t gc_execute_line(char *line) if (axis_command == AXIS_COMMAND_MOTION_MODE) { uint8_t gc_update_pos = GC_UPDATE_POS_TARGET; if (gc_state.modal.motion == MOTION_MODE_LINEAR) { - mc_line(gc_block.values.xyz, pl_data); + mc_line(gc_block.values.xyza, pl_data); } else if (gc_state.modal.motion == MOTION_MODE_SEEK) { pl_data->condition |= PL_COND_FLAG_RAPID_MOTION; // Set rapid motion condition flag. - mc_line(gc_block.values.xyz, pl_data); + mc_line(gc_block.values.xyza, pl_data); } else if ((gc_state.modal.motion == MOTION_MODE_CW_ARC) || (gc_state.modal.motion == MOTION_MODE_CCW_ARC)) { - mc_arc(gc_block.values.xyz, pl_data, gc_state.position, gc_block.values.ijk, gc_block.values.r, + mc_arc(gc_block.values.xyza, pl_data, gc_state.position, gc_block.values.ijk, gc_block.values.r, axis_0, axis_1, axis_linear, bit_istrue(gc_parser_flags,GC_PARSER_ARC_IS_CLOCKWISE)); } else { - // NOTE: gc_block.values.xyz is returned from mc_probe_cycle with the updated position value. So + // NOTE: gc_block.values.xyza is returned from mc_probe_cycle with the updated position value. So // upon a successful probing cycle, the machine position and the returned value should be the same. #ifndef ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES pl_data->condition |= PL_COND_FLAG_NO_FEED_OVERRIDE; #endif - gc_update_pos = mc_probe_cycle(gc_block.values.xyz, pl_data, gc_parser_flags); + gc_update_pos = mc_probe_cycle(gc_block.values.xyza, pl_data, gc_parser_flags); } // As far as the parser is concerned, the position is now == target. In reality the // motion control system might still be processing the action and the real tool position // in any intermediate location. if (gc_update_pos == GC_UPDATE_POS_TARGET) { - memcpy(gc_state.position, gc_block.values.xyz, sizeof(gc_block.values.xyz)); // gc_state.position[] = gc_block.values.xyz[] + memcpy(gc_state.position, gc_block.values.xyza, sizeof(gc_block.values.xyza)); // gc_state.position[] = gc_block.values.xyza[] } else if (gc_update_pos == GC_UPDATE_POS_SYSTEM) { gc_sync_position(); // gc_state.position[] = sys_position } // == GC_UPDATE_POS_NONE diff --git a/grbl/gcode.h b/grbl/gcode.h index 6cdc61b..7ecc60d 100644 --- a/grbl/gcode.h +++ b/grbl/gcode.h @@ -149,6 +149,7 @@ #define WORD_X 10 #define WORD_Y 11 #define WORD_Z 12 +#define WORD_A 13 // Define g-code parser position updating flags #define GC_UPDATE_POS_TARGET 0 // Must be zero @@ -206,7 +207,7 @@ typedef struct { float r; // Arc radius float s; // Spindle speed uint8_t t; // Tool selection - float xyz[3]; // X,Y,Z Translational axes + float xyza[N_AXIS]; // X,Y,Z,A Translational axes } gc_values_t; diff --git a/grbl/grbl.h b/grbl/grbl.h index ef1c324..2f1e740 100644 --- a/grbl/grbl.h +++ b/grbl/grbl.h @@ -23,7 +23,7 @@ // Grbl versioning system #define GRBL_VERSION "1.1f" -#define GRBL_VERSION_BUILD "20170131" +#define GRBL_VERSION_BUILD "20170511" // Define standard libraries used by Grbl. #include diff --git a/grbl/jog.c b/grbl/jog.c index 553af77..c0ba594 100644 --- a/grbl/jog.c +++ b/grbl/jog.c @@ -33,11 +33,11 @@ uint8_t jog_execute(plan_line_data_t *pl_data, parser_block_t *gc_block) #endif if (bit_istrue(settings.flags,BITFLAG_SOFT_LIMIT_ENABLE)) { - if (system_check_travel_limits(gc_block->values.xyz)) { return(STATUS_TRAVEL_EXCEEDED); } + if (system_check_travel_limits(gc_block->values.xyza)) { return(STATUS_TRAVEL_EXCEEDED); } } // Valid jog command. Plan, set state, and execute. - mc_line(gc_block->values.xyz,pl_data); + mc_line(gc_block->values.xyza,pl_data); if (sys.state == STATE_IDLE) { if (plan_get_current_block() != NULL) { // Check if there is a block to execute. sys.state = STATE_JOG; diff --git a/grbl/motion_control.c b/grbl/motion_control.c index db382bf..a3186cd 100644 --- a/grbl/motion_control.c +++ b/grbl/motion_control.c @@ -227,6 +227,9 @@ void mc_homing_cycle(uint8_t cycle_mask) #ifdef HOMING_CYCLE_2 limits_go_home(HOMING_CYCLE_2); // Homing cycle 2 #endif + #ifdef HOMING_CYCLE_3 + limits_go_home(HOMING_CYCLE_3); // Homing cycle 3 + #endif } protocol_execute_realtime(); // Check for reset and set system abort. diff --git a/grbl/motion_control.h b/grbl/motion_control.h index 0f7531e..e7fa545 100644 --- a/grbl/motion_control.h +++ b/grbl/motion_control.h @@ -31,6 +31,9 @@ #define HOMING_CYCLE_X bit(X_AXIS) #define HOMING_CYCLE_Y bit(Y_AXIS) #define HOMING_CYCLE_Z bit(Z_AXIS) +#define HOMING_CYCLE_A bit(A_AXIS) +//#define HOMING_CYCLE_B bit(B_AXIS) +//#define HOMING_CYCLE_C bit(C_AXIS) // Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second diff --git a/grbl/nuts_bolts.h b/grbl/nuts_bolts.h index f78481b..f90bb88 100644 --- a/grbl/nuts_bolts.h +++ b/grbl/nuts_bolts.h @@ -30,11 +30,13 @@ #define SOME_LARGE_VALUE 1.0E+38 // Axis array index values. Must start with 0 and be continuous. -#define N_AXIS 3 // Number of axes +#define N_AXIS 4 // Number of axes #define X_AXIS 0 // Axis indexing value. #define Y_AXIS 1 #define Z_AXIS 2 -// #define A_AXIS 3 +#define A_AXIS 3 +//#define B_AXIS 4 +//#define C_AXIS 5 // CoreXY motor assignments. DO NOT ALTER. // NOTE: If the A and B motor axis bindings are changed, this effects the CoreXY equations. diff --git a/grbl/planner.c b/grbl/planner.c index 4839bbf..131c068 100644 --- a/grbl/planner.c +++ b/grbl/planner.c @@ -336,6 +336,7 @@ uint8_t plan_buffer_line(float *target, plan_line_data_t *pl_data) position_steps[X_AXIS] = system_convert_corexy_to_x_axis_steps(sys_position); position_steps[Y_AXIS] = system_convert_corexy_to_y_axis_steps(sys_position); position_steps[Z_AXIS] = sys_position[Z_AXIS]; + position_steps[A_AXIS] = sys_position[A_AXIS]; #else memcpy(position_steps, sys_position, sizeof(sys_position)); #endif diff --git a/grbl/report.c b/grbl/report.c index e0508c2..f748d6e 100644 --- a/grbl/report.c +++ b/grbl/report.c @@ -578,6 +578,9 @@ void report_realtime_status() if (bit_istrue(lim_pin_state,bit(X_AXIS))) { serial_write('X'); } if (bit_istrue(lim_pin_state,bit(Y_AXIS))) { serial_write('Y'); } if (bit_istrue(lim_pin_state,bit(Z_AXIS))) { serial_write('Z'); } + if (bit_istrue(lim_pin_state,bit(A_AXIS))) { serial_write('A'); } + //if (bit_istrue(lim_pin_state,bit(B_AXIS))) { serial_write('B'); } + //if (bit_istrue(lim_pin_state,bit(C_AXIS))) { serial_write('C'); } } if (ctrl_pin_state) { #ifdef ENABLE_SAFETY_DOOR_INPUT_PIN diff --git a/grbl/settings.c b/grbl/settings.c index 4900ffc..ed3aabb 100644 --- a/grbl/settings.c +++ b/grbl/settings.c @@ -109,18 +109,33 @@ void settings_restore(uint8_t restore_flag) { settings.steps_per_mm[X_AXIS] = DEFAULT_X_STEPS_PER_MM; settings.steps_per_mm[Y_AXIS] = DEFAULT_Y_STEPS_PER_MM; settings.steps_per_mm[Z_AXIS] = DEFAULT_Z_STEPS_PER_MM; + settings.steps_per_mm[A_AXIS] = DEFAULT_A_STEPS_PER_MM; + //settings.steps_per_mm[B_AXIS] = DEFAULT_B_STEPS_PER_MM; + //settings.steps_per_mm[C_AXIS] = DEFAULT_C_STEPS_PER_MM; settings.max_rate[X_AXIS] = DEFAULT_X_MAX_RATE; settings.max_rate[Y_AXIS] = DEFAULT_Y_MAX_RATE; settings.max_rate[Z_AXIS] = DEFAULT_Z_MAX_RATE; + settings.max_rate[A_AXIS] = DEFAULT_A_MAX_RATE; + //settings.max_rate[B_AXIS] = DEFAULT_B_MAX_RATE; + //settings.max_rate[C_AXIS] = DEFAULT_C_MAX_RATE; settings.acceleration[X_AXIS] = DEFAULT_X_ACCELERATION; settings.acceleration[Y_AXIS] = DEFAULT_Y_ACCELERATION; settings.acceleration[Z_AXIS] = DEFAULT_Z_ACCELERATION; + settings.acceleration[A_AXIS] = DEFAULT_A_ACCELERATION; + //settings.acceleration[B_AXIS] = DEFAULT_B_ACCELERATION; + //settings.acceleration[C_AXIS] = DEFAULT_C_ACCELERATION; settings.max_travel[X_AXIS] = (-DEFAULT_X_MAX_TRAVEL); settings.max_travel[Y_AXIS] = (-DEFAULT_Y_MAX_TRAVEL); settings.max_travel[Z_AXIS] = (-DEFAULT_Z_MAX_TRAVEL); + settings.max_travel[A_AXIS] = (-DEFAULT_A_MAX_TRAVEL); + //settings.max_travel[B_AXIS] = (-DEFAULT_B_MAX_TRAVEL); + //settings.max_travel[C_AXIS] = (-DEFAULT_C_MAX_TRAVEL); settings.current[X_AXIS] = DEFAULT_X_CURRENT; settings.current[Y_AXIS] = DEFAULT_Y_CURRENT; settings.current[Z_AXIS] = DEFAULT_Z_CURRENT; + settings.current[A_AXIS] = DEFAULT_A_CURRENT; + //settings.current[B_AXIS] = DEFAULT_B_CURRENT; + //settings.current[C_AXIS] = DEFAULT_C_CURRENT; write_global_settings(false); } @@ -343,7 +358,11 @@ uint32_t get_step_pin_mask(uint8_t axis_idx) { if ( axis_idx == X_AXIS ) { return((1<steps[X_AXIS] >> st.exec_segment->amass_level; st.steps[Y_AXIS] = st.exec_block->steps[Y_AXIS] >> st.exec_segment->amass_level; st.steps[Z_AXIS] = st.exec_block->steps[Z_AXIS] >> st.exec_segment->amass_level; + st.steps[A_AXIS] = st.exec_block->steps[A_AXIS] >> st.exec_segment->amass_level; + //st.steps[B_AXIS] = st.exec_block->steps[B_AXIS] >> st.exec_segment->amass_level; + //st.steps[C_AXIS] = st.exec_block->steps[C_AXIS] >> st.exec_segment->amass_level; #endif #ifdef VARIABLE_SPINDLE @@ -433,6 +439,41 @@ extern "C" void TIMER1_IRQHandler() if (st.exec_block->direction_bits & (1<steps[A_AXIS]; + #endif + if (st.counter_a > st.exec_block->step_event_count) { + st.step_outbits |= (1<step_event_count; + if (st.exec_block->direction_bits & (1<steps[B_AXIS]; + #endif + if (st.counter_b > st.exec_block->step_event_count) { + st.step_outbits |= (1<step_event_count; + if (st.exec_block->direction_bits & (1<steps[C_AXIS]; + #endif + if (st.counter_c > st.exec_block->step_event_count) { + st.step_outbits |= (1<step_event_count; + if (st.exec_block->direction_bits & (1<