linking and unlinking a pin based on motion-enabled

More
2 years 8 months ago #293151 by linuxfan
Hi all, 

I have a net lines:

net ATC-pos-cmd  joint.3.motor-pos-cmd => cia402.3.pos-cmd
net ATC-pos-fb      joint3.motor-pos-fb <= cia402.3.pos-fb

net ATC-pos-posthome limit3.0.out => joint3.posthome-cmd

I would like limit3.0.in to be connected to ATC-pos-fb only when controller is disabled - when motion.motion-enabled pin is set to false.
When motion.motion-enabled is true, I would like to disconnect limit3.0.in from ATC-pos-fb, as once controller is enabled, I want to feed my own position into it.
Before controller is enabled and before drives are enabled, I want it to be connected to ATC-pos-fb, as I am using absolute encoders, so no homing is required. But obviously if current position read from encoder is for example 5000, and limit3.0.in is zero or some other position, motor will jump abruptly first time when machine is enabled.

So i'd like to achieve something like this:

If (motion.motion-enabled == false)then
     linksp ATC-pos-fb limit3.0.in
else
    unlinkp limit3.0.in
end

Thanks



 

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

More
2 years 8 months ago #293153 by PCW
Seems like this would be best done with a "mux2" component

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

More
2 years 8 months ago - 2 years 8 months ago #293156 by linuxfan
Thanks for a quick reply. I was suspecting that mux2 would be a way to do this. However I am totally new to linuxcnc.
Would you mind sharing exact code with mux2, that would work for my case?

Thanks
Last edit: 2 years 8 months ago by linuxfan.

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

More
2 years 8 months ago #293159 by PCW
This is just an example that sets the limit3 source to
ATC-pos-fb when motion is not enabled and 0
when motion is enabled

loadrt mux2
addf mux2.0 servo-thread

net ATC-pos-fb mux2.in0
setp mux2.0.in1 0
net limit3source mux2.0.out  limit3.0.in
net motion-enabled motion.motion-enabled mux2.0.sel
 

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

More
2 years 8 months ago #293212 by linuxfan
I tried your approach, and while it works fine for connecting ATC-pos-fb to limit3.0.in, it doesn't achieve my goal regarding disconnecting pin limit3.0.in, as instead of disconnecting it, it connects it to value zero - so pin is again not available for free input value assignment.

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

More
2 years 8 months ago #293216 by Aciera
replace:
Code:
setp mux2.0.in1 0

with:
Code:
net alt_input  <your hal signal here>  mux2.0.in1

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

Time to create page: 0.270 seconds
Powered by Kunena Forum