Set blockheight via python

More
16 Mar 2019 20:14 #128768 by MatthiasF1210
Hello,

I am writing a python script for touch probing the blockheight but can't find a way to set the value of the blockheight inside gmoccapy.

Any ideas?

Thanks

Matthias

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

More
16 Mar 2019 21:04 #128773 by rodw
Replied by rodw on topic Set blockheight via python
I'm not really good with Gcode but I think you would just touch off on the block manually and set G92 Zn. We do this with plasma machines every pierce. You may be able to program a gmoccapy macro button to help with the manual touchoff.

But maybe you can issue the G92 from within your python script with a hardcoded value. But once set, LinuxCNC should remember it between sessions.

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

More
17 Mar 2019 08:56 #128802 by newbynobi
Blockheight is a hal pin
Why not make a pin in your script and connect that one to blockheight in hal?

Otherwise just check gmoccapy.py for blockheight to see how it is handled.

I use a digital gauge connected to the machine through a BOBE keyboard usb interface and on the entry of blockheight i just push the data button on the gauge to transfer the value to gmoccapy.

May be that is also a possible way to go, just simulate the key button press event in your script.

Norbert

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

More
17 Mar 2019 11:23 #128812 by MatthiasF1210

Blockheight is a hal pin
Why not make a pin in your script and connect that one to blockheight in hal?


This was my first thought, but than i found out that the blockheight hal pin is an output. I want to set the blockheight....

I took a look in the gmoccapy.py an found the following:
def on_btn_block_height_clicked( self, widget, data = None ):
        probeheight = self.widgets.spbtn_probe_height.get_value()
        blockheight = dialogs.entry_dialog( self, data = None, header = _( "Enter the block height" ),
                                           label = _( "Block height measured from base table" ), integer = False )

        if blockheight == "CANCEL" or blockheight == "ERROR":
            return
        if blockheight != False or blockheight == 0:
            self.halcomp["blockheight"] = blockheight
            self.halcomp["probeheight"] = probeheight
            self.prefs.putpref( "blockheight", blockheight, float )
            self.prefs.putpref( "probeheight", probeheight, float )
        else:
            self.prefs.putpref( "blockheight", 0.0, float )
            self.prefs.putpref( "probeheight", 0.0, float )
            print( _( "Conversion error in btn_block_height" ) )
            dialogs.warning_dialog( self, _( "Conversion error in btn_block_height!" ),
                                   _( "Please enter only numerical values\nValues have not been applied" ) )

        # set koordinate system to new origin
        origin = self.get_ini_info.get_axis_2_min_limit() + blockheight
        self.command.mode( linuxcnc.MODE_MDI )
        self.command.wait_complete()
        self.command.mdi( "G10 L2 P0 Z%s" % origin )
        self.widgets.hal_action_reload.emit( "activate" )
        self.command.mode( linuxcnc.MODE_MANUAL )
        self.command.wait_complete()

So basicly I can use the code of the section "set koordinate sytem" in my script to make it work the same way. If no function inside linuxcnc uses the hal pin blockheight I can leave it unchanged for the moment....

Is that correct? I am not 100% sure how the auto_tool_measurement works inside gmoccapy

Thanks

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

More
17 Mar 2019 20:47 #128853 by newbynobi
Yes, that is correct, but you may need to adapt the calculation.

Norbert

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

Moderators: newbynobi
Time to create page: 0.088 seconds
Powered by Kunena Forum