83 uint8_t axis_0, uint8_t axis_1, uint8_t axis_linear, uint8_t is_clockwise_arc)
85 float center_axis0 = position[axis_0] + offset[axis_0];
86 float center_axis1 = position[axis_1] + offset[axis_1];
87 float r_axis0 = -offset[axis_0];
88 float r_axis1 = -offset[axis_1];
89 float rt_axis0 = target[axis_0] - center_axis0;
90 float rt_axis1 = target[axis_1] - center_axis1;
93 float angular_travel = atan2(r_axis0*rt_axis1-r_axis1*rt_axis0, r_axis0*rt_axis0+r_axis1*rt_axis1);
94 if (is_clockwise_arc) {
105 uint16_t segments = floor(fabs(0.5*angular_travel*radius)/
117 float theta_per_segment = angular_travel/segments;
118 float linear_per_segment = (target[axis_linear] - position[axis_linear])/segments;
146 float cos_T = 2.0 - theta_per_segment*theta_per_segment;
147 float sin_T = theta_per_segment*0.16666667*(cos_T + 4.0);
156 for (i = 1; i<segments; i++) {
160 r_axisi = r_axis0*sin_T + r_axis1*cos_T;
161 r_axis0 = r_axis0*cos_T - r_axis1*sin_T;
167 cos_Ti = cos(i*theta_per_segment);
168 sin_Ti = sin(i*theta_per_segment);
169 r_axis0 = -offset[axis_0]*cos_Ti + offset[axis_1]*sin_Ti;
170 r_axis1 = -offset[axis_0]*sin_Ti - offset[axis_1]*cos_Ti;
175 position[axis_0] = center_axis0 + r_axis0;
176 position[axis_1] = center_axis1 + r_axis1;
177 position[axis_linear] += linear_per_segment;
206 #ifdef LIMITS_TWO_SWITCHES_ON_AXES
220 #ifdef HOMING_SINGLE_AXIS_COMMANDS
227 #ifdef HOMING_CYCLE_1
230 #ifdef HOMING_CYCLE_2
308 #ifdef MESSAGE_PROBE_COORDINATES
void st_parking_restore_buffer()
Restores the step segment buffer to the normal run state after a parking motion.
void mc_homing_cycle(uint8_t cycle_mask)
Perform homing cycle to locate and set machine zero. Only '$H' executes this command.
volatile uint8_t sys_probe_state
Probing state value. Used to coordinate the probing cycle with stepper ISR.
#define EXEC_ALARM_PROBE_FAIL_CONTACT
void st_parking_setup_buffer()
Changes the run state of the step segment buffer to execute the special parking motion.
void plan_sync_position()
Reset the planner position vectors. Called by the system abort/initialization routine.
uint8_t plan_buffer_line(float *target, plan_line_data_t *pl_data)
Add a new linear movement to the buffer. target[N_AXIS] is the signed, absolute target position in mi...
void protocol_auto_cycle_start()
Auto-cycle start triggers when there is a motion ready to execute and if the main program is not...
#define EXEC_ALARM_ABORT_CYCLE
void limits_init()
Initialize the limits module.
uint8_t probe_get_state()
Returns the probe pin state. Triggered = true. Called by gcode parser and probe state monitor...
void limits_disable()
Disables hard limits.
void delay_sec(float seconds, uint8_t mode)
Non-blocking delay function used for general operation and suspend features.
void mc_dwell(float seconds)
Execute dwell in seconds.
void gc_sync_position()
Sets g-code parser position in mm. Input in steps. Called by the system abort and hard...
#define PROBE_OFF
Values that define the probing state machine.
#define bit_true(x, mask)
void system_set_exec_state_flag(uint8_t mask)
Special handlers for setting and clearing Grbl's real-time execution flags.
void protocol_buffer_synchronize()
Block until all buffered steps are executed or in a cycle state. Works with feed hold.
Planner data prototype. Must be used when passing new motions to the planner.
#define GC_PROBE_FAIL_END
#define PROBE_ACTIVE
Actively watching the input pin.
#define N_ARC_CORRECTION
Number of arc generation iterations by small angle approximation before exact arc trajectory...
#define BITFLAG_SOFT_LIMIT_ENABLE
#define GC_PARSER_PROBE_IS_NO_ERROR
volatile uint8_t sys_rt_exec_alarm
Global realtime executor bitflag variable for setting various alarms.
uint8_t state
Tracks the current system state of Grbl.
void limits_go_home(uint8_t cycle_mask)
NOTE: Only the abort realtime command can interrupt this process.
#define EXEC_RESET
bitmask 00010000
#define STEP_CONTROL_EXECUTE_HOLD
void plan_reset()
Initialize and reset the motion plan subsystem.
#define ARC_ANGULAR_TRAVEL_EPSILON
The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical...
void spindle_stop()
Disables the spindle and sets PWM output to zero when PWM variable spindle speed is enabled...
void mc_line(float *target, plan_line_data_t *pl_data)
Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second.
#define HOMING_CYCLE_1
OPTIONAL: Then move X,Y at the same time.
void probe_configure_invert_mask(uint8_t is_probe_away)
Called by probe_init() and the mc_probe() routines. Sets up the probe pin invert mask to...
uint8_t abort
System abort flag. Forces exit back to main loop for reset.
#define EXEC_ALARM_HOMING_FAIL_RESET
uint8_t mc_probe_cycle(float *target, plan_line_data_t *pl_data, uint8_t parser_flags)
Perform tool length probe cycle. Requires probe switch.
void mc_parking_motion(float *parking_target, plan_line_data_t *pl_data)
Plans and executes the single special motion case for parking. Independent of main planner buffer...
void limits_soft_check(float *target)
Performs a soft limit check. Called from mc_line() only. Assumes the machine has been homed...
#define EXEC_ALARM_PROBE_FAIL_INITIAL
#define STATE_CYCLE
Cycle is running or motions are being executed.
uint8_t flags
Contains default boolean settings.
#define STATE_CHECK_MODE
G-code check mode. Locks out planner and motion only.
void report_probe_parameters()
Prints current probe parameters. Upon a probe command, these parameters are updated upon a...
uint8_t probe_succeeded
Tracks if last probing cycle was successful.
#define EXEC_CYCLE_START
bitmask 00000010
system_t sys
Declare system global variable structure.
#define GC_PARSER_PROBE_IS_AWAY
int32_t sys_position[N_AXIS]
NOTE: These position variables may need to be declared as volatiles, if problems arise.
void st_go_idle()
Stepper shutdown.
void protocol_exec_rt_system()
Executes run-time commands, when required. This function primarily operates as Grbl's state...
#define bit_isfalse(x, mask)
uint8_t step_control
Governs the step segment generator depending on system state.
void st_prep_buffer()
Prepares step segment buffer. Continuously called from main program.
void st_wake_up()
BLOCK VELOCITY PROFILE DEFINITION.
#define HOMING_CYCLE_0
Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode...
#define EXEC_ALARM_HARD_LIMIT
Alarm executor codes. Valid values (1-255). Zero is reserved.
volatile uint8_t sys_rt_exec_state
Global realtime executor bitflag variable for state management. See EXEC bitmasks.
#define PL_COND_FLAG_INVERSE_TIME
Interprets feed rate value as inverse time when set.
memcpy(block_coord_system, gc_state.coord_system, sizeof(gc_state.coord_system))
void mc_arc(float *target, plan_line_data_t *pl_data, float *position, float *offset, float radius, uint8_t axis_0, uint8_t axis_1, uint8_t axis_linear, uint8_t is_clockwise_arc)
Execute an arc in offset mode format. position == current xyz, target == target xyz,.
#define bit_false(x, mask)
#define GC_PROBE_FAIL_INIT
#define STEP_CONTROL_END_MOTION
#define GC_PROBE_CHECK_MODE
#define STATE_JOG
Jogging mode.
#define STATE_HOMING
Performing homing cycle.
int32_t sys_probe_position[N_AXIS]
Last probe position in machine coordinates and steps.
void protocol_execute_realtime()
This function is the general interface to Grbl's real-time command execution system. It is called.
float feed_rate
Desired feed rate for line motion. Value is ignored, if rapid motion.
void system_set_exec_alarm(uint8_t code)
uint8_t condition
Bitflag variable to indicate planner conditions. See defines above.
uint8_t plan_check_full_buffer()
Returns the availability status of the block ring buffer. True, if full.
void mc_reset()
Method to ready the system to reset by setting the realtime reset command and killing any...
#define STEP_CONTROL_EXECUTE_SYS_MOTION
plan_line_data_t * pl_data
void st_reset()
Reset and clear stepper subsystem variables.
void coolant_stop()
Directly called by coolant_init(), coolant_set_state(), and mc_reset(), which can be at...
uint8_t limits_get_state()
Returns limit state as a bit-wise uint8 variable. Each bit indicates an axis limit, where.
#define GC_PROBE_FOUND
Define probe cycle exit states and assign proper position updating.
#define STATE_IDLE
Define system state bit map. The state variable primarily tracks the individual functions.
#define bit_istrue(x, mask)