Hardware button to control qtdragon_hd

More
30 Jan 2024 21:37 - 31 Jan 2024 01:17 #292021 by echristley
My Bridgeport conversion has this control.


Originally, turn the oblong black knob left or right to get clockwise and counterclockwise spindle rotation.  The red button stopped a running program.  The black button would pause/step a program. 
I've wired these to my Mesa board so that:
  • red button triggers hm2_7i96s.0.gpio.001.in_not
  • black button triggers hm2_7i96s.0.gpio.002.in_not
  • knob left triggers [HMOT](CARD0).inm.00.input-03.
  • knob right triggers [HMOT](CARD0).inm.00.input-04
  • knob center triggers nothing

    Not sure why there are two pins from the Mesa giving the same value, but. . .
    I was able to find some HAL file snippets to make this mostly work in Gmocappy.  The knob controlled the spindle.  And then you could stop it via the UI.  I can pause and resume with the buttons or the UI at will (like, pause with the button, and resume with the UI).  I never really understood how all this stuff worked, but it worked (mostly).  What I want to do is build up the functionality iteratively, so that I understand what is going on.  The first step is the spindle knob.  Just looking at making it go forward.

    I understand that a mux (multiplexer?) is required.  A mux4 will output one of 4 values depending on the combination of two inputs. In my current setup,  there is a halui.spindle.0.runs-forward tied to sel0 in the mux.  I'm assuming spindle-manual-cw is tied to the halui.spindle.0.runs-forward somewhere in the bowels of GMOCAPPY.  After extensive searching with HalShow, I've come up with:
  • halui.spindle.0.runs-forward ==> spindle-forward-button
  • spindle-manual-cw ==> halui.spindle.0.forward
  • spindle.0.forward ==> spindle_cw
I don't see any connection from the spindle-manual-cw to the input of the mux.
But, it's working.  Turn the knob and the spindle runs, and the correct button lights up in qtdragon_hd.  Move the knob to center and it keeps running though. If I stop it via the UI, it will stop even if the knob is still set to run. 


IN BOSS3.HAL
# --- SPINDLE-MANUAL-CCW ---
net spindle-manual-ccw     <=  [HMOT](CARD0).inm.00.input-03

# --- SPINDLE-MANUAL-CW ---
net spindle-manual-cw     <=  [HMOT](CARD0).inm.00.input-04

IN custom_postgui.hal
loadrt mux4 count=1 
addf mux4.0 servo-thread

#stop
setp mux4.0.in0 5
#forward
setp mux4.0.in1 1
#reverse
setp mux4.0.in2 2
#fault reset
setp mux4.0.in3 7

net spindle_forward_button halui.spindle.0.runs-forward => mux4.0.sel0
net spindle_rev_button halui.spindle.0.runs-backward => mux4.0.sel1
net spindle_commanded_state mux4.0.out => mb2hal.spindle_set.target_state

 
Attachments:
Last edit: 31 Jan 2024 01:17 by echristley.

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

More
30 Jan 2024 21:49 - 31 Jan 2024 01:20 #292024 by echristley
The next step is to get the program manipulation buttons working.  It's a complex network that I really don't understand, but combing through the HalShow signals has help.  Right now, pushing the buttons result in qtdragon switching to AUTO mode.  So, I'm off to a start (may not be a good one, but. . .).
Last edit: 31 Jan 2024 01:20 by echristley.

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

More
31 Jan 2024 18:27 #292088 by cmorley
How do you want the spindle switch to work with GUI controls? Most of the controls work by 'last comnand wins'. As they are supposed to be momentary signals.

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

More
01 Feb 2024 00:05 - 01 Feb 2024 00:05 #292112 by echristley
"Last wins" is kinda where I have to go. The knob triggers on the rising edge. If I leave it on forward or reverse, I can then use the GUI buttons to turn it off. In fact, moving the knob back to center does nothing. The only way to turn the spindle off is with the GUI button. Maybe I need to AND the NOTs of forward and reverse together, and have that trigger off?  Would I be able to start it from the GUI then?
Last edit: 01 Feb 2024 00:05 by echristley.

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

More
01 Feb 2024 07:08 #292123 by cmorley
Is there an electrical connection for the center knob?
probably not but then you could connect this to HALUI spindle off.

Or yes add logic to the fwd/rev inputs. You could use a mux or ladder logic or probably other HAL logic to set halui spindle stop if both fwd and rev are off. You should be able to turn off from the screen too - just the knob would indicate wrong.

properly planned external button control is something i should work on for qtdragon.

Chris

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

More
01 Feb 2024 15:07 #292138 by echristley
Adding the external button control to qtdragon MAY be simpler, or it MAY make the overall system more complicated. I think this can already be accomplished with halui.
Please, check my math here.
I have the inputs for forward and reverse tied to halui.spindle.0.forward, and halui.spindle.0.reverse. Halui repsonds to these pins on the RISING edge. The implication is that once turned on to either side, halui doesn't respond to the pin again.
Halui responds to that rising edge by setting halui.spindle.0.runs_forward and halui.spindle.0.runs_backward. I feed these into a mux4, which selects one of four given outputs based on the TRUE, FALSE combo. This value is tied to an mb2 component that pipes it to the VFD.
Given that, I need to update my HAL file with

loadrt and2 count=(1 + whatever was already there)
addf and2.N servo-thread
# --- SPINDLE-MANUAL-STOP ---
net spindle-manual-ccw-stop and2.1.in0 <= [HMOT](CARD0).inm.00.input-03-not
net spindle-manual-cw-stop and2.1.in1 <= [HMOT](CARD0).inm.00.input-04
net spindle-manual-stop and2.1.out => halui.spindle.0.stop

Considering that halui only responds on the rising edge, if I'm on either the forward or reverse setting, one of the and inputs will be false and the output will be false. When I move the knob back to center, the two nots will drive the and's output high, a rising edge, that will trigger halui to turn off both its runs_forward and runs_backward outputs.

From what I can see, qtdragon's forward and reverse buttons monitor runs_forward and runs_backward in order to highlight the buttons. By only responding to rising edges, halui makes it possible to have full control from either manual or gui interface.

Ooh! Fun. I get to run some experiments.

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

More
02 Feb 2024 00:22 - 02 Feb 2024 00:24 #292176 by echristley
Got it to work. In my main HAL file I have

# --- SPINDLE-MANUAL-CCW ---
net spindle-manual-ccw     <=  [HMOT](CARD0).inm.00.input-03
# --- SPINDLE-MANUAL-CW ---
net spindle-manual-cw     <=  [HMOT](CARD0).inm.00.input-04

net spindle-manual-cw halui.spindle.0.forward
net spindle-manual-ccw halui.spindle.0.reverse
net spindle-manual-stop halui.spindle.0.stop

I'm pretty sure that was there from the original configuration. In my custom_postgui.hal, I have

loadrt mux4 count=1
loadrt and2 count=5

# --- spindle control box setup ---
addf mux4.0 servo-thread

#use mux to send one of four values to vfd
#stop
setp mux4.0.in0 5
#forward
setp mux4.0.in1 1
#reverse
setp mux4.0.in2 2
#fault reset
setp mux4.0.in3 7

net spindle_forward_button halui.spindle.0.runs-forward => mux4.0.sel0
net spindle_rev_button halui.spindle.0.runs-backward => mux4.0.sel1
addf and2.4 servo-thread
net spindle_manual_ccw_stop and2.4.in0 <= [HMOT](CARD0).inm.00.input-03-not
net spindle_manual_cw_stop and2.4.in1 <= [HMOT](CARD0).inm.00.input-04-not
net spindle-manual-stop <= and2.4.out


I'll post a video of it working "real soon now".
Last edit: 02 Feb 2024 00:24 by echristley.

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

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