ability to goto ### on xyz axis ability to goto zero on same

Here is where you can request new features or special features.

Re: ability to goto ### on xyz axis ability to goto zero on

Postby dezsoe » Tue Apr 27, 2021 9:34 pm

Yes. Here are the 2 macros.

The first is to send the selected axis to work zero. Create a button on the screen and set its buttonnumber to any number 20000 to 21999. Save the following macro to your macro folder with the name Mxxxxx.txt where xxxxx is the number you gave to buttonnumber.

Code: Select all
// ================================================================================================
// Mx - Send selected MPG axis to work zero (20000 <= x <= 21999)
// ================================================================================================

int Axis = GetSelectedAxis();

if (Axis < 0)
{
  exec.AddStatusmessage("No axis selected");
  return;
}

exec.Code("G1 " + AxisNames[Axis] + "0");

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

#Events

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

const int MPGXaxisselect = 155;
const string AxisNames = "XYZABC";

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

int GetSelectedAxis()
{
  for (int i = 0; i < 6; ++i)
    if (exec.GetLED(MPGXaxisselect + i))
      return i;
  return -1;
}

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

The second macro is to send the selected axis to the given coordinate. You need one more button with an other buttonnumber. You also need a field where you can write the needed coordinate. Set the labelnumber of the new field to a number above 20000. Save the macro to this number. Edit the line where NewPositionField is set to 21000 and replace 21000 with your labelnumber. If you created the field on the jog screen then replace "AS3" with "AS3jog" in the macro.

Code: Select all
// ================================================================================================
// Mx - Send selected MPG axis to work position read from a field (20000 <= x <= 21999)
// ================================================================================================

int Axis = GetSelectedAxis();

if (Axis < 0)
{
  exec.AddStatusmessage("No axis selected");
  return;
}

double GotoPos;

if (!Double.TryParse(AS3.Getfield(NewPositionField), out GotoPos))
{
  exec.AddStatusmessage("Position is not numeric");
  return;
}

exec.Code("G1 " + AxisNames[Axis] + GotoPos.ToString("F6"));

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

#Events

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

const int MPGXaxisselect = 155;
const string AxisNames = "XYZABC";

const int NewPositionField = 21000;

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

int GetSelectedAxis()
{
  for (int i = 0; i < 6; ++i)
    if (exec.GetLED(MPGXaxisselect + i))
      return i;
  return -1;
}

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

Now you're ready to run.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: ability to goto ### on xyz axis ability to goto zero on

Postby gurusonwheels » Tue Apr 27, 2021 11:16 pm

thank you very very much ...

have no idea how it works ... but it does .....


thank you
gurusonwheels
 
Posts: 46
Joined: Mon Mar 01, 2021 11:17 pm

Previous

Return to Feature Request

Who is online

Users browsing this forum: No registered users and 2 guests