(SOLVED) Max Velocity Selector Switch

More
24 Dec 2021 11:23 #229875 by spumco
I'd like to use a selector switch to set different max velocity values and could use some assistance.

I realize that I'll have to change the values in hal if/when I change the INI file setting, but I want the end result to be the equivalent of:

Position #1 - 0 ipm
Position #2 - 5 ipm
Position #3 - 10 ipm
Position #4 - 50 ipm
Position #5 - 100 ipm (same value as MAX in INI file)

Since I'm sure it'll be suggested...I've tried an encoder connected up as max-vel override, but there were two problems:
1. halui.max-velocity is an absolute value, not a percentage, and this drove me nuts.  Maybe I'm odd, but it was hard to think in ipm values and not just 'half-speed.'
2. I'm tired of having so many different voltages in the cabinet and I don't want to re-wire my 7i84 to be half 5v / half 24v just to use a single encoder.

I have a 5-position selector switch connected to 5 inputs.  So far, so good; I'm not trying to get clever and minimize the number of inputs.

Do I need to use a mux.N function, or is there some other way to accomplish a direct value input?

Thx,
Ralph

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

More
24 Dec 2021 17:03 #229903 by Michael
I just worked through something similar to this for an MPG but wanted my selector switch to also change the jog value and be useful for my jog increment buttons. I used mux16 because it was the easiest way to select 5 values without using a complex set of or2 statements. I did use an encoder for my max velocity but the mpg selector portion should be what you are looking for. I have yet to test my hal since I finished it right before leaving for work.

Some thoughts on implementing it for max-velocity would be to use the selector to manipulate the halui.max-velocity.scale as I didn't see anything other than halui.max-velocity.counts that was an input value. To do this you would need to use the halui.max-velocity.direct-value true. Thsi causes the input logic for the value to be (.counts * .scale)

If you did that then you could:
setp halui.max-velocity.counts 1

and then mux 16 different scale values for the selector switch. These values would be in percent of max ini value I believe:
setp mux16.0.in0 0.05 # this would be 5 ipm using your example.

Any way here is my relevant code I used:
# --- Max-Velocity Override ---

setp encoder.3.x4-mode 1

net max-vel-chA        <=  hm2_7i92.0.7i84.0.2.input-30
net max-vel-chA        =>  encoder.3.phase-A

net max-vel-chB        <=  hm2_7i92.0.7i84.0.2.input-31
net max-vel-chB        =>  encoder.3.phase-B

net max-vel-output    <=  encoder.3.counts
net max-vel-output    =>  halui.max-velocity.counts

setp halui.max-velocity.count-enable 1
setp halui.max-velocity.scale .1

# --- Jogging ---

net select-x-axis    <=  hm2_7i92.0.7i84.0.2.input-05
net select-x-axis    =>  halui.axis.x.select  =>  halui.joint.0.select
net select-x-axis    =>  axis.x.jog-enable  =>  joint.0.jog-enable

net select-y-axis    <=  hm2_7i92.0.7i84.0.2.input-06
net select-y-axis    =>  halui.axis.y.select  =>  halui.joint.1.select
net select-y-axis    =>  axis.y.jog-enable  =>  joint.1.jog-enable

net select-z-axis    <=  hm2_7i92.0.7i84.0.2.input-07
net select-z-axis    =>  halui.axis.z.select  =>  halui.joint.2.select
net select-z-axis    =>  axis.z.jog-enable  =>  joint.2.jog-enable

net sel-inc-plus    <=  hm2_7i92.0.7i84.0.2.input-22
net sel-inc-plus    =>  halui.axis.selected.increment-plus  =>  halui.joint.selected.increment-plus

net sel-inc-minus    <=  hm2_7i92.0.7i84.0.2.input-23
net sel-inc-minus    =>  halui.axis.selected.increment-minus  =>  halui.joint.selected.increment-minus

net sel-jog-plus    <=  hm2_7i92.0.7i84.0.2.input-20
net sel-jog-plus    =>  halui.axis.selected.plus  =>  halui.joint.selected.plus

net sel-jog-minus    <=  hm2_7i92.0.7i84.0.2.input-21
net sel-jog-minus    =>  halui.axis.selected.minus  =>  halui.joint.selected.minus

net sel-jog-vel        <=  scale.jog.out
net sel-jog-vel        =>  halui.axis.jog-speed  =>  halui.joint.jog-speed
#setp scale.jog.gain 10000
setp scale.jog.gain 10

# --- MPG ---

setp mux16.inc.in00 0.0001
setp mux16.inc.in01 0.0005
setp mux16.inc.in02 0.0010
setp mux16.inc.in04 0.0050
setp mux16.inc.in08 0.0100

setp mux16.inc.debounce-time 0.200

setp axis.x.jog-vel-mode 1
setp axis.y.jog-vel-mode 1
setp axis.z.jog-vel-mode 1
setp joint.0.jog-vel-mode 1
setp joint.1.jog-vel-mode 1
setp joint.2.jog-vel-mode 1

net mpg-count        <=  hm2_7i92.0.7i84.0.2.enc0.count
net mpg-count        =>  axis.x.jog-counts  =>  joint.0.jog-counts
net mpg-count        =>  axis.y.jog-counts  =>  joint.1.jog-counts
net mpg-count        =>  axis.z.jog-counts  =>  joint.2.jog-counts

net mpg-scale        <=  mux16.inc.out-f
net mpg-scale        =>  axis.x.jog-scale  =>  joint.0.jog-scale
net mpg-scale        =>  axis.y.jog-scale  =>  joint.1.jog-scale
net mpg-scale        =>  axis.z.jog-scale  =>  joint.2.jog-scale
net mpg-scale        =>  scale.jog.in

#No increment switch needed for .0001

net inc-select-b    <=  hm2_7i92.0.7i84.0.2.input-01
net inc-select-b    =>  mux16.inc.sel0
net inc-select-c    <=  hm2_7i92.0.7i84.0.2.input-02
net inc-select-c    =>  mux16.inc.sel1
net inc-select-d    <=  hm2_7i92.0.7i84.0.2.input-03
net inc-select-d    =>  mux16.inc.sel2
net inc-select-e    <=  hm2_7i92.0.7i84.0.2.input-04
net inc-select-e    =>  mux16.inc.sel3
The following user(s) said Thank You: spumco

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

More
24 Dec 2021 18:30 #229915 by spumco
Thanks a ton.  It'll take me a bit to digest but I'll have a go at it shortly.

-R

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

More
24 Dec 2021 20:34 #229921 by cmorley
halui.max-velocity.direct-value option was purposely added to allow the maxvelocity to be set with a selector switch.
that option, with a mux and setting the scale appropriately will work as you described.
Yes it's awkward to not use percent, but you could use percent on rapid and feed override.

linuxcnc.org/docs/devel/html/gui/halui.html#_max_velocity
The following user(s) said Thank You: spumco

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

More
25 Dec 2021 03:40 - 25 Dec 2021 03:54 #229943 by spumco
Thanks for the guidance.

I've had a go at it using the above as a template, but not really successful yet.  I don't really understand the mux thing - hasn't sunk in yet.

It appears to only have 4 outputs (mux16.0.sel0 through .sel3) so I had to comment out one of them to stop error messages.  Am I missing something in the setup/arrangement that permits me to have 5 values?

[note - max velocity is set to 150ipm (2.5 in INI)]

setp halui.max-velocity.direct-value true
setp halui.max-velocity.counts 1
setp mux16.0.in00 0.0
setp mux16.0.in01 0.125
setp mux16.0.in02 0.25
setp mux16.0.in03 1.250
setp mux16.0.in04 2.5
net MAXVEL_0            <=  [HMOT](CARD0).7i84.0.1.input-24
net MAXVEL_0            =>  mux16.0.sel0
net MAXVEL_1            <=  [HMOT](CARD0).7i84.0.1.input-23
net MAXVEL_1            =>  mux16.0.sel1
net MAXVEL_2            <=  [HMOT](CARD0).7i84.0.1.input-22
net MAXVEL_2            =>  mux16.0.sel2
net MAXVEL_3            <=  [HMOT](CARD0).7i84.0.1.input-21
net MAXVEL_3            =>  mux16.0.sel3

#commented out mux16.0.sel4 doesn't exist
#net MAXVEL_4            <=  [HMOT](CARD0).7i84.0.1.input-20
#net MAXVEL_4            =>  mux16.0.sel4

net MAXVEL_IN           <=  mux16.0.out-f
net MAXVEL_IN           =>  halui.max-velocity.scale

This works enough so I can see the mux16 values change in halshow, but I think I need to put this in postgui.hal to have an effect.

Comments or corrections?

EDIT - still not working right; it's clear I don't grasp how mux works as switching the selector changes the values, but not as expected.
Results in halshow:
input 24 = 0
input 23 = 2.5
input 22 = .25
input 21 = .125
input 20 = 0
Last edit: 25 Dec 2021 03:54 by spumco. Reason: Tested postgui.hal

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

More
25 Dec 2021 04:31 #229944 by cmorley
mux16 uses multiplexing to get 16 outputs from 4 inputs
If you don't multiplex the select lines then:

no select true: output will be = to in00
just .sel0 true: output will be = to in01
just .sel1 true: output will be = to in02
just .sel2 true: output will be = to in04
just .sel3 true: output will be = to in08

There is mux_generic that could be used to make a mux32 - 32 outputs with 5 inputs - or any pther amount of inputs.

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

More
25 Dec 2021 04:44 - 25 Dec 2021 04:57 #229946 by spumco
I think that makes sense now.  I just need to change the inXX

Here goes nothing...

EDIT
Ok, that did the trick to get the values matching the switch positions.

Next problem is that halui.max-velocity.value isn't changing even though halui.max-velocity.scale is changing when the selector is switched.

The only thing that changes the .value is moving the screen slider.  I wonder if the Probe Basic max-vel slider is interfering with the mux16 output?
Last edit: 25 Dec 2021 04:57 by spumco. Reason: Fiddling & testing

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

More
25 Dec 2021 09:37 #229949 by cmorley
halui.max-velocity.scale shouldn't change, halui.max-velocity.counts should change.

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

More
25 Dec 2021 10:17 #229950 by cmorley
or i guess you could set the counts to 1.
counts* scale = output

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

More
25 Dec 2021 13:52 #229958 by spumco
Counts is set to 1, and scale is changing per switch position.  Output is changing... but the max velocity value does not change.

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

Time to create page: 0.102 seconds
Powered by Kunena Forum