Hello,
I'm trying to remap the S command in python as I have to do some gear-changing before starting the spindle. To get going I started with the original sim.gmoccapy configuration and the gmoccapy.ini file shipping with 2.8.1.
The only modifications I did to the gmoccapy.ini are adding the entire [PYTHON] section as well as the REMAP=S line:
Code:
[PYTHON]
# import the following Python module
TOPLEVEL= ./python/toplevel.py
# add the directory above
PATH_PREPEND= ./python
# reload on change (debug only, creates overhead)
#RELOAD_ON_CHANGE=1
# the higher the more verbose tracing of the Python plugin
LOG_LEVEL = 8
# Task controller section -----------------------------------------------------
[RS274NGC]
RS274NGC_STARTUP_CODE = G17 G21 G40 G43H0 G54 G64P0.005 G80 G90 G94 G97 M5 M9
PARAMETER_FILE = sim.var
SUBROUTINE_PATH = macros
REMAP=S python=setspeed
Further I defined the following very basic python remap function:
Code:
def setspeed(self, **words):
try:
c = self.blocks[self.remap_level]
if not c.s_flag:
self.set_errormsg("S requires a value")
return INTERP_ERROR
self.params["speed"] = c.s_number
emccanon.enqueue_SET_SPINDLE_SPEED(0, c.s_number)
return INTERP_OK
except Exception, e:
self.set_errormsg("Setspeed: %s" % (e))
return INTERP_ERROR
So this basically should not do anything beyond forward the value of the S-command. In GMOCCAPY I now have the following behavior:
1. When i issue in MDI S1000 and then manually start the spindle by clicking the corresponding icon, the spindle is started with S450 indicated in the G-code panel. Any S-command issued subsequently when the spindle is running is also ignored.
2. When I issue in MDI S1000 and then M3 to start the spindle the S1000 shows up for a split-second in the G-code panel but then is overwritten again with S450. When I then issue again S1000 the G-code panel changes and also indicates S1000. When I then stop the spindle with M5 the S1000 stays indicated in the G-code panel. However if I then restart again with M3 it goes back to S450.
The speeds seen on spindle.0.speed-cmd-rps seem to be consistent with what is indicated in the G-code panel. The behavior described in point 2 sometimes (but not always) disappears when I'm running Halshow in parallel.
Some additional info: I did the same modification to an out-of-the box sim.axis configuration.
Point 1 persists also with Axis with the only difference that it always goes to S1 and whereas Gmoccapy uses G450 and point 1 even persists without any remapping. Therefore seems to be a normal linuxcnc behavior which does not make any sense to me... But I'm happy to learn better...
Point 2 works with Axis without any problems.
Best regards,
Marc
PS: not an issue but a wish: I think the G-code panel should show the S value as soon as one is set by the S-command and not only when a M3/M4 is issued. Especially with gear-driven spindles it is nice to know where you are...