set jog-scale from input pins

More
4 years 1 month ago - 4 years 1 month ago #253166 by furynick
I searched for some time on forum and wiki but I can't figure out how to set jog-scale from a set of pins.

I would like to set a jog-scale value when a specific pin is enabled, eg.
  • input 1 => 0.01
  • input 2 => 0.05
  • input 3 => 0.1
  • input 4 => 1
  • input 5 => 10

    I found an example using 3 or2 to "rebuild" an integer from 2 pins to feed mux input but I want to use a 5-pos selector and this technique seems very complex in this case.

    I didn't find in man pages a way to convert a set of bit into an integer but I may have missed something.
Last edit: 4 years 1 month ago by furynick.

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

More
4 years 1 month ago #253170 by furynick
Answering my own question, I found weighted_sum can do the job :
Code:
loadrt weighted_sum wsum_sizes=5 addf   process_wsums servo-thread net scale-sel-1 wsum.0.bit.0.in <= [HMOT](CARD0).7i73.0.1.input-11 net scale-sel-2 wsum.0.bit.1.in <= [HMOT](CARD0).7i73.0.1.input-12 net scale-sel-3 wsum.0.bit.2.in <= [HMOT](CARD0).7i73.0.1.input-13 net scale-sel-4 wsum.0.bit.3.in <= [HMOT](CARD0).7i73.0.1.input-14 net scale-sel-5 wsum.0.bit.4.in <= [HMOT](CARD0).7i73.0.1.input-15 setp wsum.0.bit.0.weight 1 setp wsum.0.bit.1.weight 2 setp wsum.0.bit.2.weight 3 setp wsum.0.bit.3.weight 4 setp wsum.0.bit.4.weight 5 setp wsum.0.offset -10 # Don't know why sum default to 10 net scale-conv <= wsum.0.sum loadrt conv_s32_u32 addf   conv-s32-u32.0 servo-thread net scale-conv => conv-s32-u32.0.in net scale-sel <=  conv-s32-u32.0.out loadrt mux_generic config="ff6" addf   mux-gen.00 servo-thread     setp mux-gen.00.suppress-no-input False     setp mux-gen.00.in-float-00          0.010000     setp mux-gen.00.in-float-01          0.050000     setp mux-gen.00.in-float-02          0.100000     setp mux-gen.00.in-float-03          0.500000     setp mux-gen.00.in-float-04          1.000000     setp mux-gen.00.in-float-05         10.000000 net jog-scale   <=  mux-gen.00.out-float net scale-sel    => mux-gen.00.sel-int
The following user(s) said Thank You: Aciera

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

More
4 years 1 month ago - 4 years 1 month ago #253191 by JPL
Replied by JPL on topic set jog-scale from input pins
Maybe have a look here too for a classic MPG 3 axes 3 step increments: linuxcnc.org/docs/devel/html/examples/mpg.html

This is using mux4 instead of weighted_sum to set the mpg/jog scale.
There's also a mux8 and a mux16 that you can use in a similar way.
Last edit: 4 years 1 month ago by JPL.

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

More
4 years 4 weeks ago #253339 by rodw
Replied by rodw on topic set jog-scale from input pins
Here is a 7 axis MPG  with scale and axis select.
We only have 4 axes so some selections do other things.
We use Mux4 for scale select and mux8 for axis select.
Its really just an extension of the code in the docs linked earlier
Warning: Spoiler!
The following user(s) said Thank You: my1987toyota

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

Time to create page: 0.296 seconds
Powered by Kunena Forum