Skip to content

Commit

Permalink
Merge branch 'master' into 288-fr-implement-smoothieware-s-cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
Paciente8159 committed Oct 5, 2022
2 parents 4fc688c + 51d3f7d commit e744534
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 98 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@

# Changelog

## [1.5.2] - 01-10-2022

### Added

- configurable PWM frequency (#286)

### Fixed

- fixed no command response after a tool command without motion (#284)
- fixed incorrect laser power factor scaling with M4 (#282)
- $P servo report values for AVR (#283)
- fixed tool update with dwell to reach programmed speed

## [1.5.1] - 23-09-2022

### Fixed
Expand Down Expand Up @@ -999,6 +1012,7 @@ Version 1.1.0 comes with many added features and improvements over the previous

### Initial release

[1.5.2]: https://github.com/Paciente8159/uCNC/releases/tag/v1.5.2
[1.5.1]: https://github.com/Paciente8159/uCNC/releases/tag/v1.5.1
[1.5.0]: https://github.com/Paciente8159/uCNC/releases/tag/v1.5.0
[1.5.rc]: https://github.com/Paciente8159/uCNC/releases/tag/v1.5.rc
Expand Down
2 changes: 1 addition & 1 deletion uCNC/cnc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ extern "C"
/**
* accept G0 and G1 without explicit target
* */
// #define IGNORE_G0_G1_MISSING_AXIS_WORDS
#define IGNORE_G0_G1_MISSING_AXIS_WORDS

/**
* processes and displays the currently executing gcode numbered line
Expand Down
2 changes: 1 addition & 1 deletion uCNC/src/cnc_build.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern "C"
#endif

#define CNC_MAJOR_MINOR_VERSION "1.5"
#define CNC_PATCH_VERSION ".1"
#define CNC_PATCH_VERSION ".2"

#define CNC_VERSION CNC_MAJOR_MINOR_VERSION CNC_PATCH_VERSION

Expand Down
106 changes: 49 additions & 57 deletions uCNC/src/core/motion_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,12 @@ bool mc_toogle_checkmode(void)
return mc_checkmode;
}

static uint8_t mc_line_segment(float *target, motion_data_t *block_data)
static uint8_t mc_line_segment(int32_t *step_new_pos, motion_data_t *block_data)
{
int32_t step_new_pos[STEPPER_COUNT];

// applies the inverse kinematic to get next position in steps
kinematics_apply_inverse(target, step_new_pos);

// resets accumulator vars of the block
// resets accumulator vars of the block
#ifdef ENABLE_LINACT_PLANNER
block_data->full_steps = 0;
#endif
block_data->total_steps = 0;
#if KINEMATIC == KINEMATIC_DELTA
block_data->dirbits = 0;
Expand All @@ -88,7 +85,9 @@ static uint8_t mc_line_segment(float *target, motion_data_t *block_data)
}
#endif

#ifdef ENABLE_LINACT_PLANNER
block_data->full_steps += steps;
#endif
if (block_data->total_steps < steps)
{
block_data->total_steps = steps;
Expand Down Expand Up @@ -120,7 +119,9 @@ static uint8_t mc_line_segment(float *target, motion_data_t *block_data)
memset(backlash_block_data.steps, 0, sizeof(backlash_block_data.steps));
// resets accumulator vars
backlash_block_data.total_steps = 0;
#ifdef ENABLE_LINACT_PLANNER
backlash_block_data.full_steps = 0;
#endif
backlash_block_data.feed = FLT_MAX; // max feedrate possible (same as rapid move)

SETFLAG(backlash_block_data.motion_mode, MOTIONCONTROL_MODE_BACKLASH_COMPENSATION);
Expand All @@ -131,7 +132,9 @@ static uint8_t mc_line_segment(float *target, motion_data_t *block_data)
if (inverted_steps & (1 << i))
{
backlash_block_data.steps[i] = g_settings.backlash_steps[i];
#ifdef ENABLE_LINACT_PLANNER
backlash_block_data.full_steps += backlash_block_data.steps[i];
#endif
if (backlash_block_data.total_steps < backlash_block_data.steps[i])
{
backlash_block_data.total_steps = backlash_block_data.steps[i];
Expand All @@ -140,10 +143,6 @@ static uint8_t mc_line_segment(float *target, motion_data_t *block_data)
}
}

planner_add_line(&backlash_block_data);
// dwell should only execute on the first request
block_data->dwell = 0;

while (planner_buffer_is_full())
{
if (!cnc_dotasks())
Expand All @@ -152,10 +151,21 @@ static uint8_t mc_line_segment(float *target, motion_data_t *block_data)
}
}

planner_add_line(&backlash_block_data);
// dwell should only execute on the first request
block_data->dwell = 0;
mc_last_dirbits = block_data->dirbits;
}
#endif

while (planner_buffer_is_full())
{
if (!cnc_dotasks())
{
return STATUS_CRITICAL_FAIL;
}
}

#ifdef ENABLE_MOTION_CONTROL_MODULES
// event_mc_line_segment_handler
EVENT_INVOKE(mc_line_segment, block_data);
Expand All @@ -181,7 +191,7 @@ uint8_t mc_line(float *target, motion_data_t *block_data)
float prev_target[AXIS_COUNT];
block_data->dirbits = 0; // reset dirbits (this prevents odd behaviour generated by long arcs)

// In homming mode no kinematics modifications is applied to prevent unwanted axis movements
// In homing mode no kinematics modifications is applied to prevent unwanted axis movements
if (!cnc_get_exec_state(EXEC_HOMING))
{
kinematics_apply_transform(target);
Expand All @@ -198,14 +208,6 @@ uint8_t mc_line(float *target, motion_data_t *block_data)
return STATUS_OK;
}

while (planner_buffer_is_full())
{
if (!cnc_dotasks())
{
return STATUS_CRITICAL_FAIL;
}
}

uint8_t error = STATUS_OK;
int32_t step_new_pos[STEPPER_COUNT];
// converts transformed target to stepper position
Expand Down Expand Up @@ -275,9 +277,18 @@ uint8_t mc_line(float *target, motion_data_t *block_data)
float inv_delta = (!CHECKFLAG(block_data->motion_mode, MOTIONCONTROL_MODE_INVERSEFEED) ? (block_data->feed * inv_dist) : block_data->feed);
block_data->feed = (float)max_steps * inv_delta;

#if ((KINEMATIC == KINEMATIC_DELTA) || defined(BRESENHAM_16BIT))
// this contains a motion. Any tool update will be done here
uint32_t line_segments = 1;
#if (KINEMATIC != KINEMATIC_DELTA)
#if (KINEMATIC == KINEMATIC_DELTA)
line_segments = (uint32_t)ceilf(line_dist * DELTA_MOTION_SEGMENT_FACTOR);
float m_inv = 1.0f / (float)line_segments;
for (uint8_t i = AXIS_COUNT; i != 0;)
{
i--;
motion_segment[i] *= m_inv;
}
#else
if (max_steps > MAX_STEPS_PER_LINE)
{
line_segments += (max_steps >> MAX_STEPS_PER_LINE_BITS);
Expand All @@ -288,52 +299,33 @@ uint8_t mc_line(float *target, motion_data_t *block_data)
motion_segment[i] *= m_inv;
}
}
#else
line_segments = (uint32_t)ceilf(line_dist * DELTA_MOTION_SEGMENT_FACTOR);
float m_inv = 1.0f / (float)line_segments;
for (uint8_t i = AXIS_COUNT; i != 0;)
{
i--;
motion_segment[i] *= m_inv;
}
#endif

while (line_segments--)
while (--line_segments)
{
while (planner_buffer_is_full())
block_data->motion_flags.bit.is_subsegment = 1;
for (uint8_t i = AXIS_COUNT; i != 0;)
{
if (!cnc_dotasks())
{
block_data->feed = feed;
return STATUS_CRITICAL_FAIL;
}
i--;
prev_target[i] += motion_segment[i];
}

if (line_segments)
{
for (uint8_t i = AXIS_COUNT; i != 0;)
{
i--;
prev_target[i] += motion_segment[i];
}

error = mc_line_segment(prev_target, block_data);
if (error)
{
break;
}
}
else
kinematics_apply_inverse(prev_target, step_new_pos);
error = mc_line_segment(step_new_pos, block_data);
if (error)
{
error = mc_line_segment(target, block_data);
if (error)
{
break;
}
memcpy(target, prev_target, sizeof(prev_target));
block_data->feed = feed;
return error;
}
block_data->motion_flags.bit.is_subsegment = 1;
}

if (block_data->motion_flags.bit.is_subsegment)
{
kinematics_apply_inverse(target, step_new_pos);
}
#endif
error = mc_line_segment(step_new_pos, block_data);
// stores the new position for the next motion
memcpy(mc_last_target, target, sizeof(mc_last_target));
block_data->feed = feed;
Expand Down
2 changes: 2 additions & 0 deletions uCNC/src/core/motion_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ extern "C"
step_t steps[STEPPER_COUNT];
float dir_vect[AXIS_COUNT];
uint8_t dirbits;
#ifdef ENABLE_LINACT_PLANNER
uint32_t full_steps; // number of steps of all linear actuators
#endif
step_t total_steps; // the number of pulses needed to generate all steps (maximum of all linear actuators)
float feed;
uint8_t main_stepper;
Expand Down
88 changes: 49 additions & 39 deletions uCNC/src/core/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static int32_t rt_probe_step_pos[STEPPER_COUNT];
static float parser_last_pos[AXIS_COUNT];

static unsigned char parser_get_next_preprocessed(bool peek);
FORCEINLINE static uint8_t parser_get_comment(void);
FORCEINLINE static void parser_get_comment(unsigned char start_char);
FORCEINLINE static uint8_t parser_get_token(unsigned char *word, float *value);
FORCEINLINE static uint8_t parser_gcode_word(uint8_t code, uint8_t mantissa, parser_state_t *new_state, parser_cmd_explicit_t *cmd);
FORCEINLINE static uint8_t parser_mcode_word(uint8_t code, uint8_t mantissa, parser_state_t *new_state, parser_cmd_explicit_t *cmd);
Expand Down Expand Up @@ -1617,7 +1617,7 @@ uint8_t parser_exec_command(parser_state_t *new_state, parser_words_t *words, pa
break;
}

if (hold)
if (hold && !mc_get_checkmode())
{
mc_pause();
if (resetparser)
Expand Down Expand Up @@ -1791,8 +1791,11 @@ uint8_t parser_get_float(float *value)
To be compatible with Grbl it accepts bad format comments
On error returns false otherwise returns true
*/
static uint8_t parser_get_comment(void)
#define COMMENT_OK 1
#define COMMENT_NOTOK 2
static void parser_get_comment(unsigned char start_char)
{
uint8_t comment_end = 0;
#ifdef PROCESS_COMMENTS
uint8_t msg_parser = 0;
#endif
Expand All @@ -1803,50 +1806,57 @@ static uint8_t parser_get_comment(void)
{
// case '(': //error under RS274NGC (commented for Grbl compatibility)
case ')': // OK
serial_getc();
#ifdef PROCESS_COMMENTS
if (msg_parser == 4)
if (start_char == '(')
{
protocol_send_string(MSG_END);
comment_end = COMMENT_OK;
}
#endif
return STATUS_OK;
case EOL: // error under RS274NGC
return STATUS_BAD_COMMENT_FORMAT;
break;
case EOL: // error under RS274NGC is starts with '(' (it's ignored)
comment_end = COMMENT_OK;
break;
case OVF:
// return ((c==')') ? true : false); //under RS274NGC (commented for Grbl compatibility)
return STATUS_OVERFLOW;
case ' ':
return;
}

#ifdef PROCESS_COMMENTS
switch (msg_parser)
{
case 0:
msg_parser = (c == 'M' | c == 'm') ? 1 : 0xFF;
break;
case 1:
msg_parser = (c == 'S' | c == 's') ? 2 : 0xFF;
break;
case 2:
msg_parser = (c == 'G' | c == 'g') ? 3 : 0xFF;
break;
case 3:
msg_parser = (c == ',') ? 4 : 0xFF;
protocol_send_string(MSG_START);
break;
case 4:
serial_putc(c);
break;
}
#endif

if (c != EOL)
{
serial_getc();
}

if (comment_end)
{
#ifdef PROCESS_COMMENTS
default:
switch (msg_parser)
if (msg_parser == 4)
{
case 0:
msg_parser = (c == 'M' | c == 'm') ? 1 : 0xFF;
break;
case 1:
msg_parser = (c == 'S' | c == 's') ? 2 : 0xFF;
break;
case 2:
msg_parser = (c == 'G' | c == 'g') ? 3 : 0xFF;
break;
case 3:
msg_parser = (c == ',') ? 4 : 0xFF;
protocol_send_string(MSG_START);
break;
case 4:
serial_putc(c);
break;
protocol_send_string(MSG_END);
}
break;
#endif
return;
}

serial_getc();
}

return STATUS_BAD_COMMENT_FORMAT; // never reached here
}

static uint8_t parser_get_token(unsigned char *word, float *value)
Expand Down Expand Up @@ -2388,12 +2398,12 @@ static unsigned char parser_get_next_preprocessed(bool peek)
{
unsigned char c = serial_peek();

while (c == ' ' || c == '(')
while (c == ' ' || c == '(' || c == ';')
{
serial_getc();
if (c == '(')
if (c != ' ')
{
parser_get_comment();
parser_get_comment(c);
}
c = serial_peek();
}
Expand Down

0 comments on commit e744534

Please sign in to comment.