Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/nml_intf/canon.hh
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ struct CANON_VECTOR {

typedef struct {
int feed_mode;
int synched;
double speed;
int dir;
double css_maximum;
Expand All @@ -170,6 +169,7 @@ typedef struct CanonConfig_t {
naivecamTolerance(0.0),
feed_mode(0),
spindle_num(0),
synched(0),
spindle{},
linearFeedRate(0.0),
angularFeedRate(0.0),
Expand Down Expand Up @@ -214,6 +214,7 @@ typedef struct CanonConfig_t {
double naivecamTolerance;
int feed_mode;
int spindle_num; //current spindle for spindle-synch motion
int synched; // a spindle-synched move is active; motion syncs one spindle at a time
CanonSpindle_t spindle[EMCMOT_MAX_SPINDLES];

/* Prepped tool is saved here */
Expand Down
8 changes: 4 additions & 4 deletions src/emc/task/emccanon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ static void flush_segments(void) {

linearMoveMsg->type = EMC_MOTION_TYPE_FEED;
linearMoveMsg->indexer_jnum = -1;
if ((vel && acc) || canon.spindle[canon.spindle_num].synched) {
if ((vel && acc) || canon.synched) {
interp_list.set_line_number(line_no);
tag_and_send(std::move(linearMoveMsg), pos.tag);
}
Expand Down Expand Up @@ -1882,13 +1882,13 @@ void START_SPEED_FEED_SYNCH(int spindle, double feed_per_revolution, bool veloci
spindleSyncMsg->velocity_mode = velocity_mode;
spindleSyncMsg->angular_offset_degrees = angle_degrees;
interp_list.append(std::move(spindleSyncMsg));
canon.spindle[spindle].synched = 1;
canon.synched = 1;
}

void STOP_SPEED_FEED_SYNCH()
{
START_SPEED_FEED_SYNCH(0, 0, false);
canon.spindle[canon.spindle_num].synched = 0;
canon.synched = 0;
}

/* Machining Functions */
Expand Down Expand Up @@ -3984,8 +3984,8 @@ void INIT_CANON()
SET_NAIVECAM_TOLERANCE(0);
for (int s = 0; s < EMCMOT_MAX_SPINDLES; s++) {
canon.spindle[s].speed = 0.0;
canon.spindle[s].synched = 0;
}
canon.synched = 0;
canon.optional_program_stop = ON; //set enabled by default (previous EMC behaviour)
canon.block_delete = ON; //set enabled by default (previous EMC behaviour)
canon.cartesian_move = 0;
Expand Down
7 changes: 7 additions & 0 deletions tests/motion/g33-spindle-select/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
G33 with a $ word must run when no F word has been programmed.

A synchronized move takes its speed from the spindle, so task sends it even
with a zero feed rate. That exception looked at the sync state of spindle 0
in G94, so "G33 ... $1" with F still 0 was dropped without an error and the
axis never moved. Two simulated spindles; checks that a G33 synchronized to
spindle 1, with no F ever set, ends at its programmed Z.
1 change: 1 addition & 0 deletions tests/motion/g33-spindle-select/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Completed successfully
27 changes: 27 additions & 0 deletions tests/motion/g33-spindle-select/spindles.hal
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# two spindles, each with a simulated encoder giving revs and an index pulse
loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS num_spindles=[TRAJ]SPINDLES
loadrt sim_spindle names=sim_spindle.0,sim_spindle.1

addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf sim_spindle.0 servo-thread
addf sim_spindle.1 servo-thread

net Xpos joint.0.motor-pos-cmd => joint.0.motor-pos-fb
net Ypos joint.1.motor-pos-cmd => joint.1.motor-pos-fb
net Zpos joint.2.motor-pos-cmd => joint.2.motor-pos-fb

net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared
net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed

# speed-out is rpm, sim_spindle position is revs
setp sim_spindle.0.scale 0.01666667
setp sim_spindle.1.scale 0.01666667
net spindle0-cmd spindle.0.speed-out => sim_spindle.0.velocity-cmd
net spindle0-index spindle.0.index-enable <=> sim_spindle.0.index-enable
net spindle0-pos sim_spindle.0.position-fb => spindle.0.revs
net spindle1-cmd spindle.1.speed-out => sim_spindle.1.velocity-cmd
net spindle1-index spindle.1.index-enable <=> sim_spindle.1.index-enable
net spindle1-pos sim_spindle.1.position-fb => spindle.1.revs
65 changes: 65 additions & 0 deletions tests/motion/g33-spindle-select/test-ui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env python3
#
# G33 synchronized to spindle 1 with no F word ever programmed, see README.

import linuxcnc
import linuxcnc_util
import hal

import sys
import time

TIMEOUT = 30 # seconds for one MDI line to finish

c = linuxcnc.command()
s = linuxcnc.stat()
e = linuxcnc.error_channel()
l = linuxcnc_util.LinuxCNC(command=c, status=s, error=e)

c.state(linuxcnc.STATE_ESTOP_RESET)
c.state(linuxcnc.STATE_ON)
c.home(-1)
c.wait_complete()
l.wait_for_home([1, 1, 1, 0, 0, 0, 0, 0, 0])

c.mode(linuxcnc.MODE_MDI)
c.wait_complete()


def mdi(cmd):
c.mdi(cmd)
c.wait_complete()
end = time.time() + TIMEOUT
while time.time() < end:
s.poll()
if s.interp_state == linuxcnc.INTERP_IDLE and s.queue == 0 and s.inpos:
break
time.sleep(0.01)
else:
print("FAIL: '{}' did not finish".format(cmd))
sys.exit(1)
err = e.poll()
if err:
print("FAIL: '{}' raised: {}".format(cmd, err[1].strip()))
sys.exit(1)


for cmd in ("G21 G90", "M3 $1 S600", "G0 Z5"):
mdi(cmd)

mdi("G33 Z-5 K1 $1")
s.poll()
z = s.position[2]
revs = hal.get_value("spindle.1.revs")
print("after G33 $1: Z={:.4f} spindle.1.revs={:.3f}".format(z, revs))
if abs(z + 5) > 1e-6:
print("FAIL: G33 $1 with no F word ended at Z={:.4f}, expected -5".format(z))
sys.exit(1)
# the index reset zeroes revs when the move starts; K1 over 10 mm is 10 revs
if revs < 10:
print("FAIL: spindle 1 turned {:.3f} revs since the index, expected 10 or more".format(revs))
sys.exit(1)

mdi("M5 $1")
print("Completed successfully")
sys.exit(0)
96 changes: 96 additions & 0 deletions tests/motion/g33-spindle-select/test.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
[EMC]
DEBUG = 0
VERSION = 1.1

[DISPLAY]
DISPLAY = ./test-ui.py

[TASK]
TASK = milltask
CYCLE_TIME = 0.001

[RS274NGC]
PARAMETER_FILE = sim.var

[EMCMOT]
EMCMOT = motmod
BASE_PERIOD = 0
SERVO_PERIOD = 1000000

[HAL]
HALFILE = ./spindles.hal

[TRAJ]
NO_FORCE_HOMING = 1
AXES = 3
SPINDLES = 2
COORDINATES = X Y Z
HOME = 0 0 0
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 100
MAX_LINEAR_VELOCITY = 500

[KINS]
KINEMATICS = trivkins
JOINTS = 3

[AXIS_X]
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
MAX_VELOCITY = 500
MAX_ACCELERATION = 3000

[JOINT_0]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 500
MAX_ACCELERATION = 3000
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
FERROR = 0.050
MIN_FERROR = 0.010
HOME_SEQUENCE = 0

[AXIS_Y]
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
MAX_VELOCITY = 500
MAX_ACCELERATION = 3000

[JOINT_1]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 500
MAX_ACCELERATION = 3000
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
FERROR = 0.050
MIN_FERROR = 0.010
HOME_SEQUENCE = 0

[AXIS_Z]
MIN_LIMIT = -500.0
MAX_LIMIT = 500.0
MAX_VELOCITY = 500
MAX_ACCELERATION = 3000

[JOINT_2]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 500
MAX_ACCELERATION = 3000
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -500.0
MAX_LIMIT = 500.0
FERROR = 0.050
MIN_FERROR = 0.010
HOME_SEQUENCE = 0
4 changes: 4 additions & 0 deletions tests/motion/g33-spindle-select/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
if linuxcnc -r test.ini; then
echo "Completed successfully" > result
fi