Problem with: REMAP=S python=setspeed

More
05 Jun 2021 21:23 - 05 Jun 2021 21:36 #211249 by mwinterm
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:
[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:
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...
Last edit: 05 Jun 2021 21:36 by mwinterm.

Please Log in or Create an account to join the conversation.

More
06 Jun 2021 23:05 #211381 by andypugh
Is 450 set as a minimum speed in the gmoccapy config? I would suggest using grep, or a text editor (geany?) "find in files" to work out where "450" exists in your config.

I suspect that there might be a revs/min revs/second confusion at the root of this.

I would add some print() statements to the remap code (you will need to start linuxcnc from the command line to see the output) to see what is being passed in and what the remap is doing with it.

Please Log in or Create an account to join the conversation.

More
14 Jun 2021 20:22 #212053 by newbynobi
It is a known behavior. After you issued ones a s1000 M3, the spindle should run with 1000rpm if you enternow S2000 the spindle will turn with 2000 rpm. If it change back to 450 rpm, the speed is not set correctly. The 450 rpm can be adjusted on the settings page

Please Log in or Create an account to join the conversation.

More
06 Sep 2021 20:06 #219787 by mwinterm
Are there any plans to correct this behavior? Which area of Linuxcnc causes this behavior?

Please Log in or Create an account to join the conversation.

More
07 Sep 2021 01:30 #219808 by cmorley
In master the behaviour seems different.
I tested a sim with no remap though.

I can set S in mdi and m3 then m5 then m3 shows 1000 rpm
also setting s 1000 then pressing the spindle start button sets rpm at 1000

I did add some code a while back to allow the setting of S before m3/4
There are no plans to back port this code - nor am I positive this is a total cure for your problem.

Chris

Please Log in or Create an account to join the conversation.

Moderators: newbynobiHansU
Time to create page: 0.069 seconds
Powered by Kunena Forum