Lathe C axis homing
- jetbadger
- Offline
- New Member
-
Less
More
- Posts: 3
- Thank you received: 0
25 Mar 2026 12:58 - 25 Mar 2026 13:23 #344719
by jetbadger
Lathe C axis homing was created by jetbadger
First hello everyone, my first post here. 
I'm currently trying to make a Schaublin 110 retrofit work and using the config from here github.com/LinuxCNC/linuxcnc/issues/3556 as a basis to try and make the C axis functional, however I cannot get it to home. The c-index-enable signal and all corresponding ones are not set to true when homing. I can set it manually in halshow and the axis will reach the index point, but then it resets it before it latches again. I went through everything to the best of my extremely limited ability but can't figure it out. The things I've changed were that C axis is now on Joint2.
I'm currently trying to make a Schaublin 110 retrofit work and using the config from here github.com/LinuxCNC/linuxcnc/issues/3556 as a basis to try and make the C axis functional, however I cannot get it to home. The c-index-enable signal and all corresponding ones are not set to true when homing. I can set it manually in halshow and the axis will reach the index point, but then it resets it before it latches again. I went through everything to the best of my extremely limited ability but can't figure it out. The things I've changed were that C axis is now on Joint2.
Attachments:
Last edit: 25 Mar 2026 13:23 by jetbadger.
Please Log in or Create an account to join the conversation.
- spumco
- Offline
- Platinum Member
-
Less
More
- Posts: 1992
- Thank you received: 819
25 Mar 2026 16:05 #344724
by spumco
Replied by spumco on topic Lathe C axis homing
I based my C-axis config on Aciera's example as well; he really saved my bacon discovering the index-enable synchronized motion bug.
I don't see anything really obvious in your config at first glance...you've got HOME_USE_INDEX in INI set right...
Index-enable signal appears to be connected to everything:
How are you trying to home joint 2? Home-all, or just that joint/axis? halui or something else?
What actually happens when you try to home joint 2? Keep spinning forever, doesn't move, or something else?
Just for reference, my config starts up in C-axis mode, and there are (software) restrictions so I can't put it in spindle mode until the Caxis is homed.
I could post my config, but it's really complicated and not in a final-final state just yet. If you/we cant get yours sorted out quickly I'll post it for you to try to digest.
I don't see anything really obvious in your config at first glance...you've got HOME_USE_INDEX in INI set right...
Index-enable signal appears to be connected to everything:
- encoder
- spindle
- orient
- joint
- pid-spindle
- pid-orient
- pid-axis
How are you trying to home joint 2? Home-all, or just that joint/axis? halui or something else?
What actually happens when you try to home joint 2? Keep spinning forever, doesn't move, or something else?
Just for reference, my config starts up in C-axis mode, and there are (software) restrictions so I can't put it in spindle mode until the Caxis is homed.
# MAIN SPINDLE IS-HOMED SIGNAL - SWITCH FROM CAXIS TO SPINDLE MODE
setp oneshot.s0home.width 1
net SPIN0-CAXIS-IS-HOMED <= joint.2.homed #TO 02IO.HAL, M254/M255, AND PID.C MAXOUTPUT
net SPIN0-CAXIS-IS-HOMED => oneshot.s0home.in
net SPIN0-HOME-MODE-SWITCH <= oneshot.s0home.out
net SPIN0-HOME-MODE-SWITCH => halui.mdi-command-02 #CALL M255 TO PUT MAIN SPINDLE BACK TO SPINDLE MODE AFTER INITIAL CAXIS HOMINGI could post my config, but it's really complicated and not in a final-final state just yet. If you/we cant get yours sorted out quickly I'll post it for you to try to digest.
The following user(s) said Thank You: jetbadger
Please Log in or Create an account to join the conversation.
- jetbadger
- Offline
- New Member
-
Less
More
- Posts: 3
- Thank you received: 0
25 Mar 2026 16:19 #344725
by jetbadger
Replied by jetbadger on topic Lathe C axis homing
I found the error on my part just minutes ago. I had set HOME_SEARCH_VEL != 0 and that was the issue. Caused half a day of headache for myself, but now the C axis homes and after a few tweaks responds to commands to some extent, yay 
I was homing it from the gmocappy GUI and now the homing bit works great! Now the other problem is with the mcodes and remaps. Calling m419/420 causes errors with "ngc file ended with no % sign or program end" and unknown m119/120 code. Will try to figure that out next.
I have to thank you and Aciera as your work let me actually attempt this
I was homing it from the gmocappy GUI and now the homing bit works great! Now the other problem is with the mcodes and remaps. Calling m419/420 causes errors with "ngc file ended with no % sign or program end" and unknown m119/120 code. Will try to figure that out next.
I have to thank you and Aciera as your work let me actually attempt this
Please Log in or Create an account to join the conversation.
- spumco
- Offline
- Platinum Member
-
Less
More
- Posts: 1992
- Thank you received: 819
25 Mar 2026 19:43 #344732
by spumco
Replied by spumco on topic Lathe C axis homing
Good job!
I've renamed my m-codes from the original example, and due to some jitter (servo dithering) when the motor/drive is in position mode I just leave the drive in velocity mode. LCNC is switched between spindle/orient/positioning.
My M-codes and main spindle HAL file are attached for your review; maybe they can help.
There is quite a bit commented out, but the gist of it is M254/M255 are used to switch between C-axis and spindle mode, using spindle-orient to realign the spindle before re-connecting the C-axis encoder.
M102 & M103 are 'backstage' M-codes used to adjust stepgen & c-axis PID settings (and disconnect index-enable) in a way you can't (I think) do from inside a normal .ngc g-code file.
Let me know if anything is really unclear.
I've renamed my m-codes from the original example, and due to some jitter (servo dithering) when the motor/drive is in position mode I just leave the drive in velocity mode. LCNC is switched between spindle/orient/positioning.
My M-codes and main spindle HAL file are attached for your review; maybe they can help.
There is quite a bit commented out, but the gist of it is M254/M255 are used to switch between C-axis and spindle mode, using spindle-orient to realign the spindle before re-connecting the C-axis encoder.
M102 & M103 are 'backstage' M-codes used to adjust stepgen & c-axis PID settings (and disconnect index-enable) in a way you can't (I think) do from inside a normal .ngc g-code file.
Let me know if anything is really unclear.
The following user(s) said Thank You: jetbadger
Please Log in or Create an account to join the conversation.
- spumco
- Offline
- Platinum Member
-
Less
More
- Posts: 1992
- Thank you received: 819
25 Mar 2026 20:02 #344733
by spumco
Replied by spumco on topic Lathe C axis homing
I thought I'd added my HAL file, guess not.
The M-code files still have remnants of my first attempt at switching the drive (internally) between velocity and position modes as in @Aciera's example. That stuff is commented out; just ignore it if you aren't switching your drive.
If you ARE switching your drive internally, you'll probably want stuff like "M66, check for drive mode" in your M-code file.
The M-code files still have remnants of my first attempt at switching the drive (internally) between velocity and position modes as in @Aciera's example. That stuff is commented out; just ignore it if you aren't switching your drive.
If you ARE switching your drive internally, you'll probably want stuff like "M66, check for drive mode" in your M-code file.
The following user(s) said Thank You: COFHAL, jetbadger
Please Log in or Create an account to join the conversation.
- jetbadger
- Offline
- New Member
-
Less
More
- Posts: 3
- Thank you received: 0
26 Mar 2026 19:04 #344795
by jetbadger
Replied by jetbadger on topic Lathe C axis homing
Thanks! If I understand correctly you load the machine with spindle in spindle mode, rather than Caxis mode? That makes sense and is one of the things I would've wanted to achieve too, I'll be definitely taking notes from your files
Once I figure out why the mcodes don't seem to work for me even though the directory and files seem ok, probably some other silly thing I overlooked. Gotta rtfm. I will have a chance to play around with the lathe in a few days and will report the results
Please Log in or Create an account to join the conversation.
- spumco
- Offline
- Platinum Member
-
Less
More
- Posts: 1992
- Thank you received: 819
26 Mar 2026 19:33 #344797
by spumco
Replied by spumco on topic Lathe C axis homing
No, the machine starts up in C-axis mode. Actually, it may be more useful to think of it as the C-axis is always 'on', but paused when the spindle or orient is engaged.
Minor tip: one thing that frequently trips me up when copying/using other people's files is forgetting to change the M-code (and other) path(s) in the INI file.
- Start LCNC
- C-axis is not paused, encoder disconnect not active
- Home all axes
- axes-are-homed triggers C-axis homing
- C-axis is-homed signal triggers M255 via one-shot and halui.mdi
- M255
- Checks if C-axis is homed, abort if not homed
- G0 C0
- Disconnect encoder from c-axis joint/axis and PID
- Disable C-axis PID
- Change stepgen settings to spindle values
- Now in spindle mode, all automatically.
- M254
- Checks if C-axis is homed, abort if not homed
- M19 orient spindle to 0 position
- change stepgen to C-axis values
- reconnect encoder
- enable PID
- C-axis is on, and positioned at C0
Minor tip: one thing that frequently trips me up when copying/using other people's files is forgetting to change the M-code (and other) path(s) in the INI file.
Please Log in or Create an account to join the conversation.
- Aciera
-
- Offline
- Administrator
-
Less
More
- Posts: 4671
- Thank you received: 2083
26 Mar 2026 19:39 #344798
by Aciera
Replied by Aciera on topic Lathe C axis homing
Note that mcode files containing executable code (eg m119, m120) need to marked as executable (right click on the file -> properties -> permissions).Calling m419/420 causes errors with "ngc file ended with no % sign or program end" and unknown m119/120 code.
The following user(s) said Thank You: spumco
Please Log in or Create an account to join the conversation.
- spumco
- Offline
- Platinum Member
-
Less
More
- Posts: 1992
- Thank you received: 819
26 Mar 2026 19:48 #344799
by spumco
Replied by spumco on topic Lathe C axis homing
Forgot some important safety stuff...
M254 also sets an M5, as well as turns on spindle.N.inhibit.
M255 also sets an M5, and turns off spindle.N.inhibit.
I got caught out by this during testing when I left an M3 command active and switched to C-axis. When I switched back to spindle mode and gave it an Sxxxx RPM value it immediately started rotating. That was a pants-fudge event...
As you go through my HAL file, you may notice some partly-related but (perhaps) unclear functions/logic. One of these is a spindle disable/freewheel feature which I use when indicating a part or toolholder.
My particular spindle motor (SZGH) does not permit freewheeling the motor in velocity mode if it's enabled. Simply disconnecting the drive enable whenever you want isn't good enough, because the C-axis freaks out with a following error once you start rotating the chuck by hand. So the disable function has a bunch of checks to make sure C-axis is paused, and there are no other backstage things trying to force the motor to spin the moment you turn the freewheel function off.
M254 also sets an M5, as well as turns on spindle.N.inhibit.
M255 also sets an M5, and turns off spindle.N.inhibit.
I got caught out by this during testing when I left an M3 command active and switched to C-axis. When I switched back to spindle mode and gave it an Sxxxx RPM value it immediately started rotating. That was a pants-fudge event...
As you go through my HAL file, you may notice some partly-related but (perhaps) unclear functions/logic. One of these is a spindle disable/freewheel feature which I use when indicating a part or toolholder.
My particular spindle motor (SZGH) does not permit freewheeling the motor in velocity mode if it's enabled. Simply disconnecting the drive enable whenever you want isn't good enough, because the C-axis freaks out with a following error once you start rotating the chuck by hand. So the disable function has a bunch of checks to make sure C-axis is paused, and there are no other backstage things trying to force the motor to spin the moment you turn the freewheel function off.
The following user(s) said Thank You: besriworld
Please Log in or Create an account to join the conversation.
Time to create page: 0.310 seconds