Hello Guest it is March 28, 2024, 05:29:41 PM

Author Topic: Interrupting current gcode from vb  (Read 3786 times)

0 Members and 1 Guest are viewing this topic.

Interrupting current gcode from vb
« on: June 11, 2010, 05:23:12 AM »
Hello everybody,

i have wirtten a macro to compensate for backlash of my x,y,z spindle (trapezoidal thread).
On every axis I have a glass scale encoder which gives me the correct position of each axis.
What I'm doing now is checking (before a gcode execution) if the direction is changing.
If so I do a Gcode command in the corresponding direction with travel distance 1mm and feedrate
6mm/min (G01 X1 F6). Inside the "do while ismoving loop" I'm checking if the corresponding encoder
is moving (which is not the case as long as the backlash distance is not reached). When the encoder
starts moving the backlash is compensated and I exit the "do while ismoving loop".
After the loop I do a stop with DoOEMBUTTON(1003) to not move the axis any further (onyl backlash
compensation). And last but not least I update the Mach3 DRO with the actual encoder position, and also
do a G92 command with the position from the encoder.

The problem is that the DoOEMBUTTON(1003) terminates the VB-Script, what it shall not do  >:(.
I also tried using DoOEMBUTTON(250) which disables x-axis movement to stop directly when the encoder
starts moving. This works without terminating the script, but the further script execution is halted until
the Gcode execution (G01 X1 F6) is finished, which takes some time because the movement is very slow.

Does anyone know a way(trick) to use DoOEMBUTTON(1003) without terminating the VB-Script?
Or another way to interrupt and cancel a running Gcode command from a visual basic script without terminating the script itself?

I'm searching in the forum for two hours now and could not  find anything  :-[...please help

Greetings
Thomas

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Interrupting current gcode from vb
« Reply #1 on: June 11, 2010, 09:16:16 PM »
Remember mach is not a realtime system with gcode so interrupting a gcode command is really not possible. Once the moves are loaded into the buffer that is about it for interaction other than Feedhold or STOP.  Feedold comes to a controlled stop and holds position and that position is NOT predictable. STOP simply turns off the pulse stream and may even dump the buffer and you loose position.

With encoders you can read and compare and error if you are out of bandwidth.

 That is why we cannot close the control loop from mach.

And remember the macro loop is only 10hz or 10 times per sec.

Have you tried the mach backlash COMP?
Re: Interrupting current gcode from vb
« Reply #2 on: June 12, 2010, 06:35:14 AM »
Hello again,

yes I tried the normal backlash compensation but the problem is that the backlash is different for different positions
lets say on the x-axis (e.g. at x=0 it is 0.2mm and at x=300 it is 0.3mm).

But I think I have got a workaround for my problem. I use the already mentioned DoOEMButton(250) which disables
the x-axis movement directly when the encoder starts to move. I have now splitted the move command (G01 X1 F6)
into several smaller movements, lets say steps with 0.2mm distance and the next command is only executed when the encoder
has not moved. So each Gcode command is executed completely and I do not have to stop. When the encoder has moved for about 0.03mm
the backlash is compensated and I use the "Encoder to DRO" button to update position to the Mach DRO.

In this way it takes about 2-3 seconds before the backlash compensation is completed and the normal gcode programm is continued.
It is not optimal but if there is no other way to interrupt a running gcode command I think it is the only option.

Greetings
Thomas