Spindle orient PID tuning [re-solved, yay]

19 Jun 2022 15:35 #245437 by mgm
Hello Ralph,

that is a super execution ...
M19 needs an encoder in the spindle or?
Is there an alternative to orient if I do not have an encoder.

Please Log in or Create an account to join the conversation.

19 Jun 2022 16:47 #245438 by spumco

I genuinely don't know if M19 requires an encoder.  Like everything in LCNC, there are usually about 12 (or more) ways to skin a cat.

If your objective is to position the spindle anywhere you want, then it either needs to be controlled like an axis/joint or through M19 orient.  In either case some sort of feedback would be needed.

If the spindle is controlled via step-direction, I can imagine a single index signal could reset a step counter and LCNC could 'count' how many steps from that signal during a positioning move.  This is, in my mind, similar to the recent 'counts' mode for carousel.comp.

If your objective is to simply line it up for an ATC, then I bet there are ways to do it without M19 and without an encoder.  Off the top of my head I can imagine having a user-defined M-code that starts the spindle at low speed, deploys a shot pin, and shuts the spindle off when the shot pin drops in to place.  If the spindle drive (VFD, servo, etc.) has user programmable inputs, it might be smart to trigger a 'low-torque' setting in the drive during the positioning move.

There are plenty of spindle tapers that don't require the spindle be aligned.  ISO20 or 30, some HSK variants, even BT30 if you remove the drive dogs.  Some vendors sell BT30 holders that don't have dog slots, and I've read some internet speculation that the drive dogs aren't really needed on BT30 below about 4hp - but that speculation probably didn't consider gear reduction with large diameter tools.

I guess a shorter answer would be that it depends on your hardware and objective.  What do you have (or can afford), and what do you want to do with it?  What function(s) is required, and what is nice-to-have?


Please Log in or Create an account to join the conversation.

19 Jun 2022 18:02 #245440 by mgm
Yes the bt30 is only to be aligned for depositing into the carusell. If the two notches are not in insertion direction then the holders do not clamp properly.
In principle, it should then be something like you have done now.
The positioning would then have to be made on the bt30 holder.

Thanks for the inspiration 



Please Log in or Create an account to join the conversation.

19 Jun 2022 18:31 #245441 by spumco
If you're using a high-speed router spindle with smallish diameter tools, I'd be inclined to remove the drive dogs and not worry about spindle orientation.  I suspect that's why many of the ATC spindles with built-in motors I've seen are ISO30 and not BT30.

On the other hand, if you intend to put a big face mill in it to flatten the panels then the drive dogs are probably a very good insurance policy. 

Spinning a holder in the taper can make an expensive mess.

So... what is driving your spindle, and what's the slowest it can rotate?

Please Log in or Create an account to join the conversation.

19 Jun 2022 19:00 #245442 by mgm
The diameter of my tools is between 4 and 30 mm.
I had decided for the BT30, because they are cheaper than the ISO 30. It was only important to me that I have ER32, because in the carpenters many end mills, or diamond cutters have a 20 mm shank.
I was not aware at the time of purchase that there would be a problem, because the spindle has no holder for BT30!

I already have BT30 holder and the retaining clips.
I have not yet bought an ATC spindle, because I was not yet sure.
But I wanted to buy this kind.

The spindle is controlled with an inverter.
I can have my current spindle rotate from 0-18000 and programmable inputs and outputs the inverter also has.

This is the inverter

Please Log in or Create an account to join the conversation.

19 Jun 2022 19:46 #245445 by spumco
The Rattm ATC spindle is advertised as "BT30" on ebay and aliexpress, but...

It's not BT30.  It's ISO30 - same taper, but without the drive dogs.  All the photos show a spindle that's missing the drive dogs, plus I found this on the aliexpress page:


Note the highlighted area.  I think some of the Chinese vendors play a little fast & loose with BT vs ISO designations.  The tapers are interchangable, so who cares, right?

If you do a search for "BT30 Tool Fork" you'll find dozens of plastic forks from China that don't have alignment tabs built in.  Some have a provision for tabs, but very, very few of them come with tabs.  They're all really meant for ISO30 or (BT30 with no spindle drive dogs).

About the only ones that do have tabs - i.e. required for an actual BT30 spindle - are the metal ones intended for Robodrills or similar VMCs - not routers.  The one exception I've found are the Tormach 1100MX holders - those are plastic but have molded-in metal alignment tabs.


There is an actual difference between ISO30 and BT30 holders besides the slots; I think the tool fork groove is different - maybe different diameter or angle or something.  Not sure, TBH.

If you get that ebay spindle you don't need to worry about orienting the spindle.  Your holders may have drive dog slots, but the spindle doesn't need to be lined up with them and your ATC forks wont need alignment tabs.

Please Log in or Create an account to join the conversation.

20 Jun 2022 10:59 #245475 by mgm
Hello Ralph,

Thank you for looking at this!

Please Log in or Create an account to join the conversation.

21 Jun 2022 01:39 #245506 by spumco

And another thing...

I just noticed it's not going to the same orient location each time I start up the machine.  I spent quite some time fiddling with the INI orient_offset a couple days ago to get it perfectly lined up with the carousel pockets, and the 'completed' orient cycle today (attached) wound up about 60 degrees off from the last time I had the machine running.

Sadly, this is still a problem.

Orient does not go to the same place every startup.  The testing I did with the new shotpin worked great... but I'd already run orient without it that session.

I can't tell if LCNC is ignoring the index signal at the start of orient, or my various settings are wrong.

I won't post my silly hal file again, but here are the values I think may be relevant:

(INI file)

orient.0.tolerance              1.0
encoder.00.counter-mode   0
encoder.00.filter                 1
encoder.00.index-invert       0
encoder.00.index-mask       0
encoder.00.index-mask-invert   0

net spindle-index-enable encoder.00.index-enable spindle.0.index-enable

Is the orient tolerance way off? I though I read it's in degrees... but if it's in some strange unit that might explain why ORIENT_OFFSET needed to be that odd 0.328 to get things lined up with the ATC pockets.

Anyone want to take a stab at this?

Please Log in or Create an account to join the conversation.

24 Jun 2022 03:21 #245756 by spumco
Finally figured out why the spindle was orienting in different positions every time I started LCNC.

spindle.0.index-enable, encoder.00.index-enable, and pid.s.index-enable are all connected together in HAL for the orient component.  What this meant was that the index position wasn't resetting after the index pulse went past the pickup.  So every time I started LCNC it thought that the random starting position of the spindle was 'home' and then applied any orient_offset.  Orient position was repeatable during a session, but not between sessions.

Couldn't set any of the index-enable pins high in halshow - they're all connected.  But setting the encoder.00.index-enable pin high in HAL before making the hal connections worked (i.e. earlier in the file)

At LCNC startup the index-enable pins are now high.  Which means that running the spindle for at least one revolution sets the index pulse position properly, and from there I was able to adjust ORIENT_OFFSET in INI until everything lined up with the shot-pin and ATC drive dogs.

It's now behaving properly; I can close LCNC and reopen it and M19 R0 winds up at the same place every session.  Yay.

But... this means I have to run the spindle for at least one revolution before invoking an M19 orient command.  If I start it and don't run the spindle before M19, the spindle will orient based on the start-up position: index-enable hasn't triggered yet.

I could remember to run the spindle before M19 every time.  Or I could have a program that loads on startup to 'home' the spindle.  But those both feel kinda of hacky.

So my question is this: do I have the HAL connections wrong?  Should one of the 'index-enable' pins not be connected to the others?  Or is there some other way to force an index-triggering move?

Maybe remap M19 so it includes an M3 S500 for a second before moving on to the orient process?

Please Log in or Create an account to join the conversation.

24 Jun 2022 11:14 #245768 by andypugh
You have actually found the issue that ended up with me making the multi-spindle patch, but which I have still not got round to.
The idea is that spindles should be included in the home sequence. And to do that they neede to act more like joints, and then there might as well be support for more than one and...

Anyway, sorry I didn't think of this earlier when we were discussing the problem. It should have been obvious to me.

You should be able to "sets" the _signal" that links all the index-enable pins. But once they are in a net you cant "setp" the individual pins.

It should be possible in HAL to arrange for the spindle to run at constant speed if orient-enable is true and index-enable is true. (and you would need to "sets" that signal true in HAL just as you do now)

One way would be to switch-in an FF0 input on the orient PID (of you are not already using that) switched in and out by a mux2 in turn controlled by index_enable AND orient_enable.

This is already looking complicated enough for a custom component...
The following user(s) said Thank You: tommylight, spumco

Please Log in or Create an account to join the conversation.

Time to create page: 0.276 seconds
Powered by Kunena Forum