Using Spindle Speed to control Spindle Gear

Post anything you want to discuss with others about the software.

Using Spindle Speed to control Spindle Gear

Postby KLaphaphong » Tue Oct 23, 2018 4:53 am

Dear All,

This is my first time for use UCCNC.

Now, I retrofit old milling machine and this machine has gear box for spindle.

My idea is gear will change by spindle speed.

My Spindle motor : Max rpm is 3500 rpm.
My Gear box detail :
1st : Max rpm = 2000
2nd : Max rpm = 1000
3rd : Max rpm = 500
4th : rpm = 0

That mean there are 3 range of speed :
0 --> 500
501 --> 1000
1001 ---> 2000

If UCCNC has spindle speed command (Sxxx). I would like to use macro for control output to changing gear.

such as
S400 ---> Gear will change to 3rd gear

My question is : Is it possible to do like this in UCCNC by macro program?

Could someone please help to share some experience on this?

Best Regards,
Krittawit Laphaphong
KLaphaphong
 
Posts: 9
Joined: Fri Oct 19, 2018 8:01 am

Re: Using Spindle Speed to control Spindle Gear

Postby cncdrive » Tue Oct 23, 2018 4:55 pm

What you could do is you could write a macroloop or a plugin which reads the Sset DRO in a loop which DRO contains the value for the programmed spindle speed.
So, when e.g. S1000 is programmed then the Sset DRO will change it's value to 1000 and you could manipulate/switch an output or outputs or do whatever you need to do to change the gear.
cncdrive
Site Admin
 
Posts: 4717
Joined: Tue Aug 12, 2014 11:17 pm

Re: Using Spindle Speed to control Spindle Gear

Postby cncdrive » Tue Oct 23, 2018 7:54 pm

He said "control output to change gear", so I think he just needs to change output pins and some external electronics will handle the rest, but ofcourse it is kind of a guess from me...
cncdrive
Site Admin
 
Posts: 4717
Joined: Tue Aug 12, 2014 11:17 pm

Re: Using Spindle Speed to control Spindle Gear

Postby KLaphaphong » Wed Oct 24, 2018 4:23 am

Thank you very much for your help.

This gear change by pneumatic cylinder.

I connect 2 output to control solenoid valve

The logic of cylinder

Cylinder1 Cylinder2
0 1 -> Max RPM 2000
0 0 -> Max RPM 1000
1 0 -> Max RPM 500
1 1 -> 0
KLaphaphong
 
Posts: 9
Joined: Fri Oct 19, 2018 8:01 am

Re: Using Spindle Speed to control Spindle Gear

Postby cncdrive » Wed Oct 24, 2018 8:22 am

I think when my collegue Dezsoe will read this topic he will help you with some macroloop code. :)
cncdrive
Site Admin
 
Posts: 4717
Joined: Tue Aug 12, 2014 11:17 pm

Re: Using Spindle Speed to control Spindle Gear

Postby dezsoe » Wed Oct 24, 2018 12:42 pm

Hi Krittawit,

Here is the macroloop, as Balázs wrote. :) There's an error check in it: if you set the RPM higher than 2000 then it will switch to null. Also, if reset is active, the null position will be selected. Change the values of port1, pin1, neg1, port2, pin2, neg2 accroding to your machine.

Code: Select all
// ================================================================================================
// Automatic Gear change
// ================================================================================================

double RPMOvr = 0.0;

// 0 1 -> Max RPM 2000
// 0 0 -> Max RPM 1000
// 1 0 -> Max RPM 500
// 1 1 -> 0

if (exec.GetLED(ResetLED))
{
  if (NeedCheck)
  {
    SetPin(1);
    SetPin(2);
    LastRPM = 0.0;
    NeedCheck = false;
  }
}
else
{
  RPMOvr = AS3.Getfielddouble(RPMOvrFld);
  if (RPMOvr != LastRPM)
  {
    LastRPM = RPMOvr;
    if (RPMOvr == 0.0)
    {
      SetPin(1);
      SetPin(2);
    }
    else if (RPMOvr <= 500.0)
    {
      SetPin(1);
      ClrPin(2);
    }
    else if (RPMOvr <= 1000.0)
    {
      ClrPin(1);
      ClrPin(2);
    }
    else if (RPMOvr <= 2000.0)
    {
      ClrPin(1);
      SetPin(2);
    }
    else
    {
      SetPin(1);
      SetPin(2);
      exec.AddStatusmessage("RPM too high!");
    }
  }
  NeedCheck = true;
}

// ================================================================================================

#Events

// ================================================================================================

const int ResetLED = 25;

const int RPMOvrFld = 2451;

const int port1 = 2;
const int pin1 = 1;
const bool neg1 = false;

const int port2 = 2;
const int pin2 = 2;
const bool neg2 = false;

static bool NeedCheck = true;

static double LastRPM = 0;

// ================================================================================================

void SetPin(int outno)
{
  if (outno == 1)
  {
    if (neg1)
      exec.Clroutpin(port1, pin1);
    else
      exec.Setoutpin(port1, pin1);
  }
  else
  {
    if (neg2)
      exec.Clroutpin(port2, pin2);
    else
      exec.Setoutpin(port2, pin2);
  }
}

void ClrPin(int outno)
{
  if (outno == 1)
  {
    if (neg1)
      exec.Setoutpin(port1, pin1);
    else
      exec.Clroutpin(port1, pin1);
  }
  else
  {
    if (neg2)
      exec.Setoutpin(port2, pin2);
    else
      exec.Clroutpin(port2, pin2);
  }
}

// ================================================================================================
dezsoe
 
Posts: 2055
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Using Spindle Speed to control Spindle Gear

Postby KLaphaphong » Wed Oct 24, 2018 3:03 pm

Hello dezsoe,

Thank you very much for your example.

I will try.

Best Regards,
Krittawit Laphaphong
KLaphaphong
 
Posts: 9
Joined: Fri Oct 19, 2018 8:01 am

Re: Using Spindle Speed to control Spindle Gear

Postby KLaphaphong » Wed Oct 24, 2018 3:15 pm

Vmax549 wrote:Part of the HOW would be can the machine change gears on the fly with the spindle running or do you have to stop the spindle to change gears.

(;-) TP



Hello Vmax549,

This gear need to change before spindle start running.

I need to check status of machine state.

If machine not in IDLE state, Gear will be not change.

Best Regards,
Krittawit Laphaphong
KLaphaphong
 
Posts: 9
Joined: Fri Oct 19, 2018 8:01 am


Return to General discussion about the UCCNC software

Who is online

Users browsing this forum: No registered users and 9 guests