synthetos / TinyG

Affordable Industrial Grade Motion Control
https://github.com/synthetos/TinyG/wiki
893 stars 293 forks source link

Proper way to halt movement #233

Closed patrick-compass closed 6 years ago

patrick-compass commented 6 years ago

I am integrating a pressure sensor into the TinyG system.

What I want to do is descend to a -Z position until the sensor trips, and then halt movement or possibly return to Z0.

To detect the 'stop' point, I added the additional check to the end of the switch_rtc_callback, and it only operates while moving in the -Z direction.

What I need help with is what is the correct/proper way to halt current movement and make sure the planning system is in sync with the current location?

Then if I want to emulate returning to Z0, how do I programatically inject that into the system?

aldenhart commented 6 years ago

You can use a G38.2 probe move. This will move in the intended axis until the probe switch closes, then stops. The position can then be read.

patrick-compass commented 6 years ago

Unfortunately, our sensor is not wired in as a limit switch. It's a sensor that we have to check the status of via I2C.

aldenhart commented 6 years ago

I see. Then you probably want the sensor to initiate a feedhold. Check how the controller handles a ! character.

patrick-compass commented 6 years ago

What I have now is the following sequence. How does this look? Anything I missed that I should be doing?

aldenhart commented 6 years ago

That looks good. Try it out. Do not send any new moves once the Z move has been sent or it will flush as well.

patrick-compass commented 6 years ago

Preliminarily, this seems to be working.