Need help making rotary axis behave like second spindle
- theslawek
- Offline
- New Member
-
- Posts: 19
- Thank you received: 2
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
-
- Posts: 23279
- Thank you received: 4933
Please Log in or Create an account to join the conversation.
- jimmyrig
- Offline
- Premium Member
-
- Posts: 111
- Thank you received: 36
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
-
- Posts: 19
- Thank you received: 2
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
-
- Posts: 1934
- Thank you received: 773
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
-
- Posts: 19
- Thank you received: 2
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
-
- Posts: 1934
- Thank you received: 773
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
-
- Posts: 19
- Thank you received: 2
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
Please Log in or Create an account to join the conversation.
- spumco
- Offline
- Platinum Member
-
- Posts: 1934
- Thank you received: 773
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.
Please Log in or Create an account to join the conversation.
- theslawek
- Offline
- New Member
-
- Posts: 19
- Thank you received: 2
I ran into a hurdle immediately with MesaCT 2.1.7. When set to 7i76E, or any other card for that matter, the Spindle -> StepGen tab just has a message of "not functioning yet". I even cloned the lastest master from GitHub and the same message is present.
I was about to press Post on this reply, but then I thought, why don't I try PNCConf in case that's what you meant. PNCConf seems to have what you indicated. I did the changes in the INI, but I'm hung up on the HAL part.
Here are the substitutions I made from the PNCConf HAL into the clone of my good xyza config. (A parts were removed)
- pid.s is pid.s1 (including in the loadrt and do-pid-calcs parts)
- SPINDLE_0 to SPINDLE_1
- changed all ".s" entries to ".s1"
- entries such as "net spindle-vel-cmd-rps" changed to "net spindle1-vel-cmd-rps"
I'm stuck with this error:
twopass: Error in file ./hallib/main.hal:
Pin 'spindle.1.speed-ut-rps' does not exist
Which I think relates to this block. I'm not sure how to go from here. Are these related to the GUI?
My latest INI and HALs attached.net spindle1-vel-cmd-rps <= spindle.1.speed-out-rps
net spindle1-vel-cmd-rps-abs <= spindle.1.speed-out-rps-abs
net spindle1-vel-cmd-rpm <= spindle.1.speed-out
net spindle1-vel-cmd-rpm-abs <= spindle.1.speed-out-abs
net spindle1-enable <= spindle.1.on
net spindle1-cw <= spindle.1.forward
net spindle1-ccw <= spindle.1.reverse
net spindle1-brake <= spindle.1.brake
net spindle1-revs => spindle.1.revs
net spindle1-at-speed => spindle.1.at-speed
net spindle1-vel-fb-rps => spindle.1.speed-in
net spindle1-index-enable <=> spindle.1.index-enable
Please Log in or Create an account to join the conversation.