Probing macro

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

Probing macro

Postby PillyWilly » Tue Dec 11, 2018 8:28 pm

Hi

Is there a macro out there that does the following:

1. Move the spindle to a specified fixed position. (the position for my Tool length probe)
2. Probing the tool.
3. Setting the tool length in the offset table.
4. Retracting to safe Z.
5. Start machining
6. Stopping at M6.
Here I change the Tool manually
All start over from 1. to 6.

Like in this video LINK

Hoping for the best, after all, It´s Christmas time :D

Regards
Jan
PillyWilly
 
Posts: 76
Joined: Wed Oct 25, 2017 6:29 pm

Re: Probing macro

Postby Robertspark » Wed Dec 12, 2018 5:00 pm

viewtopic.php?f=11&t=1669

This one is fairly close.

You call it with M6. and its is setup as a manual toolchange + probing arrangement.

I can't understand why you would do this?
3. Setting the tool length in the offset table.

If you probe the tool then you set the offset which is what that macro does.

Try it out (without a tool !!!! Don't break anything)

Tell me how you want it changed and I can change it for you.
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Probing macro

Postby PillyWilly » Wed Dec 12, 2018 9:15 pm

Robertspark wrote:http://www.forum.cncdrive.com/viewtopic.php?f=11&t=1669

This one is fairly close.

You call it with M6. and its is setup as a manual toolchange + probing arrangement.

I can't understand why you would do this?
3. Setting the tool length in the offset table.

If you probe the tool then you set the offset which is what that macro does.

Try it out (without a tool !!!! Don't break anything)

Tell me how you want it changed and I can change it for you.


Thanks Robert

I have just tried that one, seems to be working okay. But Why have my X and Y Readings turnes red?
PillyWilly
 
Posts: 76
Joined: Wed Oct 25, 2017 6:29 pm

Re: Probing macro

Postby Robertspark » Wed Dec 12, 2018 9:34 pm

They are setting g68/g69.

Which macro did you try?

I'd suggest copying the code from my last posts into the M6 macro
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Probing macro

Postby Robertspark » Wed Dec 12, 2018 9:36 pm

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




Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Probing macro

Postby Robertspark » Thu Dec 13, 2018 9:11 am

let me know if it does not do what you want it to and I'll change it if you describe what you do want it to do.
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Probing macro

Postby PillyWilly » Thu Dec 13, 2018 4:07 pm

Robertspark wrote:They are setting g68/g69.

Which macro did you try?

I'd suggest copying the code from my last posts into the M6 macro


I thought I tried the latest version, I might be wrong.

Is it possible to have the toolchange in one location and the probing in another? That could come in handy.

Regards
Jan
PillyWilly
 
Posts: 76
Joined: Wed Oct 25, 2017 6:29 pm

Re: Probing macro

Postby Robertspark » Thu Dec 13, 2018 4:22 pm

Yes it can be split, but you would need to go through your sequence of what you would like it to do if you would like it written for you.

That one does the following (roughly):

1) Checks to see it the machine has been homed, if not it will progress no further
2) Saves all the current co-ordinates and modal information etc
3) moves the machine to the toolchange location (in machine co-ordinates) and waits.
4) once the tool change has happened it moves to the probing location (in machine co-ordinates)
5) runs the z axis probe and sets the tool offset.
6) moves back to the co-ordinates where M6 occurred.
7) restores all the current co-ordinates and modal information
8) starts the spindle
9) hands back (returns) to the gcode from the macro
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Probing macro

Postby PillyWilly » Thu Dec 13, 2018 7:45 pm

Robertspark wrote:Yes it can be split, but you would need to go through your sequence of what you would like it to do if you would like it written for you.

That one does the following (roughly):

1) Checks to see it the machine has been homed, if not it will progress no further
2) Saves all the current co-ordinates and modal information etc
3) moves the machine to the toolchange location (in machine co-ordinates) and waits.
4) once the tool change has happened it moves to the probing location (in machine co-ordinates)
5) runs the z axis probe and sets the tool offset.
6) moves back to the co-ordinates where M6 occurred.
7) restores all the current co-ordinates and modal information
8) starts the spindle
9) hands back (returns) to the gcode from the macro


Hi Rob
I have attached "my" M6. Only thing changed is the positions for probing, and shifted to metric from imperial, other than that, some text has been translated to Danish.

I have set the tool change position under settings in UCCNC to X300 Y50. As this line" 3) moves the machine to the toolchange location (in machine co-ordinates) and waits." does not seem to work.
What happens now is, when I press M6:

1) Checks to see it the machine has been homed, if not it will progress no further
2) Saves all the current co-ordinates and modal information etc (at first run it is all 0)
4) once the tool change has happened it moves to the probing location (in machine co-ordinates)
3) see comment above.
5) runs the z axis probe and sets the tool offset. (Often the slow probing is left out.!)
6) moves back to the co-ordinates where M6 occurred. (x300 y50)
7) restores all the current co-ordinates and modal information
8) starts the spindle
9) hands back (returns) to the gcode from the macro (Often retracts Zinto top limit sensor, and therefore halts)

I cannot see any patterns in the slow probing beeing left out and the Z lift at the end. Is it my start positions that is wrong?

My Machine reference point is at the lower lefthand corner, Z zero at top.

Thanks a lot for helping me out.

Regards
Jan
Attachments
M6.txt
(4.06 KiB) Downloaded 972 times
PillyWilly
 
Posts: 76
Joined: Wed Oct 25, 2017 6:29 pm

Re: Probing macro

Postby Battwell » Fri Dec 14, 2018 1:37 pm

ive uploaded my m6 macro- does everything you want and can use any tool number.
it saves to profile so everything can be re called after a power off etc.
M6.txt
(20.41 KiB) Downloaded 1144 times
Uc300eth on router and mill.
UK uccnc powered machine sales. https://cncrouter.uk/atc-cnc-routers.htm
Automateanything/duzzit cnc/mercury cnc
Battwell
 
Posts: 867
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Next

Return to Macros

Who is online

Users browsing this forum: No registered users and 6 guests