Gcode: stop current move with deceleration (no emergency)
-
Hello everybody,
tldr:
Is there a GCode command to stop the current movement apart from using an Emergency Stop? (which could result in the steppers losing track of their positions). It does not need to break immediately (deceleration is fine).Background:
I want to use Duet boards as a mainboard for all kinds of CNC prototypes we build at work.
My plan would be to have some application (mainly NodeJS) run on a RaspberryPi or Jetson that controls the Duet via USB.I have used similar approaches with boards by other manufacturers, but I really like the expandability Duet offers. Marlin does not have this feature either (or does it?).
-
is a pause enough? https://duet3d.dozuki.com/Wiki/Gcode#Section_M25_Pause_SD_print
This will run the remainder of the print queue/buffer before pausing. -
unfortunately no, since I am streaming commands via USB and because I want to stop the current movement.
As a technical background: I build a microscope that is focussed by adjusting the z-height of the optic. Detection of the focus happens on the Raspberry Pi and I would like to move the Z-axis towards an endpoint, but stop if the optics are in focus.
Let's say I am at Z-Position 0 and the maximum travel is 10 mm.
I would like to send a command to travel to +10mm. While moving, the image becomes sharper and at 4mm it is perfect. I would like to abort movement now and stay there (at 4mm Z-height) to take more images.
(This example is not perfect, since it would probably overshoot due to deceleration, but that's not important right now). -
@turbomax How about hooking one of the RPI's GPIO lines into an endstop input on the Duet?
Then, when you detect the image is in focus, you trigger the endstop and that motor will stop immediately.
-
@alankilian I have also thought about something like that, but it seems a bit hacky to me.
This is not an issue I have to resolve right now, it is more of a general question. I know it's not an essential functionality for 3D printing, but it is definitely relevant for CNC. -
The same approach also gives clean jogging: Key down, send move command towards machine limits; key up, send stop current movement command.
-
@JuKu said in Gcode: stop current move with deceleration (no emergency):
The same approach also gives clean jogging: Key down, send move command towards machine limits; key up, send stop current movement command.
what do you mean by "same approach"? the one with the endstop?
the reason why i don't really like that approach is that i would have to rely on a controller-computer that has gpio pins. i would not be able to use this with a laptop.
what kind of might work would be using a gpio on the duet board which is pulling another (endstop) pin high. still a hack though.
but at least this discussion shows that there doesn't seem to exist a command to do this...
-
@Pinninti-Ajith this feature is planned for RRF 3.5.
-
@dc42 Is this feature implemented in the current Release 3.5beta1 or Release 3.5beta2? If so, what is the GCode command to stop the current movement?
-
@avdoverflow no not yet.
Btw as a work around have you tried using a high segmentation value and then pause?
-
@T3P3Tony Thanks for the response.
I am testing out segmentation on Firmware 3.4.5. I am connected to my Duet 2 Wifi with both the web interface and YAT.
I am trying to implement a CNC jog feature. For the CNC jog, I want to be able to:
1.) Quickstop as mentioned in this thread, and
2.) Poll the current machine position during any movement.
I think segmentation might work, but I noticed something odd while testing.I first set my segmentation with "M669 S600 T0.05".
Test 1:
In Duet Web Control 3.4.5, I can do a move using the button.
In YAT, I can send "M408 S3" to poll the current position anytime during the move. I immediately get a machine position response back.Test 2:
In YAT, I send "G91 G1 X10" to move the X-axis.
In Duet Web Control 3.4.5, I can send a console command "M408 S3" to poll the current position at anytime during the move. I immediately get a machine position response back.Test 3:
In Duet Web Control 3.4.5, I can do a move using the button.
In Duet Web Control 3.4.5, I can send a console command "M408 S3" to poll the current position. The M408 command stalls and does not respond until the move is almost complete.Test 4:
In YAT, I send "G91 G1 X10" to move the X-axis.
In YAT, I can send "M408 S3" to poll the current position. I do not get a response back until the move is almost complete.Is there a way to remove that delay in Test 4? I am writing a C# program that primarily communicates with Duet through serial.
-
@avdoverflow when a channel is executing a command, it wont process the next command on that channel which is why you are seeing this discrepancy in when you are getting results.
-
@T3P3Tony
1.) Is there a way to create multiple channels in a single interface (only USB or only WiFi) and then specify certain commands to each channel? For example one channel will be only for movement and the second channel will be only for reading position.2.) Or is there a way to execute a movement command without locking the channel up? For example, in Grbl I am able to use the "?" command to get a "Status report query" anytime during a movement command. In Marlin "M114" (Get Current Position) also works anytime during a movement command.
Thanks for the help.
-
@avdoverflow I think the proper solution is to make a change to the interface to allow the commands to be buffered such that any commands in the buffer that are non motion commands could be executed on the fly/mid move? dc42 will need to confirm the possibility of this. I am very excited to see move segmentation added, does this mean that it will be possible to track the distance to go until the end of a move in DWC? If so that makes it one of the last fundamental features of a fully formed cnc controller.
-
-
@timothyz said in Gcode: stop current move with deceleration (no emergency):
does this mean that it will be possible to track the distance to go until the end of a move in DWC?
In RRF 3.5beta1 and beta2 the machine coordinates are updated during the move, whether or not you enable segmentation.
GCode is essentially a serial protocol, so it's not possible to distinguish between commands that need to be buffered and those that don't. There would always be the possibility of a pending movement command blocking a status-requesting command. The correct way to resolve this is to use two separate command channels, which is in effect how DWC gets status updated even when it is waiting for a command to complete.
I am fairly sure you will find that M114 in Marlin blocks if the input buffer is full. If the movement queue has commands in it (and perhaps is full) but the input buffer is not full, then both RRF and Marlin will respond to M114.
-
@dc42
Is there is guide or tutorial on how to create "two separate command channels?"Getting status updates while waiting for commands to complete is what I am looking for. Thanks in advance.
-
@avdoverflow on what device are you looking to get status updates while commands initiated by that device are in progress, and how will that device be connected to the Duet?
The usual way to implement jogging in a CNC pendant (such as the one described at https://docs.duet3d.com/en/User_manual/Connecting_hardware/IO_CNC_Pendant) is to send a small movement command each time the jogging wheel is moved. If you want to use a button instead of a wheel and move the axis while the button is held down, you could do a similar thing i.e. send small movement commands at intervals while the button is held down. Either way, if you avoid sending movement commands too fast to be executed in real time, movement will stop when pendant stops sending movement commands.
-
@dc42 Is there any progress on this issue?
There is another idea - you can write a macro in which the submission of a micro movement command will be looped. In this cycle we can check the state of the pin and exit by pressing a button.
I need this to connect a weight sensor in a photopolymer printer.
-
@dc42 Any news on this issue? I decided not to make a new topic so as not to create duplicates.
-
@Dep right now our focus is on getting RRF 3.5 released. RC4 is almost ready and if no serious issues are found it it we expect to release 3.5.0 stable 1 to 2 weeks later.