- LinuxCNC
- General LinuxCNC Questions
- M19 orientation drift with external encoder and orient component (LinuxCNC 2.9.4
M19 orientation drift with external encoder and orient component (LinuxCNC 2.9.4
- jelost
- Offline
- New Member
-
Less
More
- Posts: 7
- Thank you received: 0
24 Aug 2026 15:50 #348959
by jelost
Replied by jelost on topic M19 orientation drift with external encoder and orient component (LinuxCNC 2.9.4
Question about sharing index-enable between s_orient and spindle for M19 / G33.1
Hello,
I am continuing my work on spindle orientation with a servo motor and would appreciate some advice about index-enable.
My setup is:
LinuxCNC 2.9.4
Servo spindle motor with encoder
Encoder A/B/Z connected to LinuxCNC
encoder.0.x4-mode TRUE
encoder.0.position-scale 4000
encoder.0.counter-mode 0
BASE_PERIOD = 30000
SERVO_PERIOD = 1000000
I have been working on spindle orientation (M19) and I have found that s_orient is very effective.
With the s_orient version of my HAL, the spindle can be run at relatively high speed (up to about 3000 rpm), stopped at different positions, and then correctly oriented with M19. The previous version using the standard orient component could lose its angular zero reference after running the spindle at high speed.
So I would really like to keep s_orient.
The problem
With the previous HAL using the standard orient component, I had:
net spindle-index-enable encoder.0.index-enable <=> spindle.0.index-enable
This allowed rigid tapping with:
G33.1 Z-5 K1
and M19 also worked reasonably well.
With the new s_orient version, I have:
net orient-index-enable encoder.0.index-enable <=> orient.0.index-enable
This gives a much better and more stable M19, but G33.1 no longer starts correctly.
During a G33.1 test I observed:
spindle.0.index-enable = TRUE
orient.0.index-enable = FALSE
encoder.0.index-enable = FALSE
So the request from spindle.0.index-enable does not reach the encoder.
For comparison, with the old HAL, the direct connection
net spindle-index-enable encoder.0.index-enable <=> spindle.0.index-enable
made rigid tapping work.
Current s_orient connection
The relevant part of the current HAL is:
net spindle-position encoder.0.position
net spindle-position => spindle.0.revs
net spindle-position => orient.0.position
net spindle-position => orient-pid.feedback
net spindle-velocity-feedback-rps encoder.1.velocity => spindle.0.speed-in
net orient-index-enable encoder.0.index-enable <=> orient.0.index-enable
net spindle-phase-a encoder.0.phase-A
net spindle-phase-b encoder.0.phase-B
net spindle-index encoder.0.phase-Z
And:
loadrt s_orient names=orient.0
loadrt pid names=orient-pid
loadrt mux2 names=spindle-mux
addf orient.0 servo-thread
addf orient-pid.do-pid-calcs servo-thread
addf spindle-mux servo-thread
net orient-enable spindle.0.orient => orient.0.enable
net orient-enable => orient-pid.enable
net orient-angle spindle.0.orient-angle => orient.0.angle
net orient-mode spindle.0.orient-mode => orient.0.mode
net orient-command orient.0.command => orient-pid.command
net spindle-oriented orient.0.is-oriented => spindle.0.is-oriented
The PID settings currently are:
setp orient-pid.Pgain 75
setp orient-pid.Igain 0
setp orient-pid.Dgain 0
setp orient-pid.FF0 0
setp orient-pid.FF1 0
setp orient-pid.maxoutput 50
setp orient-pid.deadband 0
setp orient.0.tolerance 2.0
My question
What is the correct way to share the bidirectional index-enable function between:
spindle.0.index-enable
orient.0.index-enable
encoder.0.index-enable
so that both of these work correctly?
M19
and
G33.1
I understand that index-enable is a bidirectional HAL pin, so I suspect that simply OR-ing the signals is not the correct solution.
I also tried checking for tristate-bit, but it is not available/loaded in my LinuxCNC installation, and trying:
halcmd loadrt tristate-bit
failed with:
waitpid failed /usr/bin/rtapi_app tristate-bit
rtapi_app exited without becoming ready
insmod for tristate-bit failed
I would like to keep the s_orient solution because M19 is now very effective and stable, especially after running the spindle at high speed.
I am only looking for the correct way to restore G33.1 / rigid tapping without degrading the s_orient behaviour.
Any advice would be greatly appreciated.
Thank you!
Hello,
I am continuing my work on spindle orientation with a servo motor and would appreciate some advice about index-enable.
My setup is:
LinuxCNC 2.9.4
Servo spindle motor with encoder
Encoder A/B/Z connected to LinuxCNC
encoder.0.x4-mode TRUE
encoder.0.position-scale 4000
encoder.0.counter-mode 0
BASE_PERIOD = 30000
SERVO_PERIOD = 1000000
I have been working on spindle orientation (M19) and I have found that s_orient is very effective.
With the s_orient version of my HAL, the spindle can be run at relatively high speed (up to about 3000 rpm), stopped at different positions, and then correctly oriented with M19. The previous version using the standard orient component could lose its angular zero reference after running the spindle at high speed.
So I would really like to keep s_orient.
The problem
With the previous HAL using the standard orient component, I had:
net spindle-index-enable encoder.0.index-enable <=> spindle.0.index-enable
This allowed rigid tapping with:
G33.1 Z-5 K1
and M19 also worked reasonably well.
With the new s_orient version, I have:
net orient-index-enable encoder.0.index-enable <=> orient.0.index-enable
This gives a much better and more stable M19, but G33.1 no longer starts correctly.
During a G33.1 test I observed:
spindle.0.index-enable = TRUE
orient.0.index-enable = FALSE
encoder.0.index-enable = FALSE
So the request from spindle.0.index-enable does not reach the encoder.
For comparison, with the old HAL, the direct connection
net spindle-index-enable encoder.0.index-enable <=> spindle.0.index-enable
made rigid tapping work.
Current s_orient connection
The relevant part of the current HAL is:
net spindle-position encoder.0.position
net spindle-position => spindle.0.revs
net spindle-position => orient.0.position
net spindle-position => orient-pid.feedback
net spindle-velocity-feedback-rps encoder.1.velocity => spindle.0.speed-in
net orient-index-enable encoder.0.index-enable <=> orient.0.index-enable
net spindle-phase-a encoder.0.phase-A
net spindle-phase-b encoder.0.phase-B
net spindle-index encoder.0.phase-Z
And:
loadrt s_orient names=orient.0
loadrt pid names=orient-pid
loadrt mux2 names=spindle-mux
addf orient.0 servo-thread
addf orient-pid.do-pid-calcs servo-thread
addf spindle-mux servo-thread
net orient-enable spindle.0.orient => orient.0.enable
net orient-enable => orient-pid.enable
net orient-angle spindle.0.orient-angle => orient.0.angle
net orient-mode spindle.0.orient-mode => orient.0.mode
net orient-command orient.0.command => orient-pid.command
net spindle-oriented orient.0.is-oriented => spindle.0.is-oriented
The PID settings currently are:
setp orient-pid.Pgain 75
setp orient-pid.Igain 0
setp orient-pid.Dgain 0
setp orient-pid.FF0 0
setp orient-pid.FF1 0
setp orient-pid.maxoutput 50
setp orient-pid.deadband 0
setp orient.0.tolerance 2.0
My question
What is the correct way to share the bidirectional index-enable function between:
spindle.0.index-enable
orient.0.index-enable
encoder.0.index-enable
so that both of these work correctly?
M19
and
G33.1
I understand that index-enable is a bidirectional HAL pin, so I suspect that simply OR-ing the signals is not the correct solution.
I also tried checking for tristate-bit, but it is not available/loaded in my LinuxCNC installation, and trying:
halcmd loadrt tristate-bit
failed with:
waitpid failed /usr/bin/rtapi_app tristate-bit
rtapi_app exited without becoming ready
insmod for tristate-bit failed
I would like to keep the s_orient solution because M19 is now very effective and stable, especially after running the spindle at high speed.
I am only looking for the correct way to restore G33.1 / rigid tapping without degrading the s_orient behaviour.
Any advice would be greatly appreciated.
Thank you!
Please Log in or Create an account to join the conversation.
- Aciera
-
- Away
- Administrator
-
Less
More
- Posts: 4801
- Thank you received: 2160
24 Aug 2026 18:48 #348968
by Aciera
You just need to connect all three to the same signal, so for example like this:
Replied by Aciera on topic M19 orientation drift with external encoder and orient component (LinuxCNC 2.9.4
What is the correct way to share the bidirectional index-enable function between:
spindle.0.index-enable
orient.0.index-enable
encoder.0.index-enable
You just need to connect all three to the same signal, so for example like this:
net spindle-index-enable encoder.0.index-enable spindle.0.index-enable
net spindle-index-enable orient.0.index-enable
Please Log in or Create an account to join the conversation.
- LinuxCNC
- General LinuxCNC Questions
- M19 orientation drift with external encoder and orient component (LinuxCNC 2.9.4
Time to create page: 0.195 seconds