M19 and spindle-index-enable issues

More
06 May 2023 10:37 - 06 May 2023 17:42 #270783 by 0x2102
Bringing back an older thread because there seems to be another issue that people run into with high(er) speed spindles and spindle index / M19. 

Everything seems to work until the spindle is at higher speeds and right after that you call an M19 to orient the spindle. 

Example:

S1000 M3 
M5 
M19 R0  -> Spindle is a 0 degree

S16000 M3
M5
M19 R0 -> Spindle is at 30 degree or another number due to EMI or another reason the spindle encoder count doesn't match a 100% anymore.

I was thinking of writing a component that would wait for spindle off and a low rpm range (1000 - 2000 etc) and then set the spindle-index high again. The spindle would then re-index before it stops and the next time an M19 is called the position should be accurate again?

Thoughts or other ideas?

 
Last edit: 06 May 2023 17:42 by 0x2102.

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

More
07 May 2023 14:24 #270862 by andypugh
Maybe add homing to the orient comp?

Try this version:
Attachments:
The following user(s) said Thank You: Alexandrion

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

More
07 May 2023 14:25 #270863 by andypugh
(Note that the way to enable homing is to add 16 to the "mode" setting. Then you need to connect the new index-enable pin) 

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

More
07 May 2023 18:44 - 07 May 2023 18:46 #270882 by 0x2102
Thanks Andy. I will take a look at the new orient.comp with "homing". Not sure if will address the issue, or will the new orient re-enable the spindle encoder index with every M19 command?

My particular issue is after I run my spindle in the higher rpm range (max 36000rpm). I can replicate the issue above 16K rpm. I still get a speed signal from the spindle encoder but the mesa encoder is not counting a 100%, it's missing a few counts every second or so and that adds up when you run the spindle for 5 min order longer. Right after I stop the spindle and try to do an M19R0, the angle is off by a bit. When I call my spindle homing routing, it will re-sync everything at low spindle speed and the M19 R0 is at the right position.

I wrote a simple test comp that waits for the spindle.0.brake (M5) signal && the encoder rpm between 2000 - 1000 - to then re-enable the encoder index. The spindle still does a couple of turns before it comes to a full stop and LinuxCNC has a "clean" encoder reader for a correct M19 call right after the M5. 

This seems to be working fine for me and my particular use case: high speed spindle with encoder. 

component spindle_index_enable "Enable spindle index after M5 (brake-on)";
pin in float rpm_in;
pin in bit brake_on;
pin io bit out;
function _;
license "GPL";
author "0x2102";
;;
FUNCTION(_) 
{
        if (rpm_in >= 1000 && rpm_in <2000 && brake_on) {
            out = 1;}
        else 
            out = 0;
}

 
Last edit: 07 May 2023 18:46 by 0x2102.

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

More
07 May 2023 18:47 #270883 by andypugh
When "enable" is set with new "orient" it first sets index-enable and then sets a spindle position just a little ahead of the current position. Then when it sees index-enable go low it reverts to the previous logic.

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

More
07 May 2023 18:47 #270884 by andypugh
When "enable" is set with new "orient" it first sets index-enable and then sets a spindle position just a little ahead of the current position. Then when it sees index-enable go low it reverts to the previous logic.

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

More
25 May 2023 18:03 #272160 by Aciera
@andy
I've been trying to get that component to work, seems to be exactly what I need.
I'm having a bit of trouble with the index-enable:
Whenever I connect the orient.index-enable pin in hal everything that is using the encoder index-enable stops working. ie. I use the encoder index-enable also for joint.3.index-enable, pid.a.index-enable and for spindle.0.index-enable.
Looks like it permanently pulls the index-enable signal in hal to zero.
Any ideas?

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

More
26 May 2023 08:42 #272197 by Aciera
An update:
I got this working with some minor changes and it looks very promising. Thanks for this Andy!
This rehomes the motor in spindle mode using M19 and lets me reposition the spindle back to within 0.2 degrees of the last rotary position (which I manually type into the M19 command for now). The remaining tolerance is then compensated by the rotary joint pid as soon as I switch back to rotary mode.
The only issue I see is a somewhat unpredictable speed change in the spindle orient after the spindle index signal has been detected but this can probably be taken care of with the orient pid.


Warning: Spoiler!

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

More
26 May 2023 08:44 - 26 May 2023 08:47 #272198 by Aciera
Note that M19 will only accept values 0,1 and 2 for parameter P, everything else triggers an error message and the command is not executed. That is why I had to force the rehoming in the component. Also the index-enable signal must not be forced to 1 or 0 while the component in not enabled.
Last edit: 26 May 2023 08:47 by Aciera.

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

More
10 Jun 2023 10:40 #273265 by andypugh
Your code looks like it will always set index_enable true? Even if it is working, that probably isn't exactly what you want.

The point of IO pins is to only write any state to them when you want to set the state, and let other parts of the net be in charge at other times.

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

Time to create page: 0.487 seconds
Powered by Kunena Forum