[solved] Rehoming Lathespidle / Rotary-Axis from inside GCode

  • Aciera
  • Aciera's Avatar Topic Author
  • Offline
  • Administrator
  • Administrator
More
21 May 2023 14:16 #271822 by Aciera
I've started to build a lathe spindle / rotary axis using a servo motor. The idea is to be able to combine milling operations (as a-axis) and lathe operations (as spindle) in the same GCode using a kinematic switch. The servo controller (Mitsubishi) offers a Position/Speed mode that allows me to switch between position mode using step/dir signals from the Mesa 7i76e and speed mode using 0-10V from the spindle output. This works using simple digital outputs connected in HAL.
The problem is this:
Running the motor in speed mode for lathe operations disables the encoder feedback from the servo controller and the angular position information for the rotary axis in linuxCNC is out of sync. So switching the servo controller back to position mode leaves me with a randomly positioned rotary axis that needs to be rehomed before continuing with a GCode milling operation. 

I have the index signal available for homing but how do I reset the absolute position of the rotary joint from inside Gcode?
The following user(s) said Thank You: besriworld

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

More
21 May 2023 14:37 #271828 by andypugh
Running a dummy G33 move should cause an index set/reset cycle and zero the encoder counts in LinuxCNC.

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

More
21 May 2023 14:43 #271829 by chris@cnc
I try to this since 2 years but without success.
My idea was to reset by M-code.
forum.linuxcnc.org/38-general-linuxcnc-q...cmd-or-g-code#208748
 But rehoming is not supported yet.
forum.linuxcnc.org/24-hal-components/466...enable-signal#250055


 

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

  • Aciera
  • Aciera's Avatar Topic Author
  • Offline
  • Administrator
  • Administrator
More
21 May 2023 15:53 #271840 by Aciera

 I try to this since 2 years but without success.
My idea was to reset by M-code.
forum.linuxcnc.org/38-general-linuxcnc-q...cmd-or-g-code#208748
 But rehoming is not supported yet.
forum.linuxcnc.org/24-hal-components/466...enable-signal#250055

I thought somebody came up with a custom component that reset the encoder count. But sure enough I can't find it...
Manually enabling the index-enable and running into the index does seem to reset the encoder count but, alas, also raises a joint following error.

Running a dummy G33 move should cause an index set/reset cycle and zero the encoder counts in LinuxCNC.

So are you saying that G33 resets (ie rehomes) the absolute position of an axis?


Just realized that with my setup I have no encoder feedback during speed mode (ie no thread cutting in lathe mode) XD. Looks like i'll need to rethink a thing or two.

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

  • Aciera
  • Aciera's Avatar Topic Author
  • Offline
  • Administrator
  • Administrator
More
21 May 2023 16:11 - 21 May 2023 16:12 #271842 by Aciera
Just checked, actually the controller does keep putting out encoder signals while in speed mode. So that may still work out for me.

The other thing this means though is that with encoder feedback closing the position loop in linuxcnc running in speed mode will trigger a joint following error because the stepgen is not involved in lathemode.
Last edit: 21 May 2023 16:12 by Aciera.

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

More
21 May 2023 18:52 - 21 May 2023 18:55 #271867 by chris@cnc
Yes, I try the same way. I disconnect the encoder input by  m-code, set pin hm2**encoder.reset and connect encoder. But joint position and encoder position are not the same and the following error occur. So seems the only way to switch encoder on and off could be at zero position. And rehoming doesn't work. Seems G33 is an option but not sure if it works in speed mode. M19 should also possible, or how to control the ATC milling machine's the spindle?
Regarding your homing offset. I take a look in my ini and the x,y,z axis pid is 5 and a-axis pid is 50. But i can't remember why i increase this number. But it works i engraving round 2 mm letters with laser.  It's just only 400W Delta drive. If it helps, i would slowly increase the pid and test what happens.
Last idea is a custom comp that count a axis encoder only 0-360°. But i never start.
 
Last edit: 21 May 2023 18:55 by chris@cnc.

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

  • Aciera
  • Aciera's Avatar Topic Author
  • Offline
  • Administrator
  • Administrator
More
22 May 2023 08:44 - 22 May 2023 11:59 #271906 by Aciera
So looking at your summary a possible option would be:

1. we start in axis mode and home the rotary using index

2. to switch to spindle mode we orient the rotary to a known position, disconnect the encoder signals (in hal) and switch the controller to speed mode. Since (in my case at least) it would keep sending signals in speed mode and the stepgen remains at it's last position we would get a joint following error otherwise.

3. to switch back to rotary mode: orient the spindle to the known last (rotary) position (M19 spindle orient seems a likely candidate here, M33 is a bit of a question mark for me), connect the encoder and switch the controller to position mode.

[edit]
As for my homing offset I tried changing the pid values in the ini but it does not affect the offset at all.
Indeed, the pid values in the ini had to be adjusted properly to minimize the following error. Takes a bit more effort to get the values needed. Thanks!


Thanks for all the input.
Last edit: 22 May 2023 11:59 by Aciera.

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

  • Aciera
  • Aciera's Avatar Topic Author
  • Offline
  • Administrator
  • Administrator
More
22 May 2023 16:33 - 22 May 2023 16:38 #271947 by Aciera
@andy
ok, i think get your point now. G33 lets me reset the encoder count on the index signal without causing a following error.

@chris
Not sure if you already know this:

Looks interesting.
[edit]
Doesn't actually switch between rotary and spindle mode though but still worth a look.
Last edit: 22 May 2023 16:38 by Aciera.

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

More
22 May 2023 16:42 #271948 by spumco
@Aciera

I'm starting a C-axis lathe project too... good timing.

I recalled NoJo posting quite a bit about his trials and challenges implementing a spindle/C-axis switching function, as well as polar coordinate switching.  Like him (and you), I plan to use a step-dir controlled servo for my spindle motor.

He hasn't posted in over a year (or reported complete success), but I did find some files that may help you (us) accomplish what you want.  Note that I've just started reading the files and haven't really digested them yet.

caxis.comp appears to manage the c-axis to spindle switching
gn.userkins.comp appears to handle polar interpolation when C-axis is enabled

Hopefully you find these useful.  I also found a zip of NoJo's complete config and remaps, but it appears to be an earlier version than the two attached here.
Attachments:

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

  • Aciera
  • Aciera's Avatar Topic Author
  • Offline
  • Administrator
  • Administrator
More
22 May 2023 19:17 #271960 by Aciera
@spumco
Thanks, actually that is probably what made me think that there was a component to switch between rotary and spindle. Seems it's not really as simple as recycling a component though.
I think NoJo ended up doing a fair bit of customizing in the source code that was not shared at the time.
The following user(s) said Thank You: spumco

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

Time to create page: 0.088 seconds
Powered by Kunena Forum