mux4 for axis select??
- OT-CNC
- Offline
- Platinum Member
Less
More
- Posts: 622
- Thank you received: 75
15 Mar 2018 17:53 #107383
by OT-CNC
mux4 for axis select?? was created 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.
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 or Create an account to join the conversation.
- cmorley
- Away
- Moderator
Less
More
- Posts: 7786
- Thank you received: 2077
15 Mar 2018 18:03 #107384
by cmorley
Replied by cmorley on topic mux4 for axis select??
mux_generic can have bit output pins.
Please Log in or Create an account to join the conversation.
- OT-CNC
- Offline
- Platinum Member
Less
More
- Posts: 622
- Thank you received: 75
15 Mar 2018 18:11 #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?
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 or Create an account to join the conversation.
- cmorley
- Away
- Moderator
Less
More
- Posts: 7786
- Thank you received: 2077
15 Mar 2018 19:16 - 15 Mar 2018 19:17 #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
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
Last edit: 15 Mar 2018 19:17 by cmorley.
Please Log in or Create an account to join the conversation.
- cmorley
- Away
- Moderator
Less
More
- Posts: 7786
- Thank you received: 2077
15 Mar 2018 19:43 - 15 Mar 2018 19:44 #107391
by cmorley
Replied by cmorley on topic mux4 for axis select??
I think this would do it:
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;
}
}
}
Last edit: 15 Mar 2018 19:44 by cmorley. Reason: change name to dmux2
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 4957
- Thank you received: 1441
15 Mar 2018 19:45 #107392
by Todd Zuercher
Replied by Todd Zuercher on topic mux4 for axis select??
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.
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 or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 4957
- Thank you received: 1441
15 Mar 2018 20:29 #107395
by Todd Zuercher
Replied by Todd Zuercher on topic mux4 for axis select??
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.
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.
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
The following user(s) said Thank You: OT-CNC
Please Log in or Create an account to join the conversation.
- OT-CNC
- Offline
- Platinum Member
Less
More
- Posts: 622
- Thank you received: 75
15 Mar 2018 20:35 #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!
Thank you!
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23178
- Thank you received: 4866
15 Mar 2018 22:59 #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
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 or Create an account to join the conversation.
- rodw
- Offline
- Platinum Member
Less
More
- Posts: 10843
- Thank you received: 3580
16 Mar 2018 00:00 #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.
I think I copied everything I used.
This is basically identical to the way I select the scale using a Mux4.
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 or Create an account to join the conversation.
Time to create page: 0.069 seconds