Minor updates to code and commenting.
This commit is contained in:
parent
49f703bb2c
commit
08baabc63c
14
gcode.c
14
gcode.c
@ -77,8 +77,9 @@ static float to_millimeters(float value)
|
||||
|
||||
// Executes one line of 0-terminated G-Code. The line is assumed to contain only uppercase
|
||||
// characters and signed floating point values (no whitespace). Comments and block delete
|
||||
// characters have been removed. All units and positions are converted and exported to grbl's
|
||||
// internal functions in terms of (mm, mm/min) and absolute machine coordinates, respectively.
|
||||
// characters have been removed. In this function, all units and positions are converted and
|
||||
// exported to grbl's internal functions in terms of (mm, mm/min) and absolute machine
|
||||
// coordinates, respectively.
|
||||
uint8_t gc_execute_line(char *line)
|
||||
{
|
||||
|
||||
@ -203,7 +204,10 @@ uint8_t gc_execute_line(char *line)
|
||||
|
||||
/* Pass 2: Parameters. All units converted according to current block commands. Position
|
||||
parameters are converted and flagged to indicate a change. These can have multiple connotations
|
||||
for different commands. Each will be converted to their proper value upon execution. */
|
||||
for different commands. Each will be converted to their proper value upon execution.
|
||||
NOTE: Grbl unconventionally pre-converts these parameter values based on the block G and M
|
||||
commands. This is set out of the order of execution defined by NIST only for code efficiency/size
|
||||
purposes, but should not affect proper g-code execution. */
|
||||
float p = 0, r = 0;
|
||||
uint8_t l = 0;
|
||||
char_counter = 0;
|
||||
@ -242,9 +246,7 @@ uint8_t gc_execute_line(char *line)
|
||||
if (gc.status_code) { return(gc.status_code); }
|
||||
|
||||
|
||||
/* Execute Commands: Perform by order of execution defined in NIST RS274-NGC.v3, Table 8, pg.41.
|
||||
NOTE: Independent non-motion/settings parameters are set out of this order for code efficiency
|
||||
and simplicity purposes, but this should not affect proper g-code execution. */
|
||||
/* Execute Commands: Perform by order of execution defined in NIST RS274-NGC.v3, Table 8, pg.41. */
|
||||
|
||||
// ([F]: Set feed rate.)
|
||||
|
||||
|
18
limits.c
18
limits.c
@ -96,22 +96,16 @@ static void homing_cycle(uint8_t cycle_mask, int8_t pos_dir, bool invert_pin, fl
|
||||
// and speedy homing routine.
|
||||
// NOTE: For each axes enabled, the following calculations assume they physically move
|
||||
// an equal distance over each time step until they hit a limit switch, aka dogleg.
|
||||
uint32_t steps[N_AXIS];
|
||||
uint8_t dist = 0;
|
||||
uint32_t step_event_count, steps[N_AXIS];
|
||||
uint8_t i, dist = 0;
|
||||
clear_vector(steps);
|
||||
if (cycle_mask & (1<<X_AXIS)) {
|
||||
for (i=0; i<N_AXIS; i++) {
|
||||
if (cycle_mask & (1<<i)) {
|
||||
dist++;
|
||||
steps[X_AXIS] = lround(settings.steps_per_mm[X_AXIS]);
|
||||
steps[i] = lround(settings.steps_per_mm[i]);
|
||||
}
|
||||
if (cycle_mask & (1<<Y_AXIS)) {
|
||||
dist++;
|
||||
steps[Y_AXIS] = lround(settings.steps_per_mm[Y_AXIS]);
|
||||
}
|
||||
if (cycle_mask & (1<<Z_AXIS)) {
|
||||
dist++;
|
||||
steps[Z_AXIS] = lround(settings.steps_per_mm[Z_AXIS]);
|
||||
}
|
||||
uint32_t step_event_count = max(steps[X_AXIS], max(steps[Y_AXIS], steps[Z_AXIS]));
|
||||
step_event_count = max(steps[X_AXIS], max(steps[Y_AXIS], steps[Z_AXIS]));
|
||||
|
||||
// To ensure global acceleration is not exceeded, reduce the governing axes nominal rate
|
||||
// by adjusting the actual axes distance traveled per step. This is the same procedure
|
||||
|
@ -58,6 +58,10 @@ void mc_line(float *target, float feed_rate, uint8_t invert_feed_rate)
|
||||
// backlash steps will need to be also tracked. Not sure what the best strategy is for this,
|
||||
// i.e. keep the planner independent and do the computations in the status reporting, or let
|
||||
// the planner handle the position corrections. The latter may get complicated.
|
||||
// TODO: Backlash comp positioning values may need to be kept at a system level, i.e. tracking
|
||||
// true position after a feed hold in the middle of a backlash move. The difficulty is in making
|
||||
// sure that the stepper subsystem and planner are working in sync, and the status report
|
||||
// position also takes this into account.
|
||||
|
||||
// If the buffer is full: good! That means we are well ahead of the robot.
|
||||
// Remain in this loop until there is room in the buffer.
|
||||
@ -229,8 +233,11 @@ void mc_go_home()
|
||||
float pulloff_target[N_AXIS];
|
||||
clear_vector_float(pulloff_target); // Zero pulloff target.
|
||||
clear_vector_long(sys.position); // Zero current position for now.
|
||||
uint8_t dir_mask[N_AXIS];
|
||||
dir_mask[X_AXIS] = (1<<X_DIRECTION_BIT);
|
||||
dir_mask[Y_AXIS] = (1<<Y_DIRECTION_BIT);
|
||||
dir_mask[Z_AXIS] = (1<<Z_DIRECTION_BIT);
|
||||
uint8_t i;
|
||||
uint8_t dir_mask[N_AXIS] = { bit(X_DIRECTION_BIT),bit(Y_DIRECTION_BIT),bit(Z_DIRECTION_BIT) };
|
||||
for (i=0; i<N_AXIS; i++) {
|
||||
// Set up pull off targets and machine positions for limit switches homed in the negative
|
||||
// direction, rather than the traditional positive. Leave non-homed positions as zero and
|
||||
@ -266,8 +273,8 @@ void mc_go_home()
|
||||
// operation of cycle start is manually issuing a cycle start command whenever the user is
|
||||
// ready and there is a valid motion command in the planner queue.
|
||||
// NOTE: This function is called from the main loop and mc_line() only and executes when one of
|
||||
// two conditions exist respectively: There are no more blocks sent (i.e. streaming is finished),
|
||||
// or the planner buffer is full and ready to go.
|
||||
// two conditions exist respectively: There are no more blocks sent (i.e. streaming is finished,
|
||||
// single commands), or the planner buffer is full and ready to go.
|
||||
void mc_auto_cycle_start() { if (sys.auto_start) { st_cycle_start(); } }
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
stepper.c - stepper motor driver: executes motion plans using stepper motors
|
||||
Part of Grbl
|
||||
|
||||
Copyright (c) 2011-2012 Sungeun K. Jeon
|
||||
Copyright (c) 2011-2013 Sungeun K. Jeon
|
||||
Copyright (c) 2009-2011 Simen Svale Skogsrud
|
||||
|
||||
Grbl is free software: you can redistribute it and/or modify
|
||||
@ -107,6 +107,7 @@ void st_go_idle()
|
||||
// Disable stepper driver interrupt. Allow Timer0 to finish. It will disable itself.
|
||||
TIMSK2 &= ~(1<<OCIE2A); // Disable Timer2 interrupt
|
||||
TCCR2B = 0; // Disable Timer2
|
||||
busy = false;
|
||||
|
||||
// Disable steppers only upon system alarm activated or by user setting to not be kept enabled.
|
||||
if ((settings.stepper_idle_lock_time != 0xff) || bit_istrue(sys.execute,EXEC_ALARM)) {
|
||||
@ -193,7 +194,6 @@ ISR(TIMER2_COMPA_vect)
|
||||
} else {
|
||||
st_go_idle();
|
||||
bit_true(sys.execute,EXEC_CYCLE_STOP); // Flag main program for cycle end
|
||||
busy = false;
|
||||
return; // Nothing to do but exit.
|
||||
}
|
||||
}
|
||||
@ -237,7 +237,6 @@ ISR(TIMER2_COMPA_vect)
|
||||
if (st.delta_d <= current_block->rate_delta) {
|
||||
st_go_idle();
|
||||
bit_true(sys.execute,EXEC_CYCLE_STOP);
|
||||
busy = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user