Best HAL function 2 contol bits for S32 in, 1 of 4 out?
- slowpoke
- Offline
- Elite Member
-
Less
More
- Posts: 206
- Thank you received: 28
07 Jul 2025 20:21 #331485
by slowpoke
Best HAL function 2 contol bits for S32 in, 1 of 4 out? was created by slowpoke
I have two rotary switches, each switch has 2 outputs driving inputs on a MESA card as 00,01,10,11
Switch #1 is used to select MPG increment 0, 0.0001", 0.001", 0.01" I'm using a MUX4 to control that. No problem with this.
Switch#2 is for selection of where the MPG ticks ( net encoder-counts <= hm2_7i96s.0.inm.00.enc1-count ),gets routed, so to either:
X, Z, C (Compound), or N(None), so....
axis.x.jog-counts
axis.z.jog-counts
anglejog.counts-in
or to nowhere when position N is selected
Switch #1 is used to select MPG increment 0, 0.0001", 0.001", 0.01" I'm using a MUX4 to control that. No problem with this.
Switch#2 is for selection of where the MPG ticks ( net encoder-counts <= hm2_7i96s.0.inm.00.enc1-count ),gets routed, so to either:
X, Z, C (Compound), or N(None), so....
axis.x.jog-counts
axis.z.jog-counts
anglejog.counts-in
or to nowhere when position N is selected
Please Log in or Create an account to join the conversation.
- PCW
-
- Away
- Moderator
-
Less
More
- Posts: 18868
- Thank you received: 5212
07 Jul 2025 20:42 #331489
by PCW
Replied by PCW on topic Best HAL function 2 contol bits for S32 in, 1 of 4 out?
Typically this is done by by connecting the MPG count to all axis
and selectively enabling jogging on the desired axis
and selectively enabling jogging on the desired axis
The following user(s) said Thank You: slowpoke
Please Log in or Create an account to join the conversation.
- slowpoke
- Offline
- Elite Member
-
Less
More
- Posts: 206
- Thank you received: 28
08 Jul 2025 21:42 #331544
by slowpoke
Thanks for that. I'm almost there.....
I have two rotary switches, each switch has 2 outputs driving inputs on a MESA card as 00,01,10,11
Switch #1 is used to select MPG increment 0, 0.0001", 0.001", 0.01" I'm using a MUX4 to control that. No problem with this.
Switch#2 is for selection of where the MPG ticks ( net encoder-counts <= hm2_7i96s.0.inm.00.enc1-count ),gets routed, so to either:
X, Z, C (Compound), or N(None), so....
axis.x.jog-counts
axis.z.jog-counts
anglejog.counts-in
or to nowhere when position N is selected
I now have the rotary switch working for: none, X or Z by simply enabling jogging for X or Z as required. For Compound action I can simply enable both X and Z when in compound mode.
Final hurdle is that I have two S32 source signals:
1) The MPG signal called (encoder-counts), for non-compound moves. Configured and working as net encoder-counts => axis.x.jog-counts
2) The modified by anglejog MPG signal for compound moves called (angle_x). I can't simply configure as net angle-x => axis.x.jog-counts
HAL does not allow two sources to drive one output pin. I'm guessing that mux_generic might be the best solution, to allow choosing the source signal for axis.x.jog-counts?
Assuming mux_generic is the best solution, I need a little help configuring mux_generic:
- I assume I would add it to the servo-thread? loadrt mux_generic config="??????"
- the other pins are a bit fuzzy, looks like I need to specify:
mux-gen.00.in-s32
mux-gen.00.out-s32
I'm not sure how to:
a) assign encoder-counts and angle_x to the two inputs of the multiplexer?
b) route the output of the multiplexer to axis.x.jog-counts?
c) define the control bit that will select the desired input?
Your help is appreciated.
Replied by slowpoke on topic Best HAL function 2 contol bits for S32 in, 1 of 4 out?
Typically this is done by by connecting the MPG count to all axis
and selectively enabling jogging on the desired axis
Thanks for that. I'm almost there.....
I have two rotary switches, each switch has 2 outputs driving inputs on a MESA card as 00,01,10,11
Switch #1 is used to select MPG increment 0, 0.0001", 0.001", 0.01" I'm using a MUX4 to control that. No problem with this.
Switch#2 is for selection of where the MPG ticks ( net encoder-counts <= hm2_7i96s.0.inm.00.enc1-count ),gets routed, so to either:
X, Z, C (Compound), or N(None), so....
axis.x.jog-counts
axis.z.jog-counts
anglejog.counts-in
or to nowhere when position N is selected
I now have the rotary switch working for: none, X or Z by simply enabling jogging for X or Z as required. For Compound action I can simply enable both X and Z when in compound mode.
Final hurdle is that I have two S32 source signals:
1) The MPG signal called (encoder-counts), for non-compound moves. Configured and working as net encoder-counts => axis.x.jog-counts
2) The modified by anglejog MPG signal for compound moves called (angle_x). I can't simply configure as net angle-x => axis.x.jog-counts
HAL does not allow two sources to drive one output pin. I'm guessing that mux_generic might be the best solution, to allow choosing the source signal for axis.x.jog-counts?
Assuming mux_generic is the best solution, I need a little help configuring mux_generic:
- I assume I would add it to the servo-thread? loadrt mux_generic config="??????"
- the other pins are a bit fuzzy, looks like I need to specify:
mux-gen.00.in-s32
mux-gen.00.out-s32
I'm not sure how to:
a) assign encoder-counts and angle_x to the two inputs of the multiplexer?
b) route the output of the multiplexer to axis.x.jog-counts?
c) define the control bit that will select the desired input?
Your help is appreciated.
Please Log in or Create an account to join the conversation.
- PCW
-
- Away
- Moderator
-
Less
More
- Posts: 18868
- Thank you received: 5212
08 Jul 2025 22:11 #331550
by PCW
Replied by PCW on topic Best HAL function 2 contol bits for S32 in, 1 of 4 out?
Normally the MPG encoder count goes to all Axis jog count pins,
so no routing of the counts is needed.
This is required so that LinuxCNC can track the current MPG count
and only apply changes to the enabled axis.
so no routing of the counts is needed.
This is required so that LinuxCNC can track the current MPG count
and only apply changes to the enabled axis.
Please Log in or Create an account to join the conversation.
- slowpoke
- Offline
- Elite Member
-
Less
More
- Posts: 206
- Thank you received: 28
09 Jul 2025 00:25 #331552
by slowpoke
axis.x.jog-counts, and axis.z.jog-counts, can't be driven by both the MPG and anglejog
net encoder-counts <= hm2_7i96s.0.inm.00.enc1-count
net encoder-counts => axis.x.jog-counts
net encoder-counts => axis.z.jog-counts
net encoder-counts => anglejog.counts-in
net angle_x <= anglejog.coscounts
###net angle_x => axis.x.jog-counts can't do this!!!
net angle_z <= anglejog.sincounts
###net angle_z => axis.z.jog-counts can't do this!!!
Replied by slowpoke on topic Best HAL function 2 contol bits for S32 in, 1 of 4 out?
The problem is that when using anglejog for emulated compound movement (X+Z), the MPG ticks get processed by anglejog and then analogjog outputs the sin and cos values that are to be fed to; axis.x.jog-counts, and axis.z.jog-counts, however in HAL, axis.x.jog-counts, and axis.z.jog-counts are already being driven by the raw (non sin and cos values) from the MPG for non compound/anglejog use.Normally the MPG encoder count goes to all Axis jog count pins,
so no routing of the counts is needed.
This is required so that LinuxCNC can track the current MPG count
and only apply changes to the enabled axis.
axis.x.jog-counts, and axis.z.jog-counts, can't be driven by both the MPG and anglejog
net encoder-counts <= hm2_7i96s.0.inm.00.enc1-count
net encoder-counts => axis.x.jog-counts
net encoder-counts => axis.z.jog-counts
net encoder-counts => anglejog.counts-in
net angle_x <= anglejog.coscounts
###net angle_x => axis.x.jog-counts can't do this!!!
net angle_z <= anglejog.sincounts
###net angle_z => axis.z.jog-counts can't do this!!!
Please Log in or Create an account to join the conversation.
- PCW
-
- Away
- Moderator
-
Less
More
- Posts: 18868
- Thank you received: 5212
09 Jul 2025 03:25 #331555
by PCW
Replied by PCW on topic Best HAL function 2 contol bits for S32 in, 1 of 4 out?
I would think that could be done with 2 mux2 components
(1 for X and 1 for Z) that select between anglejog outputs
when anglejog is enabled and direct MPG counts when
anglejog is not selected.
(1 for X and 1 for Z) that select between anglejog outputs
when anglejog is enabled and direct MPG counts when
anglejog is not selected.
The following user(s) said Thank You: slowpoke
Please Log in or Create an account to join the conversation.
- slowpoke
- Offline
- Elite Member
-
Less
More
- Posts: 206
- Thank you received: 28
09 Jul 2025 08:16 #331564
by slowpoke
Agreed I will need two, one for X and one for Z, however mux2 works with floating point numbers, and the MPG counts are S32, so I don't think I can use mux2
mux_generic seems like it should work because you can select the data type, however I need a little help configuring mux_generic:
- I assume I would add it to the servo-thread? loadrt mux_generic config="??????"
- the other pins are a bit fuzzy, looks like I need to specify:
mux-gen.00.in-s32
mux-gen.00.out-s32
I'm not sure how to:
a) assign encoder-counts and angle_x to the two inputs of the multiplexer?
b) route the output of the multiplexer to axis.x.jog-counts?
c) define the control bit that will select the desired input?
Your help is appreciated.
Replied by slowpoke on topic Best HAL function 2 contol bits for S32 in, 1 of 4 out?
I would think that could be done with 2 mux2 components
(1 for X and 1 for Z) that select between anglejog outputs
when anglejog is enabled and direct MPG counts when
anglejog is not selected.
Agreed I will need two, one for X and one for Z, however mux2 works with floating point numbers, and the MPG counts are S32, so I don't think I can use mux2
mux_generic seems like it should work because you can select the data type, however I need a little help configuring mux_generic:
- I assume I would add it to the servo-thread? loadrt mux_generic config="??????"
- the other pins are a bit fuzzy, looks like I need to specify:
mux-gen.00.in-s32
mux-gen.00.out-s32
I'm not sure how to:
a) assign encoder-counts and angle_x to the two inputs of the multiplexer?
b) route the output of the multiplexer to axis.x.jog-counts?
c) define the control bit that will select the desired input?
Your help is appreciated.
Please Log in or Create an account to join the conversation.
- PCW
-
- Away
- Moderator
-
Less
More
- Posts: 18868
- Thank you received: 5212
09 Jul 2025 13:17 - 09 Jul 2025 14:18 #331572
by PCW
Replied by PCW on topic Best HAL function 2 contol bits for S32 in, 1 of 4 out?
I think its something like:
loadrt mux_generic config="ss2,ss2"
addf mux-gen.00 servo thread
addf mux-gen.01 servo thread
And the main created pins are:
mux-gen.00.sel-bit-00
mux-gen.00.in-s32-00
mux-gen.00.in-s32-00
mux-gen.00.out-s32
mux-gen.01.sel-bit-00
mux-gen.01.in-s32-00
mux-gen.01.in-s32-00
mux-gen.01.out-s32
The select pin for both would connect to the angle jog enable
so the two muxes select either the output of anglejog (when
anglejog is selected) or the raw MPG count (when anglejog is not
selected) The outputs of the muxes go to the appropriate
joint jog count pins.
loadrt mux_generic config="ss2,ss2"
addf mux-gen.00 servo thread
addf mux-gen.01 servo thread
And the main created pins are:
mux-gen.00.sel-bit-00
mux-gen.00.in-s32-00
mux-gen.00.in-s32-00
mux-gen.00.out-s32
mux-gen.01.sel-bit-00
mux-gen.01.in-s32-00
mux-gen.01.in-s32-00
mux-gen.01.out-s32
The select pin for both would connect to the angle jog enable
so the two muxes select either the output of anglejog (when
anglejog is selected) or the raw MPG count (when anglejog is not
selected) The outputs of the muxes go to the appropriate
joint jog count pins.
Last edit: 09 Jul 2025 14:18 by PCW.
The following user(s) said Thank You: slowpoke
Please Log in or Create an account to join the conversation.
- Benb
-
- Offline
- Elite Member
-
Less
More
- Posts: 162
- Thank you received: 56
09 Jul 2025 17:00 - 09 Jul 2025 17:06 #331584
by Benb
Replied by Benb on topic Best HAL function 2 contol bits for S32 in, 1 of 4 out?
An alternative approach is to create a custom mux2u32.comp component by adapting the existing mux2.comp—replacing its float data types with u32. Once modified, you can compile it with halcompile and integrate it into your local LinuxCNC.
Last edit: 09 Jul 2025 17:06 by Benb.
Please Log in or Create an account to join the conversation.
Time to create page: 0.067 seconds