mirror of
https://github.com/synthetos/g2.git
synced 2026-09-26 01:02:30 +08:00
Added some diagnostics and commenting. Aligned with buffer diagnostics from dev-p32
This commit is contained in:
@@ -1110,6 +1110,10 @@ stat_t cm_resume_origin_offsets()
|
||||
|
||||
stat_t cm_straight_traverse(const float target[], const bool flags[])
|
||||
{
|
||||
if (target[AXIS_Y] == 20) { // +++ DEBUG TRAP
|
||||
cm->gm.P_word = 20;
|
||||
}
|
||||
|
||||
cm->gm.motion_mode = MOTION_MODE_STRAIGHT_TRAVERSE;
|
||||
|
||||
// it's legal for a G0 to have no axis words but we don't want to process it
|
||||
@@ -1151,7 +1155,8 @@ stat_t _goto_stored_position(const float stored_position[], // always in mm
|
||||
// If G20 adjust stored position (always in mm) to inches so traverse will be correct
|
||||
float target[AXES]; // make a local stored position as it may be modified
|
||||
copy_vector(target, stored_position);
|
||||
if (cm->gm.units_mode == INCHES) {
|
||||
|
||||
if (cm->gm.units_mode == INCHES) {
|
||||
for (uint8_t i=0; i<AXES; i++) {
|
||||
target[i] *= INCHES_PER_MM;
|
||||
}
|
||||
|
||||
+17
-12
@@ -182,7 +182,7 @@ void cm_start_hold()
|
||||
/***********************************************************************************
|
||||
* cm_feedhold_sequencing_callback() - sequence feedhold, queue_flush, and end_hold requests
|
||||
*
|
||||
* Expected behaviors: (no-hold means machine is not in hold, etc)
|
||||
* Expected behaviors: (no-hold means machine is not in hold, etc)
|
||||
*
|
||||
* (no-cycle) ! No action. Feedhold is not run (nothing to hold!)
|
||||
* (no-hold) ~ No action. Cannot exit a feedhold that does not exist
|
||||
@@ -196,14 +196,6 @@ void cm_start_hold()
|
||||
* (in-cycle) !~% Same as above (this one's an anomaly, but the intent would be to Q flush)
|
||||
*/
|
||||
|
||||
stat_t cm_feedhold_command_blocker()
|
||||
{
|
||||
if (cm1.hold_state != FEEDHOLD_OFF) {
|
||||
return (STAT_EAGAIN);
|
||||
}
|
||||
return (STAT_OK);
|
||||
}
|
||||
|
||||
stat_t cm_feedhold_sequencing_callback()
|
||||
{
|
||||
// invoking a p1 feedhold is a 2 step process - get to the stop, then execute the hold actions
|
||||
@@ -253,7 +245,19 @@ stat_t cm_feedhold_sequencing_callback()
|
||||
}
|
||||
return (STAT_OK);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************
|
||||
* cm_feedhold_command_blocker() - prevents new Gcode commands from queueing to p2 planner
|
||||
*/
|
||||
|
||||
stat_t cm_feedhold_command_blocker()
|
||||
{
|
||||
if (cm1.hold_state != FEEDHOLD_OFF) {
|
||||
return (STAT_EAGAIN);
|
||||
}
|
||||
return (STAT_OK);
|
||||
}
|
||||
|
||||
/***********************************************************************************
|
||||
* _run_p1_hold_entry_actions() - run actions in p2 that complete the p1 hold
|
||||
* _sync_to_p1_hold_entry_actions_done() - final state change occurs here
|
||||
@@ -358,7 +362,8 @@ static stat_t _run_p1_hold_exit_actions() // LATER: if value == true return
|
||||
|
||||
static void _sync_to_p1_hold_exit_actions_done(float* vect, bool* flag)
|
||||
{
|
||||
cm1.hold_state = FEEDHOLD_P1_EXIT; // penultimate state before transitioning to FEEDHOLD_OFF
|
||||
cm1.hold_state = FEEDHOLD_P1_EXIT; // penultimate state before transitioning to FEEDHOLD_OFF
|
||||
// copy_vector(mp->position, mr->position); // +++++ Compensate for amount of move already performed
|
||||
sr_request_status_report(SR_REQUEST_IMMEDIATE);
|
||||
}
|
||||
|
||||
@@ -382,7 +387,6 @@ static stat_t _finalize_p1_hold_exit()
|
||||
}
|
||||
|
||||
// resume motion from primary planner or end cycle if no moves in planner
|
||||
cm1.hold_state = FEEDHOLD_OFF;
|
||||
if (mp_has_runnable_buffer(&mp1)) {
|
||||
cm_set_motion_state(MOTION_RUN);
|
||||
cm_cycle_start();
|
||||
@@ -391,6 +395,7 @@ static stat_t _finalize_p1_hold_exit()
|
||||
cm_set_motion_state(MOTION_STOP);
|
||||
cm_cycle_end();
|
||||
}
|
||||
cm1.hold_state = FEEDHOLD_OFF;
|
||||
return (STAT_OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,6 @@ stat_t cm_jogging_cycle_start(uint8_t axis) {
|
||||
return (STAT_OK);
|
||||
}
|
||||
|
||||
|
||||
/* Jogging axis moves - these execute in sequence for each axis
|
||||
* cm_jogging_cycle_callback() - main loop callback for running the jogging cycle
|
||||
* _set_jogging_func() - a convenience for setting the next dispatch vector and exiting
|
||||
@@ -132,7 +131,7 @@ stat_t cm_jogging_cycle_callback(void) {
|
||||
return (STAT_EAGAIN); // sync to planner move ends
|
||||
}
|
||||
// if (jog.func == _jogging_axis_ramp_jog && mp_get_buffers_available() < PLANNER_BUFFER_HEADROOM) {
|
||||
if (jog.func == _jogging_axis_ramp_jog && mp_planner_is_full(mp)) { //+++++
|
||||
if (jog.func == _jogging_axis_ramp_jog && mp_planner_is_full(mp)) { //+++++
|
||||
return (STAT_EAGAIN); // prevent flooding the queue with jog moves
|
||||
}
|
||||
return (jog.func(jog.axis)); // execute the current jogging move
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
<InterfaceName>SWD</InterfaceName>
|
||||
</ToolOptions>
|
||||
<ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
|
||||
<ToolNumber>J41800036434</ToolNumber>
|
||||
<ToolNumber>J41800030015</ToolNumber>
|
||||
<ToolName>Atmel-ICE</ToolName>
|
||||
</com_atmel_avrdbg_tool_atmelice>
|
||||
<UseGdb>True</UseGdb>
|
||||
@@ -100,7 +100,7 @@
|
||||
<HWProgramCounterSampling>True</HWProgramCounterSampling>
|
||||
</PercepioTrace>
|
||||
<preserveEEPROM>true</preserveEEPROM>
|
||||
<avrtoolserialnumber>J41800036434</avrtoolserialnumber>
|
||||
<avrtoolserialnumber>J41800030015</avrtoolserialnumber>
|
||||
<avrdeviceexpectedsignature>0x284E0A60</avrdeviceexpectedsignature>
|
||||
<avrtoolinterfaceclock>10000000</avrtoolinterfaceclock>
|
||||
<custom>
|
||||
|
||||
+14
-3
@@ -403,6 +403,7 @@ stat_t mp_exec_aline(mpBuf_t *bf)
|
||||
if (mr->block_state == BLOCK_INACTIVE) {
|
||||
|
||||
// ASSERTIONS
|
||||
|
||||
// Zero length moves (and other too-short moves) should have already been removed earlier
|
||||
// But let's still alert the condition should it ever occur
|
||||
debug_trap_if_zero(bf->length, "mp_exec_aline() zero length move");
|
||||
@@ -440,6 +441,9 @@ stat_t mp_exec_aline(mpBuf_t *bf)
|
||||
copy_vector(mr->target, bf->gm.target);
|
||||
copy_vector(mr->axis_flags, bf->axis_flags);
|
||||
|
||||
mr->run_bf = bf; // DIAGNOSTIC: points to running bf
|
||||
mr->plan_bf = bf->nx; // DIAGNOSTIC: points to next bf to forward plan
|
||||
|
||||
// characterize the move for starting section - head/body/tail
|
||||
mr->section_state = SECTION_NEW;
|
||||
mr->section = SECTION_HEAD;
|
||||
@@ -456,6 +460,9 @@ stat_t mp_exec_aline(mpBuf_t *bf)
|
||||
mr->waypoint[SECTION_BODY][axis] = mr->position[axis] + mr->unit[axis] * (mr->r->head_length + mr->r->body_length);
|
||||
mr->waypoint[SECTION_TAIL][axis] = mr->position[axis] + mr->unit[axis] * (mr->r->head_length + mr->r->body_length + mr->r->tail_length);
|
||||
}
|
||||
// if (mr->waypoint[SECTION_TAIL][AXIS_X] < 0) { //+++++
|
||||
// bf->hint = (blockHint)0;
|
||||
// }
|
||||
}
|
||||
|
||||
// Feed Override Processing - We need to handle the following cases (listed in rough sequence order):
|
||||
@@ -735,7 +742,7 @@ static stat_t _exec_aline_head(mpBuf_t *bf)
|
||||
if (mr->segment_time < MIN_SEGMENT_TIME) {
|
||||
debug_trap("mr->segment_time < MIN_SEGMENT_TIME (head)");
|
||||
return (STAT_OK); // exit without advancing position, say we're done
|
||||
}
|
||||
}
|
||||
mr->section = SECTION_HEAD; // +++++ Redundant???
|
||||
mr->section_state = SECTION_RUNNING;
|
||||
} else {
|
||||
@@ -924,7 +931,6 @@ static stat_t _exec_aline_segment()
|
||||
|
||||
static void _exec_aline_normalize_block(mpBlockRuntimeBuf_t *b)
|
||||
{
|
||||
|
||||
if ((b->head_length > 0) && (b->head_time < MIN_SEGMENT_TIME)) {
|
||||
// Compute the new body time. head_time !== body_time
|
||||
b->body_length += b->head_length;
|
||||
@@ -995,7 +1001,7 @@ static stat_t _exec_aline_feedhold(mpBuf_t *bf)
|
||||
|
||||
// If in a p2 hold, exit the p2 hold set up a flush of the p2 planner queue
|
||||
if (cm == &cm2) {
|
||||
// copy_vector(mp->position, mr->position); // update planner position from runtime
|
||||
// copy_vector(mp->position, mr->position); // +++++ update planner position from runtime
|
||||
cm->hold_state = FEEDHOLD_P2_EXIT;
|
||||
}
|
||||
// At this point we know we are in a p1 hold
|
||||
@@ -1011,6 +1017,11 @@ static stat_t _exec_aline_feedhold(mpBuf_t *bf)
|
||||
// If exiting a regular p1 hold set state to FEEDHOLD_ACTIONS_START.
|
||||
// This enables transition to p2 planner; then Z-lift, spindle, coolant actions
|
||||
else {
|
||||
if (bf->gm.linenum == 10) { // +++ DEBUG TRAP
|
||||
bf->override_factor *= 1.01;
|
||||
}
|
||||
// copy_vector(mp->position, mr->position); // ++++ update planner position from runtime
|
||||
// bf->length = get_axis_vector_length(mr->position, mr->target); //+++++
|
||||
cm->hold_state = FEEDHOLD_ACTIONS_START;
|
||||
}
|
||||
|
||||
|
||||
+10
-13
@@ -296,16 +296,13 @@ static mpBuf_t* _plan_block(mpBuf_t* bf)
|
||||
bf->pv->exit_vmax = min3(bf->pv->junction_vmax, bf->pv->cruise_vmax, bf->cruise_vmax);
|
||||
}
|
||||
}
|
||||
_calculate_override(bf); // adjust cruise_vmax for feed/traverse override
|
||||
_calculate_override(bf); // adjust cruise_vmax for feed/traverse override
|
||||
// bf->plannable_time = bf->pv->plannable_time; // set plannable time - excluding current move
|
||||
bf->buffer_state = MP_BUFFER_IN_PROCESS;
|
||||
|
||||
// +++++ Why do we have to do this here?
|
||||
// bf->pv_group = bf->pv;
|
||||
|
||||
bf->hint = NO_HINT; // ensure we've cleared the hints
|
||||
bf->hint = NO_HINT; // ensure we've cleared the hints
|
||||
|
||||
// Time: 12us-41us
|
||||
if (bf->nx->plannable) { // read in new buffers until EMPTY
|
||||
if (bf->nx->plannable) { // read in new buffers until EMPTY
|
||||
return (bf->nx);
|
||||
}
|
||||
mp->planning_return = bf->nx; // where to return after planning is complete
|
||||
@@ -422,7 +419,7 @@ static mpBuf_t* _plan_block(mpBuf_t* bf)
|
||||
optimal = true; // We can't improve this entry more
|
||||
}
|
||||
|
||||
// +++++
|
||||
// DIAGNOSTICS
|
||||
if (bf->buffer_state == MP_BUFFER_EMPTY) {
|
||||
// _debug_trap("Exec apparently cleared this block while we were planning it.");
|
||||
break; // exit the loop, we've hit and passed the running buffer
|
||||
@@ -461,24 +458,24 @@ static void _calculate_override(mpBuf_t* bf) // execute ramp to adjust cruise v
|
||||
// generate ramp term is a ramp is active
|
||||
if (mp->ramp_active) {
|
||||
bf->override_factor += mp->ramp_dvdt * bf->block_time;
|
||||
if (mp->ramp_dvdt > 0) { // positive is an acceleration ramp
|
||||
if (mp->ramp_dvdt > 0) { // positive is an acceleration ramp
|
||||
if (bf->override_factor > mp->ramp_target) {
|
||||
bf->override_factor = mp->ramp_target;
|
||||
mp->ramp_active = false; // detect end of ramp
|
||||
mp->ramp_active = false; // detect end of ramp
|
||||
}
|
||||
bf->cruise_velocity *= bf->override_factor;
|
||||
if (bf->cruise_velocity > bf->absolute_vmax) { // test max cruise_velocity
|
||||
bf->cruise_velocity = bf->absolute_vmax;
|
||||
mp->ramp_active = false; // don't allow exceeding absolute_vmax
|
||||
mp->ramp_active = false; // don't allow exceeding absolute_vmax
|
||||
}
|
||||
} else { // negative is deceleration ramp
|
||||
if (bf->override_factor < mp->ramp_target) {
|
||||
bf->override_factor = mp->ramp_target;
|
||||
mp->ramp_active = false;
|
||||
}
|
||||
bf->cruise_velocity *= bf->override_factor; // +++++ this is probably wrong
|
||||
bf->cruise_velocity *= bf->override_factor; // +++++ this is probably wrong
|
||||
// bf->exit_velocity *= bf->mfo_factor; //...but I'm not sure this is right,
|
||||
// bf->cruise_velocity = bf->pv->exit_velocity; //...either
|
||||
// bf->cruise_velocity = bf->pv->exit_velocity;//...either
|
||||
}
|
||||
} else {
|
||||
bf->cruise_velocity *= bf->override_factor; // apply original or changed factor
|
||||
|
||||
+4
-4
@@ -194,10 +194,10 @@ void planner_init(mpPlanner_t *_mp, mpPlannerRuntime_t *_mr, mpBuf_t *queue, uin
|
||||
_mr->magic_start = MAGICNUM; // mr assertions
|
||||
_mr->magic_end = MAGICNUM;
|
||||
|
||||
_mr->bf[0].nx = &_mr->bf[1]; // Handle the two "stub blocks" in the runtime structure
|
||||
_mr->bf[1].nx = &_mr->bf[0];
|
||||
_mr->r = &_mr->bf[0];
|
||||
_mr->p = &_mr->bf[1];
|
||||
_mr->block[0].nx = &_mr->block[1]; // Handle the two "stub blocks" in the runtime structure
|
||||
_mr->block[1].nx = &_mr->block[0];
|
||||
_mr->r = &_mr->block[0];
|
||||
_mr->p = &_mr->block[1];
|
||||
}
|
||||
|
||||
void planner_reset(mpPlanner_t *_mp) // reset planner queue, cease MR activity, but leave positions alone
|
||||
|
||||
+4
-1
@@ -464,7 +464,10 @@ typedef struct mpPlannerRuntime { // persistent runtime variables
|
||||
|
||||
mpBlockRuntimeBuf_t *r; // block that is running
|
||||
mpBlockRuntimeBuf_t *p; // block that is being planned, p might == r
|
||||
mpBlockRuntimeBuf_t bf[2]; // buffer holding the two blocks
|
||||
mpBlockRuntimeBuf_t block[2]; // buffer holding the two blocks
|
||||
|
||||
mpBuf_t *plan_bf; // DIAGNOSTIC - pointer to next buffer to plan
|
||||
mpBuf_t *run_bf; // DIAGNOSTIC - pointer to currently running buffer
|
||||
|
||||
float entry_velocity; // entry values for the currently running block
|
||||
|
||||
|
||||
+12
-13
@@ -2,8 +2,8 @@
|
||||
* xio.cpp - extended IO functions
|
||||
* This file is part of the g2core project
|
||||
*
|
||||
* Copyright (c) 2013 - 2016 Alden S. Hart Jr.
|
||||
* Copyright (c) 2013 - 2016 Robert Giseburt
|
||||
* Copyright (c) 2013 - 2017 Alden S. Hart Jr.
|
||||
* Copyright (c) 2013 - 2017 Robert Giseburt
|
||||
*
|
||||
* This file ("the software") is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License, version 2 as published by the
|
||||
@@ -403,8 +403,8 @@ extern xio_t xio;
|
||||
// See here for a discussion of what this means if you are not familiar with C++
|
||||
// https://github.com/synthetos/g2/wiki/Dual-Endpoint-USB-Internals#c-classes-virtual-functions-and-inheritance
|
||||
|
||||
// LineRXBuffer takes the Motate RXBuffer (which handles "transfers", usually DMA), and adds G2 line-reading
|
||||
// semantics to it.
|
||||
// LineRXBuffer takes the Motate RXBuffer (which handles "transfers", usually DMA),
|
||||
// and adds G2 line-reading semantics to it.
|
||||
template <uint16_t _size, typename owner_type, uint8_t _header_count = 8, uint16_t _line_buffer_size = RX_BUFFER_SIZE>
|
||||
struct LineRXBuffer : RXBuffer<_size, owner_type, char> {
|
||||
typedef RXBuffer<_size, owner_type, char> parent_type;
|
||||
@@ -430,15 +430,15 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> {
|
||||
// * "index" indicates it's in to _headers array
|
||||
// * "offset" means it's a character in the _data array
|
||||
|
||||
uint16_t _scan_offset; // offset into data of the last character scanned
|
||||
uint16_t _line_start_offset; // offset into first character of the line, or the first char to ignore (too-long lines)
|
||||
uint16_t _last_line_length; // used for ensuring lines aren't too long
|
||||
bool _ignore_until_next_line; // if we get a too-long-line, we ignore the rest by setting this flag
|
||||
bool _at_start_of_line; // true if the last character scanned was the end of a line
|
||||
uint16_t _scan_offset; // offset into data of the last character scanned
|
||||
uint16_t _line_start_offset; // offset into first character of the line, or the first char to ignore (too-long lines)
|
||||
uint16_t _last_line_length; // used for ensuring lines aren't too long
|
||||
bool _ignore_until_next_line; // if we get a too-long-line, we ignore the rest by setting this flag
|
||||
bool _at_start_of_line; // true if the last character scanned was the end of a line
|
||||
|
||||
uint16_t _lines_found; // count of complete non-control lines that were found during scanning.
|
||||
uint16_t _lines_found; // count of complete non-control lines that were found during scanning.
|
||||
|
||||
volatile uint16_t _last_scan_offset; // DEBUGGING
|
||||
volatile uint16_t _last_scan_offset; // DIAGNOSTIC
|
||||
|
||||
bool _last_returned_a_control = false;
|
||||
|
||||
@@ -708,8 +708,7 @@ struct LineRXBuffer : RXBuffer<_size, owner_type, char> {
|
||||
// move the start of the next skip section to after this skip
|
||||
_line_start_offset = _scan_offset;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return false; // no control was found
|
||||
};
|
||||
|
||||
|
||||
Executable → Regular
+7
-9
@@ -2,8 +2,8 @@
|
||||
* xio.h - extended IO functions
|
||||
* This file is part of the g2core project
|
||||
*
|
||||
* Copyright (c) 2013 - 2016 Alden S. Hart Jr.
|
||||
* Copyright (c) 2013 - 2016 Robert Giseburt
|
||||
* Copyright (c) 2013 - 2017 Alden S. Hart Jr.
|
||||
* Copyright (c) 2013 - 2017 Robert Giseburt
|
||||
*
|
||||
* This file ("the software") is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License, version 2 as published by the
|
||||
@@ -154,13 +154,11 @@ extern "C" {
|
||||
|
||||
/* Signal character mappings */
|
||||
|
||||
#define CHAR_RESET CAN
|
||||
#define CHAR_ALARM EOT
|
||||
#define CHAR_FEEDHOLD (char)'!'
|
||||
#define CHAR_CYCLE_START (char)'~'
|
||||
#define CHAR_QUEUE_FLUSH (char)'%'
|
||||
//#define CHAR_BOOTLOADER ESC
|
||||
|
||||
#define CHAR_RESET CAN // Control X - Reset Board
|
||||
#define CHAR_ALARM EOT // Control D - Kill Job
|
||||
#define CHAR_FEEDHOLD (char)'!' // Feedhold
|
||||
#define CHAR_CYCLE_START (char)'~' // Feedhold Exit and Resume
|
||||
#define CHAR_QUEUE_FLUSH (char)'%' // Feedhold Exit and Flush
|
||||
|
||||
/**** xio_flash_file - object to hold in-flash (compiled-in) "files" to run ****/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user