Skip to content

Commit 44c1277

Browse files
authored
Merge pull request #2248 from LinuxCNC/interpmodule-speed-type-2.8
Fix spindle speed for remap
2 parents e714b3a + ef1ac37 commit 44c1277

13 files changed

Lines changed: 102 additions & 11 deletions

File tree

configs/sim/axis/remap/getting-started/python/remap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def involute(self, **words):
4545
self.set_errormsg("feedrate > 0 required")
4646
return INTERP_ERROR
4747

48-
if equal(self.speed,0.0):
48+
if equal(self.speed[0], 0.0):
4949
self.set_errormsg("spindle speed > 0 required")
5050
return INTERP_ERROR
5151

docs/src/remap/remap.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ def involute(self, **words):
578578
if equal(self.feed_rate,0.0):
579579
return "feedrate > 0 required"
580580

581-
if equal(self.speed,0.0):
581+
if equal(self.speed[0],0.0):
582582
return "spindle speed > 0 required"
583583

584584
plunge = 0.1 # if Z word was given, plunge - with reduced feed

nc_files/remap_lib/python-stdglue/stdglue.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def setspeed_epilog(self,**words):
4444
pass
4545
#print "---------- S builtin recursion, nothing to do"
4646
else:
47-
self.speed = self.params["speed"]
48-
emccanon.enqueue_SET_SPINDLE_SPEED(self.speed)
47+
self.speed[0] = self.params["speed"]
48+
emccanon.enqueue_SET_SPINDLE_SPEED(self.speed[0])
4949
return INTERP_OK
5050
except Exception,e:
5151
self.set_errormsg("S/setspeed_epilog: %s)" % (e))

src/emc/rs274ngc/interp_array_types.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
namespace pp = pyplusplus::containers::static_sized;
2727

28+
typedef pp::array_1_t<double, EMCMOT_MAX_SPINDLES> spindle_speed_array, (*spindle_speed_w)(Interp &);
2829
typedef pp::array_1_t< int, ACTIVE_G_CODES> active_g_codes_array, (*active_g_codes_w)( Interp & );
2930
typedef pp::array_1_t< int, ACTIVE_M_CODES> active_m_codes_array, (*active_m_codes_w)( Interp & );
3031
typedef pp::array_1_t< double, ACTIVE_SETTINGS> active_settings_array, (*active_settings_w)( Interp & );

src/emc/rs274ngc/interpmodule.cc

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ namespace pp = pyplusplus::containers::static_sized;
5555
#define IS_STRING(x) (PyObject_IsInstance(x.ptr(), (PyObject*)&PyString_Type))
5656
#define IS_INT(x) (PyObject_IsInstance(x.ptr(), (PyObject*)&PyInt_Type))
5757

58+
static spindle_speed_array spindle_speed_wrapper (Interp & inst) {
59+
return spindle_speed_array(inst._setup.speed);
60+
}
61+
5862
static active_g_codes_array active_g_codes_wrapper ( Interp & inst) {
5963
return active_g_codes_array(inst._setup.active_g_codes);
6064
}
@@ -366,6 +370,14 @@ static inline double get_CC_origin_offset (Interp &interp) {
366370
static inline void set_CC_origin_offset(Interp &interp, double value) {
367371
interp._setup.CC_origin_offset = value;
368372
}
373+
374+
static inline int get_active_spindle (Interp const & interp) {
375+
return interp._setup.active_spindle;
376+
}
377+
static inline void set_active_spindle(Interp & interp, int value) {
378+
interp._setup.active_spindle = value;
379+
}
380+
369381
static inline double get_axis_offset_x (Interp &interp) {
370382
return interp._setup.axis_offset_x;
371383
}
@@ -510,12 +522,6 @@ static inline double get_rotation_xy (Interp &interp) {
510522
static inline void set_rotation_xy(Interp &interp, double value) {
511523
interp._setup.rotation_xy = value;
512524
}
513-
static inline double get_speed (Interp &interp, int spindle) {
514-
return interp._setup.speed[spindle];
515-
}
516-
static inline void set_speed(Interp &interp, int spindle, double value) {
517-
interp._setup.speed[spindle] = value;
518-
}
519525
static inline double get_traverse_rate (Interp &interp) {
520526
return interp._setup.traverse_rate;
521527
}
@@ -896,6 +902,7 @@ BOOST_PYTHON_MODULE(interpreter) {
896902
.add_property("CC_axis_offset", &get_CC_axis_offset, &set_CC_axis_offset)
897903
.add_property("CC_current", &get_CC_current, &set_CC_current)
898904
.add_property("CC_origin_offset", &get_CC_origin_offset, &set_CC_origin_offset)
905+
.add_property("active_spindle", &get_active_spindle, &set_active_spindle)
899906
.add_property("axis_offset_x", &get_axis_offset_x, &set_axis_offset_x)
900907
.add_property("axis_offset_y", &get_axis_offset_y, &set_axis_offset_y)
901908
.add_property("axis_offset_z", &get_axis_offset_z, &set_axis_offset_z)
@@ -920,7 +927,6 @@ BOOST_PYTHON_MODULE(interpreter) {
920927
.add_property("program_z", &get_program_z, &set_program_z)
921928
.add_property("return_value", &get_return_value, &set_return_value)
922929
.add_property("rotation_xy", &get_rotation_xy, &set_rotation_xy)
923-
.add_property("speed", &get_speed, &set_speed)
924930
.add_property("traverse_rate", &get_traverse_rate, &set_traverse_rate)
925931
.add_property("u_axis_offset", &get_u_axis_offset, &set_u_axis_offset)
926932
.add_property("u_origin_offset", &get_u_origin_offset, &set_u_origin_offset)
@@ -974,6 +980,14 @@ BOOST_PYTHON_MODULE(interpreter) {
974980

975981

976982
// _setup arrays
983+
.add_property(
984+
"speed",
985+
bp::make_function(
986+
spindle_speed_w(&spindle_speed_wrapper),
987+
bp::with_custodian_and_ward_postcall<0, 1>()
988+
)
989+
)
990+
977991
.add_property( "active_g_codes",
978992
bp::make_function( active_g_codes_w(&active_g_codes_wrapper),
979993
bp::with_custodian_and_ward_postcall< 0, 1 >()))

src/emc/rs274ngc/pyarrays.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ void export_Arrays()
3939
using namespace boost::python;
4040
using namespace boost;
4141

42+
pp::register_array_1<double, EMCMOT_MAX_SPINDLES>("SpindleSpeedArray");
4243
pp::register_array_1< int, ACTIVE_G_CODES> ("ActiveGcodesArray" );
4344
pp::register_array_1< int, ACTIVE_M_CODES> ("ActiveMcodesArray" );
4445
pp::register_array_1< double, ACTIVE_SETTINGS> ("ActiveSettingsArray");

tests/remap/spindle/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test remap's ability to introspect about spindles.

tests/remap/spindle/expected

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
executing
2+
1 N..... USE_LENGTH_UNITS(CANON_UNITS_MM)
3+
2 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
4+
3 N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
5+
4 N..... SET_XY_ROTATION(0.0000)
6+
5 N..... SET_FEED_REFERENCE(CANON_XYZ)
7+
6 N..... ON_RESET()
8+
M500 P0 {
9+
active spindle: 0
10+
spindle speeds: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
11+
}
12+
7 N..... SET_SPINDLE_SPEED(0, 1000.0000)
13+
8 N..... START_SPINDLE_CLOCKWISE(0)
14+
M500 P1 {
15+
active spindle: 0
16+
spindle speeds: [1000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
17+
}
18+
9 N..... SET_SPINDLE_SPEED(1, 2000.0000)
19+
10 N..... START_SPINDLE_COUNTERCLOCKWISE(1)
20+
M500 P2 {
21+
active spindle: 0
22+
spindle speeds: [1000.0, 2000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
23+
}
24+
11 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
25+
12 N..... SET_XY_ROTATION(0.0000)
26+
13 N..... SET_FEED_MODE(0, 0)
27+
14 N..... SET_FEED_RATE(0.0000)
28+
15 N..... STOP_SPINDLE_TURNING(0)
29+
16 N..... SET_SPINDLE_MODE(0 0.0000)
30+
17 N..... STOP_SPINDLE_TURNING(1)
31+
18 N..... SET_SPINDLE_MODE(1 0.0000)
32+
19 N..... STOP_SPINDLE_TURNING(2)
33+
20 N..... SET_SPINDLE_MODE(2 0.0000)
34+
21 N..... PROGRAM_END()
35+
22 N..... ON_RESET()

tests/remap/spindle/remap.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from __future__ import print_function
2+
3+
def m500(self, **words):
4+
print("M500 P{} {{".format(int(words['p'])))
5+
print(" active spindle: ", self.active_spindle)
6+
print(" spindle speeds: ", list(self.speed))
7+
print("}")

tests/remap/spindle/test.ini

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[EMC]
2+
DEBUG=0
3+
4+
[RS274NGC]
5+
SUBROUTINE_PATH = .
6+
LOG_LEVEL=0
7+
REMAP= M500 py=m500 modalgroup=10 argspec=P
8+
9+
[TRAJ]
10+
SPINDLES=3
11+
12+
[PYTHON]
13+
PATH_PREPEND=.
14+
TOPLEVEL=toplevel.py

0 commit comments

Comments
 (0)