Hello,
I have already been able to find out what was happening. I indicate it in case you can verify that the solution is correct.
The problem was that if the script ended without forcing a new signal on the probe, Mach3 would stay in "MPG JOG" mode. I have a "WHB04B-4: 4 Axis manual Pulse generator" RF that doesn't seem to need this mode (if you can explain to me what MPG is for). Reviewing the MACH3 configuration I saw that it had MPG#1 enabled in the ports and pins configuration. I have removed the enable and then when I run the program it no longer switches to MPG JOG mode.
Thanks!
My script is:
'-------------------
Dim PlateHeight As Double, FeedCurrent, ZPosCurrent As Double
'PlateHeight = getoemdro(1001) ' Get Plate Height (Mach3 Plate height)
PlateHeight = getoemdro(1151) ' Get Plate Height (Darkscreen PlateHeight)
FeedCurrent = GetOemDRO(818) 'Get the current settings
If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty
Code "(Probe plate is grounded, check connection and try again)"
Else
' ###### Probe Z- ######-
ZPosCurrent = GetDro(2) 'Get current position
Code "F100" 'slow feed rate to 100 mm/min
Code "G31 Z" & (ZPosCurrent - 25) 'probe 25mm down
While GetOemLed (825) = 0
Sleep(1)
Wend
Sleep(250) 'Wait for DRO to update
Call SetDro (2, PlateHeight) 'Set the Dro
Sleep(250) 'Wait for DRO to update
Code "G0 Z" & (GetDro(2) + Abs(10)) & " F400" 'Move off the plate 10mm
While IsMoving()
Wend
Code "(Z Axis Zeroed for PlateHeight:" & PlateHeight & ")"
Code "F" & FeedCurrent 'Restore Feedrate
End If
Call WaitProbeReady()
Exit Sub
Sub WaitProbeReady()
While GetOemLED(825)
Sleep(100)
Wend
End Sub