Page 1 of 1

Lathe Setting tool number on startup

PostPosted: Tue Nov 14, 2023 10:06 pm
by Delco
Is there a setting for the .pro file so that on startup the lathe profile shows as tool 1 rather than tool 0 , I am fitting a auto turrent to my lathe and if I start with tool zero then when asked to change to tool from tool zero to tool # it will error as tool slot zero is not a possible on the lathe.


Also with regard to threading on the lathe - using a index pulse to measure actual rpm does the software use that for doing the pitch or does it use commanded as my rpm can drop slightly when it enters the cut.

Re: Lathe Setting tool number on startup

PostPosted: Wed Nov 15, 2023 3:27 pm
by Daywalker
Maybe you can Handle that with a Macroloop like that.

Code: Select all
// ================================================================================================
// Restore last tool number on startup
// ================================================================================================

bool ResetNow = exec.GetLED(ResetLED);

if (FirstRun && !ResetNow)
{
  while (!exec.GetLED(ResetLED))
    Thread.Sleep(10);
  ResetNow = exec.GetLED(ResetLED);
}

FirstRun = false;

if (NeedCheck && !ResetNow)
{
  Thread.Sleep(100);
  exec.Codesync("");
  if (!exec.Ismacrostopped())
  {
    string LTstr = exec.Readkey("MyValues", "ToolNumber", "0");
    int LastTool = Convert.ToInt32(LTstr);
    exec.Setcurrenttool(LastTool);
   exec.Code("F300"); // Sets Feedrate
   exec.Code("S10000"); // Sets RPM
    // Uncomment the next 3 lines to turn on tool length offset for the loaded tool
    // exec.Wait(100);
    // int Currenttool = exec.Getcurrenttool();
    // exec.Code("G43 H" + Currenttool.ToString());
    exec.AddStatusmessage("Tool number T" + LastTool.ToString() + " restored.");
    NeedCheck = false;
    loop = false;
  }
  else
  {
    exec.AddStatusmessage("Waiting stop to clear...");
    Thread.Sleep(1000);
  }
}

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

#Events

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

const int ResetLED = 25;

static bool FirstRun = true;
static bool NeedCheck = true;

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



and that code in M99999.txt to Save the Last Tool by Closing UCCNC
Code: Select all
exec.Writekey("MyValues", "ToolNumber", AS3.Getfielddouble(897).ToString());            // Read & Save Last Tool


I Have write that Code in a M99995.txt an set a Macroloop. After hitting the Reset Button, the Last Tool while be writen in UCCNC.

Re: Lathe Setting tool number on startup

PostPosted: Wed Nov 15, 2023 9:32 pm
by Delco
Thanks will give it a try

Re: Lathe Setting tool number on startup

PostPosted: Wed Nov 15, 2023 10:00 pm
by dezsoe
I wrote this startup macro to run commands on the first release of the reset. However, since 1.2115 you can reload the tool number even in M99998 without turning off the reset:

Code: Select all
string LTstr = exec.Readkey("MyValues", "ToolNumber", "0");
int LastTool = Convert.ToInt32(LTstr);
exec.Setcurrenttool(LastTool);

But if you want to restore the G43 tool offset too then you'll need that macro with the G43 lines uncommented.