unload nozzle tips after work

110 views
Skip to first unread message

ozzy_sv

unread,
Jul 21, 2020, 1:40:00 PM7/21/20
to OpenPnP
Hello
I want the machine to unload the nozzle tips  at the end of work . I found a script  Job.Finished.js

//Job.Finished.js
load(scripting.getScriptsDirectory().toString() + '/Examples/JavaScript/Utility.js');

// Import some OpenPnP classes we'll use
var imports = new JavaImporter(org.openpnp.model, org.openpnp.util);

// Using the imports from above, do some work.
with (imports) {
task(function() {

        var nozzle = machine.defaultHead.defaultNozzle;
var park = machine.defaultHead.getParkLocation();
var cam = machine.defaultHead.getDefaultCamera();


nozzle.unloadNozzleTip();

cam.moveTo(park);
}
);
}

But it only works with the left nozzle (I have a peter's head). Please help me with the code, namely how do I switch to the right nozzle to unload it.
Unfortunately I don't understand much in Java

Bill Ruckman

unread,
Jul 21, 2020, 2:04:21 PM7/21/20
to ope...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openpnp/a21e3947-7dc9-4038-89c0-aeab2c70b38do%40googlegroups.com.

ozzy_sv

unread,
Jul 21, 2020, 2:18:21 PM7/21/20
to OpenPnP
thanks, this example works as expected

ozzy_sv

unread,
Jul 21, 2020, 2:34:53 PM7/21/20
to OpenPnP
I changed the script a little for better understanding by beginners

// Job.Finished.js
//
// loads desired nozzletips when job done


//####################################################
// before using, edit the names according to your


var  NameHead = "H1";
var  NameNozzleLeft = "N1_<<";
var  NameNozzleRight = "N2_>>";
var  NameNozzleTipLeft = "N1_503";
var  NameNozzleTipRight = "N2_504";
//####################################################






var imports = new JavaImporter(org.openpnp.spi.machine);
with (imports) {


   
function CheckNT (nozzle, nozzlename, nozzletipname) {
       
var nn = nozzle.getName();
       
if (nn == nozzlename) {
           
var result = "#  Nozzle: " + nn + " -> ";
           
var nt = nozzle.getNozzleTip();
           
var ntn = nt.getName();
            result
+= ntn;
           
var changed = false;
           
if (ntn == nozzletipname) {
                result
+= " -> OK";
               
} else {
                   
for each (var nozzletip in machine.getNozzleTips()) {
                        ntn1
= nozzletip.getName();
                       
if (ntn1 == nozzletipname) {
                        nozzle
.loadNozzleTip(nozzletip);
                        changed
= true;
                       
break;
                   
}    
               
}
               
if (changed) {
                    result
+= " -> changed to " + ntn1;
               
} else {
                    result
+= " -> not changed!";
               
}
           
}
           
print (result);
       
}
   
}


   
// Head One
   
var head = machine.getHead(NameHead);
   
print("###Job.Finished.js###begin#########################################");
   
print("#  Head: " + head.getName());
   
for each (var nozzle in head.getNozzles()) {
   
// First Nozzle
       
CheckNT(nozzle, NameNozzleLeft, NameNozzleTipLeft );
   
// Second Nozzle
       
CheckNT(nozzle, NameNozzleRight, NameNozzleTipRight );
   
}
 
//Parking Head

 
var park = machine.defaultHead.getParkLocation();
 
var cam = machine.defaultHead.getDefaultCamera();

 
print("######################### Park Head ##############################");
 cam
.moveTo(park);
 
print("###Job.Finished.js###end##########################################");


}

Reply all
Reply to author
Forward
0 new messages