Need help making rotary axis behave like second spindle
- theslawek
- Offline
- New Member
-
Less
More
- Posts: 13
- Thank you received: 1
09 Apr 2025 17:45 #326001
by theslawek
Need help making rotary axis behave like second spindle was created by theslawek
I have a turning application that's better suited towards a constant RPM on the rotary. I have my A axis functioning fine right now with position control.
I'd love to be able to just issue a M3 S1000 $1 instead of playing with the inverse time mode approaches.
I've searched the forum and tried several things without luck. Honestly, anything HAL related is an instant headache nightmare for me. Believe it or not, I'm an embedded programmer and did ladder logic in college, but the HAL stuff just does NOT click for me. I'd be willing to pay for someone's time to figure this out for me. I have a project for my church that is way behind.
I'm using Probe Basic for the GUI. I'd be willing to give up some GUI control as long as I can issue gcode commands.
Attached are my current INI and primary HAL.
Tried:
- Changing control_type from 1 to 0, but had no idea what else to do
- Considered the rosekins but that doesn't really apply to my needs
Other forum posts I've read:
- C Axis as Second Spindle - LinuxCNC
- Using A axis as second spindle with stepper motor - LinuxCNC
- Lathe spindle question turning and milling. - LinuxCNC
Thank you.
I'd love to be able to just issue a M3 S1000 $1 instead of playing with the inverse time mode approaches.
I've searched the forum and tried several things without luck. Honestly, anything HAL related is an instant headache nightmare for me. Believe it or not, I'm an embedded programmer and did ladder logic in college, but the HAL stuff just does NOT click for me. I'd be willing to pay for someone's time to figure this out for me. I have a project for my church that is way behind.
I'm using Probe Basic for the GUI. I'd be willing to give up some GUI control as long as I can issue gcode commands.
Attached are my current INI and primary HAL.
Tried:
- Changing control_type from 1 to 0, but had no idea what else to do
- Considered the rosekins but that doesn't really apply to my needs
Other forum posts I've read:
- C Axis as Second Spindle - LinuxCNC
- Using A axis as second spindle with stepper motor - LinuxCNC
- Lathe spindle question turning and milling. - LinuxCNC
Thank you.
Please Log in or Create an account to join the conversation.
- andypugh
-
- Offline
- Moderator
-
Less
More
- Posts: 23271
- Thank you received: 4928
11 Apr 2025 14:18 #326064
by andypugh
Replied by andypugh on topic Need help making rotary axis behave like second spindle
Please Log in or Create an account to join the conversation.
- jimmyrig
- Offline
- Premium Member
-
Less
More
- Posts: 111
- Thank you received: 36
12 Apr 2025 01:37 #326137
by jimmyrig
Replied by jimmyrig on topic Need help making rotary axis behave like second spindle
Easiest way would be to make another config.
leave the old one for when you need position.
In the new config change the A to be a spindle.
Lookup step and direction spindle for examples. If you dont want to mess with it I could do it for you.
Then it should work as you intend with me s1000 $1
leave the old one for when you need position.
In the new config change the A to be a spindle.
Lookup step and direction spindle for examples. If you dont want to mess with it I could do it for you.
Then it should work as you intend with me s1000 $1
Please Log in or Create an account to join the conversation.
- theslawek
- Offline
- New Member
-
Less
More
- Posts: 13
- Thank you received: 1
14 Apr 2025 06:16 #326244
by theslawek
I've already searched around and tried tweaking things, but wasn't getting any success. I think I may be getting stuck up on the motion related HAL entries but I'm not sure. I would be very grateful if you could sort it out for me.
Andy, I wouldn't know where to start with this.
Replied by theslawek on topic Need help making rotary axis behave like second spindle
Yes, I would plan to have an alternative config for this use case.Easiest way would be to make another config.
leave the old one for when you need position.
In the new config change the A to be a spindle.
Lookup step and direction spindle for examples. If you dont want to mess with it I could do it for you.
Then it should work as you intend with me s1000 $1
I've already searched around and tried tweaking things, but wasn't getting any success. I think I may be getting stuck up on the motion related HAL entries but I'm not sure. I would be very grateful if you could sort it out for me.
Does this help at all?
wiki.linuxcnc.org/uploads/orient.svg
It's one potential way to do it.
Andy, I wouldn't know where to start with this.
Please Log in or Create an account to join the conversation.
- spumco
- Offline
- Platinum Member
-
Less
More
- Posts: 1923
- Thank you received: 766
14 Apr 2025 12:56 #326272
by spumco
Replied by spumco on topic Need help making rotary axis behave like second spindle
OP-
Unfortunately, there is no built-in or pre-made configuration for combining a rotary axis and spindle functions in LCNC. As you've discovered in other forum posts there are a number of ways to skin the cat, but none of them can be implemented without some HAL fiddling. Much like tool changers, rotary axes/spindle combinations are very hardware dependent so a one-size-fits-all approach is unlikely to be created and incorporated in to mainstream LCNC code.
Others may - hopefully will - chime in, but what I've gathered is the fundamental hurdles to a combination axis/spindle is that LCNC cannot re-home an axis in the middle of a gcode program. Other controls I've used (or own) home the rotary axis every time the axis is engaged via M-code, including in the middle of a program. LCNC can't do this, and so the result is a massive following error between where LCNC expects the rotary axis to be and the real position after running in spindle mode and then switching back to axis mode.
If you have axis encoder feedback to LCNC, then LCNC goes crazy when you switch from spindle mode to axis mode due to the following error.
If you don't have encoder feedback (open loop), then there is no way to switch from axis to spindle and back to axis mode in the middle of a program without completely losing track of position.
All the configurations I've come across for axis/spindle are just different schemes to work around the above problem.
Do you need the A-axis/4th axis to do synchronized motion with another axis? i.e. lathe-like threading or rigid tapping?
If not, then the caxis.comp HAL component would be the easiest way to get your 4th to behave like a spindle. Once of the nice things about caxis.comp is that there are no M-codes required to 'switch' back and forth between positioning and spindle (velocity) modes. Caxis.comp handles that internally - essentially it checks for spindle-type commands and if one is issued (M3 Sxxx $xx) then it spins the rotary axis. When the spindle stop command is issued caxis.comp simply returns the rotary axis to the last position it was at before the velocity command was triggered.
If you do need synchronized motion then one of the other methods would be better; I've found that caxis.comp interferes with synchronized moves and have had to abandon attempts at using it on my lathe in favor of one of the other configuration types.
It would help if we knew what your end-goal was, or at least how you intend to use the combo spindle/axis.
Is it primarily going to be a rotary axis with infrequent spindle work? Or is it more like a lathe with infrequent C-axis positioning?
What are you driving the rotary axis with? Servo drive? If so, is the drive capable of homing accurately on its own?
Unfortunately, there is no built-in or pre-made configuration for combining a rotary axis and spindle functions in LCNC. As you've discovered in other forum posts there are a number of ways to skin the cat, but none of them can be implemented without some HAL fiddling. Much like tool changers, rotary axes/spindle combinations are very hardware dependent so a one-size-fits-all approach is unlikely to be created and incorporated in to mainstream LCNC code.
Others may - hopefully will - chime in, but what I've gathered is the fundamental hurdles to a combination axis/spindle is that LCNC cannot re-home an axis in the middle of a gcode program. Other controls I've used (or own) home the rotary axis every time the axis is engaged via M-code, including in the middle of a program. LCNC can't do this, and so the result is a massive following error between where LCNC expects the rotary axis to be and the real position after running in spindle mode and then switching back to axis mode.
If you have axis encoder feedback to LCNC, then LCNC goes crazy when you switch from spindle mode to axis mode due to the following error.
If you don't have encoder feedback (open loop), then there is no way to switch from axis to spindle and back to axis mode in the middle of a program without completely losing track of position.
All the configurations I've come across for axis/spindle are just different schemes to work around the above problem.
Do you need the A-axis/4th axis to do synchronized motion with another axis? i.e. lathe-like threading or rigid tapping?
If not, then the caxis.comp HAL component would be the easiest way to get your 4th to behave like a spindle. Once of the nice things about caxis.comp is that there are no M-codes required to 'switch' back and forth between positioning and spindle (velocity) modes. Caxis.comp handles that internally - essentially it checks for spindle-type commands and if one is issued (M3 Sxxx $xx) then it spins the rotary axis. When the spindle stop command is issued caxis.comp simply returns the rotary axis to the last position it was at before the velocity command was triggered.
If you do need synchronized motion then one of the other methods would be better; I've found that caxis.comp interferes with synchronized moves and have had to abandon attempts at using it on my lathe in favor of one of the other configuration types.
It would help if we knew what your end-goal was, or at least how you intend to use the combo spindle/axis.
Is it primarily going to be a rotary axis with infrequent spindle work? Or is it more like a lathe with infrequent C-axis positioning?
What are you driving the rotary axis with? Servo drive? If so, is the drive capable of homing accurately on its own?
Please Log in or Create an account to join the conversation.
- theslawek
- Offline
- New Member
-
Less
More
- Posts: 13
- Thank you received: 1
14 Apr 2025 14:41 #326285
by theslawek
Replied by theslawek on topic Need help making rotary axis behave like second spindle
Hi Spumco,
I can't find any official documentation about caxis.comp, just many forum posts about it from you. Is this something new not in the documentation yet?
My goal is to make my CNC router use the rotary axis and simulate a lathe. I've actually already done this before moving to my Mesa 7i76e but using an external device with a dial ( amazon link ) to control the speed. I'd like to have that programatic control over the speed for obvious reasons. I actually have a YouTube video on what I did then.
I don't need dynamic change between velocity and position controls. I'm more than happy to restart LinuxCNC with new config when changing operations.
I can't find any official documentation about caxis.comp, just many forum posts about it from you. Is this something new not in the documentation yet?
My goal is to make my CNC router use the rotary axis and simulate a lathe. I've actually already done this before moving to my Mesa 7i76e but using an external device with a dial ( amazon link ) to control the speed. I'd like to have that programatic control over the speed for obvious reasons. I actually have a YouTube video on what I did then.
I don't need dynamic change between velocity and position controls. I'm more than happy to restart LinuxCNC with new config when changing operations.
Please Log in or Create an account to join the conversation.
- spumco
- Offline
- Platinum Member
-
Less
More
- Posts: 1923
- Thank you received: 766
14 Apr 2025 17:46 #326304
by spumco
Replied by spumco on topic Need help making rotary axis behave like second spindle
Caxis.comp is not in the official LCNC distribution, so there isn't going to be any documentation beyond forum posts.
It was authored by Andy Pugh a few years ago while he was working with another forum member who was trying to get his DIY lathe sorted out. The lathe was configured to use the same motor for spindle work as well as c-axis positioning for a live tool.
I wound up in the same boat when I started my lathe project and stumbled across Andy's post where he uploaded caxis.comp. I shamelessly grabbed it and spent quite a bit of time trying to use it and get things sorted out. The forum is littered with my ramblings & whining over the past year or so.
If you don't mind re-starting LCNC for spindle-mode, then creating two configurations should be pretty easy.
Do you need two spindles at the same time? Like a router bit spinning in main spindle, and 4th axis-spindle turning as well?
Is the config you attached in the original post working well for you now and you just want some help creating a 2nd config for spindle work?
It was authored by Andy Pugh a few years ago while he was working with another forum member who was trying to get his DIY lathe sorted out. The lathe was configured to use the same motor for spindle work as well as c-axis positioning for a live tool.
I wound up in the same boat when I started my lathe project and stumbled across Andy's post where he uploaded caxis.comp. I shamelessly grabbed it and spent quite a bit of time trying to use it and get things sorted out. The forum is littered with my ramblings & whining over the past year or so.
If you don't mind re-starting LCNC for spindle-mode, then creating two configurations should be pretty easy.
Do you need two spindles at the same time? Like a router bit spinning in main spindle, and 4th axis-spindle turning as well?
Is the config you attached in the original post working well for you now and you just want some help creating a 2nd config for spindle work?
Please Log in or Create an account to join the conversation.
- theslawek
- Offline
- New Member
-
Less
More
- Posts: 13
- Thank you received: 1
15 Apr 2025 05:01 - 15 Apr 2025 05:02 #326338
by theslawek
Replied by theslawek on topic Need help making rotary axis behave like second spindle
Ah, I see. I'm not sure I want to dive into something cutting edge. Caxis.comp just sounds intimidating because I haven't read up enough about it yet.
The INI and HAL I attached is a traditional XYZA setup. A is controlled with degree command sequence like below for turning decorative spindles for example.
G00 Z3.3000
G00 A0.0000 Y0.0000 S20000
M3 S20000 (regular 10HP spindle)
G4 P1.5
G01 A359.9011 Y0.0001 Z2.1250 F200.0
For applications when I need the ACTUAL spindle and rotary to spin non-stop (like a spindle) (as in my YouTube video), I envision loading a XYZ+A_Spindle type config where I can issue this instead.
G00 Z3.3000
G00 A0.0000 Y0.0000 S20000
M3 S20000 (regular 10HP spindle)
M3 S100 $1 (additional rotary axis now turning like spindle)
G4 P1.5
G01 Y0.0001 Z2.1250 F200.0
The INI and HAL I attached is a traditional XYZA setup. A is controlled with degree command sequence like below for turning decorative spindles for example.
G00 Z3.3000
G00 A0.0000 Y0.0000 S20000
M3 S20000 (regular 10HP spindle)
G4 P1.5
G01 A359.9011 Y0.0001 Z2.1250 F200.0
For applications when I need the ACTUAL spindle and rotary to spin non-stop (like a spindle) (as in my YouTube video), I envision loading a XYZ+A_Spindle type config where I can issue this instead.
G00 Z3.3000
G00 A0.0000 Y0.0000 S20000
M3 S20000 (regular 10HP spindle)
M3 S100 $1 (additional rotary axis now turning like spindle)
G4 P1.5
G01 Y0.0001 Z2.1250 F200.0
Last edit: 15 Apr 2025 05:02 by theslawek. Reason: Formatting didn't render like preview.
Please Log in or Create an account to join the conversation.
- spumco
- Offline
- Platinum Member
-
Less
More
- Posts: 1923
- Thank you received: 766
15 Apr 2025 11:42 #326347
by spumco
Replied by spumco on topic Need help making rotary axis behave like second spindle
Not sure 'cutting edge' is the right term, but I understand if you're not interested in something slightly experimental. You can always have a go at caxis.comp later.
As far as creating a second configuration goes, there are (at least) a couple ways.
First, you can simply make a copy of your current config and then hand-edit the INI and HAL files. But you mentioned that HAL isn't clicking for you, so that may be a bit of a stretch.
Second method would be to use Mesact to create a new configuration from scratch, but this time you tell Mesact that your spindle is a step & direction type. I think you've got the 4th axis connected to stepgen.04 and are using a 6:1 belt ratio, yes? Include those values in the new config via Mesact, along with an appropriate max speed and estimated max accel for the 4th axis.
Leave out the 'real' spindle settings, and put everything else (axes & IO) the same as your existing config and then see what Mesact comes up with.
That should give you new INI and HAL files which you can use to create a merged/blended configuration that has both spindles and no 4th axis.
I find that using VSCode makes things easy to read/edit (there's a LCNC/HAL file plugin). I'd set up all three HAL files across two monitors and look at the differences. Things to look out for:
[DISPLAY]
GEOMETRY = xyz
[KINS]
KINEMATICS = trivkins coordinates=XYZ
JOINTS = 3
[TRAJ]
COORDINATES = XYZ
SPINDLES=2
[AXIS_A] - remove this entire section
[JOINT_3] - remove this entire section
[SPINDLE_1]
(put the 4th axis spindle stuff here)
Have a go and see what you come up with. Assuming it doesn't work - these things are rarely perfect the first time - and you get an error trying to start LCNC, make sure to screen capture the error and report back here.
As far as creating a second configuration goes, there are (at least) a couple ways.
First, you can simply make a copy of your current config and then hand-edit the INI and HAL files. But you mentioned that HAL isn't clicking for you, so that may be a bit of a stretch.
Second method would be to use Mesact to create a new configuration from scratch, but this time you tell Mesact that your spindle is a step & direction type. I think you've got the 4th axis connected to stepgen.04 and are using a 6:1 belt ratio, yes? Include those values in the new config via Mesact, along with an appropriate max speed and estimated max accel for the 4th axis.
Leave out the 'real' spindle settings, and put everything else (axes & IO) the same as your existing config and then see what Mesact comes up with.
That should give you new INI and HAL files which you can use to create a merged/blended configuration that has both spindles and no 4th axis.
I find that using VSCode makes things easy to read/edit (there's a LCNC/HAL file plugin). I'd set up all three HAL files across two monitors and look at the differences. Things to look out for:
- Dont forget to comment out or delete the A-axis/joint 3 section
- The new spindle needs all pins to be named 'spindle.1.nnn', and the signal names need to be 'spindle1-vel-cmd-nnn' (or similar).
[DISPLAY]
GEOMETRY = xyz
[KINS]
KINEMATICS = trivkins coordinates=XYZ
JOINTS = 3
[TRAJ]
COORDINATES = XYZ
SPINDLES=2
[AXIS_A] - remove this entire section
[JOINT_3] - remove this entire section
[SPINDLE_1]
(put the 4th axis spindle stuff here)
Have a go and see what you come up with. Assuming it doesn't work - these things are rarely perfect the first time - and you get an error trying to start LCNC, make sure to screen capture the error and report back here.
The following user(s) said Thank You: andypugh, tommylight
Please Log in or Create an account to join the conversation.
Time to create page: 0.112 seconds