2011-01-14 16:45:18 +01:00
|
|
|
/*
|
2011-02-11 00:34:53 +01:00
|
|
|
planner.c - buffers movement commands and manages the acceleration profile plan
|
2015-02-16 01:36:08 +01:00
|
|
|
Part of Grbl
|
2011-01-14 16:45:18 +01:00
|
|
|
|
2015-02-16 01:36:08 +01:00
|
|
|
Copyright (c) 2011-2015 Sungeun K. Jeon
|
|
|
|
Copyright (c) 2009-2011 Simen Svale Skogsrud
|
|
|
|
Copyright (c) 2011 Jens Geisler
|
2011-09-03 23:31:48 +02:00
|
|
|
|
2011-01-14 16:45:18 +01:00
|
|
|
Grbl is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Grbl is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2011-02-11 01:31:44 +01:00
|
|
|
|
2015-02-10 16:25:09 +01:00
|
|
|
#include "grbl.h"
|
2011-01-14 16:45:18 +01:00
|
|
|
|
2012-12-21 16:51:36 +01:00
|
|
|
#define SOME_LARGE_VALUE 1.0E+38 // Used by rapids and acceleration maximization calculations. Just needs
|
2013-01-06 20:04:02 +01:00
|
|
|
// to be larger than any feasible (mm/min)^2 or mm/sec^2 value.
|
2012-12-17 00:23:24 +01:00
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
static plan_block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instructions
|
2013-12-07 16:40:25 +01:00
|
|
|
static uint8_t block_buffer_tail; // Index of the block to process now
|
|
|
|
static uint8_t block_buffer_head; // Index of the next block to be pushed
|
|
|
|
static uint8_t next_buffer_head; // Index of the next buffer head
|
|
|
|
static uint8_t block_buffer_planned; // Index of the optimally planned block
|
2011-01-25 23:33:19 +01:00
|
|
|
|
2012-01-10 16:34:48 +01:00
|
|
|
// Define planner variables
|
|
|
|
typedef struct {
|
2012-12-12 01:42:29 +01:00
|
|
|
int32_t position[N_AXIS]; // The planner position of the tool in absolute steps. Kept separate
|
|
|
|
// from g-code position for movements requiring multiple line motions,
|
|
|
|
// i.e. arcs, canned cycles, and backlash compensation.
|
|
|
|
float previous_unit_vec[N_AXIS]; // Unit vector of previous path line segment
|
|
|
|
float previous_nominal_speed_sqr; // Nominal speed of previous path line segment
|
2012-01-10 16:34:48 +01:00
|
|
|
} planner_t;
|
|
|
|
static planner_t pl;
|
2011-09-03 23:31:48 +02:00
|
|
|
|
2012-12-17 00:23:24 +01:00
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
// Returns the index of the next block in the ring buffer. Also called by stepper segment buffer.
|
|
|
|
uint8_t plan_next_block_index(uint8_t block_index)
|
2011-12-09 02:47:48 +01:00
|
|
|
{
|
2011-09-14 05:57:16 +02:00
|
|
|
block_index++;
|
|
|
|
if (block_index == BLOCK_BUFFER_SIZE) { block_index = 0; }
|
|
|
|
return(block_index);
|
2011-09-03 23:31:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Returns the index of the previous block in the ring buffer
|
2013-10-30 02:10:39 +01:00
|
|
|
static uint8_t plan_prev_block_index(uint8_t block_index)
|
2011-12-09 02:47:48 +01:00
|
|
|
{
|
2011-09-18 13:36:55 +02:00
|
|
|
if (block_index == 0) { block_index = BLOCK_BUFFER_SIZE; }
|
|
|
|
block_index--;
|
2011-09-03 23:31:48 +02:00
|
|
|
return(block_index);
|
|
|
|
}
|
2013-02-22 16:36:27 +01:00
|
|
|
|
2011-08-16 03:37:22 +02:00
|
|
|
|
2011-09-07 03:39:14 +02:00
|
|
|
/* PLANNER SPEED DEFINITION
|
|
|
|
+--------+ <- current->nominal_speed
|
|
|
|
/ \
|
|
|
|
current->entry_speed -> + \
|
2013-10-30 02:10:39 +01:00
|
|
|
| + <- next->entry_speed (aka exit speed)
|
2011-09-07 03:39:14 +02:00
|
|
|
+-------------+
|
2012-12-08 23:00:58 +01:00
|
|
|
time -->
|
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
Recalculates the motion plan according to the following basic guidelines:
|
2011-09-14 05:57:16 +02:00
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
1. Go over every feasible block sequentially in reverse order and calculate the junction speeds
|
|
|
|
(i.e. current->entry_speed) such that:
|
|
|
|
a. No junction speed exceeds the pre-computed maximum junction speed limit or nominal speeds of
|
|
|
|
neighboring blocks.
|
|
|
|
b. A block entry speed cannot exceed one reverse-computed from its exit speed (next->entry_speed)
|
|
|
|
with a maximum allowable deceleration over the block travel distance.
|
|
|
|
c. The last (or newest appended) block is planned from a complete stop (an exit speed of zero).
|
2012-12-08 23:00:58 +01:00
|
|
|
2. Go over every block in chronological (forward) order and dial down junction speed values if
|
2013-10-30 02:10:39 +01:00
|
|
|
a. The exit speed exceeds the one forward-computed from its entry speed with the maximum allowable
|
|
|
|
acceleration over the block travel distance.
|
2012-12-08 23:00:58 +01:00
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
When these stages are complete, the planner will have maximized the velocity profiles throughout the all
|
|
|
|
of the planner blocks, where every block is operating at its maximum allowable acceleration limits. In
|
|
|
|
other words, for all of the blocks in the planner, the plan is optimal and no further speed improvements
|
|
|
|
are possible. If a new block is added to the buffer, the plan is recomputed according to the said
|
|
|
|
guidelines for a new optimal plan.
|
2012-12-08 23:00:58 +01:00
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
To increase computational efficiency of these guidelines, a set of planner block pointers have been
|
|
|
|
created to indicate stop-compute points for when the planner guidelines cannot logically make any further
|
|
|
|
changes or improvements to the plan when in normal operation and new blocks are streamed and added to the
|
|
|
|
planner buffer. For example, if a subset of sequential blocks in the planner have been planned and are
|
|
|
|
bracketed by junction velocities at their maximums (or by the first planner block as well), no new block
|
|
|
|
added to the planner buffer will alter the velocity profiles within them. So we no longer have to compute
|
|
|
|
them. Or, if a set of sequential blocks from the first block in the planner (or a optimal stop-compute
|
|
|
|
point) are all accelerating, they are all optimal and can not be altered by a new block added to the
|
|
|
|
planner buffer, as this will only further increase the plan speed to chronological blocks until a maximum
|
|
|
|
junction velocity is reached. However, if the operational conditions of the plan changes from infrequently
|
|
|
|
used feed holds or feedrate overrides, the stop-compute pointers will be reset and the entire plan is
|
|
|
|
recomputed as stated in the general guidelines.
|
2012-12-08 23:00:58 +01:00
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
Planner buffer index mapping:
|
|
|
|
- block_buffer_tail: Points to the beginning of the planner buffer. First to be executed or being executed.
|
|
|
|
- block_buffer_head: Points to the buffer block after the last block in the buffer. Used to indicate whether
|
|
|
|
the buffer is full or empty. As described for standard ring buffers, this block is always empty.
|
|
|
|
- next_buffer_head: Points to next planner buffer block after the buffer head block. When equal to the
|
|
|
|
buffer tail, this indicates the buffer is full.
|
|
|
|
- block_buffer_planned: Points to the first buffer block after the last optimally planned block for normal
|
|
|
|
streaming operating conditions. Use for planning optimizations by avoiding recomputing parts of the
|
2013-11-23 01:35:58 +01:00
|
|
|
planner buffer that don't change with the addition of a new block, as describe above. In addition,
|
|
|
|
this block can never be less than block_buffer_tail and will always be pushed forward and maintain
|
|
|
|
this requirement when encountered by the plan_discard_current_block() routine during a cycle.
|
2012-12-17 00:23:24 +01:00
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
NOTE: Since the planner only computes on what's in the planner buffer, some motions with lots of short
|
|
|
|
line segments, like G2/3 arcs or complex curves, may seem to move slow. This is because there simply isn't
|
|
|
|
enough combined distance traveled in the entire buffer to accelerate up to the nominal speed and then
|
|
|
|
decelerate to a complete stop at the end of the buffer, as stated by the guidelines. If this happens and
|
|
|
|
becomes an annoyance, there are a few simple solutions: (1) Maximize the machine acceleration. The planner
|
|
|
|
will be able to compute higher velocity profiles within the same combined distance. (2) Maximize line
|
2013-12-07 16:40:25 +01:00
|
|
|
motion(s) distance per block to a desired tolerance. The more combined distance the planner has to use,
|
2013-10-30 02:10:39 +01:00
|
|
|
the faster it can go. (3) Maximize the planner buffer size. This also will increase the combined distance
|
|
|
|
for the planner to compute over. It also increases the number of computations the planner has to perform
|
|
|
|
to compute an optimal plan, so select carefully. The Arduino 328p memory is already maxed out, but future
|
|
|
|
ARM versions should have enough memory and speed for look-ahead blocks numbering up to a hundred or more.
|
|
|
|
|
2012-12-08 23:00:58 +01:00
|
|
|
*/
|
2013-10-30 02:10:39 +01:00
|
|
|
static void planner_recalculate()
|
|
|
|
{
|
|
|
|
// Initialize block index to the last block in the planner buffer.
|
|
|
|
uint8_t block_index = plan_prev_block_index(block_buffer_head);
|
2013-11-23 01:35:58 +01:00
|
|
|
|
|
|
|
// Bail. Can't do anything with one only one plan-able block.
|
|
|
|
if (block_index == block_buffer_planned) { return; }
|
2013-10-30 02:10:39 +01:00
|
|
|
|
2013-11-23 01:35:58 +01:00
|
|
|
// Reverse Pass: Coarsely maximize all possible deceleration curves back-planning from the last
|
|
|
|
// block in buffer. Cease planning when the last optimal planned or tail pointer is reached.
|
|
|
|
// NOTE: Forward pass will later refine and correct the reverse pass to create an optimal plan.
|
|
|
|
float entry_speed_sqr;
|
|
|
|
plan_block_t *next;
|
|
|
|
plan_block_t *current = &block_buffer[block_index];
|
|
|
|
|
|
|
|
// Calculate maximum entry speed for last block in buffer, where the exit speed is always zero.
|
|
|
|
current->entry_speed_sqr = min( current->max_entry_speed_sqr, 2*current->acceleration*current->millimeters);
|
|
|
|
|
|
|
|
block_index = plan_prev_block_index(block_index);
|
|
|
|
if (block_index == block_buffer_planned) { // Only two plannable blocks in buffer. Reverse pass complete.
|
|
|
|
// Check if the first block is the tail. If so, notify stepper to update its current parameters.
|
|
|
|
if (block_index == block_buffer_tail) { st_update_plan_block_parameters(); }
|
|
|
|
} else { // Three or more plan-able blocks
|
|
|
|
while (block_index != block_buffer_planned) {
|
|
|
|
next = current;
|
|
|
|
current = &block_buffer[block_index];
|
|
|
|
block_index = plan_prev_block_index(block_index);
|
|
|
|
|
|
|
|
// Check if next block is the tail block(=planned block). If so, update current stepper parameters.
|
|
|
|
if (block_index == block_buffer_tail) { st_update_plan_block_parameters(); }
|
|
|
|
|
|
|
|
// Compute maximum entry speed decelerating over the current block from its exit speed.
|
|
|
|
if (current->entry_speed_sqr != current->max_entry_speed_sqr) {
|
|
|
|
entry_speed_sqr = next->entry_speed_sqr + 2*current->acceleration*current->millimeters;
|
|
|
|
if (entry_speed_sqr < current->max_entry_speed_sqr) {
|
|
|
|
current->entry_speed_sqr = entry_speed_sqr;
|
|
|
|
} else {
|
|
|
|
current->entry_speed_sqr = current->max_entry_speed_sqr;
|
2013-10-30 02:10:39 +01:00
|
|
|
}
|
2012-12-11 03:17:22 +01:00
|
|
|
}
|
2013-11-23 01:35:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Forward Pass: Forward plan the acceleration curve from the planned pointer onward.
|
|
|
|
// Also scans for optimal plan breakpoints and appropriately updates the planned pointer.
|
|
|
|
next = &block_buffer[block_buffer_planned]; // Begin at buffer planned pointer
|
|
|
|
block_index = plan_next_block_index(block_buffer_planned);
|
|
|
|
while (block_index != block_buffer_head) {
|
|
|
|
current = next;
|
|
|
|
next = &block_buffer[block_index];
|
|
|
|
|
|
|
|
// Any acceleration detected in the forward pass automatically moves the optimal planned
|
|
|
|
// pointer forward, since everything before this is all optimal. In other words, nothing
|
|
|
|
// can improve the plan from the buffer tail to the planned pointer by logic.
|
|
|
|
if (current->entry_speed_sqr < next->entry_speed_sqr) {
|
|
|
|
entry_speed_sqr = current->entry_speed_sqr + 2*current->acceleration*current->millimeters;
|
|
|
|
// If true, current block is full-acceleration and we can move the planned pointer forward.
|
|
|
|
if (entry_speed_sqr < next->entry_speed_sqr) {
|
|
|
|
next->entry_speed_sqr = entry_speed_sqr; // Always <= max_entry_speed_sqr. Backward pass sets this.
|
|
|
|
block_buffer_planned = block_index; // Set optimal plan pointer.
|
2013-02-20 14:56:47 +01:00
|
|
|
}
|
|
|
|
}
|
2013-10-30 02:10:39 +01:00
|
|
|
|
2013-11-23 01:35:58 +01:00
|
|
|
// Any block set at its maximum entry speed also creates an optimal plan up to this
|
|
|
|
// point in the buffer. When the plan is bracketed by either the beginning of the
|
|
|
|
// buffer and a maximum entry speed or two maximum entry speeds, every block in between
|
|
|
|
// cannot logically be further improved. Hence, we don't have to recompute them anymore.
|
|
|
|
if (next->entry_speed_sqr == next->max_entry_speed_sqr) { block_buffer_planned = block_index; }
|
|
|
|
block_index = plan_next_block_index( block_index );
|
|
|
|
}
|
2013-10-30 02:10:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-30 04:34:51 +01:00
|
|
|
void plan_reset()
|
2011-12-09 02:47:48 +01:00
|
|
|
{
|
2016-03-04 21:39:29 +01:00
|
|
|
memset(&pl, 0, sizeof(planner_t)); // Clear planner struct
|
2013-10-30 02:10:39 +01:00
|
|
|
block_buffer_tail = 0;
|
|
|
|
block_buffer_head = 0; // Empty = tail
|
|
|
|
next_buffer_head = 1; // plan_next_block_index(block_buffer_head)
|
2013-11-23 01:35:58 +01:00
|
|
|
block_buffer_planned = 0; // = block_buffer_tail;
|
2011-12-09 02:47:48 +01:00
|
|
|
}
|
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
|
|
|
|
void plan_discard_current_block()
|
2011-12-09 02:47:48 +01:00
|
|
|
{
|
2013-10-30 02:10:39 +01:00
|
|
|
if (block_buffer_head != block_buffer_tail) { // Discard non-empty buffer.
|
2013-11-23 01:35:58 +01:00
|
|
|
uint8_t block_index = plan_next_block_index( block_buffer_tail );
|
|
|
|
// Push block_buffer_planned pointer, if encountered.
|
|
|
|
if (block_buffer_tail == block_buffer_planned) { block_buffer_planned = block_index; }
|
|
|
|
block_buffer_tail = block_index;
|
2011-02-06 23:52:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
plan_block_t *plan_get_parking_block()
|
|
|
|
{
|
|
|
|
return(&block_buffer[block_buffer_head]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
plan_block_t *plan_get_current_block()
|
2011-12-09 02:47:48 +01:00
|
|
|
{
|
2013-11-23 01:35:58 +01:00
|
|
|
if (block_buffer_head == block_buffer_tail) { return(NULL); } // Buffer empty
|
2011-02-06 23:52:12 +01:00
|
|
|
return(&block_buffer[block_buffer_tail]);
|
|
|
|
}
|
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
|
2013-11-23 01:35:58 +01:00
|
|
|
float plan_get_exec_block_exit_speed()
|
2013-10-30 02:10:39 +01:00
|
|
|
{
|
2013-11-23 01:35:58 +01:00
|
|
|
uint8_t block_index = plan_next_block_index(block_buffer_tail);
|
|
|
|
if (block_index == block_buffer_head) { return( 0.0 ); }
|
|
|
|
return( sqrt( block_buffer[block_index].entry_speed_sqr ) );
|
2013-10-30 02:10:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-09 02:47:48 +01:00
|
|
|
// Returns the availability status of the block ring buffer. True, if full.
|
|
|
|
uint8_t plan_check_full_buffer()
|
|
|
|
{
|
2013-10-30 02:10:39 +01:00
|
|
|
if (block_buffer_tail == next_buffer_head) { return(true); }
|
2011-12-09 02:47:48 +01:00
|
|
|
return(false);
|
|
|
|
}
|
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
|
|
|
|
/* Add a new linear movement to the buffer. target[N_AXIS] is the signed, absolute target position
|
|
|
|
in millimeters. Feed rate specifies the speed of the motion. If feed rate is inverted, the feed
|
|
|
|
rate is taken to mean "frequency" and would complete the operation in 1/feed_rate minutes.
|
|
|
|
All position data passed to the planner must be in terms of machine position to keep the planner
|
|
|
|
independent of any coordinate system changes and offsets, which are handled by the g-code parser.
|
|
|
|
NOTE: Assumes buffer is available. Buffer checks are handled at a higher level by motion_control.
|
|
|
|
In other words, the buffer head is never equal to the buffer tail. Also the feed rate input value
|
|
|
|
is used in three ways: as a normal feed rate if invert_feed_rate is false, as inverse time if
|
|
|
|
invert_feed_rate is true, or as seek/rapids rate if the feed_rate value is negative (and
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
invert_feed_rate always false).
|
|
|
|
The is_parking_motion boolean tells the planner to plan a motion in the always unused block buffer
|
|
|
|
head. It avoids changing the planner state and preserves the buffer to ensure subsequent gcode
|
|
|
|
motions are still planned correctly, while the stepper module only points to the block buffer head
|
|
|
|
to execute the parking motion. */
|
2014-02-26 20:10:07 +01:00
|
|
|
#ifdef USE_LINE_NUMBERS
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
uint8_t plan_buffer_line(float *target, float feed_rate, uint8_t invert_feed_rate, uint8_t is_parking_motion, int32_t line_number)
|
2014-02-26 20:10:07 +01:00
|
|
|
#else
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
uint8_t plan_buffer_line(float *target, float feed_rate, uint8_t invert_feed_rate, uint8_t is_parking_motion)
|
2014-02-26 20:10:07 +01:00
|
|
|
#endif
|
2011-12-09 02:47:48 +01:00
|
|
|
{
|
2013-10-30 02:10:39 +01:00
|
|
|
// Prepare and initialize new block
|
|
|
|
plan_block_t *block = &block_buffer[block_buffer_head];
|
|
|
|
block->step_event_count = 0;
|
|
|
|
block->millimeters = 0;
|
|
|
|
block->direction_bits = 0;
|
|
|
|
block->acceleration = SOME_LARGE_VALUE; // Scaled down to maximum acceleration later
|
2014-02-19 15:48:09 +01:00
|
|
|
#ifdef USE_LINE_NUMBERS
|
|
|
|
block->line_number = line_number;
|
|
|
|
#endif
|
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
// Compute and store initial move distance data.
|
|
|
|
// TODO: After this for-loop, we don't touch the stepper algorithm data. Might be a good idea
|
|
|
|
// to try to keep these types of things completely separate from the planner for portability.
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
int32_t target_steps[N_AXIS], position_steps[N_AXIS];
|
2013-10-30 02:10:39 +01:00
|
|
|
float unit_vec[N_AXIS], delta_mm;
|
|
|
|
uint8_t idx;
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
|
|
|
|
// Copy position data based on type of motion being planned.
|
|
|
|
if (is_parking_motion) { memcpy(position_steps, sys.position, sizeof(sys.position)); }
|
|
|
|
else { memcpy(position_steps, pl.position, sizeof(pl.position)); }
|
|
|
|
|
2015-01-15 06:14:52 +01:00
|
|
|
#ifdef COREXY
|
|
|
|
target_steps[A_MOTOR] = lround(target[A_MOTOR]*settings.steps_per_mm[A_MOTOR]);
|
|
|
|
target_steps[B_MOTOR] = lround(target[B_MOTOR]*settings.steps_per_mm[B_MOTOR]);
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
block->steps[A_MOTOR] = labs((target_steps[X_AXIS]-position_steps[X_AXIS]) + (target_steps[Y_AXIS]-position_steps[Y_AXIS]));
|
|
|
|
block->steps[B_MOTOR] = labs((target_steps[X_AXIS]-position_steps[X_AXIS]) - (target_steps[Y_AXIS]-position_steps[Y_AXIS]));
|
2015-01-15 06:14:52 +01:00
|
|
|
#endif
|
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
for (idx=0; idx<N_AXIS; idx++) {
|
2015-01-15 06:14:52 +01:00
|
|
|
// Calculate target position in absolute steps, number of steps for each axis, and determine max step events.
|
|
|
|
// Also, compute individual axes distance for move and prep unit vector calculations.
|
2013-10-30 02:10:39 +01:00
|
|
|
// NOTE: Computes true distance from converted step values.
|
2015-01-15 06:14:52 +01:00
|
|
|
#ifdef COREXY
|
|
|
|
if ( !(idx == A_MOTOR) && !(idx == B_MOTOR) ) {
|
|
|
|
target_steps[idx] = lround(target[idx]*settings.steps_per_mm[idx]);
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
block->steps[idx] = labs(target_steps[idx]-position_steps[idx]);
|
2015-01-15 06:14:52 +01:00
|
|
|
}
|
|
|
|
block->step_event_count = max(block->step_event_count, block->steps[idx]);
|
|
|
|
if (idx == A_MOTOR) {
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
delta_mm = ((target_steps[X_AXIS]-position_steps[X_AXIS]) + (target_steps[Y_AXIS]-position_steps[Y_AXIS]))/settings.steps_per_mm[idx];
|
2015-05-24 00:40:20 +02:00
|
|
|
} else if (idx == B_MOTOR) {
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
delta_mm = ((target_steps[X_AXIS]-position_steps[X_AXIS]) - (target_steps[Y_AXIS]-position_steps[Y_AXIS]))/settings.steps_per_mm[idx];
|
2015-01-15 06:14:52 +01:00
|
|
|
} else {
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
delta_mm = (target_steps[idx] - position_steps[idx])/settings.steps_per_mm[idx];
|
2015-01-15 06:14:52 +01:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
target_steps[idx] = lround(target[idx]*settings.steps_per_mm[idx]);
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
block->steps[idx] = labs(target_steps[idx]-position_steps[idx]);
|
2015-01-15 06:14:52 +01:00
|
|
|
block->step_event_count = max(block->step_event_count, block->steps[idx]);
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
delta_mm = (target_steps[idx] - position_steps[idx])/settings.steps_per_mm[idx];
|
|
|
|
#endif
|
2013-10-30 02:10:39 +01:00
|
|
|
unit_vec[idx] = delta_mm; // Store unit vector numerator. Denominator computed later.
|
|
|
|
|
|
|
|
// Set direction bits. Bit enabled always means direction is negative.
|
Settings refactoring. Bug fixes. Misc new features.
This is likely the last major change to the v0.9 code base before push
to master. Only two minor things remain on the agenda (CoreXY support,
force clear EEPROM, and an extremely low federate bug).
- NEW! Grbl is now compile-able and may be flashed directly through the
Arduino IDE. Only minor changes were required for this compatibility.
See the Wiki to learn how to do it.
- New status reporting mask to turn on and off what Grbl sends back.
This includes machine coordinates, work coordinates, serial RX buffer
usage, and planner buffer usage. Expandable to more information on user
request, but that’s it for now.
- Settings have been completely renumbered to allow for future new
settings to be installed without having to constantly reshuffle and
renumber all of the settings every time.
- All settings masks have been standardized to mean bit 0 = X, bit 1 =
Y, and bit 2 = Z, to reduce confusion on how they work. The invert
masks used by the internal Grbl system were updated to accommodate this
change as well.
- New invert probe pin setting, which does what it sounds like.
- Fixed a probing cycle bug, where it would freeze intermittently, and
removed some redundant code.
- Homing may now be set to the origin wherever the limit switches are.
Traditionally machine coordinates should always be in negative space,
but when limit switches on are on the opposite side, the machine
coordinate would be set to -max_travel for the axis. Now you can always
make it [0,0,0] via a compile-time option in config.h. (Soft limits
routine was updated to account for this as well.)
- Probe coordinate message immediately after a probing cycle may now
be turned off via a compile-time option in config.h. By default the
probing location is always reported.
- Reduced the N_ARC_CORRECTION default value to reflect the changes in
how circles are generated by an arc tolerance, rather than a fixed arc
segment setting.
- Increased the incoming line buffer limit from 70 to 80 characters.
Had some extra memory space to invest into this.
- Fixed a bug where tool number T was not being tracked and reported
correctly.
- Added a print free memory function for debugging purposes. Not used
otherwise.
- Realtime rate report should now work during feed holds, but it hasn’t
been tested yet.
- Updated the streaming scripts with MIT-license and added the simple
streaming to the main stream.py script to allow for settings to be sent.
- Some minor code refactoring to improve flash efficiency. Reduced the
flash by several hundred KB, which was re-invested in some of these new
features.
2014-07-26 23:01:34 +02:00
|
|
|
if (delta_mm < 0 ) { block->direction_bits |= get_direction_pin_mask(idx); }
|
2013-10-30 02:10:39 +01:00
|
|
|
|
|
|
|
// Incrementally compute total move distance by Euclidean norm. First add square of each term.
|
|
|
|
block->millimeters += delta_mm*delta_mm;
|
|
|
|
}
|
|
|
|
block->millimeters = sqrt(block->millimeters); // Complete millimeters calculation with sqrt()
|
|
|
|
|
|
|
|
// Bail if this is a zero-length block. Highly unlikely to occur.
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
if (block->step_event_count == 0) { return(PLAN_EMPTY_BLOCK); }
|
2011-02-06 23:23:34 +01:00
|
|
|
|
2012-12-17 00:23:24 +01:00
|
|
|
// Adjust feed_rate value to mm/min depending on type of rate input (normal, inverse time, or rapids)
|
|
|
|
// TODO: Need to distinguish a rapids vs feed move for overrides. Some flag of some sort.
|
|
|
|
if (feed_rate < 0) { feed_rate = SOME_LARGE_VALUE; } // Scaled down to absolute max/rapids rate later
|
2015-03-28 01:13:18 +01:00
|
|
|
else if (invert_feed_rate) { feed_rate *= block->millimeters; }
|
2014-08-06 00:17:45 +02:00
|
|
|
if (feed_rate < MINIMUM_FEED_RATE) { feed_rate = MINIMUM_FEED_RATE; } // Prevents step generation round-off condition.
|
2012-12-11 02:50:18 +01:00
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
// Calculate the unit vector of the line move and the block maximum feed rate and acceleration scaled
|
|
|
|
// down such that no individual axes maximum values are exceeded with respect to the line direction.
|
2012-12-14 16:27:02 +01:00
|
|
|
// NOTE: This calculation assumes all axes are orthogonal (Cartesian) and works with ABC-axes,
|
|
|
|
// if they are also orthogonal/independent. Operates on the absolute value of the unit vector.
|
2013-10-30 02:10:39 +01:00
|
|
|
float inverse_unit_vec_value;
|
2012-12-17 00:23:24 +01:00
|
|
|
float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple float divides
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
float junction_cos_theta = 0.0;
|
2013-10-30 02:10:39 +01:00
|
|
|
for (idx=0; idx<N_AXIS; idx++) {
|
|
|
|
if (unit_vec[idx] != 0) { // Avoid divide by zero.
|
|
|
|
unit_vec[idx] *= inverse_millimeters; // Complete unit vector calculation
|
2013-12-11 06:33:06 +01:00
|
|
|
inverse_unit_vec_value = fabs(1.0/unit_vec[idx]); // Inverse to remove multiple float divides.
|
2013-10-30 02:10:39 +01:00
|
|
|
|
|
|
|
// Check and limit feed rate against max individual axis velocities and accelerations
|
2013-12-07 16:40:25 +01:00
|
|
|
feed_rate = min(feed_rate,settings.max_rate[idx]*inverse_unit_vec_value);
|
2013-10-30 02:10:39 +01:00
|
|
|
block->acceleration = min(block->acceleration,settings.acceleration[idx]*inverse_unit_vec_value);
|
|
|
|
|
|
|
|
// Incrementally compute cosine of angle between previous and current path. Cos(theta) of the junction
|
|
|
|
// between the current move and the previous move is simply the dot product of the two unit vectors,
|
|
|
|
// where prev_unit_vec is negative. Used later to compute maximum junction speed.
|
|
|
|
junction_cos_theta -= pl.previous_unit_vec[idx] * unit_vec[idx];
|
2012-12-17 00:23:24 +01:00
|
|
|
}
|
2012-12-11 02:50:18 +01:00
|
|
|
}
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
// TODO: Need to check this method handling zero junction speeds when starting from rest.
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
if ((block_buffer_head == block_buffer_tail) || is_parking_motion) {
|
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
// Initialize block entry speed as zero. Assume it will be starting from rest. Planner will correct this later.
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
// If parking motion, the parking block always is assumed to start from rest and end at a complete stop.
|
2013-10-30 02:10:39 +01:00
|
|
|
block->entry_speed_sqr = 0.0;
|
|
|
|
block->max_junction_speed_sqr = 0.0; // Starting from rest. Enforce start from zero velocity.
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
Compute maximum allowable entry speed at junction by centripetal acceleration approximation.
|
|
|
|
Let a circle be tangent to both previous and current path line segments, where the junction
|
|
|
|
deviation is defined as the distance from the junction to the closest edge of the circle,
|
|
|
|
colinear with the circle center. The circular segment joining the two paths represents the
|
|
|
|
path of centripetal acceleration. Solve for max velocity based on max acceleration about the
|
|
|
|
radius of the circle, defined indirectly by junction deviation. This may be also viewed as
|
2015-01-17 16:12:37 +01:00
|
|
|
path width or max_jerk in the previous Grbl version. This approach does not actually deviate
|
2013-10-30 02:10:39 +01:00
|
|
|
from path, but used as a robust way to compute cornering speeds, as it takes into account the
|
|
|
|
nonlinearities of both the junction angle and junction velocity.
|
|
|
|
|
|
|
|
NOTE: If the junction deviation value is finite, Grbl executes the motions in an exact path
|
|
|
|
mode (G61). If the junction deviation value is zero, Grbl will execute the motion in an exact
|
|
|
|
stop mode (G61.1) manner. In the future, if continuous mode (G64) is desired, the math here
|
|
|
|
is exactly the same. Instead of motioning all the way to junction point, the machine will
|
|
|
|
just follow the arc circle defined here. The Arduino doesn't have the CPU cycles to perform
|
|
|
|
a continuous mode path, but ARM-based microcontrollers most certainly do.
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
NOTE: The max junction speed is a fixed value, since machine acceleration limits cannot be
|
|
|
|
changed dynamically during operation nor can the line move geometry. This must be kept in
|
|
|
|
memory in the event of a feedrate override changing the nominal speeds of blocks, which can
|
|
|
|
change the overall maximum entry speed conditions of all blocks.
|
|
|
|
*/
|
|
|
|
// NOTE: Computed without any expensive trig, sin() or acos(), by trig half angle identity of cos(theta).
|
2016-03-04 21:39:29 +01:00
|
|
|
if (junction_cos_theta > 0.999999) {
|
2015-02-10 16:25:09 +01:00
|
|
|
// For a 0 degree acute junction, just set minimum junction speed.
|
|
|
|
block->max_junction_speed_sqr = MINIMUM_JUNCTION_SPEED*MINIMUM_JUNCTION_SPEED;
|
|
|
|
} else {
|
2016-03-04 21:39:29 +01:00
|
|
|
junction_cos_theta = max(junction_cos_theta,-0.999999); // Check for numerical round-off to avoid divide by zero.
|
2015-02-10 16:25:09 +01:00
|
|
|
float sin_theta_d2 = sqrt(0.5*(1.0-junction_cos_theta)); // Trig half angle identity. Always positive.
|
|
|
|
|
|
|
|
// TODO: Technically, the acceleration used in calculation needs to be limited by the minimum of the
|
|
|
|
// two junctions. However, this shouldn't be a significant problem except in extreme circumstances.
|
|
|
|
block->max_junction_speed_sqr = max( MINIMUM_JUNCTION_SPEED*MINIMUM_JUNCTION_SPEED,
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
(block->acceleration * settings.junction_deviation * sin_theta_d2)/(1.0-sin_theta_d2) );
|
2013-10-30 02:10:39 +01:00
|
|
|
|
2015-02-10 16:25:09 +01:00
|
|
|
}
|
2013-10-30 02:10:39 +01:00
|
|
|
}
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
// Store block nominal speed
|
|
|
|
block->nominal_speed_sqr = feed_rate*feed_rate; // (mm/min). Always > 0
|
|
|
|
|
|
|
|
// Compute the junction maximum entry based on the minimum of the junction speed and neighboring nominal speeds.
|
|
|
|
block->max_entry_speed_sqr = min(block->max_junction_speed_sqr,
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
min(block->nominal_speed_sqr,pl.previous_nominal_speed_sqr));
|
|
|
|
|
|
|
|
// Block parking motion from updating this data to ensure next g-code motion is computed correctly.
|
|
|
|
if (!is_parking_motion) {
|
|
|
|
// Update previous path unit_vector and nominal speed (squared)
|
|
|
|
memcpy(pl.previous_unit_vec, unit_vec, sizeof(unit_vec)); // pl.previous_unit_vec[] = unit_vec[]
|
|
|
|
pl.previous_nominal_speed_sqr = block->nominal_speed_sqr;
|
2013-10-30 02:10:39 +01:00
|
|
|
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
// Update planner position
|
|
|
|
memcpy(pl.position, target_steps, sizeof(target_steps)); // pl.position[] = target_steps[]
|
2013-02-20 14:56:47 +01:00
|
|
|
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
// New block is all set. Update buffer head and next buffer head indices.
|
|
|
|
block_buffer_head = next_buffer_head;
|
|
|
|
next_buffer_head = plan_next_block_index(block_buffer_head);
|
2013-10-30 02:10:39 +01:00
|
|
|
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
// Finish up by recalculating the plan with the new block.
|
|
|
|
planner_recalculate();
|
|
|
|
}
|
|
|
|
return(PLAN_OK);
|
2011-01-14 16:56:44 +01:00
|
|
|
}
|
2011-02-20 00:29:56 +01:00
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
|
2012-12-21 16:51:36 +01:00
|
|
|
// Reset the planner position vectors. Called by the system abort/initialization routine.
|
2013-10-30 02:10:39 +01:00
|
|
|
void plan_sync_position()
|
2012-01-29 04:41:08 +01:00
|
|
|
{
|
2015-01-15 06:14:52 +01:00
|
|
|
// TODO: For motor configurations not in the same coordinate frame as the machine position,
|
|
|
|
// this function needs to be updated to accomodate the difference.
|
2013-10-30 02:10:39 +01:00
|
|
|
uint8_t idx;
|
|
|
|
for (idx=0; idx<N_AXIS; idx++) {
|
2015-01-15 06:14:52 +01:00
|
|
|
#ifdef COREXY
|
v1.0 Beta Release.
- Tons of new stuff in this release, which is fairly stable and well
tested. However, much more is coming soon!
- Real-time parking motion with safety door. When this compile option
is enabled, an opened safety door will cause Grbl to automatically feed
hold, retract, de-energize the spindle/coolant, and parks near Z max.
After the door is closed and resume is commanded, this reverses and the
program continues as if nothing happened. This is also highly
configurable. See config.h for details.
- New spindle max and min rpm ‘$’ settings! This has been requested
often. Grbl will output 5V when commanded to turn on the spindle at its
max rpm, and 0.02V with min rpm. The voltage and the rpm range are
linear to each other. This should help users tweak their settings to
get close to true rpm’s.
- If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the
spindle speed PWM pin will act like a regular on/off spindle enable
pin. On pin D11.
- BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm
settings require a new settings version, so Grbl will automatically
wipe and restore the EEPROM with the new defaults.
- Control pin can now be inverted individually with a
CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users
to need this, but handy to have.
- Fixed bug when Grbl receive too many characters in a line and
overflows. Previously it would respond with an error per overflow
character and another acknowledge upon an EOL character. This broke the
streaming protocol. Now fixed to only respond with an error after an
EOL character.
- Fixed a bug with the safety door during an ALARM mode. You now can’t
home or unlock the axes until the safety door has been closed. This is
for safety reasons (obviously.)
- Tweaked some the Mega2560 cpu_map settings . Increased segment buffer
size and fixed the spindle PWM settings to output at a higher PWM
frequency.
- Generalized the delay function used by G4 delay for use by parking
motion. Allows non-blocking status reports and real-time control during
re-energizing of the spindle and coolant.
- Added spindle rpm max and min defaults to default.h files.
- Added a new print float for rpm values.
2015-08-28 05:37:19 +02:00
|
|
|
if (idx==A_MOTOR) {
|
2015-01-15 06:14:52 +01:00
|
|
|
pl.position[idx] = (sys.position[A_MOTOR] + sys.position[B_MOTOR])/2;
|
|
|
|
} else if (idx==B_MOTOR) {
|
|
|
|
pl.position[idx] = (sys.position[A_MOTOR] - sys.position[B_MOTOR])/2;
|
|
|
|
} else {
|
|
|
|
pl.position[idx] = sys.position[idx];
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
pl.position[idx] = sys.position[idx];
|
|
|
|
#endif
|
2013-10-30 02:10:39 +01:00
|
|
|
}
|
2012-01-29 04:41:08 +01:00
|
|
|
}
|
|
|
|
|
2013-10-30 02:10:39 +01:00
|
|
|
|
Settings refactoring. Bug fixes. Misc new features.
This is likely the last major change to the v0.9 code base before push
to master. Only two minor things remain on the agenda (CoreXY support,
force clear EEPROM, and an extremely low federate bug).
- NEW! Grbl is now compile-able and may be flashed directly through the
Arduino IDE. Only minor changes were required for this compatibility.
See the Wiki to learn how to do it.
- New status reporting mask to turn on and off what Grbl sends back.
This includes machine coordinates, work coordinates, serial RX buffer
usage, and planner buffer usage. Expandable to more information on user
request, but that’s it for now.
- Settings have been completely renumbered to allow for future new
settings to be installed without having to constantly reshuffle and
renumber all of the settings every time.
- All settings masks have been standardized to mean bit 0 = X, bit 1 =
Y, and bit 2 = Z, to reduce confusion on how they work. The invert
masks used by the internal Grbl system were updated to accommodate this
change as well.
- New invert probe pin setting, which does what it sounds like.
- Fixed a probing cycle bug, where it would freeze intermittently, and
removed some redundant code.
- Homing may now be set to the origin wherever the limit switches are.
Traditionally machine coordinates should always be in negative space,
but when limit switches on are on the opposite side, the machine
coordinate would be set to -max_travel for the axis. Now you can always
make it [0,0,0] via a compile-time option in config.h. (Soft limits
routine was updated to account for this as well.)
- Probe coordinate message immediately after a probing cycle may now
be turned off via a compile-time option in config.h. By default the
probing location is always reported.
- Reduced the N_ARC_CORRECTION default value to reflect the changes in
how circles are generated by an arc tolerance, rather than a fixed arc
segment setting.
- Increased the incoming line buffer limit from 70 to 80 characters.
Had some extra memory space to invest into this.
- Fixed a bug where tool number T was not being tracked and reported
correctly.
- Added a print free memory function for debugging purposes. Not used
otherwise.
- Realtime rate report should now work during feed holds, but it hasn’t
been tested yet.
- Updated the streaming scripts with MIT-license and added the simple
streaming to the main stream.py script to allow for settings to be sent.
- Some minor code refactoring to improve flash efficiency. Reduced the
flash by several hundred KB, which was re-invested in some of these new
features.
2014-07-26 23:01:34 +02:00
|
|
|
// Returns the number of active blocks are in the planner buffer.
|
|
|
|
uint8_t plan_get_block_buffer_count()
|
|
|
|
{
|
|
|
|
if (block_buffer_head >= block_buffer_tail) { return(block_buffer_head-block_buffer_tail); }
|
|
|
|
return(BLOCK_BUFFER_SIZE - (block_buffer_tail-block_buffer_head));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-09 02:47:48 +01:00
|
|
|
// Re-initialize buffer plan with a partially completed block, assumed to exist at the buffer tail.
|
|
|
|
// Called after a steppers have come to a complete stop for a feed hold and the cycle is stopped.
|
Reinstated feed holds into new stepper algorithm and planner. Rough draft, but working.
- Reinstated the feed hold feature with the new stepper algorithm and
new optimized planner. It works, but will be re-factored a bit soon to
clean up the code.
- At this point, feedrate overrides may need to be installed in the
v1.0 version of grbl, while this version will likely be pushed to the
edge branch soon and pushed to master after the bugs have been squashed.
- Measured the overall performance of the new planner and stepper
algorithm on an oscilloscope. The new planner is about 4x faster than
before, where it is completing a plan in around 1ms. The stepper
algorithm itself is minutely faster, as it is a little lighter. The
trade-off in the increased planner performance comes from the new step
segment buffer. However, even in the worse case scenario, the step
segment buffer generates a new segment with a typical 0.2 ms, and the
worse case is 1ms upon a new block or replanning the active block.
Added altogether, it’s argubly still twice as efficient as the old one.
2013-12-05 05:49:24 +01:00
|
|
|
void plan_cycle_reinitialize()
|
2011-12-09 02:47:48 +01:00
|
|
|
{
|
2013-10-30 02:10:39 +01:00
|
|
|
// Re-plan from a complete stop. Reset planner entry speeds and buffer planned pointer.
|
2013-12-07 16:40:25 +01:00
|
|
|
st_update_plan_block_parameters();
|
2013-10-30 02:10:39 +01:00
|
|
|
block_buffer_planned = block_buffer_tail;
|
2011-12-09 02:47:48 +01:00
|
|
|
planner_recalculate();
|
|
|
|
}
|