mux4 for axis select??

More
8 years 7 months ago #107383 by OT-CNC
I'm working on a jog pendant/ MPG handwheel. I have the mux4 component working for jog increment select based on MPG pendant
examples:
linuxcnc.org/docs/html/examples/mpg.html
Question is, is there a way to implement mux4 for axis select? Based on the mux4 manual it only works with input values:
linuxcnc.org/docs/ja/html/man/man9/mux4.9.html

I'm a bit short on wiring and I'm looking for a workaround to do axis select A,X,Y,Z with 2 inputs.

Please Log in to join the conversation.

More
8 years 7 months ago #107384 by cmorley
Replied by cmorley on topic mux4 for axis select??
mux_generic can have bit output pins.

Please Log in to join the conversation.

More
8 years 7 months ago #107386 by OT-CNC
Replied by OT-CNC on topic mux4 for axis select??
I just looked at the doc:
linuxcnc.org/docs/html/man/man9/mux_generic.9.html

Is there a good hal example out there that uses the 2 inputs that I can look at to adapt?

Please Log in to join the conversation.

More
8 years 7 months ago #107389 by cmorley
Replied by cmorley on topic mux4 for axis select??
Sorry I lead you astray... looks like mux_generic wouldnt do what you wish.
Seems you actually need to de-multiplex signals.


so 2 bit inputs control 4 bit outputs.
you may need to compile a custom component or use classicladder.
Some one else may have a smarter answer for you yet...

Chris M

Please Log in to join the conversation.

More
8 years 7 months ago #107391 by cmorley
Replied by cmorley on topic mux4 for axis select??
I think this would do it:
Code:
component dmux2 "Select one of four output values"; pin in bit sel0; pin in bit sel1; pin out bit out0; pin out bit out1; pin out bit out2; pin out bit out3; function _; license "GPL"; ;; FUNCTION(_) { if(sel0) { if(sel1) { out0 =0; out1 =0; out2 =0; out3 =1; }else{ out0 =0; out1 =1; out2 =0; out3 =0; } }else { if(sel1) { out0 =0; out1 =0; out2 =1; out3 =0; }else{ out0 =1; out1 =0; out2 =0; out3 =0; } } }

Please Log in to join the conversation.

More
8 years 7 months ago #107392 by Todd Zuercher
I think you can do this with the hal logic component.
linuxcnc.org/docs/html/man/man9/logic.9.html
I'll have to think on it a bit to be able to give you an example how to use it in your hal file.

Till then, maybe Andy (I think he wrote this little gem) will chime in with instructions.

Please Log in to join the conversation.

More
8 years 7 months ago #107395 by Todd Zuercher
Never mind logic doesn't work.

It might not be as elegant as writing a component, but you could do it by simply using 4 and2s connected to the your two input pins and their inverses.

X=00
Y=01
Z=10
A=11
If you were using parallel ports pin 9 and 10 as your inputs it would look something like this.
Code:
loadrt and2 count=4 addf and2.0 servo-thread addf and2.1 servo-thread addf and2.2 servo-thread addf and2.3 servo-thread net input1-not <= parport.1.pin-9-in-not => and2.0.in0 net input2-not <= parport.1.pin-10-in-not => and2.0.in1 net mpg-x <= and2.0.out => axis.0.jog-enable net input1-not => and2.1.in0 net input2 <= parport.1.pin-10-in => and2.1.in1 net mpg-y <= and2.1.out => axis.0.jog-enable net input1 <= parport.1.pin-9-in-not => and2.2.in0 net input2-not => and2.2.in1 net mpg-z <= and2.2.out => axis.0.jog-enable net input1 => and2.3.in0 net input2 => and2.3.in1 net mpg-z <= and2.3.out => axis.0.jog-enable

Please Log in to join the conversation.

More
8 years 7 months ago #107396 by OT-CNC
Replied by OT-CNC on topic mux4 for axis select??
I appreciate the leads. I will try the last example and see if I can adapt it.

Thank you!

Please Log in to join the conversation.

More
8 years 7 months ago #107403 by andypugh
Replied by andypugh on topic mux4 for axis select??
This could also be done with multiswitch
But I am not sure it is worth the bother, because you would have to turn the input bits into a number with weighted_sum and then, because select8 takes a signed-32 input (for no good reason) you would need to convert to S32 with conv_s32_u32

An alternative would be to use 4 x binary mux4 components (from mux_generic with each having three zero inputs and one true input.

Or 4 x lut5

Please Log in to join the conversation.

More
8 years 7 months ago #107405 by rodw
Replied by rodw on topic mux4 for axis select??
I don't think you need a special component. I have used a Mux8 and Select8 for axis select. I only have 3 axes but my pendant had a 6 position switch. The trick is to convert the type to use it in the select8.
This is basically identical to the way I select the scale using a Mux4.
Code:
loadrt mux8 count=1 loadrt select8 count=1 addf mux8.0 servo-thread addf select8.0 servo-thread #Axis Select (0=off, 1=x, 2=z, 3=y, na, 5=6, 6=4, 7=5) setp mux8.0.in0 0 setp mux8.0.in1 1 setp mux8.0.in2 2 setp mux8.0.in3 3 setp mux8.0.in4 4 setp mux8.0.in5 5 setp mux8.0.in6 6 setp mux8.0.in7 7 net mux8-sel0 <= hm2_7i76e.0.7i76.0.0.input-23 net mux8-sel1 <= hm2_7i76e.0.7i76.0.0.input-24 net mux8-sel2 <= hm2_7i76e.0.7i76.0.0.input-25 net mux8-sel0 => mux8.0.sel0 net mux8-sel1 => mux8.0.sel1 net mux8-sel2 => mux8.0.sel2 net mux-float conv-float-s32.1.in <= mux8.0.out net mux-s32 <= conv-float-s32.1.out net mux-s32 => select8.0.sel net axis-select-x <= select8.0.out1 net axis-select-y <= select8.0.out3 net axis-select-z <= select8.0.out2 net axis-select-4 <= select8.0.out6 net axis-select-5 <= select8.0.out7 net axis-select-6 <= select8.0.out5 net axis-select-x => axis.x.jog-enable net axis-select-y => axis.y.jog-enable net axis-select-z => axis.z.jog-enable

I think I copied everything I used.

Please Log in to join the conversation.

Time to create page: 0.103 seconds
Powered by Kunena Forum