NozzleTip.Unloaded.js & async gcode execution.

83 views
Skip to first unread message

adcNoise

unread,
Jul 8, 2026, 1:43:02 PM (9 days ago) Jul 8
to OpenPnP
I have a simple script NozzleTip.Unloaded.js:

print('-------------Running script----------');
var duet6hc = machine.getDrivers().get(0)
duet6hc.sendCommand("M42 P0 S1");
print('-------------Script complete---------');

 When I run nozzle unload in Openpnp, the script executes before the nozzle reaches the nozzle changer. I'm sure this has something to do with gcodeAsyncDriver. But I have no idea how to fix this. M400 doesn't help. I've attached the logs.


logs.txt

bert shivaan

unread,
Jul 9, 2026, 3:59:22 AM (9 days ago) Jul 9
to ope...@googlegroups.com
When did you want the script to run? I think you have this as the script that is run when the tool change cycle is started?
You can run a script after any step in the tool change process.

--
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 visit https://groups.google.com/d/msgid/openpnp/a1afb290-4786-400c-b376-8409707a223bn%40googlegroups.com.

Toby Dickenson

unread,
Jul 9, 2026, 4:45:47 AM (9 days ago) Jul 9
to ope...@googlegroups.com
> When I run nozzle unload in Openpnp, the script executes before the nozzle reaches the nozzle changer. I'm sure this has something to do with gcodeAsyncDriver.

This is exactly right.

openpnp and your machine run asynchronously. openpnp races ahead,
planning and executing the next steps of the process, and openpnp only
stops to wait for the machine to catch up when it needs an input from
the machine, for example a camera image for a vision check.

> But I have no idea how to fix this. M400 doesn't help. I've attached the logs.

Thats close, but you need to use a higher level API for "machine
coordination". In this case I think WaitForStandstill coordination
will do what you want.
https://github.com/openpnp/openpnp/wiki/Motion-Planner#custom-scripts

Alternatively there might be a duet-specific solution. I dont know
what your M42 command is doing. But there may be an alternative which
allows the duet to manage the synchronisation here. Hopefully some
duet users can help out.

adcNoise

unread,
Jul 9, 2026, 6:57:19 AM (9 days ago) Jul 9
to OpenPnP

Thank you. I have refined my script. It now works as expected—executing after the nozzle tip unload movement is fully completed:

print('-------------Running script----------');

var nozzle = machine.defaultHead.defaultNozzle;
nozzle.waitForCompletion(org.openpnp.spi.MotionPlanner.CompletionType.WaitForUnconditionalCoordination);

var duet6hc = machine.getDrivers().get(0)
duet6hc.sendCommand("M42 P0 S1");    // This command: DOUT - enable, is for debugging only

print('-------------Script complete---------');

Now to the core issue. Due to the mechanical design of my machine, when removing the nozzle tip, it is possible—though not frequent—for the Z-axis to bind slightly in the lower position, since the Z-axis returns to its home position via a spring.

This script should check the state of the ENDSTOPs – ZA and ZB. Upon completion of the nozzle tip unload, if the two endstops do not both return to 1 (i.e., are not in the correct state), it should display a message and pause the  next operation.
четверг, 9 июля 2026 г. в 16:45:47 UTC+8, to...@tarind.com:
IMG_20260709_183632.jpg
Reply all
Reply to author
Forward
0 new messages