M6

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

Re: M6

Postby tracar » Tue Dec 04, 2018 2:41 pm

i don't think i will be needing to rotate anything like the big mills, mine is a older wood/soft metal cnc retrofitted with new electronics.
i will test the new M6 out when i get back later today, Thankyou for all the help on this, i have been scouring thru the uccnc documents folder and can see how each line of code does what, but to use it in context , i just dont have anything to reference it to until someone does it for me, Learning is fun :)

Thankoy for all your time on this Rob !!!!
tracar
 
Posts: 30
Joined: Sun Jun 18, 2017 6:37 pm

Re: M6

Postby tracar » Tue Dec 04, 2018 4:23 pm

G68
i dont use or im unaware of how G68 gets active i dont believe i will ever need to use this rotation for probing using G68 in this machine ever. can it be disabled? and the script simplified ?
tracar
 
Posts: 30
Joined: Sun Jun 18, 2017 6:37 pm

Re: M6

Postby Robertspark » Tue Dec 04, 2018 4:42 pm

No G68 code in this one:

Code: Select all
// "automatic"  tool change

double parkZ = 0;
double parkX = 1.7;
double parkY = -23;

if(!exec.GetLED(56)||!exec.GetLED(57)||!exec.GetLED(58)) // If machine was not homed then it is unsafe to move in machine coordinates, stop here...
{
  MessageBox.Show("The machine was not yet homed, home the machine before run to parking position!");
  exec.Stop();
  return;
}

while(exec.IsMoving()){}

int originalmodalmode = exec.actualmodal; // remember the modal mode
int originaldistancemode = exec.actualdistmode; // remember the distance (G90/G91) mode
double Xmachposvariable = exec.GetXmachpos(); // remember X Axis
double Ymachposvariable = exec.GetYmachpos(); // remember Y Axis
double Zposvariable = exec.GetZpos(); // remember Z Axis

string Activemodal = AS3.Getfield(877); // Field 877: Activemodal
string[] WordSeparator = new string[] {"|"};
string[] ParamSeparator = new string[] {","};
string[] Modals = Activemodal.Split(WordSeparator, StringSplitOptions.None);
string WorkOffset = Modals[4]; // G54-G59 save current work offset
exec.Wait(200);

// begin toolchange macro movement.....
exec.Code("G90"); // set machine to absloute distance mode
exec.Code("G00 G53 Z"+ parkZ); // Move Z up first to park2 Z position
while(exec.IsMoving()){}

exec.Code ("M5");  // ***** added this to stop the spindle after it raises from the cut *****

exec.Code("G00 G53 X" + parkX +" Y" + parkY); // Move to XY park2 position
while(exec.IsMoving()){}

{
  MessageBox.Show("Manually Change Tool NOW, Then Press OK To Continue");
}


//Simple Probe for Zero
//This routine probes in negative Z at the current XY location
//Z offsets for G54 to G59 are then re-written to the new Z0

double ZRetractHeight = 1;  //Height above Z0 to which probe will retract
double CoarseRate = 30; //Feedrate for initial probing
double FineRate = 2;  //Feedrate for fine probing
double Zmin = -5.5; //maximum probing distance

double PlateThickness = .244;  //thickness of the probing plate
double MaterialOffset = 0; //compensation for part thickness

double CombinedOffset = PlateThickness - MaterialOffset;  //really for use later when PlateThickness and MaterialOffset are DROs

exec.Code( "G91" ); //switch machine to incremental distance mode
exec.Code( "G31 Z" + Zmin + "F" + CoarseRate); // Probe Z quickly to get rough height
while(exec.IsMoving()){}
exec.Wait(200);

exec.Code ("G00 Z" + .1); // Retract .1" above the plate
while(exec.IsMoving()){}
exec.Wait(100);

exec.Code("G31 Z" + Zmin + "F" + FineRate); // Probe Z slowly for better resolution
while(exec.IsMoving()){}
exec.Wait(200);

exec.mainform.sumoffsetcontrol1.G54.newCzinput(CombinedOffset);  // Set G54 to new Zzero
//exec.mainform.sumoffsetcontrol1.G55.newCzinput(CombinedOffset);  // Set G55 to new Zzero   
//exec.mainform.sumoffsetcontrol1.G56.newCzinput(CombinedOffset);  // Set G56 to new Zzero
//exec.mainform.sumoffsetcontrol1.G57.newCzinput(CombinedOffset);  // Set G57 to new Zzero
//exec.mainform.sumoffsetcontrol1.G58.newCzinput(CombinedOffset);  // Set G58 to new Zzero
//exec.mainform.sumoffsetcontrol1.G59.newCzinput(CombinedOffset);  // Set G59 to new Zzero
//probing routine & tool offset complete

//move back & restart motion
exec.Code("G00 G53 Z"+ parkZ); // Move Z up first to park Z position
while(exec.IsMoving()){}
exec.Wait(200);
exec.Code ("M3");  //  restart start
exec.Wait(200);
exec.Code("G00 G53 X"+ Xmachposvariable + " Y"+ Ymachposvariable); // move cutter back to X&Y toolchange position
while(exec.IsMoving()){}
exec.Wait(200);

//reset machine modal, distance mode and work offsets.

exec.Code (" G"+ WorkOffset );// restore G54-G59 work offset
exec.Code (" G"+ originaldistancemode );// restore the distance (G90/G91) mode
exec.Code (" G"+ originalmodalmode );// restore the modal before the toolchange {G0, G1, G2, G3 etc}
exec.Wait(200);

exec.Code("G00 Z"+ Zposvariable); // move cutter back to Z toolchange position
while(exec.IsMoving()){}
exec.Wait(200);
//return to where we left off at the start of the toolchange


G68 is not used for probing, it is just used to rotate the workplane, very useful for repeat operations.

https://www.cnccookbook.com/g68-g69-rot ... nc-g-code/
Rob
Einstein ― “If you can't explain it to a six year old, you don't understand it yourself”
...working my way through the 1000+ ways things don't work to find the one that does
UC400eth, UC300eth, UCCNC v1.2106, Neuron Lite
UCCNC v1.2105 Macro Manual
Robertspark
 
Posts: 1092
Joined: Sat Sep 03, 2016 4:27 pm
Location: Nr Liverpool, England

Re: M6

Postby tracar » Wed Dec 05, 2018 7:56 am

so what part of the code enables g68?
tracar
 
Posts: 30
Joined: Sun Jun 18, 2017 6:37 pm

Re: M6

Postby Robertspark » Wed Dec 05, 2018 10:28 am

Check if G68 is active and store the current rotation co-ordinates + rotation angle

Code: Select all
int G68active = 0;
double Rx = 0;
double Ry = 0;
double Angle = 0;
if (AS3.GetLED(254) == true){  // check if G68 active, if so store current settings to reset later.

exec.GetRotate(out Rx, out Ry, out Angle); // returns values  into the defined variables Rx, Ry and Angle
G68active = 128; // set flag
exec.Code("G69"); // clear rotation
}


Restore G68 9if it was active {it checks a variable / flag (G68active) to see if it was set with a random integer "128" (I could have set it to anything)}
It then clears the G68active variable.

Code: Select all
if (G68active == 128){  //  check if G68 flag set, if so, restore G68
exec.Code ( "G68 A" + Rx + " B" + Ry + " R" + Angle );
G68active = 0; // clear flag
}
Rob
Einstein ― “If you can't explain it to a six year old, you don't understand it yourself”
...working my way through the 1000+ ways things don't work to find the one that does
UC400eth, UC300eth, UCCNC v1.2106, Neuron Lite
UCCNC v1.2105 Macro Manual
Robertspark
 
Posts: 1092
Joined: Sat Sep 03, 2016 4:27 pm
Location: Nr Liverpool, England

Previous

Return to Macros

Who is online

Users browsing this forum: No registered users and 4 guests