cncserver icon indicating copy to clipboard operation
cncserver copied to clipboard

Is there an ability to perform a hardware pause within cncserver?

Open oskay opened this issue 12 years ago • 13 comments
trafficstars

We need the ability to request a pause via the API. That could be a timed move of distance zero, Is this presently supported? (My guess: no.) It could also be a separate Pause command.

oskay avatar Jul 24 '13 01:07 oskay

Yep, currently no hardware pause. Not exactly sure what it would mean, other than perhaps simply blocking commands from continuing or being sent along. Currently the only method of pause in RoboPaint is to just stop sending data.

Most importantly, this does not cancel or stop semi-automated actions like "tool" changes, which unlike commands that have already been pushed out through serial to the buffer, are totally pausable.

This shouldn't be too hard to do, now I just need to think up a good place to put it in the RESTful URI stack. Perhaps Something like PUT {pause: true} /motors, and this would stop moving on the next command, and return some kind of useful code for new commands sent while pause is on.

techninja avatar Jul 24 '13 02:07 techninja

Would definitely like this to be a timed pause-- PUT {pause: 2300} /motors

oskay avatar Jul 24 '13 02:07 oskay

Hmmm.. That is something else from what I was thinking entirely. Seems easy to add, but to help me wrap my head around it, do you have a use case handy?

techninja avatar Jul 24 '13 03:07 techninja

Note that if it is important to insert very accurately timed pauses in the motion control side of things, you can keep pushing commands out to the EBB as fast as possible (so that there are no random length pauses caused by buffer underruns) but use SM,x,0,0 commands where x is in milliseconds when you want to insert a pause in the stream. I believe this will work just like a normal motion command but will not move the motors.

On Tue, Jul 23, 2013 at 10:33 PM, James T [email protected] wrote:

Hmmm.. That is something else from what I was thinking entirely. Seems easy to add, but to help me wrap my head around it, do you have a use case handy?

— Reply to this email directly or view it on GitHubhttps://github.com/techninja/cncserver/issues/34#issuecomment-21461630 .

EmbeddedMan avatar Jul 24 '13 03:07 EmbeddedMan

Oh, hey there Brian! Yes, we're currently taking advantage of that for pen lift/drops (don't things to move around while we wait for the servo to get to its final position).

And yes, this would be exactly what I'd be doing for the proposed pause command. I'm just personally at a loss as to what circumstance you'd need to arbitrarily pause within the buffer via the API.

techninja avatar Jul 24 '13 03:07 techninja

I could imagine a situation where certain types of brushes, combined with a certain viscosity of paint, would require a 'pause' after gathering paint and raising the brush up to allow the paint to pool at the tip of the brush before hitting the paper. Or if you wanted to 'shake' extra water or paint from the brush tip, you may want to add 100ms pauses between moves.

To me, this feature just gives the API a more broad appeal, as it may open the doors (along with some of the other stuff you're doing) to paint (or even non painting) robots that are more sophisticated than simple water color type painting.

On Tue, Jul 23, 2013 at 10:55 PM, James T [email protected] wrote:

Oh, hey there Brian! Yes, we're currently taking advantage of that for pen lift/drops (don't things to move around while we wait for the servo to get to its final position).

And yes, this would be exactly what I'd be doing for the proposed pause command. I'm just personally at a loss as to what circumstance you'd need to arbitrarily pause within the buffer via the API.

— Reply to this email directly or view it on GitHubhttps://github.com/techninja/cncserver/issues/34#issuecomment-21462260 .

EmbeddedMan avatar Jul 24 '13 04:07 EmbeddedMan

This question was made in direct response to a question about the API-- and I'm at a loss as to what circumstance you'd be able to operate the robot without having pauses available.

oskay avatar Jul 24 '13 04:07 oskay

My assumption is that to pause, (not do anything for a set period of time), you would simply _not send_ any commands after the last command completed. A "pause" command to the API in this respect is identical to a delay on the client spent not sending any other commands, apart from the EBB actually being blocked from executing anything else, or for said pause to be aborted. (If you told the EBB to wait for 60 seconds, how to you cancel that apart from severing power or pressing the reset button?)

techninja avatar Jul 24 '13 04:07 techninja

I think that you have already seen that zero-distance timed moves are extremely helpful for various utility functions.

If you really don't want to implement this, what about implementing a move (x, y, duration) command?

oskay avatar Jul 24 '13 04:07 oskay

Ha! No, no. I've already agreed to add it. I just wanted a better example of where it would be used in a case where a simple client pause wouldn't suffice to better understand where to place it within the API. It isn't technically a "pen move". /motors somewhat makes sense. Perhaps DELETE /motors/2300, where the argument for motors is the number of milliseconds to pause? Might be a little confusing.

techninja avatar Jul 24 '13 06:07 techninja

That could be a bit confusing.

It may be better to add it in the motor PUT context.

oskay avatar Jul 24 '13 07:07 oskay

Putting one off verb type commands in JSON request bodies is... mostly non-restful. EG

PUT /motors
{
  "pause": 2300
}

JSON payload should be per-request options, for the RESTful URI given. We also can't just do /motors/pause as that puts a verb in the URI, and that's supposed to come from the request method. Though it's somewhat frowned on to use non-standard methods, I think it's supported in every HTTP Request package that supports PUT/POST/DELETE, not to mention, we have a non-standard verb that eludes common use cases.

Perhaps:

PAUSE /pen
{
  "duration": 2300
}

techninja avatar Jul 24 '13 07:07 techninja

My assumption is that to pause, (not do anything for a set period of time), you would simply not send any commands after the last command completed

Hey @techninja I'm trying to implement a pause on (for paint brush cleaning, as proposed above) but running into the issue where even if I stop sending data I've already sent too many commands that are buffered up inside of cncserver.

Do you have any suggestions? I could slow down my requests so they don't buffer up as much but I'm not exactly sure where to start with that. I don't want to go to slow and slow down the bot.

Chandler avatar Jan 04 '20 04:01 Chandler