Set blockheight via python
- MatthiasF1210
- Offline
- Junior Member
Less
More
- Posts: 37
- Thank you received: 0
16 Mar 2019 20:14 #128768
by MatthiasF1210
Set blockheight via python was created 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
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.
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.
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.
17 Mar 2019 08:56 #128802
by newbynobi
Replied by newbynobi on topic Set blockheight via python
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
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.
- MatthiasF1210
- Offline
- Junior Member
Less
More
- Posts: 37
- Thank you received: 0
17 Mar 2019 11:23 #128812
by MatthiasF1210
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:
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
Replied by MatthiasF1210 on topic Set blockheight via python
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.
17 Mar 2019 20:47 #128853
by newbynobi
Replied by newbynobi on topic Set blockheight via python
Yes, that is correct, but you may need to adapt the calculation.
Norbert
Norbert
Please Log in or Create an account to join the conversation.
- MatthiasF1210
- Offline
- Junior Member
Less
More
- Posts: 37
- Thank you received: 0
02 Apr 2019 19:27 #130170
by MatthiasF1210
Replied by MatthiasF1210 on topic Set blockheight via python
Hi,
after some efforts I finallized my script. In the simulation it works fine, but not at the real machine ;(
here is the relevant code from my script:
When I Set the blockheight with this Code, all the G54 Codes seems to be set right. In the Simulation oll the calculations are ok. If I move to the real machine the code is working well for measuring and setting blockheight.
But when I start my Testprogramm with the autotoolchager, the tool compensation is not working and the tool is not stopping at the correct height (it's going to much lower z values)
If I just set the Blockheight manually, the testprogramm works fine.
It seems to me that nothing is "saved" when I use my script.
Any Ideas?
Matthias
after some efforts I finallized my script. In the simulation it works fine, but not at the real machine ;(
here is the relevant code from my script:
origin = self.inifile.find("AXIS_2", "MIN_LIMIT")
# calculate absolute position from blockheight
a = self.probed_position_with_offsets()
blockheight = a[2]
probeheight = self.prefs.getpref("probeheight", 0, float)
origin = float(origin) + blockheight
self.prefs.putpref("blockheight", blockheight, float)
self.prefs.putpref("probeheight", probeheight, float)
# set koordinate system to new origin
self.command.mode( linuxcnc.MODE_MDI )
self.command.wait_complete()
self.command.mdi( "G10 L2 P0 Z%s" % origin )
self.command.mode( linuxcnc.MODE_MANUAL )
self.command.wait_complete()
When I Set the blockheight with this Code, all the G54 Codes seems to be set right. In the Simulation oll the calculations are ok. If I move to the real machine the code is working well for measuring and setting blockheight.
But when I start my Testprogramm with the autotoolchager, the tool compensation is not working and the tool is not stopping at the correct height (it's going to much lower z values)
If I just set the Blockheight manually, the testprogramm works fine.
It seems to me that nothing is "saved" when I use my script.
Any Ideas?
Matthias
Please Log in or Create an account to join the conversation.
02 Apr 2019 20:44 #130173
by newbynobi
Replied by newbynobi on topic Set blockheight via python
Your code is strange, you read probeheight and you set it again, but you did not modify it. So it will be unchanged.
Do you issue a G43 after the tool change?
It is done automatically in the sim! But will not in your config if you changed the remap!
Norbert
Do you issue a G43 after the tool change?
It is done automatically in the sim! But will not in your config if you changed the remap!
Norbert
Please Log in or Create an account to join the conversation.
- MatthiasF1210
- Offline
- Junior Member
Less
More
- Posts: 37
- Thank you received: 0
03 Apr 2019 04:57 #130185
by MatthiasF1210
Replied by MatthiasF1210 on topic Set blockheight via python
Yes I know, this is a left over from Testing. Probeheight does not change anyway.Your code is strange, you read probeheight and you set it again, but you did not modify it. So it will be unchanged.
Yes I think so, will check the Maschine tonight. But the Testprogramm works perfekt if I use manual Setting blockheight.Do you issue a G43 after the tool change?
It is done automatically in the sim! But will not in your config if you changed the remap
Please Log in or Create an account to join the conversation.
- MatthiasF1210
- Offline
- Junior Member
Less
More
- Posts: 37
- Thank you received: 0
04 Apr 2019 19:25 #130307
by MatthiasF1210
Replied by MatthiasF1210 on topic Set blockheight via python
Hi,
after a lot of test at the machine and reading thrue all that code, I have an Idea wath the error could be.
@newbynobi
Can it be that the tool change program uses the hal pin blockheight?
This is my only posible explaination. If I use my new script this testprogram:
the machine allways stops 2mm above the table surface (with tool 200, 2008). When I use the same Testprogramm after I manually edited the Blockheigt via the gmoccapy button, everthing works fine.
While I'am writing this I found the
inside change.ngc.
As gmoccapy.blockheight is an output, I can't write it... So I have to add a workarount to change.ngc
after a lot of test at the machine and reading thrue all that code, I have an Idea wath the error could be.
@newbynobi
Can it be that the tool change program uses the hal pin blockheight?
This is my only posible explaination. If I use my new script this testprogram:
%
(Test File Auto Tool Measure)
N10 G64 P0.015 (Setzen des Path Blending)
N15 G90 G94 G17 G91.1
N20 G21
N25 G28 G91 Z0.
N30 G90
(BOHREN2)
N17455 M1
N17460 T200 M6
N17465 T2008
N17470 S2865 M3
N17475 G54
N17480 G0 X10. Y-10.
N17485 G43 Z15. H200
N17490 G0 Z5.
N17495 Z2.
N17500 M0
N17590 Z15.
N17595 M5
N17600 G28 G91 Z0.
N17605 G90
(2D FASE1)
N17610 M1
N17615 T2008 M6
N17620 T2004
N17625 S7500 M3
N17630 G54
N17635 G0 X10 Y-10
N17640 G43 Z15. H2008
N17645 G0 Z5.
N17650 Z2
N17655 M0
N17720 G0 Z15.
N17725 G28 G91 Z0.
N17730 G90
N17735 M30
%
the machine allways stops 2mm above the table surface (with tool 200, 2008). When I use the same Testprogramm after I manually edited the Blockheigt via the gmoccapy button, everthing works fine.
While I'am writing this I found the
#<blockheight> = #<_hal[gmoccapy.blockheight]>
As gmoccapy.blockheight is an output, I can't write it... So I have to add a workarount to change.ngc
Please Log in or Create an account to join the conversation.
07 Apr 2019 09:00 - 07 Apr 2019 09:01 #130433
by newbynobi
Replied by newbynobi on topic Set blockheight via python
You do not need to use blockheight!
You can do everythink you like just with hal and your own remap file, in this case change.ngc.
You ngc code is IMHO a mess,
First you change to tool 200 with T200 M6
after that you prepare tool 2008, what is OK, but why do you mix around with G43, Z values and H values
Just do you code as follows and it will be more readable:
G43 : without an H word uses the currently loaded tool from the last Tn M6.
Do you use wear offsets? (such large tool numbers are not common)
Norbert
You can do everythink you like just with hal and your own remap file, in this case change.ngc.
You ngc code is IMHO a mess,
N17460 T200 M6
N17465 T2008
N17470 S2865 M3
N17475 G54
N17480 G0 X10. Y-10.
N17485 G43 Z15. H200
First you change to tool 200 with T200 M6
after that you prepare tool 2008, what is OK, but why do you mix around with G43, Z values and H values
Just do you code as follows and it will be more readable:
T200 M6
G43
T2008
S2865 M3
G54
G0 X10. Y-10. Z15
G43 : without an H word uses the currently loaded tool from the last Tn M6.
Do you use wear offsets? (such large tool numbers are not common)
Norbert
Last edit: 07 Apr 2019 09:01 by newbynobi.
Please Log in or Create an account to join the conversation.
Time to create page: 0.112 seconds