diff --git a/g2core/canonical_machine.cpp b/g2core/canonical_machine.cpp index 8ddd1bb5..0bd4baa6 100644 --- a/g2core/canonical_machine.cpp +++ b/g2core/canonical_machine.cpp @@ -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; iposition, 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); } diff --git a/g2core/cycle_jogging.cpp b/g2core/cycle_jogging.cpp index a2f7b4e2..2e781f34 100644 --- a/g2core/cycle_jogging.cpp +++ b/g2core/cycle_jogging.cpp @@ -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 diff --git a/g2core/g2core.cppproj b/g2core/g2core.cppproj index 0014b2ec..bb1cf7a0 100644 --- a/g2core/g2core.cppproj +++ b/g2core/g2core.cppproj @@ -73,7 +73,7 @@ SWD com.atmel.avrdbg.tool.atmelice - J41800036434 + J41800030015 Atmel-ICE True @@ -100,7 +100,7 @@ True true - J41800036434 + J41800030015 0x284E0A60 10000000 diff --git a/g2core/plan_exec.cpp b/g2core/plan_exec.cpp index bd288825..8a2a59c9 100644 --- a/g2core/plan_exec.cpp +++ b/g2core/plan_exec.cpp @@ -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; } diff --git a/g2core/plan_line.cpp b/g2core/plan_line.cpp index a487c9f7..b5564636 100644 --- a/g2core/plan_line.cpp +++ b/g2core/plan_line.cpp @@ -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 diff --git a/g2core/planner.cpp b/g2core/planner.cpp index f5b1900a..e5be1e51 100644 --- a/g2core/planner.cpp +++ b/g2core/planner.cpp @@ -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 diff --git a/g2core/planner.h b/g2core/planner.h index 606c2785..7f9ee27e 100644 --- a/g2core/planner.h +++ b/g2core/planner.h @@ -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 diff --git a/g2core/xio.cpp b/g2core/xio.cpp index 3993150e..d8f79698 100644 --- a/g2core/xio.cpp +++ b/g2core/xio.cpp @@ -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 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 }; diff --git a/g2core/xio.h b/g2core/xio.h old mode 100755 new mode 100644 index ec04b668..743d1ae2 --- a/g2core/xio.h +++ b/g2core/xio.h @@ -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 ****/