Lathe with C axis and some challenges...

More
27 Aug 2022 16:38 #250584 by Henk
HI
I searched the forum for some answers or someone who has done this before, but no luck yet so far. The closest i found was in one of the topics by NoJo on his home built cnc lathe with live tooling and C axis, but his setup is more "ideal" than mine.

My setup is a Gildemeister CTX400E from the late '90s

The machine has a main spindle, sub spindle and live tooling. I would like to set up the main and the sub spindle to be a C axis with position control in order to use the live tooling.

Now the challenge....
The encoder on the spindle (lets just focus on one of them for now) is a 512 pulse Sin/Cos encoder, which i am interpolating using the IC-NV package by a factor of 5, resulting in 2560 counts per rev, or 10240 in quadrature. The IC-NV chip does not seem to be able to keep up with the spindle, it stops counting at approx 2400RPM, which means that the absolute spindle position will be lost due to lost counts

So when changing to C axis mode, i have to cater for the offset created during running the spindle, but that offset is now unknown because of the lost counts.

I would like to automatically home the C axis when enabled, but im not sure how to do this. I will most likely do this by using a custom component, so here is my thoughts

Default mode will be lathe mode
  • Enable the C-axis using a remapped M-code
  • The O-word ngc sub will enable the c-axis component which will set the index-enable pin for the spindle encoder to true
  • start the spindle at a low RPM, say 20 RPM and wait for the component to signal that the index was found (M66)
  • O-word routine stops the spindle
  • Component enables the spindle position control, there is a slight movement of about 1 degree when this happens
  • Component , when the spindle is in position (step & dir) mode, calculate the offset from the index pulse
  • Component use the offset and sets the position command to the stepgen the same as the feedback value, taking into account the offset
  • Enables the stepgen
  • on exit/disable c-axis mode, set the C axis feedback = pos cmd and disables the stepgen 

    I am probably missing a whole bunch of things with this idea, so im looking for some tips and or advice, or maybe im going in the completely wrong direction here. A lot of this is driven by the limitations of the hardware that i have at the moment
    Maybe there is a better/standard solution to this that im not aware of

    Thanks
    Henk

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

More
30 Aug 2022 22:19 #250805 by robh
hi
how are you driving the C axis side of things.. changing from Spindle mode to Servo?
is C axis done by the spindle motor? or is it a clutch in and out Servo?
as i have seen both ways done before on C Axis lathes more so on the early lathes or where high rigid servo spindle was needed..

are you are you using the real spindle drive still, or setup? just talking to it with linuxcnc?

or pulled it all out and doing it anew way for some reason?

but you are pritty much on the right track if you need to do it all your self to do lets say a MODE change, i take it there is only one encoder on the spindle so you need to find away to read above 2400rpm also. most C axis have a speed limit of 200/500rpm or so because of the interperlation they do to get to 0.001deg resolution.

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

More
30 Aug 2022 23:37 - 30 Aug 2022 23:39 #250811 by PCW
This seems to be a common issue and I wish LinucCNC
had built in support for switching the spindle between
normal and Axis use.

Could  most of your list  be done by re-homing C?
(not sure how awkward this is to trigger)
Last edit: 30 Aug 2022 23:39 by PCW. Reason: clarify
The following user(s) said Thank You: besriworld

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

More
31 Aug 2022 06:01 #250839 by Henk
HI
The machine was equipped with Siemens 611 drives, but they died and the Heidenhain control talked to them using a fiber optic link. So even if i could repair the broken drive and power supply, i was still faced with the control board that would need replacing with a Siemens analog model.

So i opted to install new drives to power the integrated Baumuller spindle motors. They are 6 pole, rated to 250Hz. The drive is capable of analog velocity input or step/dir. The step/dir method provides a position control mode as well, and this seems to be pretty good for positioning, with reasonable torque at zero RPM. 

Any way, i have the drive running in both modes. 

Not sure why the encoder stops counting on the LCNC side at 2400RPM. The interpolator is capable of 200KHz output, which is close to 5000RPM. 

I guess a perfect system will not miss counts and i can use the encoder position as is and just account for the offset in a comp, but i would be more comfortable to "home" at the change to C axis mode. 

I will probably start playing with the comp in the next couple of days. 

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

More
31 Aug 2022 08:42 #250848 by robh
maybe start with a comp based around spindle Orientation , and start with M19 Rxx commands to index to postion get that working... then once happy work on a true C axis mode with a PID etc so you can rotate and mill together.

i have a lathe with power tooling twin turret etc so i will be intrested to see how you take this on, i just have not had the time to retro fit it. have looked into it quite alot
but like you , it also needs new Drives also for axis and spindle as they are tempermental and old


not sure how many changes are needed to have a C axis in a setup , and enable and disable the C axis and joint between spindle and C axis commands. as this is bacily how the controls do it underneath.
maybe its just stoping the following errors when not using C axis maybe a few other things also?

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

More
31 Aug 2022 13:28 #250856 by andypugh
I think that the process outlined over-complicates the process. Once the index-enable has gone false then the spindle is homed, you shouldn't need to handle any offsets.
Then position the spindle using a PID (and, if step-dir, with a velocity-mode stepgen)

Does this diagram help at all?
wiki.linuxcnc.org/cgi-bin/wiki.pl?SpindleOrient

(The input to the position PID does not need to be from spindle.0.orient, it could be from axis.c.motor-pos-cmd )

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

More
31 Aug 2022 14:08 #250858 by PCW
You also may be able to use stepgen index if you are running Mesa hardware and LinuxCNC 2.9 (so the encoder would not be used except for its index signal)

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

More
31 Aug 2022 14:09 #250859 by spumco

 i would be more comfortable to "home" at the change to C axis mode. 


 


I think you're on the right track.  Like @robh, I have a non C-axis lathe and mine re-homes the C-axis each time it's enabled.  Different control (non-LCNC), different lathe, but it seems to work.  It does not disengage, re-engage, and re-home if I switch tools.

Unlike yours, my lathe has a single encoder (belt-driven) and separate spindle & C-axis motors.  The spindle motor is "dumb" and the C-axis is a closed-loop stepper on a swing-arm gear drive - but I believe the stepper encoder just goes back to the drive and not the main control.

I think homing the C-axis at each M-code enable will allow you to bypass the lost encoder counts issue - or at least get it working until you have time & patience to track down the problem.

The other thing to consider is how do you (eventually) want to program the g-code?  If you're using a CAM package it might work better with an existing post processor to not try to home the spindle with M19 and just stick with C-axis homing.

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

More
07 Sep 2022 02:27 #251383 by Henk
HI
I managed to get the c-axis and spindle working using the component below. Thanks for all the suggestions. I realize now what Andy meant in his earlier message, and i think it is possible to achieve this with standard hal components only, or maybe not...i dont know.

Anyway, the reason i stuck with this is that this machine has two spindles (Main spindle and Sub spindle) that can hold the workpiece, both of which can transform to C axis mode. In order to not mess up the axis conventions, i would like to keep the axis a C axis irrespective of which spindle is in C axis mode so my next step is to add support for the other spindle, but keeping a single C axis on Linuxcnc....
component spindlecv "Component to control lathe spindle and C";

pin in  bit   enable      "enable signal for c axis mode";
pin in  float c_pos_cmd_in    "current commanded pos of c axis";
pin in  float c_pos_fb_in       "c axis feedback position from encoder";
pin out float c_pos_fb_out     "c axis feedback out _ takin offset into account";
pin out float joint-pos-fb-out   "c axis feedback to linuxcnc joint feedback";
pin io bit set_c_index_enable      "connect to index_enable for c axis encoder";
pin out bit drive_position_mode   "to output pin for enabling drive position mode";
pin in s32 decel_delay         "delay time to allow spindle to decelerate";
pin out float c_pos_cmd_out     "pos cmd out for c axis";
pin in float spindle_vel_cmd_in;
pin out float spindle_vel_cmd_out;
pin out bit control_mode =1    "connect to stepgen control type";   
pin in bit spindle_enable_in_fwd;
pin out bit spindle_enable_out_fwd;
pin in bit spindle_enable_in_rev;
pin out bit spindle_enable_out_rev;
pin out bit drive_analog_mode;
pin out float pid-maxerror;
pin in float pid-maxerror-homeing;
pin in float pid-maxerror-operating;
pin in s32 counts        "encoder counts";
pin in float enc-scale   "encoder counts/degree"; 
pin out float spindle-position;
pin out float spindle-speed-fb-rpm;
pin in bit index-enable-spindle;
pin in float c-enc-vel-fb-per-min; 

// debug pins
pin out s32 step_state;
pin out bit last-enable-dbug;
pin out s32 step-point =0;
pin out s32 pos_counts;

pin out float err = 1;
pin in float tolerance = 0.5  "Tolerance for iitial positioning before enbling linuxcnc feedback, the c axis pid loop wil do the rest";
/*

*/    

variable int   last_enable = 0;
variable int    debounce = 0; 
variable float timer=0;
variable int min_speed = 100;





option fp yes;

option singleton yes;

function _;
author "HDP";




license "GPL";
;;
#include <rtapi_math.h>

FUNCTION(_) {


    if (enable) {
       if (enable != last_enable) { //rising edge of enble

    step_state=0;
    last_enable=enable;
    debounce=0;
    timer=0;

    }
            switch (step_state) {
            case 0: // run spindle in analog mode, allow time to decel in case it was running fast, set index-enable
              

        c_pos_fb_out = c_pos_cmd_in;
        spindle_enable_out_fwd = 1;
        spindle_enable_out_rev= 0;
        drive_analog_mode=1;
        spindle_vel_cmd_out = min_speed;
        timer += fperiod;
        
        if (timer >= decel_delay) {
            set_c_index_enable = 1;
                       step_state = 1;
            timer = 0;
        }

                break;

            case 1: // monitor index-enable

                if (set_c_index_enable==0) {
            spindle_vel_cmd_out=0;
            drive_analog_mode = 0;
            control_mode = 1;
            timer=0;
            step_state=2;
        }
                
        break;

            case 2: // delay for spindle to stop, enable drive position mode, set pid_maxerror higher to position spindle, check error
        c_pos_fb_out = c_pos_cmd_in;
        timer += fperiod;
        if (timer >= 1) {
        drive_position_mode=1;
             control_mode = 1;
        }

        if (timer>=2) {
               
        pid_maxerror = pid_maxerror_homeing;
        c_pos_cmd_out = c_pos_cmd_in; 
        c_pos_fb_out = c_pos_fb_in;
        
        err = (c_pos_fb_in - c_pos_cmd_in);
        debounce += (fabs(err) < tolerance && debounce <=100);
        
        if (debounce > 100) {
        
        
        step_state=3;

        }
        }
                      
                break;



        case 3: //change to c axis mode, connect feedback, reset pid_maxerror

        pid_maxerror = pid_maxerror_operating;
        joint_pos_fb_out = c_pos_fb_in;
        c_pos_fb_out = c_pos_fb_in;
        spindle_enable_out_fwd=1;
        spindle_enable_out_rev=0;

        drive_position_mode=1;
        c_pos_cmd_out = c_pos_cmd_in; 

        break;    
            }
       }

 if (!enable) { //if not enable, connect c-pos-fb with c-pos-cmd to prevent following error, connect spindle control signals
    step_state=0;
     c_pos_fb_out = c_pos_cmd_in;
     spindle_vel_cmd_out = spindle_vel_cmd_in;
     spindle_enable_out_fwd = spindle_enable_in_fwd;
     spindle_enable_out_rev = spindle_enable_in_rev;
     drive_position_mode=0;
     drive_analog_mode=1;

    spindle_position = c_pos_fb_in/360; // scle c axis position for spindle mode 

    set_c_index_enable = index_enable_spindle; // provide spindle index-enable signal for threading, this only avoids additional hal connections

}
     

        last_enable = enable;
    last_enable_dbug=last_enable;    
    spindle_speed_fb_rpm = c_enc_vel_fb_per_min/360; //scale c vel-fb for spindle mode

}
The following user(s) said Thank You: vmihalca, spumco

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

More
07 Sep 2022 05:33 #251390 by Henk
Didnt attache the hal file...

 
Attachments:
The following user(s) said Thank You: tommylight, jpg, smc.collins

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

Time to create page: 0.258 seconds
Powered by Kunena Forum