4th axis as lathe spindle: question about index
Since I want a rotary axis capable of functioning as a lathe spindle somewhere in the future too I am creating a 'millturn-helper' component which goes inbetween 'motion', the spindle control and the 4th axis control. It supports three modes:
- mode 0: regular XYZ(A|B|C) operation.
- mode 1: 4th axis rotates with a given speed in a given direction, rest of the mill basically functions as a configuration without that rotary axis.
- mode 2: 4th axis becomes the main spindle. The regular spindle becomes an auxiliary spindle which can be given a speed and direction.
A remapped M-code can switch modes and set 'auxiliary spindle' speed.
I have mode 0 and 1 working, including accel/decel within given limits, raising a busy flag when things are getting to the right speed/position, returning the 4th axis to the previous angular position when switching back to mode 0, etcetera.
For mode 2 I think I need to process motion.spindle-index-enable and generate motion-spindle-revs if I want to be able to use spindle synchronised motion. But I cannot figure out how LinuxCNC uses these / what the timing is with the spindle. I do not have a 4th axis myself yet (although I did a minimal hookup of a servo to do some testing) and I cannot persuade halscope to trigger on motion.spindle-index-enable when using the axis lathe sim config.
Questions:
- Can anybody with a lathe make a trace of motion.spindle-index-enable and motion.spindle-revs so I can see what happens and when?
- How does one process a bidirectional (io) bit in comp? For example, how does one create just a pass through from pin A to pin B?
Please Log in or Create an account to join the conversation.
for your second question, I think something like that should work:
pin io bit A;
pin io bit B ;
and in your main code,
A=B;
but just for a pass through
pin in bit A;
pin out bit B;
B=A;
Please Log in or Create an account to join the conversation.
component iotest;
pin io bit A;
pin io bit B;
function _;
license "GPL"; // indicates GPL v2 or later
author "DaBit (dabitATicecoldcomputingDOTcom)";
;;
FUNCTION(_) {
A = B;
}
Then at startup:
A value: FALSE
B value: FALSE
After executing setp iotest.0.A TRUE:
A value: FALSE
B value: FALSE
After executing setp iotest.0.B TRUE:
A value: TRUE
B value: TRUE.
So the assignment only works one way. As expected since we assign A the value of B.
Something that does seem to work both ways for both polarities is this:
component iotest;
pin io bit A;
pin io bit B;
variable u32 prevA;
variable u32 prevB;
function _;
license "GPL"; // indicates GPL v2 or later
author "DaBit (dabitATicecoldcomputingDOTcom)";
;;
FUNCTION(_) {
if ((u32)A != prevA) B=A;
else if ((u32)B != prevB) A=B;
prevA = (u32)A; prevB = (u32)B;
}
Now we can set and clear either A or B, and a change on one of the ports is reflected on the other.
But I really wonder if this is how I am supposed to handle io signals?
if I remember correctly, you have to set indexenable to "1", and when it reaches the index pulse it goes to "0", so it can't be the reason why you can trigger it.
Yes, I know. But I wonder how LinuxCNC uses motion.spindle-index-enable and motion.spindle-revs when doing spindle-synchronised motion. In mode 2 (lathe-mode) I have to swap spindles while keeping LinuxCNC happy and I wonder what the best method is..
Anyway, mode 0 and 1 work nicely. When I execute a 'M120 P1 Q1000':
And after 'M120 P0 Q0' the axis stops nicely at the angular position where it was before the 'M120 P1 Q1000' was executed.
For the guy who needs this earlier than I do it is probably sufficient; as far as i know he has no index pulse on his chuck anyway.
Please Log in or Create an account to join the conversation.
Since I want a rotary axis capable of functioning as a lathe spindle somewhere in the future too I am creating a 'millturn-helper' component which goes inbetween 'motion', the spindle control and the 4th axis control. It supports three modes:
It might actually be easier to have three separate configs that use the same hardware. This is the approach I have taken on my combo machine, I load the lathe config or the mill config depending on the job. I also do the same thing with my mill, I load "mill" or "hobbing" depending on what I am doing.
motion.spindle-index-enable is only used for threading (G76 or G38 / G38.1). The pin is set to 1 before the beginning of the threading pass, then the encoder sets it to zero and zeros the position output (motion.spindle-revs) when it sees the index. motion sees that the pin has gone to zero and starts the threading move, synchronised to the encoder position output.Can anybody with a lathe make a trace of motion.spindle-index-enable and motion.spindle-revs so I can see what happens and when?
Note that spindle-revs is "revolutions" not "rpm".
[/quote]- How does one process a bidirectional (io) bit in comp? For example, how does one create just a pass through from pin A to pin B?[/quote]
You need to only ever write to it when necessary, as your second bit of code is. It is quite likely that your comp might never need to write to the pin, it might simply want to watch it.
Please Log in or Create an account to join the conversation.
It might actually be easier to have three separate configs that use the same hardware. This is the approach I have taken on my combo machine, I load the lathe config or the mill config depending on the job. I also do the same thing with my mill, I load "mill" or "hobbing" depending on what I am doing.
With separate configs it is also necessary to re-home between 'lathe' and 'mill' passes on the same piece of stock. Or at least you want to re-home to make sure the machine coordinates are the same.
And since it is possible to have the lathe tools and the spindle mounted simultaneously to the Z column it kind of makes sense to be able to swap between the two in the same session or even program. Also: one solution does not rule out the other; if you are only using the lathe mode it makes sense to load an XZ config and in an XYZA config the 'millturn-helper' component is transparent unless you put it in another mode than 0.
But to be honest: I never ever ran a lathe myself so I probably have no idea what I am talking about.. But whenever I make round things (which I can only do using circular interpolation at the moment) I very often have to mill a flat or hex somewhere to be able to put a wrench on it, drill a couple of holes, etc. I am also pretty sure that hobby class milling machines lack the stiffness of a decent lathe and building a 4th axis capable of acting as a lathe headstock is probably just as expensive as buying a used lathe, but I am simply lacking space in my shed to put in all the machinery I want.
Oh well, if reality shows that this component is a solution for a nonexistent problem then at least I learned a bit more about the inner workings of LinuxCNC.
The pin is set to 1 before the beginning of the threading pass, then the encoder sets it to zero and zeros the position output (motion.spindle-revs) when it sees the index. motion sees that the pin has gone to zero and starts the threading move, synchronised to the encoder position output.
Note that spindle-revs is "revolutions" not "rpm".
I'll check the lathe sim config.
It is quite likely that your comp might never need to write to the pin, it might simply want to watch it.
I probably do not need to watch it either. To swap rotary axis and spindle I probably just need to multiplex the pin. Although the resetting that happens on the index pulse might cause a bit of trouble. We shall see.
Please Log in or Create an account to join the conversation.
Have you seen Simpson36's efforts to do basically the same as you talk about here with Mach3? He basically had to make hardware electronics to make it happen in Mach3. I believe you can do all he was doing purely in software in LinuxCNC.
Here is a link to the thread about it on the mach support forum.
As is quite evident he is quite a skilled guy capable of building high quality machines. Also check out his videos of this on YouTube. He's username is the same there. And he is building all his machines from scratch himself. Quite impressive really!
As you can see in the thread (if you read all of it, it's quite long...) I say to him I'd like to build something similar. And the fact is that I still do. But I'd like to do it in LinuxCNC though.
I now have gathered several good alternatives for hardware to use as my 4th axis to accomplish this. One of them is a directly driven sub-spindle of off a Gildemeister CTX (I have the main spindle too, but that's way to big and heavy to use like that). I also have a 1:100 harmonic drive to gear down a separate servo motor to use it as a C-axis. This will have to be mechanically interfaced to be able to engage and disengage it as needed. I also have a normal 4th axis, but I'm not sure how to make that work as a lathe. I will look in to more details of this when I come to it. For now I have more basic config issues to solve.
Anyway. I was very happy to read you were working on implementing what would be needed to do this in LinuxCNC. I would be sorry to hear you gave it up just like that. Yes, multiple configs will be possible like Andy use. Possibly also able to read and save to the same position save file so you in theory won't need to re-home. Although I would want to do a re-homing after switching between configs anyway......
So I do hope you can be inspired by simpson36's efforts and keep working on this idea. This proves it has been done before by others, and I think it would be worth it. If you make it work I will be one of the guys to try it on my mill (hope to convert to mill-turn soon
![:) :)](/media/kunena/emoticons/smile.png)
I just took a look at his YouTube channel to check if he had come with any new videos lately, and he has! He recently posted new videos of his latest generation of 4th axis. Very interesting to see a guy like that do his thing!
Anders
Please Log in or Create an account to join the conversation.
I certainly won't stop developing that millturn-helper component, but I'll postpone implementing 'mode 2: 4th axis as main spindle' until I have my own 4th axis. In it's current state it is useable; one can make the 4th axis rotate with a given RPM, do turning operations that don't require spindle synchronisation or CSS, and switch back to indexed mode. Things like thread cutting can be done in indexed mode as well: G1 X-10 A3600 would cut a helix with 1mm (or 1 inch) pitch. It is only a bit fiddly with choosing the feed rate and returning the A axis to zero.
If you need the component, just shout. It is too untested and undocumented to put it in public yet, but if you want to be a beta tester: yes please!
In the end I need a few more features BTW: I definitely want a lock/brake on the A-axis spindle for example. LinuxCNC supports a locking indexer, but then you cannot do simultaneous linear/rotary moves. That probably also requires a helper component to generate a lock/unlock signal and feed-hold signal based on A axis movement. Or so; I did not think very hard about that yet.
The good thing: LinuxCNC can be persuaded to do all this and more. No need for external control boxes, just a bit of HALlogic, remapped M codes and a few lines of C code run through 'comp' where it beats tying together a gazillion standard RT components. That's the real beauty of LinuxCNC.
Totally offtopic: my scratch-built CNC machine made it's first cut yesterday, and I am sooooo happy!
Still far from 'finished'; I have a gazillion small issues to resolve and jobs to do.
Gantry style mill, 25mm indexed endmill, cutting steel. Some say that cannot be done on a gantry mill
![:P :P](/media/kunena/emoticons/tongue.png)
Absolutely boring video, except for the person who is already spending a year on construction of that machine:
Please Log in or Create an account to join the conversation.
Have you seen Simpson36's efforts to do basically the same as you talk about here with Mach3? He basically had to make hardware electronics to make it happen in Mach3. I believe you can do all he was doing purely in software in LinuxCNC.
You can, here is an example using just the standard spindle servo on a Hardinge lathe:
The "orient" component can be handy for providing a position reference, but that only updates the output when the enable changes, so any C-axis position command would need to be added to the orient.0.command output rather then the more obvious approach of wiring the C-axis command position into the orient.0.angle pin.
There is a slight risk of running out of position resolution after running the spindle for a long time prior to using C-axis mode. ( Actually, that isn't a concern: Double-precision has 52 bits of resolution, so you would only have 0.1 degrees of accuracy in spindle position after 6E11 spindle revolutions. which is 20,000 days of running at 20,000 rpm...)
I don't believe that C-axis spindle is especially difficult, but any particular solution is likely to be rather hardware-dependant.
Please Log in or Create an account to join the conversation.
Things like thread cutting can be done in indexed mode as well: G1 X-10 A3600 would cut a helix with 1mm (or 1 inch) pitch. It is only a bit fiddly with choosing the feed rate and returning the A axis to zero.
If you have a spindle encoder you can do this with a standard config and G38.1.
(YouTube Video)
Please Log in or Create an account to join the conversation.
Yes, being able to use G33, G96, M19, etc. is the purpose of 'mode 2'.
But if you only intend to do lathe operations within a single program, a 'lathe config' makes more sense.
BTW: what about the signed 32-bit counter inside the (software/mesa) encoder components? What happens if that one overflows? Is that captured and accounted for in software?
(I can figure that one out by looking into the source also, BTW)
Please Log in or Create an account to join the conversation.