Skip to content

Axis Replacement on Y emits duplicate Y words and causes GRBL error 25 #310

Description

@DickHorner

Description

When using a rotary module in Axis Replacement mode with Axis Y, Rayforge generates G-code containing the Y word twice in the same block.

GRBL rejects these commands with:

error:25

GRBL error 25 means that a G-code word was repeated in the same block.

Environment

  • Rayforge version: 1.8.2
  • Operating system: Linux/CachyOS
  • Machine: Atomstack A10 Pro V1
  • Controller firmware: GRBL 1.1h
  • Rotary connection: Rotary module connected instead of the physical Y-axis motor
  • Rotary connection mode: Axis Replacement
  • Replacement axis: Y
  • Rotary type: Rollers

Steps to reproduce

  1. Configure a GRBL machine.
  2. Add a rotary module.
  3. Set the rotary module connection mode to Axis Replacement.
  4. Set the replacement axis to Y.
  5. Set the rotary type to Rollers.
  6. Enable the rotary module for a layer.
  7. Add or import simple geometry, such as a rectangle.
  8. Generate or run the G-code.

Actual result

Rayforge generates commands such as:

T0
G0 X455.603 Y143.374 Y322.591
M4 S244
G1 Y13.531 Y30.446 F500
G1 X599.189 Y13.531 F500
G1 Y143.374 Y322.591 F500
G1 X455.603 Y143.374 F500

The first movement command contains:

Y143.374 Y322.591

The following cutting command contains:

Y13.531 Y30.446

GRBL consequently reports:

[MSG:Tool No: 0]
error:25
ERROR GRBL error during job: error:25. Halting stream.
ALARM:3

Expected result

When Y is used as an axis replacement, the rotary coordinate should replace the normal Cartesian Y coordinate.

Each G-code block must contain no more than one Y word, for example:

G0 X455.603 Y322.591
G1 Y30.446 F500

The exact value depends on the rotary transformation, but the original Cartesian Y value and the rotary replacement value must not both be emitted.

Additional observations

The issue remains after:

  • selecting Axis Replacement instead of True 4th Axis
  • selecting Y as the replacement axis
  • recreating the rotary module configuration
  • regenerating the job

The generated output suggests that the original Cartesian value is emitted through y_cmd, while the rotary replacement value is additionally emitted through extra_cmd.

Possible technical cause

This is only a hypothesis based on the generated output:

  • KinematicMapping.apply() stores the rotary coordinate as an extra axis.
  • Machine._apply_replacement_downstream() is expected to move that value into the replaced Cartesian axis.
  • The G-code encoder later renders both {y_cmd} and {extra_cmd}.
  • For Y-axis replacement, the extra Axis.Y value appears to remain present during encoding, producing two Y words.

A regression test should verify that an Axis Replacement rotary configured for Y never produces more than one Y word per G-code block.

Safety impact

The generated G-code is invalid and cannot be executed by GRBL. Rayforge begins streaming the job, receives error:25, halts the stream, and resets or aborts the controller state.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingrca-doneA root cause analysis was attached

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions