How to add buttons at interface Axis?

More
17 Mar 2022 08:40 #237522 by Nest
hi, i want to add two buttons at Axis interface, i want to add the probe touch button and button go to position cero of piece. Is difficult to add that buttons?
thanks you

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

More
17 Mar 2022 09:03 #237523 by phillc54
There are some customization hints in the documents 
linuxcnc.org/docs/2.8/html/gui/axis.html...d_a_goto_home_button

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

More
21 Mar 2022 19:44 #237949 by Nest
Hi, where do you add that code?

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

More
21 Mar 2022 22:53 #237972 by phillc54
From the same document:
linuxcnc.org/docs/2.8/html/gui/axis.html#_axisrc

I would recommend 12.4: USER_COMMAND_FILE
The following user(s) said Thank You: Nest

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

More
22 Mar 2022 08:30 #238001 by Nest
The information in this document is not clear, it is very difficult to understand.
thanks for your help

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

More
22 Mar 2022 12:30 #238007 by robertspark
create a document and call it

usercommand.py

save it within your config file for your machine (~/linuxcnc/config/ ...... whatever your machine is called

open up your configuration ini file and under the display section add:

[DISPLAY]
USER_COMMAND_FILE = usercommand.py

open the usercommand.py file in Geany and edit it to add the following code:
def goto_home(axis):
    if s.interp_state == linuxcnc.INTERP_IDLE:
        home = inifile.find('JOINT_' + str(inifile.find('TRAJ', 'COORDINATES').upper().index(axis)), 'HOME')
        mode = s.task_mode
        if s.task_mode != linuxcnc.MODE_MDI:
            c.mode(linuxcnc.MODE_MDI)
        c.mdi('G53 G0 ' + axis + home)

# make a button to home y axis
root_window.tk.call('button','.pane.top.tabs.fmanual.homey','-text','Home Y','-command','goto_home Y','-height','2')

# place the button
root_window.tk.call('grid','.pane.top.tabs.fmanual.homey','-column','1','-row','7','-columnspan','2','-padx','4','-sticky','w')

# any function called from tcl needs to be added to TclCommands
TclCommands.goto_home = goto_home
commands = TclCommands(root_window)

as taken from here:
linuxcnc.org/docs/devel/html/gui/axis.ht...d_a_goto_home_button

you can edit this section / add more lines to get the button to do whatever you want:

c.mdi('G53 G0 ' + axis + home)

Also

edit this section to give the button a custom name to your needs
# make a button to home y axis
root_window.tk.call('button','.pane.top.tabs.fmanual.homey','-text','Home Y','-command','goto_home Y','-height','2')

if you have not done it before you will need to test it a few times, but its all part of learning.

you can add another button then the same way
The following user(s) said Thank You: andypugh, cakeslob, Nest

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

More
26 Mar 2022 19:14 #238417 by Nest
hello, I have already added two buttons to my AXIS
I have used the MDI format
1º I installed nativecam with this manual video


2º in the folder where the configuration of your machine is, there is a file called pyvcp-panel.xml, in that file is the spindle speed display, we add the buttons that we are going to use, for example one for home piece and test probe
<hbox>
        <relief>RAISED</relief>
        <bd>5</bd>            
             <button>
                       <halpin>"zeropiece"</halpin>
                       <text>"Home Pieza"</text>
                       <font>('Fixed',11)</font>
                       <width>10</width>
             </button>
        </hbox>

        <hbox>
        <relief>RAISED</relief>
        <bd>5</bd>            
            <button>
                      <halpin>"touchplate"</halpin>
                      <text>"Sonda Probe"</text>
                      <font>('Fixed',11)</font>
                      <width>10</width>
            </button>
        </hbox>


3º in the same folder of the previous step in the .ini file of your configuration, the mine is CNC3040Z-DQ.ini we edit it, look for the [HAULI] section and add being that way
MDI_COMMAND = O <zero_piece> CALL
MDI_COMMAND = O <touch_plate> CALL

4º In the custom_postgui.hal file we add this
net remote-zero_piece halui.mdi-command-03 => pyvcp.zeropiece
net remote-sondazero halui.mdi-command-04 <= pyvcp.sondazero
if you look at halui.mdi-command-03 the 03 corresponds to the position of the command MDI_COMMAND in the file CNC3040Z-DQ.ini

start with 0, 1, 2, 3, 4 ....

When installing nativecam a folder is created where to put the custom configurations, the folder is in the path linuxcnc/configs/CNC3040Z-DQ/ncam/my-stuff/ inside that folder generate two new files, the first you call zero_piece.ngr and the second touch_plate.ngr


inside zero_piece.ngr type
O <zero_piece> sub
G90
G0 Z5   (coordenada z que queremos)
G0 X0 Y0    (coordenada X Y Z de la pieza)
O <zero_piece> endsub
M2

inside touch_plate.nrg type
O <touch_plate> sub
(*** GCode generated by NativeCAM for LinuxCNC ***)

(*.ngc files are best viewed with Syntax Highlighting)
(visit https://forum.linuxcnc.org/forum/20-g-code/30840-new-syntax-highlighting-for-gedit)
(or https://github.com/FernV/Gcode-highlight-for-Kate)

G21  (metric)
G17 G40 G49 G90 G92.1 G94 G54 G64 p0.001


#<center_drill_depth>       = -3.0

#<_pocket_expand_mode>      = 0

(optimization values)
#<_tool_eng1>               = 0.20
#<_tool_eng2>               = 0.30
#<_tool_eng3>               = 0.80

#<_feedfactor1>             = 1.60
#<_feedfactor2>             = 1.40
#<_feedfactor3>             = 1.25
#<_feedfactor4>             = 1.00
#<_feedfactor0>             = 1.00

#<_speedfactor1>            = 1.25
#<_speedfactor2>            = 1.25
#<_speedfactor3>            = 1.25
#<_speedfactor4>            = 1.00
#<_speedfactor0>            = 1.00

#<_probe_func>              = 38.4
#<_probe_feed>              = 200
#<_probe_latch>             = -1
#<_probe_latch_feed>        = 50
#<_probe_safe>              = 5.0
#<_probe_tip_dia>           = 3.0

#<_probe_tool_len_comp>     = 1
#<probe_height>             = 0
#<_tool_probe_z>            = 0.0

#<_off_rot_coord_system>    = 57

#<_mill_data_start>         = 70
#<in_polyline>              = 0

#<_has_z_axis>              = 1

#<_show_final_cuts>         = 1
#<_show_bottom_cut>         = 1

#<_spindle_all_time>        = 1

#<_spindle_speed_up_delay>  = 0.0

(end defaults)

#<_units_radius>            = 1  (for backward compatibility)
#<_units_width>             = 1  (for backward compatibility)
#<_units_cut_depth>         = 1  (for backward compatibility)

#<_tool_dynamic_dia>        = 0.0

(This is a built-in safety to help avoid gouging into your work piece)
/ o<safety_999> if [#<_show_final_cuts>]
/    o<safety_9999> repeat [1000]
/       M123
/       M0
/    o<safety_9999> endrepeat
/ o<safety_999> endif


(sub definitions)
(end sub definitions)


(begin Probe Surface)
(probe z and set author : Fernand Veilleux)

o<probe_surf_001_ena> if [1]
    o<probe> call [0] [0] [-1.000000]
    G10 L20 P#5220 Z[#<probe_height>]
    G0 Z[#<probe_height> + 55.000000]
    o<probe_surf_0010> if [1 EQ 1]
        M2
    o<probe_surf_0010> endif
o<probe_surf_001_ena> endif
(end Probe Surface)

O <thouch_plate> endsub
M2

Where did I get this code from? of nativecam, there are tutorials that teach how to handle nativecam, what I have done is generate a surface probe file and I have copied it in linuxcnc and pasted it inside touch_plate
The following user(s) said Thank You: RobC

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

More
26 Mar 2022 19:18 - 26 Mar 2022 19:22 #238419 by Nest
Last edit: 26 Mar 2022 19:22 by Nest.

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

Time to create page: 0.101 seconds
Powered by Kunena Forum