Jogging with a four way joystick in normal jog-speed and rapid speed

More
18 Sep 2020 08:44 #182622 by Scuba-Mania
Hello to everyone,
i'm trying to convert a Weiler 120 CNC lathe with LinuxCNC in a modern cycle lathe.
Actually i'm in the test phase with flying wired 7i76e.No motors connected (are in delivery from china).
All my wishes seems to work (four potentiometers, two mpgs, two direction switch for the spindle cw and ccw, a four direction joystick for manually movement of the two axis and a nice surface with the macros for cycles).
But my problem is, that the joystick have two switches for each direction. And i want to use both of them.
I want to use the first switch (it is snapping in) for slow moving depending on my potentiometer (for jog-speed). It is working perfect.
The second switch of each direction should be for fast jogging in max jog-speed. This switch comes in addition to the existing switch.
That means: one switch drives the axis slowly (working), two switches together should drive the axis fast (not working).
I don't know how to implement this in the HAL file.
Should i use one input for all four switches or one input for each to drive fast?
Any idea?
Thanks
Sascha

(sorry if my English is not so good, I am from Germany, Deepl is helping)

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

More
18 Sep 2020 09:34 #182625 by Scuba-Mania
Additional Informations:
I'm using LinuxCNC in version 2.8. Axis is my actual screen.
And if it helps, i've attached my complete configuration.
Attachments:

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

More
18 Sep 2020 12:15 - 18 Sep 2020 12:27 #182637 by BeagleBrainz
Have you had a look at this component ?
linuxcnc.org/docs/2.8/html/man/man9/mux4.9.html to pick the speed either fast or slow.

The two switches on each axis go to the MUX to select the speed and to a OR gate to create the jog signal.

The input to the "slow input" to the MUX could from your logic, the "fast input" to the MUX could be fixed or created by manipulating the slow speed selection, either adding an offest or multiplication factor.

You could even write a simple comp that combines the two functions of the MUX and OR gate. Thereby only having to send signals to one "black box"
Last edit: 18 Sep 2020 12:27 by BeagleBrainz.
The following user(s) said Thank You: Scuba-Mania

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

More
19 Sep 2020 05:50 #182708 by Scuba-Mania
Hello BeagleBrainz,
thanks for jour Answer.
I will try it on monday. But it is very difficult for a newbee like me. All functions i used coming from other users, i‘ve put them only together.
Do you have maybe a example for me?
Sascha

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

More
19 Sep 2020 07:58 #182715 by BeagleBrainz
No not really, but writing simple user comps are quite easy, if you have a basic knowledge of C you shouldn't have too much trouble.
The docs have some really simple examples that you can build on from.

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

More
21 Sep 2020 08:01 #183098 by Scuba-Mania
I've tried some AND and OR additions:

# ALT:
#setp hm2_7i76e.0.7i76.0.0.analogin3-scalemax 400
#net halui.maxjoganalog <= hm2_7i76e.0.7i76.0.0.analogin3 => halui.axis.jog-speed


# NEW:
loadrt mux4 count=1
loadrt or2 count=2
addf mux4.0 servo-thread
addf or2.0 servo-thread
addf or2.1 servo-thread
addf and2.1 servo-thread
addf and2.2 servo-thread
addf and2.3 servo-thread
addf and2.4 servo-thread

# Analog input
setp mux4.0.in0 hm2_7i76e.0.7i76.0.0.analogin3
#fixed vaiue for fast jogging
setp mux4.0.in1 800

#first switch for each diretion
net select1 or2.1.in0 <= hm2_7i76e.0.7i76.0.0.input-06
net select2 or2.1.in1 <= hm2_7i76e.0.7i76.0.0.input-07
net select3 or2.1.in2 <= hm2_7i76e.0.7i76.0.0.input-08
net select4 or2.1.in3 <= hm2_7i76e.0.7i76.0.0.input-09

#first + second switch for each direction
net select9 and2.1.in0 <= hm2_7i76e.0.7i76.0.0.input-06
net select10 and2.1.in1 <= hm2_7i76e.0.7i76.0.0.input-25
net select11 and2.2.in0 <= hm2_7i76e.0.7i76.0.0.input-07
net select12 and2.2.in1 <= hm2_7i76e.0.7i76.0.0.input-26
net select13 and2.3.in0 <= hm2_7i76e.0.7i76.0.0.input-08
net select14 and2.3.in1 <= hm2_7i76e.0.7i76.0.0.input-27
net select15 and2.4.in0 <= hm2_7i76e.0.7i76.0.0.input-09
net select16 and2.4.in1 <= hm2_7i76e.0.7i76.0.0.input-28

#second switch addition
net select5 or2.0.in0 <= and2.1.out
net select6 or2.0.in1 <= and2.2.out
net select7 or2.0.in2 <= and2.3.out
net select8 or2.0.in3 <= and2.4.out

net scale1 mux4.0.sel0 <= or2.0.out
net scale2 mux4.0.sel1 <= or2.1.out

net mpg-scale <= mux4.0.out
net halui.maxjoganalog <= mpg-scale => halui.axis.jog-speed


If my brain wasn't damaged by so much ANDs and ORs it should be working, right? Actually I can't try it, it is only some mental acrobatics.
The logics behind:
Switch X+ or X- or Z+ or Z- -> slow speed depending on my potentiometer
Switch (X+ and X++) or (X- and X--) or (Z+ and Z++) or (Z- and Z--) -> fast fixed speed.
X+ is the first switch of one direction for example, X++ is the second switch which switches additionally.

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

More
21 Sep 2020 10:18 #183112 by Scuba-Mania
And it will not work.
First: AND and OR can only handle two signals. I've tried to fix this. Not the best solution, but don't know better.
Second: MUX4.0.in0 will have float:
setp mux4.0.in0 hm2_7i76e.0.7i76.0.0.analogin3
brings hm2_7i76e.0.7i76.0.0.analogin3 invalid for float. How can i convert this?
Third: How can i use signals from my inputs on several places?
I used .input-06 for moving the axis X in pos direction, but i need this signal also for changing jog speed.


Here is what i've now tried.

# NEW:
loadrt mux4 count=1
loadrt or2 count=8
addf mux4.0 servo-thread

addf or2.0 servo-thread
addf or2.1 servo-thread
addf or2.2 servo-thread
addf or2.3 servo-thread
addf or2.4 servo-thread
addf or2.5 servo-thread
addf or2.6 servo-thread

addf and2.1 servo-thread
addf and2.2 servo-thread
addf and2.3 servo-thread
addf and2.4 servo-thread


# Analog input
setp mux4.0.in0 hm2_7i76e.0.7i76.0.0.analogin3
#fixed value for fast jogging
setp mux4.0.in1 800

#first switch for each diretion
net select1.1 or2.1.in0 <= hm2_7i76e.0.7i76.0.0.input-06
net select1.2 or2.1.in1 <= hm2_7i76e.0.7i76.0.0.input-07
net select2.1 or2.2.in0 <= hm2_7i76e.0.7i76.0.0.input-08
net select2.1 or2.2.in1 <= or2.1.out
net select3.1 or2.3.in0 <= hm2_7i76e.0.7i76.0.0.input-09
net select3.1 or2.3.in1 <= or2.2.out

#first + second switch for each direction
net select9 and2.1.in0 <= hm2_7i76e.0.7i76.0.0.input-06
net select10 and2.1.in1 <= hm2_7i76e.0.7i76.0.0.input-25
net select11 and2.2.in0 <= hm2_7i76e.0.7i76.0.0.input-07
net select12 and2.2.in1 <= hm2_7i76e.0.7i76.0.0.input-26
net select13 and2.3.in0 <= hm2_7i76e.0.7i76.0.0.input-08
net select14 and2.3.in1 <= hm2_7i76e.0.7i76.0.0.input-27
net select15 and2.4.in0 <= hm2_7i76e.0.7i76.0.0.input-09
net select16 and2.4.in1 <= hm2_7i76e.0.7i76.0.0.input-28

#second switch addition
net select4.1 or2.4.in0 <= and2.1.out
net select4.2 or2.4.in1 <= and2.2.out
net select5.1 or2.5.in0 <= and2.3.out
net select5.2 or2.5.in1 <= or2.4.out
net select6.1 or2.6.in0 <= and2.4.out
net select6.2 or2.6.in1 <= or2.5.out

net scale1 mux4.0.sel0 <= or2.3.out
net scale2 mux4.0.sel1 <= or2.6.out

net mpg-scale <= mux4.0.out
net halui.maxjoganalog <= mpg-scale => halui.axis.jog-speed

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

More
21 Sep 2020 10:33 #183115 by BeagleBrainz
Maybe not of help to your particular application but this should give you the basic structure of a user comp
forum.linuxcnc.org/media/kunena/attachme...536/mpg_pendant.comp

Rather than using multiple components you can lump everything into a blackbox.

Have look through and I'll try and answer any questions.

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

More
21 Sep 2020 11:56 #183122 by Scuba-Mania
Thanks for your help. I'll have a look at them
but actually (except the analog signal with the MUX2) it works fine.
It was simpler than i thought with MUX2 and only one of the signals from each direction from my joystick.
I can jog (actually with fixed values) with my joystick in all directions in normal speed and in fast speed.
Also the jog-display shows the value i choose with the joystick.
I'm very happy.

My last problem is to get the analog input to the MUX2.
I've tried this, but it will not work.

# Analog input
# net halui.maxjoganalog <= hm2_7i76e.0.7i76.0.0.analogin3 => conv_float_s32.maxjog.in
(first try)
net convert conv_float_s32.maxjog.in <= hm2_7i76e.0.7i76.0.0.analogin3
#setp mux2.0.in0 conv_float_s32.maxjog.out
will show "conv_float_s32.maxjog.in invalid for flow"
setp mux2.0.in0 100 i set it to fixed value to try the rest
#fixed value for fast jogging
setp mux2.0.in1 800


What mistake have i made?
Attachments:

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

More
21 Sep 2020 12:47 #183128 by BeagleBrainz
My reading of he hal docs I would write the code as such
    #signal      source                            destination 
net convert      hm2_7i76e.0.7i76.0.0.analogin3    conv_float_s32.maxjog.in

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

Time to create page: 0.358 seconds
Powered by Kunena Forum