USB pendant button to zero axis

More
10 months 2 weeks ago #340224 by frayja2002
Hi all

I have a DragonRise USB board that I am using for a pendant.
Currently I press and hold a button for the speed & then an X Y or Z axis button to jog.

I would like to be able press a zero button & one of the axis to zero that one.

I did see this code for the ini file....
[HALUI]
# add halui MDI commands here (max 64)
MDI_COMMAND = "G10 L20 P0 X0"
MDI_COMMAND = "G10 L20 P0 Y0"
MDI_COMMAND = "G10 L20 P0 Z0"

but I am not sure how to call it from my hal file.

I have attached my ini & the USB part of the hal file.
Any pointers in the right direction would be appreciated.

Thnks
Alex.

After mucking about for a while I would like to be able to do something like this (i think)

#
setp zero-mux4.in0     99             # Setting this input  prevents motion unless one of the other buttons is pressed.
setp zero-mux4.in1     02             # Zero X
setp zero-mux4.in2     03             # Zero Y
setp zero-mux4.in3     04             # Zero Z

net zero-btn0        <= zero-mux4.sel0    <= input.0.btn-base
net zero-btn1        <= zero-mux4.sel1    <= input.0.btn-trigger

#net zero-axis         => zero-mux4.out    => halui.mdi-command-(zero-mux4.out)

Does this sound like how it should be done.

 

Please Log in to join the conversation.

More
10 months 1 week ago #340255 by Todd Zuercher
 
I don't think you want to use the Mux4 component. It is for setting an output to one of 4 numeric values. I think you would want to use multiple And2 components. Also you have the the Halui MDI Hal pin names wrong. To call the first Halui MDI command in your INI file's list the Hal pin name should be "halui.mdi-command-00" and the 2nd would be "halui.mdi-command-01"...

To do it you'd need to put the following lines in your hal file.  Assuming your button output pin names are "input.0.btn" for the zero button, "input.x.btn" for the X button, "input.y.btn" for the Y button, and "input.z.btn" for the Z button.  And since your INI file already has 6 Halui MDI commands listed, adding 3 more to zero each axis would be.
Code:
loadrt  and2  counts=3 addf  and2.0  servothread addf  and2.1  servothread addf  and2.2  servothread net zero-btn  <= input.0.btn  =>  and2.0.in0  =>  and2.1.in0  =>  and2.2.in0 net x-btn  <=  input.x.btn  =>  and2.0.in1 net y-btn  <=   input.y.btn  =>  and2.1.in1 net z-btn  <=  input.z.btn  =>  and2.2.in1 net zero-x  <=  and2.0.out  =>  halui.mdi-command-06 net zero-y  <=  and2.1.out  =>  halui.mdi-command-07 net zero-z  <=  and2.2.out  =>  halui.mdi-command-08

That said, if you are wanting to use a button input that is already used elsewhere in your hal file that is ok.  Simply either use that hal signal name to connect the appropriate and2.N.in1 to it, or add the and2.N.in1 to the existing net line.
 

Please Log in to join the conversation.

More
10 months 1 week ago #340262 by frayja2002
Thanks for that.

With a bit of fiddling I have some code that is doing the job....
My halui was set up like this

[HALUI]
# add halui MDI commands here (max 64)
MDI_COMMAND = O<b01-go_to_switches> call
MDI_COMMAND = O<b02-go_to_wco> call
MDI_COMMAND = G10 L20 P0 X0 # zero x axis
MDI_COMMAND = G10 L20 P0 Y0 # zero y axis
MDI_COMMAND = G10 L20 P0 Z0 # zero z axis

and the code for the buttons ended up looking like this...

#
# Buttons to zero the axis of the machine.
#
addf AND-zero-x servo-thread
addf AND-zero-y servo-thread
addf AND-zero-z servo-thread

net zero-button <= input.0.btn-base3 => AND-zero-x.in0 => AND-zero-y.in0 => AND-zero-z.in0
net x-btn <= AND-zero-x.in1 <= input.0.btn-trigger
net y-btn <= AND-zero-y.in1 <= input.0.btn-thumb
net z-btn <= AND-zero-z.in1 <= input.0.btn-base

net zero-x <= AND-zero-x.out => halui.mdi-command-02
net zero-y <= AND-zero-y.out => halui.mdi-command-03
net zero-z <= AND-zero-z.out => halui.mdi-command-04

I'll post the files for anyone who is interested.

Thanks
Alex
 

Please Log in to join the conversation.

Time to create page: 0.086 seconds
Powered by Kunena Forum