- Configuring LinuxCNC
- Advanced Configuration
- [solved] Rehoming Lathespidle / Rotary-Axis from inside GCode
[solved] Rehoming Lathespidle / Rotary-Axis from inside GCode
- Aciera
- Topic Author
- Offline
- Administrator
Less
More
- Posts: 3925
- Thank you received: 1687
24 May 2023 13:38 - 24 May 2023 13:40 #272088
by Aciera
Replied by Aciera on topic Rehoming Lathespidle / Rotary-Axis from inside GCode
switching between Mesa stepgen and the electronic spindle pot works fine. I can jog as rotary and as soon as I issue a spindle enable I can control the servomotor in speed mode using the analog input as soon a spindle is disabled I'm back to the stepgen and position control in the servo controller.
The problem is the encoder position changes when using the servo in speed mode which gets it out of sync to the joint motor position-fb. Hence the idea to orient the spindle to match the motor position-fb value before switching back to position mode.
The problem is the encoder position changes when using the servo in speed mode which gets it out of sync to the joint motor position-fb. Hence the idea to orient the spindle to match the motor position-fb value before switching back to position mode.
Last edit: 24 May 2023 13:40 by Aciera.
Please Log in or Create an account to join the conversation.
- spumco
- Offline
- Platinum Member
Less
More
- Posts: 1804
- Thank you received: 725
24 May 2023 15:25 #272090
by spumco
Replied by spumco on topic Rehoming Lathespidle / Rotary-Axis from inside GCode
I see, thanks.
I guess there's a subtlety in the sequencing variations, and I don't know which is 'better' or if it makes any difference:
There (probably) wouldn't be an error accumulation over multiple axis-spindle-axis mode changes, but I fear using orient wouldn't nail the position each time the axis mode is enabled.
I would think that the encoder reset plus a forced C-axis homing to index at each positioning-mode enable would be the most accurate method? That seems to be the scheme used in caxis.comp, and is also the method used on my Fanuc thing.
I guess there's a subtlety in the sequencing variations, and I don't know which is 'better' or if it makes any difference:
- Scheme #1
- C-axis homes to encoder index on enable/home
- run some positioning moves
- Switch to velocity mode
- control method doesn't matter (analog or step/dir or pwm)
- run spindle in velocity mode
- Encoder is now out of sync with last axis position command
- Switch to axis mode
- reset encoder index
- home C-axis
- C-axis homes to encoder index on enable/home
- Scheme #2
- Same as above but instead of resetting the encoder index
- Orient spindle before switching to axis mode (using orient.comp)
- Switch to C-axis mode
- no need to home axis?
There (probably) wouldn't be an error accumulation over multiple axis-spindle-axis mode changes, but I fear using orient wouldn't nail the position each time the axis mode is enabled.
I would think that the encoder reset plus a forced C-axis homing to index at each positioning-mode enable would be the most accurate method? That seems to be the scheme used in caxis.comp, and is also the method used on my Fanuc thing.
Please Log in or Create an account to join the conversation.
- Aciera
- Topic Author
- Offline
- Administrator
Less
More
- Posts: 3925
- Thank you received: 1687
24 May 2023 16:09 #272091
by Aciera
Replied by Aciera on topic Rehoming Lathespidle / Rotary-Axis from inside GCode
I agree that homing the rotary at each switch to positioning mode seems the most sensible approach. I'll need to have a closer look at the caxis.comp.
Please Log in or Create an account to join the conversation.
- chris@cnc
- Offline
- Platinum Member
Less
More
- Posts: 529
- Thank you received: 139
24 May 2023 18:39 #272094
by chris@cnc
Replied by chris@cnc on topic Rehoming Lathespidle / Rotary-Axis from inside GCode
The caxis.com looking always with lathe eyes. What happens if you have a milling machine with toolspindle and A or C axis and want turning? Then we have two spindles and the story begins new. I think first step should be teaching lincnc that round axis only count max. 360° and second step supported rehoming. But i take a look in the homing.c and closed it. Behind my mind...
What do think about this idea? And is there someone who can do it?
What do think about this idea? And is there someone who can do it?
Please Log in or Create an account to join the conversation.
- spumco
- Offline
- Platinum Member
Less
More
- Posts: 1804
- Thank you received: 725
24 May 2023 20:09 #272105
by spumco
The lines get blurry between a mill-turn or a turn-mill, don't they?
I haven't done this, but I believe controlling two spindles can be done in LCNC using spindle.1 for the 2nd spindle motor. Main spindle would be spindle.0.
So you set up the A-axis with a position-mode PID and a second PID connected to spindle.1. Switch between them, just like we've been discussing for C-axis lathe stuff in this thread. Could probably recycle the caxis.comp as 'aaxis_spindle.comp' with some minor editing.
LCNC is already capable of treating a rotary axis as only having 0-359.999 degrees. See the [AXIS] section of the INI file help document.
Regarding A-axis homing/rehoming:
My mill has an A-axis driven by a servo, open-loop to LCNC. I'm using the drive's internal home-to-index function through a couple of IO pins:
All the usual homing data is pre-programmed in the drive (homing speed, index search speed, encoder offset)
The normal LCNC X/Y/Z homing function omits the A-axis entirely; I usually have a trunnion table on the A-axis and I don't always have 360 clearance if there's a long tool in the spindle. Having a separate HOME-A button helps me remember to check for interference.
Point is, you can home/unhome any joint you want via gcode in a macro. i.e. the same macro that switches between axis-position mode and spindle-velocity mode can unhome the axis each time its run. And it's not limited to lathe main spindles.
Unless I misunderstood something, I think all of your questions/comments are already addressed - or at least manageable - in LCNC.
Replied by spumco on topic Rehoming Lathespidle / Rotary-Axis from inside GCode
The caxis.com looking always with lathe eyes. What happens if you have a milling machine with toolspindle and A or C axis and want turning? Then we have two spindles and the story begins new. I think first step should be teaching lincnc that round axis only count max. 360° and second step supported rehoming. But i take a look in the homing.c and closed it. Behind my mind...
What do think about this idea? And is there someone who can do it?
The lines get blurry between a mill-turn or a turn-mill, don't they?
I haven't done this, but I believe controlling two spindles can be done in LCNC using spindle.1 for the 2nd spindle motor. Main spindle would be spindle.0.
So you set up the A-axis with a position-mode PID and a second PID connected to spindle.1. Switch between them, just like we've been discussing for C-axis lathe stuff in this thread. Could probably recycle the caxis.comp as 'aaxis_spindle.comp' with some minor editing.
LCNC is already capable of treating a rotary axis as only having 0-359.999 degrees. See the [AXIS] section of the INI file help document.
Regarding A-axis homing/rehoming:
My mill has an A-axis driven by a servo, open-loop to LCNC. I'm using the drive's internal home-to-index function through a couple of IO pins:
- LCNC->Drive
- start homing
- Drive->LCNC
- homing complete
- alarm
- halui.joint.3.unhome (unhomes A)
- (slight pause)
- halui.joint.3.home (LCNC immediately sets DRO to 0.000)
- start homing (via motion.digital-out)
- wait for homing complete (via motion.digital-in)
- if complete w/in time permitted - macro is done
- if fails to get complete signal
- alarm
- unhome joint
All the usual homing data is pre-programmed in the drive (homing speed, index search speed, encoder offset)
The normal LCNC X/Y/Z homing function omits the A-axis entirely; I usually have a trunnion table on the A-axis and I don't always have 360 clearance if there's a long tool in the spindle. Having a separate HOME-A button helps me remember to check for interference.
Point is, you can home/unhome any joint you want via gcode in a macro. i.e. the same macro that switches between axis-position mode and spindle-velocity mode can unhome the axis each time its run. And it's not limited to lathe main spindles.
Unless I misunderstood something, I think all of your questions/comments are already addressed - or at least manageable - in LCNC.
Please Log in or Create an account to join the conversation.
- chris@cnc
- Offline
- Platinum Member
Less
More
- Posts: 529
- Thank you received: 139
24 May 2023 21:09 #272117
by chris@cnc
It doesn't matter which machine or axis we're working on.
It seems I won at my workshop next weekend. Let's see what the big boss say about it...
Replied by chris@cnc on topic Rehoming Lathespidle / Rotary-Axis from inside GCode
Thanks for this hint. I see now the option "WRAPPED_ROTARY = 1"
LCNC is already capable of treating a rotary axis as only having 0-359.999 degrees. See the [AXIS] section of the INI file help document.
The Same should be possible on a lathe c axis. The "drive-index signal" can touch the halui.joint.3.home and hm2***encoder.reset and then switch axis to closed loop and joint mode.
Regarding A-axis homing/rehoming:
My mill has an A-axis driven by a servo, open-loop to LCNC. I'm using the drive's internal home-to-index function through a couple of IO pins:
LCNC->Drive
start homing
Drive->LCNC
homing complete
alarm
My particular drive doesn't require an 'unhome' signal before homing a second (or more) time. So my "Home-A" button (macro) outputs:
halui.joint.3.unhome (unhomes A)
(slight pause)
halui.joint.3.home (LCNC immediately sets DRO to 0.000)
start homing (via motion.digital-out)
wait for homing complete (via motion.digital-in)
if complete w/in time permitted - macro is done
if fails to get complete signal
alarm
unhome joint
It doesn't matter which machine or axis we're working on.
It seems I won at my workshop next weekend. Let's see what the big boss say about it...
Please Log in or Create an account to join the conversation.
- chris@cnc
- Offline
- Platinum Member
Less
More
- Posts: 529
- Thank you received: 139
25 May 2023 18:15 #272161
by chris@cnc
Replied by chris@cnc on topic Rehoming Lathespidle / Rotary-Axis from inside GCode
I test these two points
First thing, "WRAPPED_ROTARY = 1"
Axis data show 0-360° but joint.pos.fb data is still the same. This is no real option to go to G0 A0 and disconnect encoder for reset.
In case of connection must be joint.pos.fb an encoder data the same to avoid the following error. And this is serous only by zero possible.
Second idea: try to rehome joint by m-code.
This will not work by M-Code. In terminal works this way one by one.
halcmd setp halui.mode.joint 0
halcmd setp halui.mode.joint 1
halcmd setp halui.joint.5.unhome 1
halcmd setp halui.joint.5.unhome 0
halcmd setp halui.joint.5.home 0
halcmd setp halui.joint.5.home 1
halcmd setp halui.joint.5.home 0
But start this by M-Code, machine is switching to halui.mode.mdi and no manual operation possible.
Now i am on the starting point again. Or did i something wrong?
First thing, "WRAPPED_ROTARY = 1"
Axis data show 0-360° but joint.pos.fb data is still the same. This is no real option to go to G0 A0 and disconnect encoder for reset.
In case of connection must be joint.pos.fb an encoder data the same to avoid the following error. And this is serous only by zero possible.
Second idea: try to rehome joint by m-code.
This will not work by M-Code. In terminal works this way one by one.
halcmd setp halui.mode.joint 0
halcmd setp halui.mode.joint 1
halcmd setp halui.joint.5.unhome 1
halcmd setp halui.joint.5.unhome 0
halcmd setp halui.joint.5.home 0
halcmd setp halui.joint.5.home 1
halcmd setp halui.joint.5.home 0
But start this by M-Code, machine is switching to halui.mode.mdi and no manual operation possible.
Now i am on the starting point again. Or did i something wrong?
Please Log in or Create an account to join the conversation.
- smc.collins
- Offline
- Platinum Member
Less
More
- Posts: 687
- Thank you received: 123
25 May 2023 19:30 #272165
by smc.collins
Replied by smc.collins on topic Rehoming Lathespidle / Rotary-Axis from inside GCode
I'm thinking a lot on how to do this, 2 macro's and a hal component to manage the encoder and control switching most likely
Please Log in or Create an account to join the conversation.
- Aciera
- Topic Author
- Offline
- Administrator
Less
More
- Posts: 3925
- Thank you received: 1687
26 May 2023 06:21 #272189
by Aciera
Replied by Aciera on topic Rehoming Lathespidle / Rotary-Axis from inside GCode
I've been playing around with this for a while now, neither G33 nor M19 reset the encoder position when the index signal is detected.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.
- Aciera
- Topic Author
- Offline
- Administrator
Less
More
- Posts: 3925
- Thank you received: 1687
26 May 2023 08:49 - 26 May 2023 08:51 #272199
by Aciera
Replied by Aciera on topic Rehoming Lathespidle / Rotary-Axis from inside GCode
This custom orient component looks like it might do the trick:
forum.linuxcnc.org/10-advanced-configura...sues?start=10#272197
More testing needed.
forum.linuxcnc.org/10-advanced-configura...sues?start=10#272197
More testing needed.
Last edit: 26 May 2023 08:51 by Aciera.
Please Log in or Create an account to join the conversation.
- Configuring LinuxCNC
- Advanced Configuration
- [solved] Rehoming Lathespidle / Rotary-Axis from inside GCode
Time to create page: 0.082 seconds