#include "grbl.h"
Go to the source code of this file.
Functions | |
void | mc_line (float *target, plan_line_data_t *pl_data) |
Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second. More... | |
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,. More... | |
void | mc_dwell (float seconds) |
Execute dwell in seconds. More... | |
void | mc_homing_cycle (uint8_t cycle_mask) |
Perform homing cycle to locate and set machine zero. Only '$H' executes this command. More... | |
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. More... | |
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. More... | |
void | mc_reset () |
Method to ready the system to reset by setting the realtime reset command and killing any. More... | |
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,.
< Radius vector from center to current location
< Correct atan2 output per direction
NOTE: Segment end points are on the arc, which can lead to the arc diameter being smaller by up to
< Force as feed absolute mode over arc segments.
Vector rotation by transformation matrix: r is the original vector, r_T is the rotated vector, and phi is the angle of rotation. Solution approach by Jens Geisler. r_T = [cos(phi) -sin(phi); sin(phi) cos(phi] * r ;
For arc generation, the center of the circle is the axis of rotation and the radius vector is defined from the circle center to the initial position. Each line segment is formed by successive vector rotations. Single precision values can accumulate error greater than tool precision in rare cases. So, exact arc path correction is implemented. This approach avoids the problem of too many very expensive trig operations [sin(),cos(),tan()] which can take 100-200 usec each to compute.
Small angle approximation may be used to reduce computation overhead further. A third-order approximation (second order sin() has too much error) holds for most, if not, all CNC applications. Note that this approximation will begin to accumulate a numerical drift error when theta_per_segment is greater than ~0.25 rad(14 deg) AND the approximation is successively used without correction several dozen times. This scenario is extremely unlikely, since segment lengths and theta_per_segment are automatically generated and scaled by the arc tolerance setting. Only a very large arc tolerance setting, unrealistic for CNC applications, would cause this numerical drift error. However, it is best to set N_ARC_CORRECTION from a low of ~4 to a high of ~20 or so to avoid trig operations while keeping arc generation accurate.
This approximation also allows mc_arc to immediately insert a line segment into the planner without the initial overhead of computing cos() or sin(). By the time the arc needs to be applied a correction, the planner should have caught up to the lag caused by the initial mc_arc overhead. This is important when there are successive arc motions.
< Increment (segments-1).
Definition at line 82 of file motion_control.c.
void mc_dwell | ( | float | seconds | ) |
Execute dwell in seconds.
Dwell for a specific number of seconds.
Definition at line 190 of file motion_control.c.
void mc_homing_cycle | ( | uint8_t | cycle_mask | ) |
Perform homing cycle to locate and set machine zero. Only '$H' executes this command.
Perform homing cycle to locate machine zero. Requires limit switches.
NOTE: There should be no motions in the buffer and Grbl must be in an idle state before
< Disable hard limits pin change register for cycle duration
NOTE: Special motion case. Only system reset works.
< Homing cycle 0
< Homing cycle 1
< Check for reset and set system abort.
Definition at line 201 of file motion_control.c.
void mc_line | ( | float * | target, |
plan_line_data_t * | pl_data | ||
) |
Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second.
NOTE: This is the primary gateway to the grbl planner. All line motions, including arc line
NOTE: Block jog state. Jogging is a special case and soft limits are handled independently.
NOTE: Backlash compensation may be installed here. It will need direction info to track when
NOTE: Perhaps as a middle-ground, all that needs to be sent is a flag or special command that
< Check for any run-time commands
Definition at line 32 of file motion_control.c.
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.
NOTE: Uses the always free planner ring buffer head to store motion parameters for execution.
< Allow parking motion to execute, if feed hold is active.
< Setup step segment buffer for special parking motion case
< Restore step segment buffer to normal run state.
Definition at line 320 of file motion_control.c.
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.
NOTE: Upon probe failure, the program will be stopped and placed into ALARM state.
< Re-initialize probe history before beginning cycle.
NOTE: This probe initialization error applies to all probing cycles.
< Check probe pin state.
< Re-initialize invert mask before returning.
< Nothing else to do but bail.
< Indicate to system the probing cycle completed successfully.
< Ensure probe state monitor is disabled.
< Re-initialize invert mask.
< Check and execute run-time commands
< Reset step segment buffer.
< Reset planner buffer. Zero planner positions. Ensure probing motion is cleared.
< Sync planner position to current machine position.
Definition at line 252 of file motion_control.c.
void mc_reset | ( | ) |
Method to ready the system to reset by setting the realtime reset command and killing any.
Performs system reset. If in motion state, kills all motion and sets system alarm.
NOTE: If steppers are kept enabled via the step idle delay setting, this also keeps
< Force kill steppers. Position has likely been lost.
Definition at line 349 of file motion_control.c.