manual while paused ?

10 Aug 2010 06:34 #3665 by gtom
manual while paused ? was created by gtom
Ive read the documentation of and i understand that it will be nearly impossible to do manual operations on a pause.

inspired by the fanuc, HH and other controls that allow a stop and reentry of the program i have played with several ideas and i am looking for a solution that might work without touching the emc code itself.

The first important thing is to realize a GOTO function for the gcode:

Question : What happens if the user tells emc to start in the middle of a program??? Example: First line of a program has G20.
Change in MDI to G21 (metric) and start the program behind the G20 line. It will be executed in G20 (inch mode) Seems that the interpreter will pick up this information from the code before the start line. Other code before the start line is ignored, like offsets, coolant, flood etc.

Explained in the documentation by chris radek the manual while paused is hard to realize. I think it is not necessary to do manual operations in paused mode, it is possible to stop the program, do manual operations and to restart. If we use the last line of gcode as our stop/restart point and not the position of the moves performed by the motion controller things are easier to handle.

As we have a second interpreter in Axis and in Mocca available (the preview is displayed with this interpreter) we can simulate the machine position and movements in relation to the line of code where the user stopped the machine. We also know from this interpreter the (simulated) machine state (Offsets, Tool, Spindle, Coolant, Feedrate etc) As long as the preview shows the part 1:1 to the real motion of the machine this will be correct.

We have the machine state before we start the program
We know the machine state when the machine is stopped
We have the (simulated) machine state at a particular move
(not the "move" from the motion controler but the line of g-code)

I have written the following code for this function and it seems to work:

1.) the machine state is stored before the user starts the program.
-> Varfile,Offsets,Tool,Spindle,Coolant,Position...

2.) if the user stops the program the last line of code will be stored (pause -> store values -> stop)
-> Program line, position, tool, spindle, offsets, feedrate

3.) file is reloaded in the (preview) interpreter with the settings of point 1.
-> Varfile is copied, offsets, spindle etc also.

4.) program is "executed" in preview and a snapshot of the machine state is taken at the line where emc was stopped.
-> machinestate is stored, all G&MCodes, Position.

5.) Now the user presses the "reentry" button

6.) nc code that is required to put the machine in the desired state is sent using MDI commands:
first move to a save z position (defined by the user)
send the commands to turn on spindle,coolant, apply offsets etc
move to the last position x,y and perform G1 to the z-Position (for xyz mills only)
switch back to mode auto and restart the program at the line where the program was stopped.

This works for usual g-code...
Now it is possible to stop and restart the program without using pause.

"Goto" via g-code:

as mocca can execute commands send by hal i realized also the code to perform some "special" functions:

Example: Homing via gcode

user_defined_function M101:

"halcmd setp moc.command 228"

(228 is the internal command for "home all axes")
(moc.command is the mocca hal command pin)

if program reaches the M101
1. mocca gets the command 228
2. mocca knows that the command 228 requires manual mode.
3. interpreter is stopped
4. manual is activated
5. home all axes (command 228) is executed
6. user gets a dialog (ok -> reentry program, cancel -> stop execution)
7. mode auto is activated
8. the "goto" function will be executed, program restarts at last line


1.) if the program is running without exact stop mode the position of the last line maybe different from the simulated position.
The motion does not stop exactly at the command. Doing a "Goto" results in a slightly different path for the first move. Example:

G1 X20 F1000
G1 Y20

will produce an arc move at the corner depending on the speed and the exact stop settings.
The reentry function knows the position from the gcode but nothing about the arc.

2.) O-Words, still dont know how to handle this... Any ideas ?

Is there a way to have a exact stop on a M101 command ???

regards, Thomas

Please Log in or Create an account to join the conversation.

11 Aug 2010 04:54 #3684 by cmorley
Replied by cmorley on topic Re:manual while paused ?
I was thinking today why could one not set up 'job while pausing' right at tool change points?
now I don't know the interpretor at all other when what I have read from other people.
the problem is the motion list is way ahead of the actually motion. but I think that the motion list is flushed at tool changes.
you should be able to do what ever you want then tell EMC to start loading the list again.
this would allow tool probing and touch off at least.

just thinking out loud... keep thinking outside the box Tom!

Chris m

Please Log in or Create an account to join the conversation.

11 Aug 2010 06:22 #3685 by gtom
Replied by gtom on topic Re:manual while paused ?
The problem is that i have to find a solution without touching the emc code. Also i do not know enough of this code to make any changes.

My first idea was the following:

Adding a reference "counter" to each move of the motion controller. The counter is set by the interpreter (according to the line of gcode). In case of a pause the value of the counter will be stored as the last known move. Now, to resume the program, the interpreter runs the entire program (without moving the machine!) until it reaches the same position where it was stopped before. the next moves will be real moves of the machine.

by adding a counter i would expect no effect on the existing code, dont think that this will create lot of bugs.

regards, Thomas

Please Log in or Create an account to join the conversation.

11 Aug 2010 12:11 #3695 by BigJohnT
Replied by BigJohnT on topic Re:manual while paused ?
It seems to me that this type of function should be natural to M60 and not part on only one interface. That way all interfaces can take advantage of it. I wish I knew enough code to try anything...


Please Log in or Create an account to join the conversation.

Moderators: HansU
Time to create page: 0.129 seconds
Powered by Kunena Forum