Cambio utensile manuale.

Sezione dedicata al software di casa CncDrive
Rispondi
camivic
Junior
Junior
Messaggi: 63
Iscritto il: martedì 13 marzo 2007, 22:29
Località: Brindisi

Cambio utensile manuale.

Messaggio da camivic » lunedì 9 novembre 2015, 21:45

Ragazzi,
come si fa a far fare a UCCNC il cambio utensile manuale.
Al momento una volta che riceve il comando "100 T1 M06" se ne va per i fatti suoi.
Quello che vorrei ottenere alla ricezione del comando Gcode è:
- spostare il mandrino in una determinata posizione;
- lui rimane in attesa del cambio utensile;
- io mi attivo cambiando manualmente l'utensile;
- lo informo che l'utensile è stato cambiato;
- lui mi ricalcola lo zero dell'asse Z con il comando Probe e ritorna a lavorare.

Ci sarà pure un modo per farlo!!!!

GRazie

Diego
Member
Member
Messaggi: 559
Iscritto il: domenica 13 gennaio 2008, 15:18
Località: Vicenza

Re: Cambio utensile manuale.

Messaggio da Diego » mercoledì 11 novembre 2015, 7:02

si può fare... io l'ho fatto assieme a Badade qui sul forum... prima di cominciare devi dirmi se usi il tastatore "fisso sulla tavola" o lo vuoi spostare ogni volta (spero sia fisso)... se il tuo cam permette di numerare gli utensili nel g-code partendo sempre da T1 a Tx... indipendentemente da quale numero è nella libreria del CAM che utilizzi (dovrebbe per prassi).
Se entrambe le risposte sono positive devi cercare nel manuale del tuo software due cose:

- il numero della variabile che viene scritta dal tastatore (G38.2)
- se ha disponibili 3 o 4 variabili "libere" per poter eseguire delle somme e sottrazioni nostre...

e devi avere sotto mano una copia del tuo file macro del programma dove aggiungeremo una macro secondaria per un IF

ciao

camivic
Junior
Junior
Messaggi: 63
Iscritto il: martedì 13 marzo 2007, 22:29
Località: Brindisi

Re: Cambio utensile manuale.

Messaggio da camivic » mercoledì 11 novembre 2015, 18:58

Riepilogando:
- il tastatore è mobile, ma nulla toglie che possa fissarlo su determinata posizione;
- il mio ha una Tool Table, e nella macro M05, che in seguito allego, sono anche indicata le coordinate dei vari utensili, ma questo credo riguardi solo il caso in cui ci sia un ATC;
- il G38.1 non è riportato tra i comandi supportati.

A questo punto mi sa che è problematico, o no??

Comunque allego la macro M6 di UCCNC.

Grazie.

Codice: Seleziona tutto

//Example linear toolchanger code

//Tool positions definition
int Chuckopenport = 1;
int Chuckopenpin = 16;

double[] ToolX = new double[11];
double[] ToolY = new double[11];
ToolX[0] = 0; // Tool0 X position
ToolY[0] = 0; // Tool0 Y position

ToolX[1] = 50; // Tool1 X position
ToolY[1] = 10; // Tool1 Y position
ToolX[2] = 100; // Tool2 X position
ToolY[2] = 10; // Tool2 Y position
ToolX[3] = 150; // Tool3 X position
ToolY[3] = 10; // Tool3 Y position
ToolX[4] = 200; // Tool4 X position
ToolY[4] = 10; // Tool4 Y position
ToolX[5] = 250; // Tool5 X position
ToolY[5] = 10; // Tool5 Y position
ToolX[6] = 300; // Tool6 X position
ToolY[6] = 10; // Tool6 Y position
ToolX[7] = 350; // Tool7 X position
ToolY[7] = 10; // Tool7 Y position
ToolX[8] = 400; // Tool8 X position
ToolY[8] = 10; // Tool8 Y position
ToolX[9] = 450; // Tool9 X position
ToolY[9] = 10; // Tool9 Y position
ToolX[10] = 500; // Tool10 X position
ToolY[10] = 10; // Tool10 Y position

double SafeZ = 100;
double Ztoolrelease = 30;
double Ztoolpickup = 28;

int Newtool = exec.Getnewtool();
int Currenttool = exec.Getcurrenttool();

if(Newtool == -1) // If new tool number is -1 means a missing T code, so we need to stop here...
return; 

if(Newtool <1 || Newtool >10) // Tool number is out of range, so we need to stop here...
return;

if(Newtool == Currenttool) // Same tool was selected, so do nothing, stop here...
return; 

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, do homeing before executing a tool change!");
  exec.Stop();
  return;
}

while(exec.IsMoving()){}

// Get current XY machine coordinates to return to this position at the end of the macro

double Xoriginalpos = exec.GetXmachpos();
double Yoriginalpos = exec.GetYmachpos();

// Stop spindle if running and Move Z up

exec.Stopspin(); 
exec.Code("G00 G53 Z"+ SafeZ); // Move Z up
while(exec.IsMoving()){}

if(Currenttool!=0) // No need to drop down tool if current tool number is zero
{
  // Move to old tool position on XY plane

  exec.Code("G00 G53 X" + ToolX[Currenttool] + " Y" + ToolY[Currenttool]);
  while(exec.IsMoving()){}

  // Drop current tool
  
  exec.Code("G00 G53 Z"+ Ztoolrelease); // Move Z axis down to tool holder position
  while(exec.IsMoving()){}
  exec.Setoutpin(Chuckopenport, Chuckopenpin); // Open the chuck with pneumatic valve
  exec.Wait(1000); // Wait one 1000msec
  exec.Code("G00 G53 Z"+ SafeZ); // Move Z up
  while(exec.IsMoving()){}
}

// Move to new tool position on XY plane
exec.Code("G00 G53 X" + ToolX[Newtool] + " Y" + ToolY[Newtool]);
while(exec.IsMoving()){}
// Pick new tool

exec.Code("G00 G53 Z"+ Ztoolpickup); // Move Z axis down to tool holder position
while(exec.IsMoving()){}
exec.Clroutpin(Chuckopenport, Chuckopenpin); // Close the chuck with pneumatic valve
exec.Wait(1000); // Wait one 1000msec
exec.Code("G00 G53 Z"+ SafeZ); // Move Z up
while(exec.IsMoving()){}

// Move back to start point

exec.Code("G00 G53 X" + Xoriginalpos + " Y" + Yoriginalpos);
while(exec.IsMoving()){}

// Measure new tool will go here....
//exec.Code("G43 H"+Newtool); // Load new tool offset

exec.Wait(200);
while(exec.IsMoving()){}
if(!exec.Ismacrostopped()) // If tool change was not interrupted with a stop only then validate new tool number
{
  exec.Setcurrenttool(Newtool); //Set the current tool -> the new tool
  MessageBox.Show("Tool change done.");
}
else
{
  exec.StopWithDeccel();
  MessageBox.Show("Tool change was interrupted by user!");
}


Ultima modifica di Pedro il mercoledì 11 novembre 2015, 23:44, modificato 1 volta in totale.
Motivazione: riporto inutile, e vietato dal regolamento, del messaggio precedente

camivic
Junior
Junior
Messaggi: 63
Iscritto il: martedì 13 marzo 2007, 22:29
Località: Brindisi

Re: Cambio utensile manuale.

Messaggio da camivic » mercoledì 11 novembre 2015, 20:31

Dopo un'analisi un po più approfondita ci sono quasi.
Oltre ad eliminare tutta la parte inerente il cambio utensile automatico, riesco a farlo andare in una posizione da me stabilita, e farlo ritornare alle coordinate in cui si è fermato al comando M6.
Ora mi rimane il problema di come fargli effettuare il "Probe", che su UCCNC equivale al comando M31.

Vi aggiorno, intanto sono ben accetti consigli e suggerimenti.

Diego
Member
Member
Messaggi: 559
Iscritto il: domenica 13 gennaio 2008, 15:18
Località: Vicenza

Re: Cambio utensile manuale.

Messaggio da Diego » giovedì 12 novembre 2015, 6:16

ok continuiamo: appena sei sopra al tastatore la macro deve andare in pausa... cambi la fresa e devi dar un comando di consenso (di solito "INVIO") per far proseguire la macro che scenderà ad una Z prestabilita... la z prestabilita io ce l'ho di 10 mm (può essere 20 50 1mm scegli tu) sopra al pulsante del tastatore (10 mm del tuo utensile più lungo che hai in possesso ovviamente... se monti l'utensile più corto saranno 10 + la differenza tra il lungo e il corto) e da lì parte la M31 sarà collegata ad una variabile... tale variabile viene scritta la fresa risale a Z max e ritorna a g92...

quando arrivi a questo faremo le somme e gli IF

fai gli esperimenti sopra al tastatore senza fresa... per evitare di distruggere il tastatore.... imposta una F di discesa in M31 del tastatore se vuoi (lento o veloce in base alle tue esigenze)... cerca sul manuale il modo di far comparire a monitor una frase tipo "appena cambiato utensile premi invio". Penso so scriva così...
MessageBox.Show("Appena canbiato utensile premi invio!");
ma manca il "comando" INVIO. crea un G code con dei movimenti di x e y a caso... metti in mezzo al g-code il Message box... e scrivi altri movimenti... quando lo lanci che succede? appena trova la scritta va in pausa? per farlo ripartire cosa premi...

nikigio
Junior
Junior
Messaggi: 172
Iscritto il: mercoledì 9 gennaio 2019, 11:07

Re: Cambio utensile manuale.

Messaggio da nikigio » martedì 3 maggio 2022, 19:10

Ho le macro che fanno al caso tuo.

RENATO SEVERIN
Newbie
Newbie
Messaggi: 33
Iscritto il: mercoledì 6 marzo 2019, 9:55

Re: Cambio utensile manuale.

Messaggio da RENATO SEVERIN » domenica 8 gennaio 2023, 13:43

Se possibile, sono interessato anch'io alle macro. Grazie.

nikigio
Junior
Junior
Messaggi: 172
Iscritto il: mercoledì 9 gennaio 2019, 11:07

Re: Cambio utensile manuale.

Messaggio da nikigio » sabato 7 ottobre 2023, 17:46

eccole e fammi sapere
prima M6
DOPO M31

nikigio
Junior
Junior
Messaggi: 172
Iscritto il: mercoledì 9 gennaio 2019, 11:07

Re: Cambio utensile manuale.

Messaggio da nikigio » sabato 7 ottobre 2023, 17:47

//QTC touch off code

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, do homeing before executing a tool change!");
exec.Stop();
return;
}

exec.Stopspin();

exec.Code("G53 Z-3 F2000"); // Move to 3mm below the homed position - note this assumes the Z max machine co ords limit is 0 and from there down in z is negative
while(exec.IsMoving());
// for full auto mode add X y sensor positions


exec.Code("G53 x10"); // X tool change position
while(exec.IsMoving());
exec.Code("G53 y10"); // Y tool change position
while(exec.IsMoving());


//MessageBox.Show("Please change to tool");

int Newtool = exec.Getnewtool();
exec.Code("G43 H"+Newtool); // Load new tool offset



if (Newtool == 0)
{
MessageBox.Show("Tool number must be greater than 0");
return;
}

if (Newtool > 20)
{
MessageBox.Show("Tool number must be less than 20");
return;
}


{
MessageBox.Show("Please change to tool " + Newtool);

}


//{


exec.Setcurrenttool(Newtool); //Set the current tool -> the new tool


//MessageBox.Show("Tool change done. NOTE! Check you have the correct tool in the spindle. The tool in the spindle should be tool " + Newtool);
// return;
//}



////////////////////////QTC

MessageBox.Show("OK to run tool setup? ");

//MessageBox.Show("Please pull down the Z Pen");

exec.Stopspin(); //stop spindle just in case

// Set ToolNumber to the tool you are probing, or leave it as is to probe the current tool
int ToolNumber = exec.Getcurrenttool();

// Use G0 in movements! At least the first, because if the last movement was something else then it can be a problem (e.g. G2/G3...)
// After every! exec.Code, use while(exec.IsMoving()); to wait for the controller to finish!

exec.Code("G0 G53 Z-3"); // Move to 3mm below the homed position - note this assumes the Z max machine co ords limit is 0 and from there down in z is negative
while(exec.IsMoving());



exec.Callbutton(516); // This turns the machine co-ordinates on for the marco... this is important.

// for full auto mode add X y sensor position



exec.Code("G0 G53 y50"); //y sensor posisiton
while(exec.IsMoving());

exec.Code("G0 G53 x560"); // X sensor position
while(exec.IsMoving());


//exec.Code("G0 G53 Z-100"); // option to rapid down in Z to save time (careful here)
while(exec.IsMoving());

// START PROBING - z moves down to sensor and stops when sensor is hit
exec.Code("G91"); // Select incremental mode, because G31 uses work coordinates!
while(exec.IsMoving());
exec.Code("G31 Z-200 F1000"); // Start probing, max. -10mm, 25mm/min (convert to imperial as needed)
while(exec.IsMoving());

exec.Code("G1 Z5 F500"); // Start probing, max. -10mm, 25mm/min (convert to imperial as needed)

exec.Code("G31 Z-200 F500"); // Start probing, max. -10mm, 25mm/min (convert to imperial as needed)
while(exec.IsMoving());

exec.Code("G90"); // Switch back to absolute mode
while(exec.IsMoving());

// Check if probe was successful, warn user and exit if not
if (!exec.GetLED(_ProbedOK))
{
MessageBox.Show("Probe was not successful!");
exec.Callbutton(517); // turns MAch co ords off
return;
}

// WHEN PROBE IS HIT AND INPUT GOES HIGH WRITE MachZ co-ordinate VALUE TO TOOL TABLE
// It's a bit complicated, because the probing result is in work coordinates, so we need to calculate the machine coords
double ZProbeMachPos = MachFromProbeZ();

exec.AddStatusmessage("Probe Z machine coord: " + ZProbeMachPos.ToString("F4"));




exec.Code("G10 L1 P" + ToolNumber.ToString() + " Z" + ZProbeMachPos.ToString("F4"));
while(exec.IsMoving());



exec.Callbutton(517); // turns Mach co ords off


exec.Code("G0 G53 Z-3"); // Move to 3mm below the homed position - note this assumes the Z max machine co ords limit is 0 and from there down in z is negative
while(exec.IsMoving());

exec.Code("G0 G53 x166"); // Move away from sensor
while(exec.IsMoving());
//MessageBox.Show("Please Retract the Z pen ");

exec.Code("G43 H"+Newtool); // Load new tool offset for current tool just set
exec.Setcurrenttool(Newtool);

// Probing ends here as if a return; was here

#Events

// After the Events keyword you can place functions and global constants/variables
// Global means that the whole macro can use it

const int _G54Button = 118; // G54..G59: LED 118..123
const int _G55Button = 119;
const int _G56Button = 120;
const int _G57Button = 121;
const int _G58Button = 122;
const int _G59Button = 123;

const int _G92OffsetZField = 502; // 500..505 XYZABC
const int _ToolOffsetZField = 169; // Tool length offset

const int _ProbedOK = 244; // ON if probe was successful

double MachFromProbeZ()
{
int FixtureNo = 0; // Will be 1 to 6 on G54..G59
if (AS3.Getbuttonstate(_G54Button))
FixtureNo = 1;
else if (AS3.Getbuttonstate(_G55Button))
FixtureNo = 2;
else if (AS3.Getbuttonstate(_G56Button))
FixtureNo = 3;
else if (AS3.Getbuttonstate(_G57Button))
FixtureNo = 4;
else if (AS3.Getbuttonstate(_G58Button))
FixtureNo = 5;
else if (AS3.Getbuttonstate(_G59Button))
FixtureNo = 6;
double G92OffsetZ = AS3.Getfielddouble(_G92OffsetZField); // Temporary offset if set
double ToolOffsetZ = AS3.Getfielddouble(_ToolOffsetZField); // Tool offset if set
double WorkOffsetZ = AS3.Getfielddouble(135 + 6 * (FixtureNo - 1)); // Work offset of G54..G59
return (exec.ivars[5063] + WorkOffsetZ + G92OffsetZ + ToolOffsetZ); // #5063 is the exact Z work pos when probe went active
}



////////////////////////QTC

nikigio
Junior
Junior
Messaggi: 172
Iscritto il: mercoledì 9 gennaio 2019, 11:07

Re: Cambio utensile manuale.

Messaggio da nikigio » sabato 7 ottobre 2023, 17:47

double Zmin = -100; //Max.Z depth
double Feedrate = 250; //Feedrate for probing
double retractheight = 10; //The retract height
double newZ = 25; //The new Z DRO value after probing

exec.Code("G31 Z" + Zmin + "F" + Feedrate); // Start probing

while(exec.IsMoving()){} // Wait while there is motion

exec.Wait(200); //Safety wait for the UC100 syncronisation


exec.ChangeaxisDROvalue(2, newZ.ToString()); //Change the DRO value
exec.Wait(200); //Safety wait for the UC100 syncronisation

if(!exec.Ismacrostopped()) // If tool change was not interrupted with a stop only then validate new tool number
{ double Zup = exec.GetZmachpos() + retractheight; //Calculate the new coordinate for the retract of Z axis
exec.Code("G00 G53 Z" + Zup); //Retract the Z-axis
while(exec.IsMoving()){} // Wait while there is motion
}

Rispondi

Torna a “UcCnc”