Button to toggle continuous jogging?

More
10 Sep 2020 01:24 #181536 by lllars
I would like to have a button that would toggle continuous jogging mode on/off.

I'm envisioning using this for quasi-manual machining, where I would set my desired step-over distance as the jog increment. Then toggle the continuous jog button and make a pass. Toggle the button back off and step over (or step down), then back on for the next pass.

I've got an ActionButton and can see how to set it to control Jog Increment. But I don't see how to set it for continuous jogging like can be selected in the JogIncrements widget.

Is there any easy way to do this? I am working with a modified version of QtDragon.

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

More
10 Sep 2020 01:27 #181537 by lllars
Another way to skin this cat could be to set up a separate JogIncrements widget for each axis. Then maybe X could be set for continuous, Y for a step-over, and Z for a step down. Is there a way to restrict a JogIncrements widget to just one axis?

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

More
10 Sep 2020 02:35 #181543 by cmorley
I think I have the principle behavior figured out:
In designer:
use an action button with no action. call it 'btn_toggle_continuous'
set the AbstractButton property 'checkable' true
set the ActionButton properties 'incr_imperial_number' and 'incr_mm_number' to 0
use designer slot editor: linuxcnc.org/docs/2.8/html/gui/qtvcp.htm...esigner_to_add_slots
to use the button signal clicked(bool) to call form function 'toggle_continuous_clicked()'

In the handler file add this to the call backs section:
    #######################
    # callbacks from form #
    #######################

    def toggle_continuous_clicked(self, state):
        if state:
            # record current linear increment
            self.L_incr = STATUS.get_jog_increment()
            self.L_text = STATUS.current_jog_distance_text
            # set continuous 
            self.w.btn_toggle_continuous.incr_action()
        else:
            # reset previously recorded increment
            ACTION.SET_JOG_INCR(self.L_incr, self.L_text)

For some reason the indicator option doesn't toggle nor does the indicated text - i'll check that out soon.

This is pretty cool - I'll probably write it up as a code snippet

Chris

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

More
10 Sep 2020 02:37 #181544 by cmorley
Jog increments are global settings currently.
In fact linuxcnc doesn't have an internally tracked increment setting -each GUI decides, so you could code a per axis increment but it would be tricky to incorporate with Qtvcp jog related widgets.

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

More
10 Sep 2020 04:17 #181548 by cmorley
The last code had a weakness - the continuous button only remembered the increments that were on when continuous was toggled on. if you changed increments it would remember the wrong increment setting.
This is better:
    # at this point:
    # the widgets are instantiated.
    # the HAL pins are built but HAL is not set ready
    def initialized__(self):
        STATUS.connect('jogincrement-changed', lambda w, d, t: self.record_jog_incr(d,t))
    def record_jog_incr(self,d, t):
        if d != 0:
            self.L_incr = d
            self.L_text = t
            # next line - only after update!
            #self.w.btn_toggle_continuous.safecheck(False)

    def toggle_continuous_clicked(self, state):
        if state:
            # set continuous 
            self.w.btn_toggle_continuous.incr_action()
        else:
            # reset previously recorded increment
            ACTION.SET_JOG_INCR(self.L_incr, self.L_text)

The commented out line can only be un-commented after updating linuxcnc - i added code to make this easier.

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

More
10 Sep 2020 23:17 #181686 by lllars
Thanks Chris, this is awesome! I've got it working (without updating linuxcnc), and it seems to work fine.

The only issue I noticed is if I set continuous mode and then unset it without ever having selected an increment (which is admittedly a dumb thing to do), then it gives me an error. I've got a workaround in place, though it is not very elegant:
STATUS.connect('jogincrement-changed', lambda w, d, t: self.record_jog_incr(d,t))
self.L_incr = 0.01
self.L_text = "0.01in"

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

More
10 Sep 2020 23:36 #181689 by cmorley
that's a perfectly valid way to fix that bug.
Thanks for the feedback.

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

More
15 Sep 2020 08:56 #182194 by hottabich

Thanks Chris, this is awesome! I've got it working (without updating linuxcnc), and it seems to work fine.
Please explain step by step how it works for you. I did everything as described above and I just switch to INCR mode, but not back and how do you set the interval? Thank you in advance!

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

More
15 Sep 2020 13:26 #182230 by lllars
I set the increment with a jogincrements widget. I don't see one of those on your setup, so maybe that is what is needed.

Your handler file and widget setup looks OK to me, but I'll attach mine for reference anyway.
Attachments:

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

More
15 Sep 2020 19:19 #182260 by hottabich
Thanks for your attention! Everything is the same but does not go back to cont. Since I don't see the meaning in this button therefore the question is closed.

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

Moderators: cmorley
Time to create page: 0.138 seconds
Powered by Kunena Forum